@webitel/api-services 26.8.43 → 26.8.45

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.43",
3
+ "version": "26.8.45",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,11 @@
1
+ import type { LocateCaseNeighborDirection } from '@webitel/api-services/gen/models';
2
+ import type { ApiParams, GetItemParams } from '../../_shared/types';
3
+
4
+ export interface GetCaseParams extends GetItemParams {
5
+ listParams?: ApiParams;
6
+ }
7
+
8
+ export interface GetCaseNeighborParams extends GetItemParams {
9
+ direction: LocateCaseNeighborDirection;
10
+ listParams: ApiParams;
11
+ }
@@ -21,10 +21,10 @@ import type {
21
21
  ApiId,
22
22
  ApiParams,
23
23
  DeleteItemParams,
24
- GetItemParams,
25
24
  } from '../_shared/types';
26
25
  import { FTSServiceAPI } from './_internals/ftsService';
27
26
  import { stringifyCaseFilters } from './_internals/stringifyCaseFilters';
27
+ import type { GetCaseNeighborParams, GetCaseParams } from './_internals/types';
28
28
 
29
29
  const casesService = getCases();
30
30
 
@@ -174,11 +174,36 @@ const caseFieldsToSend = [
174
174
  'custom',
175
175
  ];
176
176
 
177
- const getCase = async ({ itemId: id }: GetItemParams) => {
177
+ const caseNeighborFields = [
178
+ 'has_prev',
179
+ 'has_next',
180
+ ];
181
+
182
+ const getCaseListContext = ({ sort, ...filters }: ApiParams) => ({
183
+ q: filters.search,
184
+ sort,
185
+ filters: stringifyCaseFilters(filters),
186
+ });
187
+
188
+ const getLocateCaseParams = (listParams?: ApiParams) =>
189
+ listParams
190
+ ? {
191
+ ...getCaseListContext(listParams),
192
+ fields: [
193
+ ...caseFieldsToSend,
194
+ ...caseNeighborFields,
195
+ ],
196
+ }
197
+ : {
198
+ fields: caseFieldsToSend,
199
+ };
200
+
201
+ const getCase = async ({ itemId: id, listParams }: GetCaseParams) => {
178
202
  try {
179
- const response = await casesService.locateCase(String(id), {
180
- fields: caseFieldsToSend,
181
- });
203
+ const response = await casesService.locateCase(
204
+ String(id),
205
+ getLocateCaseParams(listParams),
206
+ );
182
207
  return applyTransform(response.data, [
183
208
  snakeToCamel([
184
209
  'custom',
@@ -193,6 +218,29 @@ const getCase = async ({ itemId: id }: GetItemParams) => {
193
218
  }
194
219
  };
195
220
 
221
+ const getCaseNeighbor = async ({
222
+ itemId: id,
223
+ direction,
224
+ listParams,
225
+ }: GetCaseNeighborParams) => {
226
+ try {
227
+ const response = await casesService.locateCaseNeighbor(String(id), {
228
+ ...getCaseListContext(listParams),
229
+ direction,
230
+ fields: [
231
+ 'id',
232
+ ],
233
+ });
234
+ return applyTransform(response.data, [
235
+ snakeToCamel(),
236
+ ]);
237
+ } catch (err) {
238
+ throw applyTransform(err, [
239
+ notify,
240
+ ]);
241
+ }
242
+ };
243
+
196
244
  const deleteCase = async ({ id }: DeleteItemParams) => {
197
245
  try {
198
246
  const response = await casesService.deleteCase(String(id));
@@ -364,6 +412,7 @@ export const CasesAPI = {
364
412
  getList: getCasesList,
365
413
  getLookup: getCasesLookup,
366
414
  get: getCase,
415
+ getNeighbor: getCaseNeighbor,
367
416
  delete: deleteCase,
368
417
  update: updateCase,
369
418
  add: addCase,
@@ -8,7 +8,7 @@ import {
8
8
  snakeToCamel,
9
9
  starToSearch,
10
10
  } from '../../transformers';
11
- import type { ApiParams } from '../_shared/types';
11
+ import type { ApiParams, GetItemParams } from '../_shared/types';
12
12
 
13
13
  /**
14
14
  * The logger endpoints have no natural ordering, so both lists default to
@@ -146,6 +146,19 @@ const getLogsByConfigList = async (params: ApiParams) => {
146
146
  }
147
147
  };
148
148
 
149
+ const getLog = async ({ itemId: id }: GetItemParams) => {
150
+ try {
151
+ const response = await getLoggerService().loggerServiceGetLog(Number(id));
152
+ return applyTransform(response.data, [
153
+ snakeToCamel(),
154
+ ]);
155
+ } catch (err) {
156
+ throw applyTransform(err, [
157
+ notify,
158
+ ]);
159
+ }
160
+ };
161
+
149
162
  /** Audit log of everything one user did. */
150
163
  export const UserLogsAPI = {
151
164
  getList: getLogsByUserList,
@@ -154,4 +167,5 @@ export const UserLogsAPI = {
154
167
  /** Audit log of everything done to one logger config's object. */
155
168
  export const ConfigLogsAPI = {
156
169
  getList: getLogsByConfigList,
170
+ get: getLog,
157
171
  };