@webitel/api-services 1.0.6 → 1.0.8
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 +2 -1
- package/src/api/clients/calendars/__tests__/calendars.spec.ts +71 -0
- package/src/api/clients/calendars/calendars.ts +2 -2
- package/src/api/clients/caseComments/caseComments.ts +141 -0
- package/src/api/clients/caseFiles/caseFiles.ts +79 -0
- package/src/api/clients/caseLinks/caseLinks.ts +150 -0
- package/src/api/clients/caseRelatedCases/caseRelatedCases.ts +125 -0
- package/src/api/clients/caseServices/services.ts +38 -72
- package/src/api/clients/cases/_internals/ftsService.ts +67 -0
- package/src/api/clients/cases/_internals/stringifyCaseFilters.ts +156 -0
- package/src/api/clients/cases/cases.ts +360 -0
- package/src/api/clients/chatMessagesHistory/chatMessagesHistory.ts +64 -0
- package/src/api/clients/configurations/configurations.ts +56 -39
- package/src/api/clients/contactCases/contactCases.ts +109 -0
- package/src/api/clients/emails/emails.ts +11 -7
- package/src/api/clients/index.ts +9 -0
- package/src/api/clients/labels/labels.ts +24 -29
- package/src/api/clients/phones/phones.ts +11 -7
- package/src/api/clients/timeline/timeline.ts +124 -0
- package/src/api/clients/variables/variables.ts +10 -5
- package/src/api/clients/wtTypes/_shared/utils/assignFieldPositions.ts +28 -0
- package/src/api/clients/wtTypes/_shared/utils/sortDynamicFields.ts +7 -9
- package/src/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.ts +19 -16
- package/src/api/clients/wtTypes/adjunctTypes/adjunctTypes.ts +4 -0
- package/src/api/clients/wtTypes/typeExtensions/typeExtensions.ts +21 -31
- package/src/api/clients//321/201ontacts/contacts.ts +103 -234
- package/src/api/clients//321/201ontacts/getContactAccessFromMode.ts +9 -0
- package/src/api/clients//321/201ontacts/index.ts +1 -1
- package/src/validations/adjunctType/adjunctType.validations.ts +18 -0
- package/src/validations/case/case.validations.ts +33 -0
- package/src/validations/caseClose/caseClose.validations.ts +30 -0
- package/src/validations/caseExportOptions/caseExportOptions.validations.ts +27 -0
- package/src/validations/contact/contact.validations.ts +12 -7
- package/src/validations/index.ts +5 -0
- package/src/validations/typeExtension/typeExtension.validations.ts +8 -0
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/caseComments/caseComments.d.ts +20 -0
- package/types/api/clients/caseFiles/caseFiles.d.ts +10 -0
- package/types/api/clients/caseLinks/caseLinks.d.ts +22 -0
- package/types/api/clients/caseRelatedCases/caseRelatedCases.d.ts +14 -0
- package/types/api/clients/caseServices/services.d.ts +3 -12
- package/types/api/clients/cases/_internals/ftsService.d.ts +7 -0
- package/types/api/clients/cases/_internals/stringifyCaseFilters.d.ts +2 -0
- package/types/api/clients/cases/cases.d.ts +35 -0
- package/types/api/clients/chatMessagesHistory/chatMessagesHistory.d.ts +15 -0
- package/types/api/clients/contactCases/contactCases.d.ts +9 -0
- package/types/api/clients/index.d.ts +9 -0
- package/types/api/clients/labels/labels.d.ts +2 -2
- package/types/api/clients/timeline/timeline.d.ts +16 -0
- package/types/api/clients/wtTypes/_shared/utils/assignFieldPositions.d.ts +2 -0
- package/types/api/clients/wtTypes/_shared/utils/sortDynamicFields.d.ts +2 -2
- package/types/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.d.ts +11 -11
- package/types/api/clients/wtTypes/typeExtensions/typeExtensions.d.ts +1 -1
- package/types/api/clients//321/201ontacts/getContactAccessFromMode.d.ts +5 -0
- package/types/api/clients//321/201ontacts/index.d.ts +1 -1
- package/types/validations/adjunctType/adjunctType.validations.d.ts +11 -0
- package/types/validations/case/case.validations.d.ts +31 -0
- package/types/validations/caseClose/caseClose.validations.d.ts +8 -0
- package/types/validations/caseExportOptions/caseExportOptions.validations.d.ts +9 -0
- package/types/validations/contact/contact.validations.d.ts +15 -15
- package/types/validations/index.d.ts +5 -0
- package/types/validations/typeExtension/typeExtension.validations.d.ts +20 -0
- package/src/api/clients//321/201ontacts/types/ContactEntity.types.ts +0 -25
- package/types/api/clients//321/201ontacts/types/ContactEntity.types.d.ts +0 -14
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ContactsApiFactory } from 'webitel-sdk';
|
|
1
|
+
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
3
2
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from '
|
|
3
|
+
CreateContactBody,
|
|
4
|
+
getContacts,
|
|
5
|
+
SearchContactsQueryParams,
|
|
6
|
+
UpdateContactBody,
|
|
7
|
+
} from '../../../gen-wire';
|
|
8
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
9
9
|
import {
|
|
10
10
|
applyTransform,
|
|
11
|
-
camelToSnake,
|
|
12
11
|
merge,
|
|
13
12
|
notify,
|
|
14
|
-
|
|
13
|
+
sanitizeToWire,
|
|
15
14
|
snakeToCamel,
|
|
16
15
|
} from '../../transformers';
|
|
17
16
|
import { generatePermissionsApi } from '../_shared/generatePermissionsApi';
|
|
@@ -23,37 +22,13 @@ import type {
|
|
|
23
22
|
} from '../_shared/types';
|
|
24
23
|
import { ContactsSearchMode } from './enums/ContactsSearchMode';
|
|
25
24
|
|
|
26
|
-
const instance = getDefaultInstance();
|
|
27
|
-
const configuration = getDefaultOpenAPIConfig();
|
|
28
|
-
|
|
29
|
-
const contactService = ContactsApiFactory(configuration, '', instance);
|
|
30
|
-
|
|
31
25
|
const baseUrl = '/contacts';
|
|
32
26
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
edit: item.mode.includes('w'),
|
|
37
|
-
delete: item.mode.includes('d'),
|
|
38
|
-
},
|
|
39
|
-
});
|
|
27
|
+
const searchFieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
28
|
+
SearchContactsQueryParams,
|
|
29
|
+
);
|
|
40
30
|
|
|
41
31
|
const getList = async (params: ApiParams) => {
|
|
42
|
-
const fieldsToSend = [
|
|
43
|
-
'page',
|
|
44
|
-
'size',
|
|
45
|
-
'q',
|
|
46
|
-
'sort',
|
|
47
|
-
'fields',
|
|
48
|
-
'id',
|
|
49
|
-
'qin',
|
|
50
|
-
'notIdGroup',
|
|
51
|
-
'group',
|
|
52
|
-
'owner',
|
|
53
|
-
'label',
|
|
54
|
-
'user',
|
|
55
|
-
];
|
|
56
|
-
|
|
57
32
|
if (!params.fields) {
|
|
58
33
|
params.fields = [
|
|
59
34
|
'id',
|
|
@@ -70,44 +45,7 @@ const getList = async (params: ApiParams) => {
|
|
|
70
45
|
];
|
|
71
46
|
}
|
|
72
47
|
|
|
73
|
-
|
|
74
|
-
items?.map((item) => ({
|
|
75
|
-
...item,
|
|
76
|
-
name: item.name.commonName,
|
|
77
|
-
managers: item.managers
|
|
78
|
-
? [
|
|
79
|
-
...item.managers.data,
|
|
80
|
-
]
|
|
81
|
-
: [],
|
|
82
|
-
labels: item.labels
|
|
83
|
-
? [
|
|
84
|
-
...item.labels.data,
|
|
85
|
-
]
|
|
86
|
-
: [],
|
|
87
|
-
groups: getGroupsFromResponse(item),
|
|
88
|
-
variables: item.variables
|
|
89
|
-
? [
|
|
90
|
-
...item.variables.data,
|
|
91
|
-
]
|
|
92
|
-
: [],
|
|
93
|
-
timezones: item.timezones
|
|
94
|
-
? [
|
|
95
|
-
...item.timezones.data,
|
|
96
|
-
]
|
|
97
|
-
: [],
|
|
98
|
-
phones: item.phones
|
|
99
|
-
? [
|
|
100
|
-
...item.phones.data,
|
|
101
|
-
]
|
|
102
|
-
: [],
|
|
103
|
-
emails: item.emails
|
|
104
|
-
? [
|
|
105
|
-
...item.emails.data,
|
|
106
|
-
]
|
|
107
|
-
: [],
|
|
108
|
-
}));
|
|
109
|
-
|
|
110
|
-
let changedParams: Record<string, unknown> = {};
|
|
48
|
+
let changedParams: ApiParams;
|
|
111
49
|
|
|
112
50
|
if (params?.search) {
|
|
113
51
|
changedParams = {
|
|
@@ -139,34 +77,29 @@ const getList = async (params: ApiParams) => {
|
|
|
139
77
|
searchKey = 'emails,phones,imclients{user{name}}';
|
|
140
78
|
}
|
|
141
79
|
|
|
142
|
-
// This code needed for adding starToSearch method to applyTransform while searchKey !== SearchMode.VARIABLES because '*' in variables search mode brokes backend logic.
|
|
143
|
-
// if (searchKey !== ContactsSearchMode.VARIABLES) {
|
|
144
|
-
// transformations.push(starToSearch('q')); WTEL-4265
|
|
145
|
-
// }
|
|
146
|
-
|
|
147
80
|
changedParams = {
|
|
148
81
|
...params,
|
|
149
82
|
q: searchValue || '',
|
|
150
83
|
qin: searchKey || '',
|
|
151
84
|
};
|
|
152
|
-
}
|
|
153
85
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
86
|
+
if (params.hasUser != null) {
|
|
87
|
+
changedParams.user = params.hasUser;
|
|
88
|
+
}
|
|
157
89
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
90
|
+
if (params.contactGroup) {
|
|
91
|
+
changedParams.group = [
|
|
92
|
+
...params.contactGroup.list,
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
if (params.contactLabel) {
|
|
96
|
+
changedParams.label = params.contactLabel.map(
|
|
97
|
+
(item: ApiParams) => item.label,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
if (params.contactOwner) {
|
|
101
|
+
changedParams.owner = params.contactOwner;
|
|
102
|
+
}
|
|
170
103
|
}
|
|
171
104
|
|
|
172
105
|
if (params.parentId) {
|
|
@@ -175,47 +108,30 @@ const getList = async (params: ApiParams) => {
|
|
|
175
108
|
];
|
|
176
109
|
}
|
|
177
110
|
|
|
178
|
-
|
|
179
|
-
|
|
111
|
+
// `notIdGroup`/`qin`/`group`/`owner`/`label`/`user` are the field names the
|
|
112
|
+
// generated `SearchContactsParams` type declares for this endpoint — unlike
|
|
113
|
+
// the old `ContactsApiFactory`-based client, no camelCase->snake_case
|
|
114
|
+
// conversion is applied on the way out here.
|
|
115
|
+
const searchParams = applyTransform(changedParams, [
|
|
116
|
+
sanitizeToWire(searchFieldsToSend),
|
|
180
117
|
merge(getDefaultGetParams()),
|
|
181
|
-
|
|
182
|
-
];
|
|
183
|
-
|
|
184
|
-
const {
|
|
185
|
-
page,
|
|
186
|
-
size,
|
|
187
|
-
q,
|
|
188
|
-
sort,
|
|
189
|
-
fields,
|
|
190
|
-
id,
|
|
191
|
-
qin,
|
|
192
|
-
mode,
|
|
193
|
-
group,
|
|
194
|
-
not_id_group,
|
|
195
|
-
owner,
|
|
196
|
-
label,
|
|
197
|
-
user,
|
|
198
|
-
} = applyTransform(changedParams, transformations);
|
|
118
|
+
]);
|
|
199
119
|
|
|
200
120
|
try {
|
|
201
|
-
const response = await
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
121
|
+
const response = await getContacts().searchContacts({
|
|
122
|
+
...searchParams,
|
|
123
|
+
sort: searchParams.sort
|
|
124
|
+
? [
|
|
125
|
+
searchParams.sort,
|
|
126
|
+
]
|
|
127
|
+
: [
|
|
128
|
+
'+name',
|
|
129
|
+
],
|
|
130
|
+
fields: [
|
|
207
131
|
'mode',
|
|
208
|
-
...fields,
|
|
132
|
+
...(searchParams.fields || []),
|
|
209
133
|
],
|
|
210
|
-
|
|
211
|
-
qin,
|
|
212
|
-
mode,
|
|
213
|
-
not_id_group,
|
|
214
|
-
group,
|
|
215
|
-
owner,
|
|
216
|
-
label,
|
|
217
|
-
user,
|
|
218
|
-
);
|
|
134
|
+
});
|
|
219
135
|
|
|
220
136
|
const { items, next } = applyTransform(
|
|
221
137
|
{
|
|
@@ -231,10 +147,7 @@ const getList = async (params: ApiParams) => {
|
|
|
231
147
|
);
|
|
232
148
|
|
|
233
149
|
return {
|
|
234
|
-
items
|
|
235
|
-
(items: ApiParams[]) => items?.map((item) => formatAccessMode(item)),
|
|
236
|
-
listResponseHandler,
|
|
237
|
-
]),
|
|
150
|
+
items,
|
|
238
151
|
next,
|
|
239
152
|
};
|
|
240
153
|
} catch (err) {
|
|
@@ -244,71 +157,32 @@ const getList = async (params: ApiParams) => {
|
|
|
244
157
|
}
|
|
245
158
|
};
|
|
246
159
|
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
];
|
|
160
|
+
const contactFieldsToSend = [
|
|
161
|
+
'name',
|
|
162
|
+
'about',
|
|
163
|
+
'labels',
|
|
164
|
+
'groups',
|
|
165
|
+
'etag',
|
|
166
|
+
'mode',
|
|
167
|
+
'managers',
|
|
168
|
+
'timezones',
|
|
169
|
+
'variables',
|
|
170
|
+
'phones',
|
|
171
|
+
'emails',
|
|
172
|
+
'imclients',
|
|
173
|
+
'user',
|
|
174
|
+
'custom',
|
|
175
|
+
];
|
|
264
176
|
|
|
265
|
-
|
|
266
|
-
const itemResponseHandler = (item: ApiParams) => {
|
|
267
|
-
return {
|
|
268
|
-
...item,
|
|
269
|
-
name: item.name.commonName,
|
|
270
|
-
labels: item.labels
|
|
271
|
-
? [
|
|
272
|
-
...item.labels.data,
|
|
273
|
-
]
|
|
274
|
-
: [],
|
|
275
|
-
groups: getGroupsFromResponse(item),
|
|
276
|
-
managers: item.managers
|
|
277
|
-
? [
|
|
278
|
-
...item.managers.data,
|
|
279
|
-
]
|
|
280
|
-
: [],
|
|
281
|
-
timezones: item.timezones
|
|
282
|
-
? [
|
|
283
|
-
...item.timezones.data,
|
|
284
|
-
]
|
|
285
|
-
: [],
|
|
286
|
-
variables: item.variables
|
|
287
|
-
? [
|
|
288
|
-
...item.variables.data,
|
|
289
|
-
]
|
|
290
|
-
: [],
|
|
291
|
-
phones: item.phones
|
|
292
|
-
? [
|
|
293
|
-
...item.phones.data,
|
|
294
|
-
]
|
|
295
|
-
: [],
|
|
296
|
-
emails: item.emails
|
|
297
|
-
? [
|
|
298
|
-
...item.emails.data,
|
|
299
|
-
]
|
|
300
|
-
: [],
|
|
301
|
-
};
|
|
302
|
-
};
|
|
177
|
+
const get = async ({ itemId: id }: GetItemParams) => {
|
|
303
178
|
try {
|
|
304
|
-
const response = await
|
|
179
|
+
const response = await getContacts().locateContact(String(id), {
|
|
180
|
+
fields: contactFieldsToSend,
|
|
181
|
+
});
|
|
305
182
|
return applyTransform(response.data, [
|
|
306
183
|
snakeToCamel([
|
|
307
184
|
'custom',
|
|
308
185
|
]),
|
|
309
|
-
merge(defaultObject),
|
|
310
|
-
itemResponseHandler,
|
|
311
|
-
formatAccessMode,
|
|
312
186
|
]);
|
|
313
187
|
} catch (err) {
|
|
314
188
|
throw applyTransform(err, [
|
|
@@ -317,16 +191,15 @@ const get = async ({ itemId: id }: GetItemParams) => {
|
|
|
317
191
|
}
|
|
318
192
|
};
|
|
319
193
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
'
|
|
325
|
-
|
|
326
|
-
|
|
194
|
+
// `custom` is tenant-defined and has no fixed shape, so it's not part of the
|
|
195
|
+
// generated body schemas — kept on the allowlist by hand alongside them.
|
|
196
|
+
const createFieldsToSend = [
|
|
197
|
+
...getShallowFieldsToSendFromZodSchema(CreateContactBody),
|
|
198
|
+
'custom',
|
|
199
|
+
];
|
|
200
|
+
const updateFieldsToSend = [
|
|
201
|
+
...getShallowFieldsToSendFromZodSchema(UpdateContactBody),
|
|
327
202
|
'custom',
|
|
328
|
-
'emails',
|
|
329
|
-
'phones',
|
|
330
203
|
];
|
|
331
204
|
|
|
332
205
|
const sanitizeManagers = (itemInstance: ApiParams) => {
|
|
@@ -374,35 +247,20 @@ const sanitizeGroups = (itemInstance: ApiParams) => {
|
|
|
374
247
|
};
|
|
375
248
|
};
|
|
376
249
|
|
|
377
|
-
const preRequestHandler = (item: ApiParams) => {
|
|
378
|
-
const copy = deepCopy(item);
|
|
379
|
-
copy.name = {
|
|
380
|
-
commonName: copy.name,
|
|
381
|
-
};
|
|
382
|
-
return copy;
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
const getGroupsFromResponse = (item: ApiParams) => {
|
|
386
|
-
return item.groups
|
|
387
|
-
? [
|
|
388
|
-
...item.groups.data.map((el: ApiParams) => el.group),
|
|
389
|
-
]
|
|
390
|
-
: [];
|
|
391
|
-
};
|
|
392
|
-
|
|
393
250
|
const add = async ({ itemInstance }: AddItemParams) => {
|
|
251
|
+
// `name`/`managers[].user`/`timezones[].timezone`/`groups[].group` are
|
|
252
|
+
// expected already in the shape `ContactsInputContact` declares (e.g.
|
|
253
|
+
// `name: { commonName }`, not a plain string) — callers build the draft
|
|
254
|
+
// against the raw `Contact` type now, so no request-side wrapping happens
|
|
255
|
+
// here anymore.
|
|
394
256
|
const item = applyTransform(itemInstance, [
|
|
395
|
-
preRequestHandler,
|
|
396
257
|
sanitizeManagers,
|
|
397
258
|
sanitizeTimezones,
|
|
398
259
|
sanitizeGroups,
|
|
399
|
-
|
|
400
|
-
camelToSnake([
|
|
401
|
-
'custom',
|
|
402
|
-
]),
|
|
260
|
+
sanitizeToWire(createFieldsToSend),
|
|
403
261
|
]);
|
|
404
262
|
try {
|
|
405
|
-
const response = await
|
|
263
|
+
const response = await getContacts().createContact(item);
|
|
406
264
|
return applyTransform(response.data, [
|
|
407
265
|
snakeToCamel([
|
|
408
266
|
'custom',
|
|
@@ -418,17 +276,15 @@ const add = async ({ itemInstance }: AddItemParams) => {
|
|
|
418
276
|
const update = async ({ itemInstance }: AddItemParams) => {
|
|
419
277
|
const { etag } = itemInstance;
|
|
420
278
|
const item = applyTransform(itemInstance, [
|
|
421
|
-
preRequestHandler,
|
|
422
279
|
sanitizeManagers,
|
|
423
280
|
sanitizeTimezones,
|
|
424
281
|
sanitizeGroups,
|
|
425
|
-
|
|
426
|
-
camelToSnake([
|
|
427
|
-
'custom',
|
|
428
|
-
]),
|
|
282
|
+
sanitizeToWire(updateFieldsToSend),
|
|
429
283
|
]);
|
|
430
284
|
try {
|
|
431
|
-
const response = await
|
|
285
|
+
const response = await getContacts().updateContact(etag, item, {
|
|
286
|
+
fields: contactFieldsToSend,
|
|
287
|
+
});
|
|
432
288
|
return applyTransform(response.data, [
|
|
433
289
|
snakeToCamel([
|
|
434
290
|
'custom',
|
|
@@ -443,7 +299,7 @@ const update = async ({ itemInstance }: AddItemParams) => {
|
|
|
443
299
|
|
|
444
300
|
const deleteContact = async ({ id }: DeleteItemParams) => {
|
|
445
301
|
try {
|
|
446
|
-
const response = await
|
|
302
|
+
const response = await getContacts().deleteContact(String(id));
|
|
447
303
|
return applyTransform(response.data, []);
|
|
448
304
|
} catch (err) {
|
|
449
305
|
throw applyTransform(err, [
|
|
@@ -452,14 +308,27 @@ const deleteContact = async ({ id }: DeleteItemParams) => {
|
|
|
452
308
|
}
|
|
453
309
|
};
|
|
454
310
|
|
|
455
|
-
const getContactsLookup = (params: Parameters<typeof getList>[0]) =>
|
|
456
|
-
|
|
311
|
+
const getContactsLookup = async (params: Parameters<typeof getList>[0]) => {
|
|
312
|
+
// Every other entity's lookup returns a flat `{id, name: string}` shape,
|
|
313
|
+
// and generic search/select components across the app rely on that
|
|
314
|
+
// convention for their default option rendering — so `name` is flattened
|
|
315
|
+
// here (unlike `getList`/`get`, which return the raw `Contact` shape with
|
|
316
|
+
// `name: { commonName }`) to keep lookups a drop-in for those components.
|
|
317
|
+
const { items, next } = await getList({
|
|
457
318
|
...params,
|
|
458
319
|
fields: params.fields || [
|
|
459
320
|
'id',
|
|
460
321
|
'name',
|
|
461
322
|
],
|
|
462
323
|
});
|
|
324
|
+
return {
|
|
325
|
+
items: items.map((item: ApiParams) => ({
|
|
326
|
+
...item,
|
|
327
|
+
name: item.name?.commonName,
|
|
328
|
+
})),
|
|
329
|
+
next,
|
|
330
|
+
};
|
|
331
|
+
};
|
|
463
332
|
|
|
464
333
|
export const ContactsAPI = {
|
|
465
334
|
getList,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DataInputDictionary } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import type { ZodShape } from '../types';
|
|
5
|
+
|
|
6
|
+
export const adjunctTypeSchema = z.object<ZodShape<DataInputDictionary>>({
|
|
7
|
+
name: z.string().min(1),
|
|
8
|
+
repo: z
|
|
9
|
+
.string()
|
|
10
|
+
.min(1)
|
|
11
|
+
.regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/),
|
|
12
|
+
about: z.string().optional(),
|
|
13
|
+
administered: z.boolean().optional(),
|
|
14
|
+
primary: z.string().optional(),
|
|
15
|
+
display: z.string().optional(),
|
|
16
|
+
fields: z.array(z.any()).optional(),
|
|
17
|
+
indexes: z.any().optional(),
|
|
18
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { WebitelCasesCase } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { lookupSchema } from '../_shared/lookup.validations';
|
|
5
|
+
|
|
6
|
+
const lookupShape = () => lookupSchema.passthrough().default({});
|
|
7
|
+
|
|
8
|
+
const statusConditionShape = () =>
|
|
9
|
+
z
|
|
10
|
+
.object({
|
|
11
|
+
id: z
|
|
12
|
+
.union([
|
|
13
|
+
z.string(),
|
|
14
|
+
z.number(),
|
|
15
|
+
])
|
|
16
|
+
.optional(),
|
|
17
|
+
name: z.string().optional(),
|
|
18
|
+
final: z.boolean().optional(),
|
|
19
|
+
initial: z.boolean().optional(),
|
|
20
|
+
})
|
|
21
|
+
.passthrough()
|
|
22
|
+
.default({});
|
|
23
|
+
|
|
24
|
+
export const caseSchema = z.object({
|
|
25
|
+
subject: z.string().default(''),
|
|
26
|
+
source: lookupShape(),
|
|
27
|
+
priority: lookupShape(),
|
|
28
|
+
reporter: lookupShape(),
|
|
29
|
+
service: lookupShape(),
|
|
30
|
+
statusCondition: statusConditionShape(),
|
|
31
|
+
closeReason: lookupShape(),
|
|
32
|
+
closeResult: z.string().default(''),
|
|
33
|
+
} satisfies Partial<Record<keyof WebitelCasesCase, z.ZodType>>);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const caseCloseSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
reason: z
|
|
6
|
+
.object({
|
|
7
|
+
id: z.union([
|
|
8
|
+
z.string(),
|
|
9
|
+
z.number(),
|
|
10
|
+
]),
|
|
11
|
+
})
|
|
12
|
+
.passthrough()
|
|
13
|
+
.nullable(),
|
|
14
|
+
result: z.string().nullable(),
|
|
15
|
+
})
|
|
16
|
+
.superRefine((data, ctx) => {
|
|
17
|
+
if (!data.reason?.id) {
|
|
18
|
+
ctx.addIssue({
|
|
19
|
+
code: 'custom',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!data.result) {
|
|
24
|
+
ctx.addIssue({
|
|
25
|
+
code: 'custom',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export type CaseClose = z.infer<typeof caseCloseSchema>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const caseExportOptionsSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
type: z
|
|
6
|
+
.object({
|
|
7
|
+
name: z.string(),
|
|
8
|
+
value: z.string(),
|
|
9
|
+
})
|
|
10
|
+
.nullable(),
|
|
11
|
+
separator: z.string().nullable(),
|
|
12
|
+
})
|
|
13
|
+
.superRefine((data, ctx) => {
|
|
14
|
+
if (!data.type) {
|
|
15
|
+
ctx.addIssue({
|
|
16
|
+
code: 'custom',
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (data.type?.value === 'csv' && !data.separator) {
|
|
21
|
+
ctx.addIssue({
|
|
22
|
+
code: 'custom',
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type CaseExportOptions = z.infer<typeof caseExportOptionsSchema>;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import type { WebitelContactsContact } from '@webitel/api-services/gen/models';
|
|
1
2
|
import { z } from 'zod';
|
|
2
|
-
import type { ContactEntity } from '../../api/clients/сontacts/types/ContactEntity.types';
|
|
3
3
|
import type { ZodShape } from '../types';
|
|
4
4
|
|
|
5
|
-
export const contactSchema = z.object<ZodShape<
|
|
6
|
-
name: z
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export const contactSchema = z.object<ZodShape<WebitelContactsContact>>({
|
|
6
|
+
name: z
|
|
7
|
+
.object({
|
|
8
|
+
commonName: z.string().optional(),
|
|
9
|
+
})
|
|
10
|
+
.passthrough()
|
|
11
|
+
.optional(),
|
|
12
|
+
timezones: z.any().optional(),
|
|
13
|
+
managers: z.any().optional(),
|
|
14
|
+
groups: z.any().optional(),
|
|
15
|
+
labels: z.any().optional(),
|
|
11
16
|
about: z.string().nullish(),
|
|
12
17
|
user: z.any().nullish(),
|
|
13
18
|
});
|
package/src/validations/index.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export * from './_shared/duration.validations';
|
|
2
2
|
export * from './_shared/lookup.validations';
|
|
3
3
|
export * from './_shared/variablePair.validations';
|
|
4
|
+
export * from './adjunctType/adjunctType.validations';
|
|
4
5
|
export * from './auditForm/auditForm.validations';
|
|
5
6
|
export * from './bucket/bucket.validations';
|
|
6
7
|
export * from './calendar/calendar.validations';
|
|
8
|
+
export * from './case/case.validations';
|
|
9
|
+
export * from './caseClose/caseClose.validations';
|
|
7
10
|
export * from './caseCloseReason/caseCloseReason.validations';
|
|
8
11
|
export * from './caseCloseReasonGroup/caseCloseReasonGroup.validations';
|
|
12
|
+
export * from './caseExportOptions/caseExportOptions.validations';
|
|
9
13
|
export * from './casePriority/casePriority.validations';
|
|
10
14
|
export * from './caseService/caseService.validations';
|
|
11
15
|
export * from './caseServiceCatalog/caseServiceCatalog.validations';
|
|
@@ -32,5 +36,6 @@ export * from './queueResGroup/queueResGroup.validations';
|
|
|
32
36
|
export * from './queueSkill/queueSkill.validations';
|
|
33
37
|
export * from './sla/sla.validations';
|
|
34
38
|
export * from './slaCondition/slaCondition.validations';
|
|
39
|
+
export * from './typeExtension/typeExtension.validations';
|
|
35
40
|
export * from './types';
|
|
36
41
|
export * from './variable/variable.validations';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProtoDataStruct } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import type { ZodShape } from '../types';
|
|
5
|
+
|
|
6
|
+
export const typeExtensionSchema = z.object<ZodShape<ProtoDataStruct>>({
|
|
7
|
+
fields: z.array(z.any()).optional(),
|
|
8
|
+
});
|