@webitel/api-services 0.1.68 → 0.1.70
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 +3 -1
- package/src/api/clients/_shared/types.ts +25 -0
- package/src/api/clients/caseServiceCatalogs/serviceCatalogs.ts +37 -71
- package/src/api/clients/caseServices/services.ts +43 -57
- package/src/api/clients/index.ts +9 -0
- package/src/api/clients/queues/__tests__/fieldsToSend.spec.ts +135 -0
- package/src/api/clients/queues/__tests__/queueLogs.spec.ts +132 -0
- package/src/api/clients/queues/__tests__/queueMembers.spec.ts +175 -0
- package/src/api/clients/queues/__tests__/queues.spec.ts +130 -0
- package/src/api/clients/queues/defaults/__tests__/queueTypeDefaults.spec.ts +143 -0
- package/src/api/clients/queues/defaults/amd.ts +17 -0
- package/src/api/clients/queues/defaults/defaultQueue.ts +9 -0
- package/src/api/clients/queues/defaults/processing.ts +8 -4
- package/src/api/clients/queues/defaults/queueTypeDefaults.ts +305 -0
- package/src/api/clients/queues/queueAgents.ts +48 -0
- package/src/api/clients/queues/queueBuckets.ts +187 -0
- package/src/api/clients/queues/queueHooks.ts +184 -0
- package/src/api/clients/queues/queueLogs.ts +80 -0
- package/src/api/clients/queues/queueMembers.ts +426 -0
- package/src/api/clients/queues/queueResGroups.ts +176 -0
- package/src/api/clients/queues/queueSkills.ts +183 -0
- package/src/api/clients/queues/queueState.ts +97 -0
- package/src/api/clients/queues/queues.ts +124 -94
- package/src/api/clients/queues/scripts/__tests__/mapResetMembersFilters.spec.ts +132 -0
- package/src/api/clients/queues/scripts/mapResetMembersFilters.ts +52 -0
- package/src/enums/CallReportingStatus/CallReportingStatus.ts +13 -0
- package/src/enums/MemberStopCause/MemberStopCause.ts +13 -0
- package/src/enums/QueueStrategy/QueueStrategy.ts +27 -0
- package/src/enums/QueueType/QueueType.ts +31 -0
- package/src/enums/TimeBaseScore/TimeBaseScore.ts +6 -0
- package/src/enums/TypesResourceStrategy/TypesResourceStrategy.ts +7 -0
- package/src/enums/index.ts +21 -1
- package/src/scripts/index.ts +19 -1
- package/src/scripts/normalizeDatetime/normalizeDatetime.ts +132 -0
- package/src/validations/_shared/isFilled.ts +15 -0
- package/src/validations/_shared/lookup.validations.ts +28 -0
- package/src/validations/_shared/variablePair.validations.ts +18 -0
- package/src/validations/caseService/caseService.validations.ts +15 -0
- package/src/validations/caseServiceCatalog/caseServiceCatalog.validations.ts +23 -0
- package/src/validations/index.ts +14 -0
- package/src/validations/queue/__tests__/queue.validations.spec.ts +159 -0
- package/src/validations/queue/queue.rules.ts +166 -0
- package/src/validations/queue/queue.validations.ts +105 -0
- package/src/validations/queue/queueAmd.validations.ts +22 -0
- package/src/validations/queue/queuePayload.validations.ts +71 -0
- package/src/validations/queue/taskProcessing.validations.ts +21 -0
- package/src/validations/queueBucket/queueBucket.validations.ts +10 -0
- package/src/validations/queueHook/queueHook.validations.ts +10 -0
- package/src/validations/queueMember/memberCommunication.validations.ts +25 -0
- package/src/validations/queueMember/queueMember.validations.ts +38 -0
- package/src/validations/queueResGroup/queueResGroup.validations.ts +15 -0
- package/src/validations/queueSkill/queueSkill.validations.ts +42 -0
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/_shared/types.d.ts +20 -0
- package/types/api/clients/caseServices/services.d.ts +4 -2
- package/types/api/clients/index.d.ts +9 -0
- package/types/api/clients/queues/defaults/amd.d.ts +17 -0
- package/types/api/clients/queues/defaults/defaultQueue.d.ts +9 -0
- package/types/api/clients/queues/defaults/processing.d.ts +7 -2
- package/types/api/clients/queues/defaults/queueTypeDefaults.d.ts +31 -0
- package/types/api/clients/queues/queueAgents.d.ts +7 -0
- package/types/api/clients/queues/queueBuckets.d.ts +12 -0
- package/types/api/clients/queues/queueHooks.d.ts +12 -0
- package/types/api/clients/queues/queueLogs.d.ts +7 -0
- package/types/api/clients/queues/queueMembers.d.ts +30 -0
- package/types/api/clients/queues/queueResGroups.d.ts +15 -0
- package/types/api/clients/queues/queueSkills.d.ts +12 -0
- package/types/api/clients/queues/queueState.d.ts +8 -0
- package/types/api/clients/queues/queues.d.ts +9 -1
- package/types/api/clients/queues/scripts/mapResetMembersFilters.d.ts +30 -0
- package/types/enums/CallReportingStatus/CallReportingStatus.d.ts +11 -0
- package/types/enums/MemberStopCause/MemberStopCause.d.ts +11 -0
- package/types/enums/QueueStrategy/QueueStrategy.d.ts +21 -0
- package/types/enums/QueueType/QueueType.d.ts +28 -0
- package/types/enums/TimeBaseScore/TimeBaseScore.d.ts +5 -0
- package/types/enums/TypesResourceStrategy/TypesResourceStrategy.d.ts +5 -0
- package/types/enums/index.d.ts +7 -1
- package/types/scripts/index.d.ts +3 -1
- package/types/scripts/normalizeDatetime/normalizeDatetime.d.ts +14 -0
- package/types/validations/_shared/isFilled.d.ts +9 -0
- package/types/validations/_shared/lookup.validations.d.ts +18 -0
- package/types/validations/_shared/variablePair.validations.d.ts +16 -0
- package/types/validations/caseService/caseService.validations.d.ts +20 -0
- package/types/validations/caseServiceCatalog/caseServiceCatalog.validations.d.ts +21 -0
- package/types/validations/index.d.ts +14 -0
- package/types/validations/queue/queue.rules.d.ts +21 -0
- package/types/validations/queue/queue.validations.d.ts +285 -0
- package/types/validations/queue/queueAmd.validations.d.ts +22 -0
- package/types/validations/queue/queuePayload.validations.d.ts +75 -0
- package/types/validations/queue/taskProcessing.validations.d.ts +22 -0
- package/types/validations/queueBucket/queueBucket.validations.d.ts +9 -0
- package/types/validations/queueHook/queueHook.validations.d.ts +10 -0
- package/types/validations/queueMember/memberCommunication.validations.d.ts +16 -0
- package/types/validations/queueMember/queueMember.validations.d.ts +48 -0
- package/types/validations/queueResGroup/queueResGroup.validations.d.ts +11 -0
- package/types/validations/queueSkill/queueSkill.validations.d.ts +34 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/api-services",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"CHANGELOG.md"
|
|
40
40
|
],
|
|
41
41
|
"peerDependencies": {
|
|
42
|
+
"date-fns": "^4.1.0",
|
|
42
43
|
"deep-copy": "^1.4.2",
|
|
43
44
|
"deep-equal": "^2.2.3",
|
|
44
45
|
"deepmerge": "^4.3.1",
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"@types/node": "^22.13.10",
|
|
52
53
|
"axios": "^1.15.2",
|
|
53
54
|
"change-case": "^5.4.4",
|
|
55
|
+
"date-fns": "^4.1.0",
|
|
54
56
|
"globby": "^14.1.0",
|
|
55
57
|
"husky": "^9.1.7",
|
|
56
58
|
"is-json": "^2.0.1",
|
|
@@ -32,3 +32,28 @@ export interface PatchItemParams {
|
|
|
32
32
|
export interface DeleteItemParams {
|
|
33
33
|
id: ApiId;
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Params for entities that only exist under a parent — queue hooks, skills,
|
|
38
|
+
* buckets, resource groups, members. ui-datalist threads `parentId` through
|
|
39
|
+
* every call a nested table or its card popup makes.
|
|
40
|
+
*/
|
|
41
|
+
export interface NestedGetItemParams extends GetItemParams {
|
|
42
|
+
parentId: ApiId;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface NestedAddItemParams extends AddItemParams {
|
|
46
|
+
parentId: ApiId;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface NestedUpdateItemParams extends UpdateItemParams {
|
|
50
|
+
parentId: ApiId;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface NestedPatchItemParams extends PatchItemParams {
|
|
54
|
+
parentId: ApiId;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface NestedDeleteItemParams extends DeleteItemParams {
|
|
58
|
+
parentId: ApiId;
|
|
59
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { CatalogsApiFactory } from 'webitel-sdk';
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
2
|
+
CreateCatalogBody,
|
|
3
|
+
getCatalogs,
|
|
4
|
+
ListCatalogsQueryParams,
|
|
5
|
+
UpdateCatalogBody,
|
|
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,
|
|
@@ -22,11 +24,6 @@ import type {
|
|
|
22
24
|
UpdateItemParams,
|
|
23
25
|
} from '../_shared/types';
|
|
24
26
|
|
|
25
|
-
const instance = getDefaultInstance();
|
|
26
|
-
const configuration = getDefaultOpenAPIConfig();
|
|
27
|
-
|
|
28
|
-
const catalogsService = CatalogsApiFactory(configuration, '', instance);
|
|
29
|
-
|
|
30
27
|
const fieldsToSend = [
|
|
31
28
|
'id',
|
|
32
29
|
'name',
|
|
@@ -60,44 +57,38 @@ const servicesFieldsToSend = [
|
|
|
60
57
|
];
|
|
61
58
|
|
|
62
59
|
const getCatalogsList = async (params: ApiParams) => {
|
|
63
|
-
const fieldsToSend =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
'q',
|
|
67
|
-
'sort',
|
|
68
|
-
'fields',
|
|
69
|
-
'id',
|
|
70
|
-
'state',
|
|
71
|
-
'hasSubservices',
|
|
72
|
-
];
|
|
60
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
61
|
+
ListCatalogsQueryParams,
|
|
62
|
+
);
|
|
73
63
|
|
|
74
|
-
const { page, size, fields, sort, id,
|
|
64
|
+
const { page, size, fields, sort, id, query, state, has_subservices } =
|
|
75
65
|
applyTransform(params, [
|
|
76
66
|
merge(getDefaultGetParams()),
|
|
77
67
|
starToSearch('search'),
|
|
78
68
|
(params) => ({
|
|
79
69
|
...params,
|
|
80
|
-
|
|
70
|
+
query: params.search,
|
|
81
71
|
}),
|
|
82
72
|
sanitize(fieldsToSend),
|
|
83
73
|
camelToSnake(),
|
|
84
74
|
]);
|
|
75
|
+
|
|
85
76
|
try {
|
|
86
|
-
const response = await
|
|
77
|
+
const response = await getCatalogs().listCatalogs({
|
|
87
78
|
page,
|
|
88
79
|
size,
|
|
89
|
-
[
|
|
80
|
+
fields: [
|
|
90
81
|
...fields,
|
|
91
82
|
'services',
|
|
92
83
|
],
|
|
93
84
|
sort,
|
|
94
85
|
id,
|
|
95
|
-
|
|
86
|
+
query,
|
|
96
87
|
state,
|
|
97
|
-
'100', // Implemented depth 100 for load all subservices in one request
|
|
98
|
-
servicesFieldsToSend,
|
|
99
|
-
has_subservices,
|
|
100
|
-
);
|
|
88
|
+
depth: '100', // Implemented depth 100 for load all subservices in one request
|
|
89
|
+
subFields: servicesFieldsToSend,
|
|
90
|
+
hasSubservices: has_subservices,
|
|
91
|
+
});
|
|
101
92
|
const { items, next } = applyTransform(response.data, [
|
|
102
93
|
merge(getDefaultGetListResponse()),
|
|
103
94
|
]);
|
|
@@ -115,16 +106,13 @@ const getCatalogsList = async (params: ApiParams) => {
|
|
|
115
106
|
};
|
|
116
107
|
|
|
117
108
|
const getCatalog = async ({ itemId: id }: GetItemParams) => {
|
|
118
|
-
const itemResponseHandler = (item: ApiParams) =>
|
|
119
|
-
return item.catalog;
|
|
120
|
-
};
|
|
109
|
+
const itemResponseHandler = (item: ApiParams) => item.catalog;
|
|
121
110
|
|
|
122
111
|
try {
|
|
123
|
-
const response = await
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
);
|
|
112
|
+
const response = await getCatalogs().locateCatalog(String(id), {
|
|
113
|
+
fields: fieldsToSend,
|
|
114
|
+
subFields: servicesFieldsToSend,
|
|
115
|
+
});
|
|
128
116
|
return applyTransform(response.data, [
|
|
129
117
|
snakeToCamel(),
|
|
130
118
|
itemResponseHandler,
|
|
@@ -137,25 +125,14 @@ const getCatalog = async ({ itemId: id }: GetItemParams) => {
|
|
|
137
125
|
};
|
|
138
126
|
|
|
139
127
|
const addCatalog = async ({ itemInstance }: AddItemParams) => {
|
|
140
|
-
const fieldsToSend =
|
|
141
|
-
|
|
142
|
-
'description',
|
|
143
|
-
'prefix',
|
|
144
|
-
'code',
|
|
145
|
-
'state',
|
|
146
|
-
'sla',
|
|
147
|
-
'status',
|
|
148
|
-
'close_reason_group',
|
|
149
|
-
'default_priority',
|
|
150
|
-
'teams',
|
|
151
|
-
'skills',
|
|
152
|
-
];
|
|
128
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(CreateCatalogBody);
|
|
129
|
+
|
|
153
130
|
const item = applyTransform(itemInstance, [
|
|
154
|
-
camelToSnake(),
|
|
155
131
|
sanitize(fieldsToSend),
|
|
132
|
+
camelToSnake(),
|
|
156
133
|
]);
|
|
157
134
|
try {
|
|
158
|
-
const response = await
|
|
135
|
+
const response = await getCatalogs().createCatalog(item);
|
|
159
136
|
return applyTransform(response.data, [
|
|
160
137
|
snakeToCamel(),
|
|
161
138
|
]);
|
|
@@ -170,25 +147,14 @@ const updateCatalog = async ({
|
|
|
170
147
|
itemInstance,
|
|
171
148
|
itemId: id,
|
|
172
149
|
}: UpdateItemParams) => {
|
|
173
|
-
const fieldsToSend =
|
|
174
|
-
|
|
175
|
-
'description',
|
|
176
|
-
'prefix',
|
|
177
|
-
'code',
|
|
178
|
-
'state',
|
|
179
|
-
'sla',
|
|
180
|
-
'status',
|
|
181
|
-
'close_reason_group',
|
|
182
|
-
'default_priority',
|
|
183
|
-
'teams',
|
|
184
|
-
'skills',
|
|
185
|
-
];
|
|
150
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(UpdateCatalogBody);
|
|
151
|
+
|
|
186
152
|
const item = applyTransform(itemInstance, [
|
|
187
|
-
camelToSnake(),
|
|
188
153
|
sanitize(fieldsToSend),
|
|
154
|
+
camelToSnake(),
|
|
189
155
|
]);
|
|
190
156
|
try {
|
|
191
|
-
const response = await
|
|
157
|
+
const response = await getCatalogs().updateCatalog(String(id), item);
|
|
192
158
|
return applyTransform(response.data, [
|
|
193
159
|
snakeToCamel(),
|
|
194
160
|
]);
|
|
@@ -206,11 +172,11 @@ const patchCatalog = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
|
|
|
206
172
|
'state',
|
|
207
173
|
];
|
|
208
174
|
const item = applyTransform(itemInstance, [
|
|
209
|
-
camelToSnake(),
|
|
210
175
|
sanitize(fieldsToSend),
|
|
176
|
+
camelToSnake(),
|
|
211
177
|
]);
|
|
212
178
|
try {
|
|
213
|
-
const response = await
|
|
179
|
+
const response = await getCatalogs().updateCatalog2(String(id), item);
|
|
214
180
|
return applyTransform(response.data, [
|
|
215
181
|
snakeToCamel(),
|
|
216
182
|
]);
|
|
@@ -223,7 +189,7 @@ const patchCatalog = async ({ itemInstance, itemId: id }: UpdateItemParams) => {
|
|
|
223
189
|
|
|
224
190
|
const deleteCatalog = async ({ id }: DeleteItemParams) => {
|
|
225
191
|
try {
|
|
226
|
-
const response = await
|
|
192
|
+
const response = await getCatalogs().deleteCatalog([
|
|
227
193
|
String(id),
|
|
228
194
|
]);
|
|
229
195
|
return applyTransform(response.data, []);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { ServicesApiFactory, WebitelContactsGroupType } from 'webitel-sdk';
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
CreateServiceBody,
|
|
3
|
+
getServices,
|
|
4
|
+
ListServicesQueryParams,
|
|
5
|
+
UpdateService2Body,
|
|
6
|
+
UpdateServiceBody,
|
|
7
|
+
} from '@webitel/api-services/gen';
|
|
8
|
+
import { ContactsGroupType } from '@webitel/api-services/gen/models';
|
|
9
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
10
|
+
|
|
11
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
8
12
|
import {
|
|
9
13
|
applyTransform,
|
|
10
14
|
camelToSnake,
|
|
@@ -22,39 +26,17 @@ import type {
|
|
|
22
26
|
PatchItemParams,
|
|
23
27
|
} from '../_shared/types';
|
|
24
28
|
|
|
25
|
-
const instance = getDefaultInstance();
|
|
26
|
-
const configuration = getDefaultOpenAPIConfig();
|
|
27
|
-
|
|
28
|
-
const servicesService = ServicesApiFactory(configuration, '', instance);
|
|
29
|
-
|
|
30
|
-
const fieldsToSend = [
|
|
31
|
-
'name',
|
|
32
|
-
'code',
|
|
33
|
-
'sla',
|
|
34
|
-
'status',
|
|
35
|
-
'state',
|
|
36
|
-
'description',
|
|
37
|
-
'group',
|
|
38
|
-
'assignee',
|
|
39
|
-
'services',
|
|
40
|
-
'root_id',
|
|
41
|
-
'catalog_id',
|
|
42
|
-
];
|
|
43
|
-
|
|
44
29
|
const getServicesList = async ({
|
|
30
|
+
parentId,
|
|
45
31
|
rootId,
|
|
46
32
|
...rest
|
|
47
33
|
}: {
|
|
34
|
+
parentId?: ApiId;
|
|
48
35
|
rootId: ApiId;
|
|
49
36
|
} & ApiParams) => {
|
|
50
|
-
const fieldsToSend =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
'q',
|
|
54
|
-
'sort',
|
|
55
|
-
'fields',
|
|
56
|
-
'id',
|
|
57
|
-
];
|
|
37
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
38
|
+
ListServicesQueryParams,
|
|
39
|
+
);
|
|
58
40
|
|
|
59
41
|
const { page, size, fields, sort, id, q } = applyTransform(rest, [
|
|
60
42
|
merge(getDefaultGetParams()),
|
|
@@ -66,22 +48,24 @@ const getServicesList = async ({
|
|
|
66
48
|
sanitize(fieldsToSend),
|
|
67
49
|
camelToSnake(),
|
|
68
50
|
]);
|
|
51
|
+
|
|
69
52
|
try {
|
|
70
|
-
const response = await
|
|
53
|
+
const response = await getServices().listServices({
|
|
71
54
|
page,
|
|
72
55
|
size,
|
|
56
|
+
fields,
|
|
73
57
|
sort,
|
|
74
58
|
id,
|
|
75
59
|
q,
|
|
76
|
-
String(rootId),
|
|
77
|
-
|
|
78
|
-
fields,
|
|
79
|
-
);
|
|
60
|
+
rootId: String(rootId ?? parentId),
|
|
61
|
+
});
|
|
80
62
|
const { items, next } = applyTransform(response.data, [
|
|
81
63
|
merge(getDefaultGetListResponse()),
|
|
82
64
|
]);
|
|
83
65
|
return {
|
|
84
|
-
items: applyTransform(items, [
|
|
66
|
+
items: applyTransform(items, [
|
|
67
|
+
snakeToCamel(),
|
|
68
|
+
]),
|
|
85
69
|
next,
|
|
86
70
|
};
|
|
87
71
|
} catch (err) {
|
|
@@ -101,19 +85,17 @@ const getService = async ({ itemId: id }: GetItemParams) => {
|
|
|
101
85
|
'group',
|
|
102
86
|
'assignee',
|
|
103
87
|
'description',
|
|
88
|
+
'default_priority',
|
|
104
89
|
'catalog_id',
|
|
105
90
|
'root_id',
|
|
106
91
|
];
|
|
107
92
|
|
|
108
|
-
const itemResponseHandler = (item: ApiParams) =>
|
|
109
|
-
return item.service;
|
|
110
|
-
};
|
|
93
|
+
const itemResponseHandler = (item: ApiParams) => item.service;
|
|
111
94
|
|
|
112
95
|
try {
|
|
113
|
-
const response = await
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
);
|
|
96
|
+
const response = await getServices().locateService(String(id), {
|
|
97
|
+
fields: fieldsToSend,
|
|
98
|
+
});
|
|
117
99
|
return applyTransform(response.data, [
|
|
118
100
|
snakeToCamel(),
|
|
119
101
|
itemResponseHandler,
|
|
@@ -135,11 +117,9 @@ const preRequestHandler = ({
|
|
|
135
117
|
return (item: ApiParams) => ({
|
|
136
118
|
...item,
|
|
137
119
|
assignee:
|
|
138
|
-
item.group?.type ===
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
rootId,
|
|
142
|
-
catalogId,
|
|
120
|
+
item.group?.type === ContactsGroupType.Dynamic ? {} : item.assignee,
|
|
121
|
+
rootId: rootId ?? item.rootId,
|
|
122
|
+
catalogId: catalogId ?? item.catalogId,
|
|
143
123
|
});
|
|
144
124
|
};
|
|
145
125
|
|
|
@@ -152,17 +132,19 @@ const addService = async ({
|
|
|
152
132
|
rootId: ApiId;
|
|
153
133
|
catalogId: ApiId;
|
|
154
134
|
}) => {
|
|
135
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(CreateServiceBody);
|
|
136
|
+
|
|
155
137
|
const item = applyTransform(itemInstance, [
|
|
156
138
|
preRequestHandler({
|
|
157
139
|
rootId,
|
|
158
140
|
catalogId,
|
|
159
141
|
}),
|
|
160
|
-
camelToSnake(),
|
|
161
142
|
sanitize(fieldsToSend),
|
|
143
|
+
camelToSnake(),
|
|
162
144
|
]);
|
|
163
145
|
|
|
164
146
|
try {
|
|
165
|
-
const response = await
|
|
147
|
+
const response = await getServices().createService(item);
|
|
166
148
|
return applyTransform(response.data, [
|
|
167
149
|
snakeToCamel(),
|
|
168
150
|
]);
|
|
@@ -184,17 +166,19 @@ const updateService = async ({
|
|
|
184
166
|
rootId: ApiId;
|
|
185
167
|
catalogId: ApiId;
|
|
186
168
|
}) => {
|
|
169
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(UpdateServiceBody);
|
|
170
|
+
|
|
187
171
|
const item = applyTransform(itemInstance, [
|
|
188
172
|
preRequestHandler({
|
|
189
173
|
rootId,
|
|
190
174
|
catalogId,
|
|
191
175
|
}),
|
|
192
|
-
camelToSnake(),
|
|
193
176
|
sanitize(fieldsToSend),
|
|
177
|
+
camelToSnake(),
|
|
194
178
|
]);
|
|
195
179
|
|
|
196
180
|
try {
|
|
197
|
-
const response = await
|
|
181
|
+
const response = await getServices().updateService(String(id), item);
|
|
198
182
|
return applyTransform(response.data, [
|
|
199
183
|
snakeToCamel(),
|
|
200
184
|
]);
|
|
@@ -206,12 +190,14 @@ const updateService = async ({
|
|
|
206
190
|
};
|
|
207
191
|
|
|
208
192
|
const patchService = async ({ changes, id }: PatchItemParams) => {
|
|
193
|
+
const fieldsToSend = getShallowFieldsToSendFromZodSchema(UpdateService2Body);
|
|
194
|
+
|
|
209
195
|
const body = applyTransform(changes, [
|
|
210
196
|
sanitize(fieldsToSend),
|
|
211
197
|
camelToSnake(),
|
|
212
198
|
]);
|
|
213
199
|
try {
|
|
214
|
-
const response = await
|
|
200
|
+
const response = await getServices().updateService2(String(id), body);
|
|
215
201
|
return applyTransform(response.data, [
|
|
216
202
|
snakeToCamel(),
|
|
217
203
|
]);
|
|
@@ -224,7 +210,7 @@ const patchService = async ({ changes, id }: PatchItemParams) => {
|
|
|
224
210
|
|
|
225
211
|
const deleteService = async ({ id }: DeleteItemParams) => {
|
|
226
212
|
try {
|
|
227
|
-
const response = await
|
|
213
|
+
const response = await getServices().deleteService([
|
|
228
214
|
String(id),
|
|
229
215
|
]);
|
|
230
216
|
return applyTransform(response.data, []);
|
package/src/api/clients/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './caseCloseReasonGroups/caseCloseReasonGroups';
|
|
|
10
10
|
export * from './caseCloseReasons/caseCloseReasons';
|
|
11
11
|
export * from './casePriorities/casePriorities';
|
|
12
12
|
export * from './caseServiceCatalogs/serviceCatalogs';
|
|
13
|
+
export * from './caseServices/services';
|
|
13
14
|
export * from './caseSources/caseSources';
|
|
14
15
|
export * from './caseStatusConditions/caseStatusConditions';
|
|
15
16
|
export * from './caseStatuses/caseStatuses';
|
|
@@ -36,6 +37,14 @@ export * from './object/object';
|
|
|
36
37
|
export * from './onlineSkills/onlineSkills';
|
|
37
38
|
export * from './pdfServices/pdfServices';
|
|
38
39
|
export * from './phones/phones';
|
|
40
|
+
export * from './queues/queueAgents';
|
|
41
|
+
export * from './queues/queueBuckets';
|
|
42
|
+
export * from './queues/queueHooks';
|
|
43
|
+
export * from './queues/queueLogs';
|
|
44
|
+
export * from './queues/queueMembers';
|
|
45
|
+
export * from './queues/queueResGroups';
|
|
46
|
+
export * from './queues/queueSkills';
|
|
47
|
+
export * from './queues/queueState';
|
|
39
48
|
export * from './queues/queues';
|
|
40
49
|
export * from './quickReplies/quickReplies';
|
|
41
50
|
export * from './regions/regions';
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
queueBucketSchema,
|
|
6
|
+
queueHookSchema,
|
|
7
|
+
queueMemberSchema,
|
|
8
|
+
queueResGroupSchema,
|
|
9
|
+
queueSchema,
|
|
10
|
+
queueSkillSchema,
|
|
11
|
+
} from '../../../../validations';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The queue api modules derive their `sanitize()` whitelists from these
|
|
15
|
+
* schemas, so the form and the request cannot drift apart. That only holds
|
|
16
|
+
* while `getShallowFieldsToSendFromZodSchema` can still read the keys — and
|
|
17
|
+
* `queueSchema` and `queueSkillSchema` are `superRefine`-wrapped, which would
|
|
18
|
+
* hide them if zod ever moved refinements back outside the object.
|
|
19
|
+
*/
|
|
20
|
+
const fieldsOf = (
|
|
21
|
+
schema: Parameters<typeof getShallowFieldsToSendFromZodSchema>[0],
|
|
22
|
+
) =>
|
|
23
|
+
[
|
|
24
|
+
...getShallowFieldsToSendFromZodSchema(schema),
|
|
25
|
+
].sort();
|
|
26
|
+
|
|
27
|
+
describe('fields derived from the queue schemas', () => {
|
|
28
|
+
it('sends every editable queue field', () => {
|
|
29
|
+
expect(fieldsOf(queueSchema)).toEqual([
|
|
30
|
+
'afterSchema',
|
|
31
|
+
'calendar',
|
|
32
|
+
'description',
|
|
33
|
+
'dncList',
|
|
34
|
+
'doSchema',
|
|
35
|
+
'enabled',
|
|
36
|
+
'formSchema',
|
|
37
|
+
'grantee',
|
|
38
|
+
'name',
|
|
39
|
+
'payload',
|
|
40
|
+
'priority',
|
|
41
|
+
'ringtone',
|
|
42
|
+
'schema',
|
|
43
|
+
'stickyAgent',
|
|
44
|
+
'strategy',
|
|
45
|
+
'tags',
|
|
46
|
+
'taskProcessing',
|
|
47
|
+
'team',
|
|
48
|
+
'type',
|
|
49
|
+
'variables',
|
|
50
|
+
]);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('reads through the queue superRefine', () => {
|
|
54
|
+
// the rules wrapper must not hide the shape from the whitelist
|
|
55
|
+
expect(fieldsOf(queueSchema)).toContain('payload');
|
|
56
|
+
expect(fieldsOf(queueSkillSchema)).toContain('skill');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it.each([
|
|
60
|
+
[
|
|
61
|
+
'hook',
|
|
62
|
+
queueHookSchema,
|
|
63
|
+
[
|
|
64
|
+
'enabled',
|
|
65
|
+
'event',
|
|
66
|
+
'properties',
|
|
67
|
+
'schema',
|
|
68
|
+
],
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
'bucket',
|
|
72
|
+
queueBucketSchema,
|
|
73
|
+
[
|
|
74
|
+
'bucket',
|
|
75
|
+
'disabled',
|
|
76
|
+
'priority',
|
|
77
|
+
],
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
'resource group',
|
|
81
|
+
queueResGroupSchema,
|
|
82
|
+
[
|
|
83
|
+
'communication',
|
|
84
|
+
'resourceGroup',
|
|
85
|
+
],
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
'skill',
|
|
89
|
+
queueSkillSchema,
|
|
90
|
+
[
|
|
91
|
+
'buckets',
|
|
92
|
+
'enabled',
|
|
93
|
+
'lvl',
|
|
94
|
+
'maxCapacity',
|
|
95
|
+
'minCapacity',
|
|
96
|
+
'skill',
|
|
97
|
+
],
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
'member',
|
|
101
|
+
queueMemberSchema,
|
|
102
|
+
[
|
|
103
|
+
'agent',
|
|
104
|
+
'bucket',
|
|
105
|
+
'communications',
|
|
106
|
+
'expireAt',
|
|
107
|
+
'minOfferingAt',
|
|
108
|
+
'name',
|
|
109
|
+
'priority',
|
|
110
|
+
'stopCause',
|
|
111
|
+
'timezone',
|
|
112
|
+
'variables',
|
|
113
|
+
],
|
|
114
|
+
],
|
|
115
|
+
])('sends every editable %s field', (_entity, schema, expected) => {
|
|
116
|
+
expect(fieldsOf(schema)).toEqual(expected);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* `queueId` is put on nested bodies by each module's `preRequestHandler`; it
|
|
121
|
+
* belongs to the url, not the form, so it is appended to the derived list
|
|
122
|
+
* rather than added to the schema.
|
|
123
|
+
*/
|
|
124
|
+
it('leaves queueId out of the nested schemas', () => {
|
|
125
|
+
for (const schema of [
|
|
126
|
+
queueHookSchema,
|
|
127
|
+
queueBucketSchema,
|
|
128
|
+
queueResGroupSchema,
|
|
129
|
+
queueSkillSchema,
|
|
130
|
+
queueMemberSchema,
|
|
131
|
+
]) {
|
|
132
|
+
expect(fieldsOf(schema)).not.toContain('queueId');
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|