@webitel/api-services 26.8.4 → 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
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,
|