@webitel/api-services 26.8.4 → 26.8.6

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/api-services",
3
- "version": "26.8.4",
3
+ "version": "26.8.6",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,7 +48,7 @@ const getServicesList = async ({
48
48
  ...rest
49
49
  }: {
50
50
  parentId?: ApiId;
51
- rootId: ApiId;
51
+ rootId?: ApiId;
52
52
  } & ApiParams) => {
53
53
  const listFieldsToSend = getShallowFieldsToSendFromZodSchema(
54
54
  ListServicesQueryParams,
@@ -65,6 +65,8 @@ const getServicesList = async ({
65
65
  camelToSnake(),
66
66
  ]);
67
67
 
68
+ const catalogId = rootId ?? parentId;
69
+
68
70
  try {
69
71
  const response = await getServices().listServices({
70
72
  page,
@@ -72,7 +74,7 @@ const getServicesList = async ({
72
74
  sort,
73
75
  id,
74
76
  q,
75
- root_id: String(rootId ?? parentId),
77
+ root_id: catalogId != null ? String(catalogId) : undefined,
76
78
  fields,
77
79
  });
78
80
  const { items, next } = applyTransform(response.data, [
@@ -1,4 +1,7 @@
1
- import type { SearchMemberInQueueParams } from '@webitel/api-services/gen/models';
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,