@webitel/api-services 26.8.43 → 26.8.44
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
|
@@ -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
|
|
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(
|
|
180
|
-
|
|
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,
|