@webitel/api-services 26.8.3 → 26.8.5
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/queues/queueMembers.ts +89 -1
- package/src/api/clients/wtTypes/adjunctTypes/adjunctTypes.ts +2 -0
- package/src/api/clients/wtTypes/typeExtensions/typeExtensions.ts +2 -0
- package/types/.tsbuildinfo +1 -1
- package/types/api/clients/queues/queueMembers.d.ts +5 -0
package/package.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ExportMembersParams,
|
|
3
|
+
SearchMemberInQueueParams,
|
|
4
|
+
} from '@webitel/api-services/gen/models';
|
|
2
5
|
import { getShallowFieldsToSendFromZodSchema } from '@webitel/api-services/gen/utils';
|
|
3
6
|
import { queueMemberSchema } from '@webitel/api-services/validations';
|
|
4
7
|
import deepCopy from 'deep-copy';
|
|
@@ -180,6 +183,90 @@ const getMembersList = async (params: ApiParams) => {
|
|
|
180
183
|
}
|
|
181
184
|
};
|
|
182
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Streamed CSV/XLSX export of the current filter set. Returns the raw axios
|
|
188
|
+
* response with an unread Blob body — the caller passes it to the shared
|
|
189
|
+
* `downloadFile` script to save it, same as PdfServicesAPI.downloadCallArchive.
|
|
190
|
+
*/
|
|
191
|
+
const exportMembers = async ({
|
|
192
|
+
parentId,
|
|
193
|
+
format,
|
|
194
|
+
separator,
|
|
195
|
+
...filters
|
|
196
|
+
}: ApiParams & {
|
|
197
|
+
parentId: ApiId;
|
|
198
|
+
}) => {
|
|
199
|
+
const {
|
|
200
|
+
search,
|
|
201
|
+
sort,
|
|
202
|
+
fields,
|
|
203
|
+
id,
|
|
204
|
+
createdAt,
|
|
205
|
+
offeringAt,
|
|
206
|
+
bucket,
|
|
207
|
+
memberPriority,
|
|
208
|
+
stopCause,
|
|
209
|
+
agent,
|
|
210
|
+
attempts,
|
|
211
|
+
name,
|
|
212
|
+
destination,
|
|
213
|
+
} = applyTransform(filters, [
|
|
214
|
+
({ createdAt, offeringAt, from, to, cause, stopCause, ...rest }) => ({
|
|
215
|
+
...rest,
|
|
216
|
+
createdAt: normalizeDatetimeRange(
|
|
217
|
+
createdAt ??
|
|
218
|
+
(from != null || to != null
|
|
219
|
+
? {
|
|
220
|
+
from,
|
|
221
|
+
to,
|
|
222
|
+
}
|
|
223
|
+
: undefined),
|
|
224
|
+
),
|
|
225
|
+
offeringAt: normalizeDatetimeRange(offeringAt),
|
|
226
|
+
stopCause: stopCause ?? cause,
|
|
227
|
+
}),
|
|
228
|
+
starToSearch('search'),
|
|
229
|
+
]);
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
const requestParams = {
|
|
233
|
+
q: search,
|
|
234
|
+
sort,
|
|
235
|
+
fields,
|
|
236
|
+
id,
|
|
237
|
+
bucket_id: bucket,
|
|
238
|
+
stop_cause: stopCause,
|
|
239
|
+
agent_id: agent,
|
|
240
|
+
'created_at.from': createdAt?.from,
|
|
241
|
+
'created_at.to': createdAt?.to,
|
|
242
|
+
'offering_at.from': offeringAt?.from,
|
|
243
|
+
'offering_at.to': offeringAt?.to,
|
|
244
|
+
'priority.from': memberPriority?.from,
|
|
245
|
+
'priority.to': memberPriority?.to,
|
|
246
|
+
'attempts.from': attempts?.from,
|
|
247
|
+
'attempts.to': attempts?.to,
|
|
248
|
+
name,
|
|
249
|
+
destination,
|
|
250
|
+
format,
|
|
251
|
+
separator,
|
|
252
|
+
} as ExportMembersParams;
|
|
253
|
+
const response = await getMemberService().exportMembers(
|
|
254
|
+
Number(parentId),
|
|
255
|
+
requestParams,
|
|
256
|
+
{
|
|
257
|
+
responseType: 'blob',
|
|
258
|
+
},
|
|
259
|
+
);
|
|
260
|
+
return {
|
|
261
|
+
response,
|
|
262
|
+
};
|
|
263
|
+
} catch (err) {
|
|
264
|
+
throw applyTransform(err, [
|
|
265
|
+
notify,
|
|
266
|
+
]);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
183
270
|
const getMember = async ({ parentId, itemId: id }: NestedGetItemParams) => {
|
|
184
271
|
const responseHandler = (response: ApiParams) => {
|
|
185
272
|
const copy = deepCopy(response);
|
|
@@ -431,6 +518,7 @@ const deleteMembersBulk = async ({
|
|
|
431
518
|
|
|
432
519
|
export const QueueMembersAPI = {
|
|
433
520
|
getList: getMembersList,
|
|
521
|
+
exportMembers,
|
|
434
522
|
getQuantity: getMembersQuantity,
|
|
435
523
|
get: getMember,
|
|
436
524
|
add: addMember,
|
|
@@ -124,6 +124,7 @@ const addAdjunctType = async ({ itemInstance }: AddItemParams) => {
|
|
|
124
124
|
return applyTransform(response.data, [
|
|
125
125
|
snakeToCamel(),
|
|
126
126
|
itemResponseHandler,
|
|
127
|
+
assignFieldPositions,
|
|
127
128
|
]);
|
|
128
129
|
} catch (err) {
|
|
129
130
|
throw applyTransform(err, [
|
|
@@ -146,6 +147,7 @@ const updateAdjunctType = async ({
|
|
|
146
147
|
return applyTransform(response.data, [
|
|
147
148
|
snakeToCamel(),
|
|
148
149
|
itemResponseHandler,
|
|
150
|
+
assignFieldPositions,
|
|
149
151
|
]);
|
|
150
152
|
} catch (err) {
|
|
151
153
|
throw applyTransform(err, [
|
|
@@ -62,6 +62,7 @@ const addTypeExtension = async ({
|
|
|
62
62
|
return applyTransform(response.data, [
|
|
63
63
|
snakeToCamel(),
|
|
64
64
|
generateIdsFromRepos,
|
|
65
|
+
assignFieldPositions,
|
|
65
66
|
]);
|
|
66
67
|
} catch (err) {
|
|
67
68
|
throw applyTransform(err, [
|
|
@@ -124,6 +125,7 @@ const updateTypeExtension = async ({
|
|
|
124
125
|
return applyTransform(response.data, [
|
|
125
126
|
snakeToCamel(),
|
|
126
127
|
generateIdsFromRepos,
|
|
128
|
+
assignFieldPositions,
|
|
127
129
|
]);
|
|
128
130
|
} catch (err) {
|
|
129
131
|
throw applyTransform(err, [
|