@monkvision/network 4.3.16 → 4.4.0

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/README.md CHANGED
@@ -210,33 +210,33 @@ Delete a damage of an inspection.
210
210
  |-----------|---------------------|-----------------------------|----------|
211
211
  | options | DeleteDamageOptions | The options of the request. | ✔️ |
212
212
 
213
- ### getInspections
213
+ ### getAllInspections
214
214
  ```typescript
215
215
  import { MonkApi } from '@monkvision/network';
216
216
 
217
- MonkApi.getInspections(options, apiConfig, dispatch);
217
+ MonkApi.getAllInspections(options, apiConfig, dispatch);
218
218
  ```
219
219
 
220
220
  Fetch the details of multiple inspections using the provided filters. The resulting action of this request will contain
221
221
  a list of all entities that match the specified criteria.
222
222
 
223
- | Parameter | Type | Description | Required |
224
- |-----------|-----------------------|-----------------------------|----------|
225
- | options | getInspectionsOptions | The options of the request. | ✔️ |
223
+ | Parameter | Type | Description | Required |
224
+ |-----------|--------------------------|-----------------------------|----------|
225
+ | options | GetAllInspectionsOptions | The options of the request. | ✔️ |
226
226
 
227
227
 
228
- ### getInspectionsCount
228
+ ### getAllInspectionsCount
229
229
  ```typescript
230
230
  import { MonkApi } from '@monkvision/network';
231
231
 
232
- MonkApi.getInspectionsCount(options, apiConfig, dispatch);
232
+ MonkApi.getAllInspectionsCount(options, apiConfig, dispatch);
233
233
  ```
234
234
 
235
235
  Gets the count of inspections that match the given filters.
236
236
 
237
- | Parameter | Type | Description | Required |
238
- |-----------|-----------------------|-----------------------------|----------|
239
- | options | getInspectionsOptions | The options of the request. | ✔️ |
237
+ | Parameter | Type | Description | Required |
238
+ |-----------|--------------------------|-----------------------------|----------|
239
+ | options | GetAllInspectionsOptions | The options of the request. | ✔️ |
240
240
 
241
241
  # React Tools
242
242
  In order to simply integrate the Monk Api requests into your React app, you can make use of the `useMonkApi` hook. This
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkvision/network",
3
- "version": "4.3.15",
3
+ "version": "4.3.16",
4
4
  "license": "BSD-3-Clause-Clear",
5
5
  "packageManager": "yarn@3.2.4",
6
6
  "description": "MonkJs core package used to communicate with the API",
@@ -28,8 +28,8 @@
28
28
  "lint:fix": "yarn run prettier:fix && yarn run eslint:fix"
29
29
  },
30
30
  "dependencies": {
31
- "@monkvision/common": "4.3.15",
32
- "@monkvision/sights": "4.3.15",
31
+ "@monkvision/common": "4.3.16",
32
+ "@monkvision/sights": "4.3.16",
33
33
  "jsonwebtoken": "^9.0.2",
34
34
  "jwt-decode": "^4.0.0",
35
35
  "ky": "^1.2.0",
@@ -42,12 +42,12 @@
42
42
  "react-router-dom": "^6.22.3"
43
43
  },
44
44
  "devDependencies": {
45
- "@monkvision/eslint-config-base": "4.3.15",
46
- "@monkvision/eslint-config-typescript": "4.3.15",
47
- "@monkvision/jest-config": "4.3.15",
48
- "@monkvision/prettier-config": "4.3.15",
49
- "@monkvision/types": "4.3.15",
50
- "@monkvision/typescript-config": "4.3.15",
45
+ "@monkvision/eslint-config-base": "4.3.16",
46
+ "@monkvision/eslint-config-typescript": "4.3.16",
47
+ "@monkvision/jest-config": "4.3.16",
48
+ "@monkvision/prettier-config": "4.3.16",
49
+ "@monkvision/types": "4.3.16",
50
+ "@monkvision/typescript-config": "4.3.16",
51
51
  "@types/jest": "^29.2.2",
52
52
  "@types/jsonwebtoken": "^9.0.5",
53
53
  "@types/node": "^18.11.9",
@@ -1,4 +1,4 @@
1
- import { getInspection, createInspection, updateAdditionalData, getInspections, getInspectionsCount } from './inspection';
1
+ import { getInspection, createInspection, updateAdditionalData, getAllInspections, getAllInspectionsCount } from './inspection';
2
2
  import { addImage } from './image';
3
3
  import { startInspectionTasks, updateTaskStatus } from './task';
4
4
  import { getLiveConfig } from './liveConfigs';
@@ -11,8 +11,8 @@ import { createDamage, deleteDamage } from './damage';
11
11
  */
12
12
  export declare const MonkApi: {
13
13
  getInspection: typeof getInspection;
14
- getInspections: typeof getInspections;
15
- getInspectionsCount: typeof getInspectionsCount;
14
+ getAllInspections: typeof getAllInspections;
15
+ getAllInspectionsCount: typeof getAllInspectionsCount;
16
16
  createInspection: typeof createInspection;
17
17
  addImage: typeof addImage;
18
18
  updateTaskStatus: typeof updateTaskStatus;
@@ -14,8 +14,8 @@ var damage_1 = require("./damage");
14
14
  */
15
15
  exports.MonkApi = {
16
16
  getInspection: inspection_1.getInspection,
17
- getInspections: inspection_1.getInspections,
18
- getInspectionsCount: inspection_1.getInspectionsCount,
17
+ getAllInspections: inspection_1.getAllInspections,
18
+ getAllInspectionsCount: inspection_1.getAllInspectionsCount,
19
19
  createInspection: inspection_1.createInspection,
20
20
  addImage: image_1.addImage,
21
21
  updateTaskStatus: task_1.updateTaskStatus,
@@ -4,7 +4,7 @@ export { useMonkApi } from './react';
4
4
  export { MonkNetworkError, type MonkHTTPError } from './error';
5
5
  export { MonkApi } from './api';
6
6
  export * from './hooks';
7
- export { type GetInspectionOptions, type GetInspectionResponse } from './inspection';
7
+ export { type GetInspectionOptions, type GetInspectionResponse, type GetAllInspectionsCountResponse, type UpdateAdditionalDataOptions, type GetAllInspectionsResponse, } from './inspection';
8
8
  export { type AddImageResponse, type AddBeautyShotImageOptions, type Add2ShotCloseUpImageOptions, type AddImageOptions, type AddVideoFrameOptions, ImageUploadType, } from './image';
9
9
  export { type UpdateProgressStatus, type UpdateTaskStatusOptions, type StartInspectionTasksOptions, } from './task';
10
10
  export { type UpdateInspectionVehicleOptions } from './vehicle';
@@ -1,7 +1,7 @@
1
1
  import { MonkState } from '@monkvision/common';
2
2
  import { ComplianceOptions, CreateInspectionOptions, SortOrder } from '@monkvision/types';
3
- import { ApiInspectionGet, ApiInspectionPost, ApiInspectionsGet } from '../models';
4
- export declare function mapApiInspectionsGet(response: ApiInspectionsGet, thumbnailDomain: string): MonkState;
3
+ import { ApiAllInspectionsVerboseGet, ApiInspectionGet, ApiInspectionPost } from '../models';
4
+ export declare function mapApiAllInspectionsVerboseGet(data: ApiAllInspectionsVerboseGet[], thumbnailDomain: string): MonkState;
5
5
  export declare function mapApiInspectionGet(response: ApiInspectionGet, thumbnailDomain: string, complianceOptions?: ComplianceOptions): MonkState;
6
6
  export declare function mapApiInspectionPost(options: CreateInspectionOptions): ApiInspectionPost;
7
7
  /**
@@ -39,9 +39,9 @@ export interface SortRequestParams {
39
39
  sortOrder?: SortOrder;
40
40
  }
41
41
  /**
42
- * Options passed to the `getInspections` or `getInspectionsCount` API request.
42
+ * Options passed to the `getAllInspections` or `getAllInspectionsCount` API request.
43
43
  */
44
- export interface GetInspectionsOptions {
44
+ export interface GetAllInspectionsOptions {
45
45
  /**
46
46
  * The filter request parameters.
47
47
  */
@@ -55,4 +55,4 @@ export interface GetInspectionsOptions {
55
55
  */
56
56
  sort?: SortRequestParams;
57
57
  }
58
- export declare function mapApiInspectionsUrlParamsGet(options: GetInspectionsOptions): string;
58
+ export declare function mapApiAllInspectionsUrlParamsGet(options: GetAllInspectionsOptions, verbose: boolean): string;
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.mapApiInspectionsUrlParamsGet = exports.mapApiInspectionPost = exports.mapApiInspectionGet = exports.mapApiInspectionsGet = void 0;
14
+ exports.mapApiAllInspectionsUrlParamsGet = exports.mapApiInspectionPost = exports.mapApiInspectionGet = exports.mapApiAllInspectionsVerboseGet = void 0;
15
15
  var types_1 = require("@monkvision/types");
16
16
  var mappers_1 = require("../image/mappers");
17
17
  var config_1 = require("../config");
@@ -28,7 +28,9 @@ function mapDamages(response) {
28
28
  type: damage.damage_type,
29
29
  size: damage.damage_size_cm,
30
30
  parts: (_a = damage.part_ids) !== null && _a !== void 0 ? _a : [],
31
- relatedImages: (_c = (_b = damage.related_images) === null || _b === void 0 ? void 0 : _b.map(function (relatedImage) { return relatedImage.base_image_id; })) !== null && _c !== void 0 ? _c : [],
31
+ relatedImages: (_c = ('related_images' in damage
32
+ ? (_b = damage.related_images) === null || _b === void 0 ? void 0 : _b.map(function (relatedImage) { return relatedImage.base_image_id; })
33
+ : [])) !== null && _c !== void 0 ? _c : [],
32
34
  });
33
35
  damageIds.push(damage.id);
34
36
  });
@@ -90,19 +92,23 @@ function mapImages(response, thumbnailDomain, complianceOptions) {
90
92
  var _a, _b;
91
93
  var imageRenderedOutputs = [];
92
94
  var imageViews = [];
93
- (_a = image.rendered_outputs) === null || _a === void 0 ? void 0 : _a.forEach(function (renderedOutput) {
94
- renderedOutputIds.push(renderedOutput.id);
95
- imageRenderedOutputs.push(renderedOutput.id);
96
- renderedOutputs.push(mapRenderedOutput(renderedOutput));
97
- });
98
- (_b = image.views) === null || _b === void 0 ? void 0 : _b.forEach(function (apiView) {
99
- var _a = mapView(apiView), view = _a.view, viewRenderedOutputs = _a.renderedOutputs;
100
- viewIds.push(view.id);
101
- imageViews.push(view.id);
102
- views.push(view);
103
- renderedOutputs.push.apply(renderedOutputs, viewRenderedOutputs);
104
- renderedOutputIds.push.apply(renderedOutputIds, view.renderedOutputs);
105
- });
95
+ if ('rendered_outputs' in image) {
96
+ (_a = image.rendered_outputs) === null || _a === void 0 ? void 0 : _a.forEach(function (renderedOutput) {
97
+ renderedOutputIds.push(renderedOutput.id);
98
+ imageRenderedOutputs.push(renderedOutput.id);
99
+ renderedOutputs.push(mapRenderedOutput(renderedOutput));
100
+ });
101
+ }
102
+ if ('views' in image) {
103
+ (_b = image.views) === null || _b === void 0 ? void 0 : _b.forEach(function (apiView) {
104
+ var _a = mapView(apiView), view = _a.view, viewRenderedOutputs = _a.renderedOutputs;
105
+ viewIds.push(view.id);
106
+ imageViews.push(view.id);
107
+ views.push(view);
108
+ renderedOutputs.push.apply(renderedOutputs, viewRenderedOutputs);
109
+ renderedOutputIds.push.apply(renderedOutputIds, view.renderedOutputs);
110
+ });
111
+ }
106
112
  imageIds.push(image.id);
107
113
  images.push(__assign(__assign({}, (0, mappers_1.mapApiImage)(image, response.id, thumbnailDomain, complianceOptions)), { renderedOutputs: imageRenderedOutputs, views: imageViews }));
108
114
  });
@@ -127,8 +133,10 @@ function mapParts(response) {
127
133
  entityType: types_1.MonkEntityType.PART,
128
134
  inspectionId: response.id,
129
135
  type: part.part_type,
130
- damages: (_a = part.damage_ids) !== null && _a !== void 0 ? _a : [],
131
- relatedImages: (_c = (_b = part.related_images) === null || _b === void 0 ? void 0 : _b.map(function (relatedImage) { return relatedImage.base_image_id; })) !== null && _c !== void 0 ? _c : [],
136
+ damages: (_a = ('damage_ids' in part ? part.damage_ids : [])) !== null && _a !== void 0 ? _a : [],
137
+ relatedImages: (_c = ('related_images' in part
138
+ ? (_b = part.related_images) === null || _b === void 0 ? void 0 : _b.map(function (relatedImage) { return relatedImage.base_image_id; })
139
+ : [])) !== null && _c !== void 0 ? _c : [],
132
140
  });
133
141
  });
134
142
  return { partIds: partIds, parts: parts };
@@ -253,17 +261,19 @@ function mapVehicle(response) {
253
261
  }
254
262
  function mapWheelAnalysis(response) {
255
263
  var _a, _b;
256
- return ((_b = (_a = response.wheel_analysis) === null || _a === void 0 ? void 0 : _a.map(function (wheelAnalysis) { return ({
257
- inspectionId: response.id,
258
- rimCondition: wheelAnalysis.rim_condition,
259
- rimMaterial: wheelAnalysis.rim_material,
260
- rimVisualAspect: wheelAnalysis.rim_visual_aspect,
261
- hubcapOverRim: wheelAnalysis.hubcap_over_rim,
262
- hubcapCondition: wheelAnalysis.hubcap_condition,
263
- hubcapVisualAspect: wheelAnalysis.hubcap_visual_aspect,
264
- imageId: wheelAnalysis.image_id,
265
- wheelName: wheelAnalysis.wheel_name,
266
- }); })) !== null && _b !== void 0 ? _b : []);
264
+ return ((_b = ('wheel_analysis' in response
265
+ ? (_a = response.wheel_analysis) === null || _a === void 0 ? void 0 : _a.map(function (wheelAnalysis) { return ({
266
+ inspectionId: response.id,
267
+ rimCondition: wheelAnalysis.rim_condition,
268
+ rimMaterial: wheelAnalysis.rim_material,
269
+ rimVisualAspect: wheelAnalysis.rim_visual_aspect,
270
+ hubcapOverRim: wheelAnalysis.hubcap_over_rim,
271
+ hubcapCondition: wheelAnalysis.hubcap_condition,
272
+ hubcapVisualAspect: wheelAnalysis.hubcap_visual_aspect,
273
+ imageId: wheelAnalysis.image_id,
274
+ wheelName: wheelAnalysis.wheel_name,
275
+ }); })
276
+ : [])) !== null && _b !== void 0 ? _b : []);
267
277
  }
268
278
  function mapInspection(response, ids) {
269
279
  return {
@@ -280,7 +290,7 @@ function mapInspection(response, ids) {
280
290
  additionalData: response.additional_data,
281
291
  };
282
292
  }
283
- function mapApiInspectionsGet(response, thumbnailDomain) {
293
+ function mapApiAllInspectionsVerboseGet(data, thumbnailDomain) {
284
294
  var state = {
285
295
  damages: [],
286
296
  images: [],
@@ -294,10 +304,7 @@ function mapApiInspectionsGet(response, thumbnailDomain) {
294
304
  pricings: [],
295
305
  partOperations: [],
296
306
  };
297
- if (!response.data) {
298
- return state;
299
- }
300
- return response.data.reduce(function (acc, inspection) {
307
+ return data.reduce(function (acc, inspection) {
301
308
  var _a, _b, _c, _d, _e;
302
309
  var _f = mapImages(inspection, thumbnailDomain), images = _f.images, renderedOutputs = _f.renderedOutputs, imageIds = _f.imageIds, renderedOutputIds = _f.renderedOutputIds, viewIds = _f.viewIds;
303
310
  var _g = mapDamages(inspection), damages = _g.damages, damageIds = _g.damageIds;
@@ -327,7 +334,7 @@ function mapApiInspectionsGet(response, thumbnailDomain) {
327
334
  return acc;
328
335
  }, state);
329
336
  }
330
- exports.mapApiInspectionsGet = mapApiInspectionsGet;
337
+ exports.mapApiAllInspectionsVerboseGet = mapApiAllInspectionsVerboseGet;
331
338
  function mapApiInspectionGet(response, thumbnailDomain, complianceOptions) {
332
339
  var _a = mapImages(response, thumbnailDomain, complianceOptions), images = _a.images, renderedOutputs = _a.renderedOutputs, views = _a.views, imageIds = _a.imageIds, renderedOutputIds = _a.renderedOutputIds, viewIds = _a.viewIds;
333
340
  var _b = mapDamages(response), damages = _b.damages, damageIds = _b.damageIds;
@@ -484,14 +491,17 @@ function mapApiInspectionPost(options) {
484
491
  };
485
492
  }
486
493
  exports.mapApiInspectionPost = mapApiInspectionPost;
487
- function mapApiInspectionsUrlParamsGet(options) {
494
+ function mapApiAllInspectionsUrlParamsGet(options, verbose) {
488
495
  var _a, _b;
489
496
  var params = new URLSearchParams();
490
- var url = options.filters || options.pagination ? '?' : '';
497
+ params.append('verbose', verbose ? '1' : '0');
498
+ var ignoredFilters = ['verbose'];
491
499
  if (options.filters) {
492
500
  Object.entries(options.filters).forEach(function (_a) {
493
501
  var key = _a[0], value = _a[1];
494
- params.append(key, value.toString());
502
+ if (!ignoredFilters.includes(key)) {
503
+ params.append(key, value.toString());
504
+ }
495
505
  });
496
506
  }
497
507
  if (options.pagination) {
@@ -506,6 +516,6 @@ function mapApiInspectionsUrlParamsGet(options) {
506
516
  if ((_b = options.sort) === null || _b === void 0 ? void 0 : _b.sortOrder) {
507
517
  params.append('pagination_order', options.sort.sortOrder.toString());
508
518
  }
509
- return "".concat(url).concat(params.toString());
519
+ return "?".concat(params.toString());
510
520
  }
511
- exports.mapApiInspectionsUrlParamsGet = mapApiInspectionsUrlParamsGet;
521
+ exports.mapApiAllInspectionsUrlParamsGet = mapApiAllInspectionsUrlParamsGet;
@@ -2,9 +2,9 @@ import { MonkAction, MonkGotOneInspectionAction, MonkState, MonkUpdatedOneInspec
2
2
  import { AdditionalData, ComplianceOptions, CreateInspectionOptions } from '@monkvision/types';
3
3
  import { Dispatch } from 'react';
4
4
  import { MonkApiConfig } from '../config';
5
- import { ApiInspectionGet, ApiInspectionsCountGet, ApiInspectionsGet } from '../models';
6
- import { GetInspectionsOptions } from './mappers';
7
- import { MonkApiResponse } from '../types';
5
+ import { ApiAllInspectionsVerboseGet, ApiInspectionGet, ApiInspectionsCountGet, ApiPaginatedResponse } from '../models';
6
+ import { GetAllInspectionsOptions } from './mappers';
7
+ import { MonkApiResponse, PaginationResponse } from '../types';
8
8
  /**
9
9
  * Options passed to the `getInspection` API request.
10
10
  */
@@ -28,9 +28,9 @@ export interface GetInspectionResponse {
28
28
  entities: MonkState;
29
29
  }
30
30
  /**
31
- * Type definition for the result of the `getInspectionsCount` API request.
31
+ * Type definition for the result of the `getAllInspectionsCount` API request.
32
32
  */
33
- export interface GetInspectionsCountResponse {
33
+ export interface GetAllInspectionsCountResponse {
34
34
  /**
35
35
  * The total number of inspections that match the given filters.
36
36
  */
@@ -79,6 +79,19 @@ export interface UpdateAdditionalDataOptions {
79
79
  * @see UpdateAdditionalDataOptions
80
80
  */
81
81
  export declare function updateAdditionalData(options: UpdateAdditionalDataOptions, config: MonkApiConfig, dispatch?: Dispatch<MonkUpdatedOneInspectionAdditionalDataAction>): Promise<MonkApiResponse>;
82
+ /**
83
+ * Type definition for the result of the `getAllInspection` API request.
84
+ */
85
+ export interface GetAllInspectionsResponse {
86
+ /**
87
+ * The normalized entities related to the inspections that have been fetched from the API.
88
+ */
89
+ entities: MonkState;
90
+ /**
91
+ * The pagination details.
92
+ */
93
+ pagination: PaginationResponse;
94
+ }
82
95
  /**
83
96
  * Fetch the details of multiple inspections.
84
97
  *
@@ -87,13 +100,13 @@ export declare function updateAdditionalData(options: UpdateAdditionalDataOption
87
100
  * @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
88
101
  * state management for you.
89
102
  */
90
- export declare function getInspections(options: GetInspectionsOptions, config: MonkApiConfig, dispatch?: Dispatch<MonkGotOneInspectionAction>): Promise<MonkApiResponse<GetInspectionResponse, ApiInspectionsGet>>;
103
+ export declare function getAllInspections(options: GetAllInspectionsOptions, config: MonkApiConfig, dispatch?: Dispatch<MonkGotOneInspectionAction>): Promise<MonkApiResponse<GetAllInspectionsResponse, ApiPaginatedResponse<ApiAllInspectionsVerboseGet>>>;
91
104
  /**
92
105
  * Gets the count of inspections that match the given filters.
93
106
  *
94
107
  * @param options The options of the request.
95
108
  * @param config The API config.
96
- * @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
109
+ * @param [_dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
97
110
  * state management for you.
98
111
  */
99
- export declare function getInspectionsCount(options: GetInspectionsOptions, config: MonkApiConfig, _dispatch?: Dispatch<MonkAction>): Promise<MonkApiResponse<GetInspectionsCountResponse, ApiInspectionsCountGet>>;
112
+ export declare function getAllInspectionsCount(options: GetAllInspectionsOptions, config: MonkApiConfig, _dispatch?: Dispatch<MonkAction>): Promise<MonkApiResponse<GetAllInspectionsCountResponse, ApiInspectionsCountGet>>;
@@ -50,7 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.getInspectionsCount = exports.getInspections = exports.updateAdditionalData = exports.createInspection = exports.getInspection = void 0;
53
+ exports.getAllInspectionsCount = exports.getAllInspections = exports.updateAdditionalData = exports.createInspection = exports.getInspection = void 0;
54
54
  var ky_1 = __importDefault(require("ky"));
55
55
  var common_1 = require("@monkvision/common");
56
56
  var config_1 = require("../config");
@@ -174,46 +174,50 @@ exports.updateAdditionalData = updateAdditionalData;
174
174
  * @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
175
175
  * state management for you.
176
176
  */
177
- function getInspections(options, config, dispatch) {
177
+ function getAllInspections(options, config, dispatch) {
178
178
  return __awaiter(this, void 0, void 0, function () {
179
- var kyOptions, response, body, entities;
179
+ var kyOptions, response, body, entities, pagination;
180
180
  return __generator(this, function (_a) {
181
181
  switch (_a.label) {
182
182
  case 0:
183
183
  kyOptions = (0, config_1.getDefaultOptions)(config);
184
- return [4 /*yield*/, ky_1.default.get("inspections".concat((0, mappers_1.mapApiInspectionsUrlParamsGet)(options)), kyOptions)];
184
+ return [4 /*yield*/, ky_1.default.get("inspections".concat((0, mappers_1.mapApiAllInspectionsUrlParamsGet)(options, true)), kyOptions)];
185
185
  case 1:
186
186
  response = _a.sent();
187
187
  return [4 /*yield*/, response.json()];
188
188
  case 2:
189
189
  body = _a.sent();
190
- entities = (0, mappers_1.mapApiInspectionsGet)(body, config.thumbnailDomain);
190
+ entities = (0, mappers_1.mapApiAllInspectionsVerboseGet)(body.data, config.thumbnailDomain);
191
+ pagination = {
192
+ before: body.paging.cursors.before,
193
+ after: body.paging.cursors.after,
194
+ };
191
195
  dispatch === null || dispatch === void 0 ? void 0 : dispatch({
192
196
  type: common_1.MonkActionType.GOT_ONE_INSPECTION,
193
197
  payload: entities,
194
198
  });
195
- return [2 /*return*/, { entities: entities, response: response, body: body }];
199
+ return [2 /*return*/, { entities: entities, pagination: pagination, response: response, body: body }];
196
200
  }
197
201
  });
198
202
  });
199
203
  }
200
- exports.getInspections = getInspections;
204
+ exports.getAllInspections = getAllInspections;
201
205
  /**
202
206
  * Gets the count of inspections that match the given filters.
203
207
  *
204
208
  * @param options The options of the request.
205
209
  * @param config The API config.
206
- * @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
210
+ * @param [_dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
207
211
  * state management for you.
208
212
  */
209
- function getInspectionsCount(options, config, _dispatch) {
213
+ function getAllInspectionsCount(options, config, _dispatch) {
210
214
  return __awaiter(this, void 0, void 0, function () {
211
215
  var kyOptions, response, body;
212
216
  return __generator(this, function (_a) {
213
217
  switch (_a.label) {
214
218
  case 0:
215
219
  kyOptions = (0, config_1.getDefaultOptions)(config);
216
- return [4 /*yield*/, ky_1.default.get("inspections/count".concat((0, mappers_1.mapApiInspectionsUrlParamsGet)(options)), kyOptions)];
220
+ return [4 /*yield*/, ky_1.default.get("inspections/count".concat((0, mappers_1.mapApiAllInspectionsUrlParamsGet)(options, false)), kyOptions)];
217
221
  case 1:
218
222
  response = _a.sent();
219
223
  return [4 /*yield*/, response.json()];
@@ -224,4 +228,4 @@ function getInspectionsCount(options, config, _dispatch) {
224
228
  });
225
229
  });
226
230
  }
227
- exports.getInspectionsCount = getInspectionsCount;
231
+ exports.getAllInspectionsCount = getAllInspectionsCount;
@@ -8,6 +8,12 @@ export interface ApiDamage {
8
8
  part_ids: ApiPartIds;
9
9
  related_images?: ApiRelatedImages;
10
10
  }
11
+ export interface ApiDamageSimplifiedGet {
12
+ damage_type: string;
13
+ id: string;
14
+ part_ids: ApiPartIds;
15
+ damage_size_cm?: number;
16
+ }
11
17
  export type ApiDamages = ApiDamage[];
12
18
  export type ApiDamageIds = string[];
13
19
  export interface ApiDamagePost {
@@ -1,15 +1,14 @@
1
- import { SortOrder } from '@monkvision/types';
2
1
  import type { ApiAdditionalData } from './common';
3
- import type { ApiDamages } from './damage';
4
- import type { ApiImagePost, ApiImages } from './image';
5
- import type { ApiParts } from './part';
2
+ import { ApiDamages, ApiDamageSimplifiedGet } from './damage';
3
+ import { ApiImage, ApiImagePost, ApiImages } from './image';
4
+ import { ApiParts, ApiPartSimplifiedGet } from './part';
6
5
  import type { ApiPricingV2 } from './pricingV2';
7
6
  import type { ApiSeverityResults } from './severityResult';
8
7
  import type { ApiBusinessClients, ApiTasks } from './task';
8
+ import { ApiTasksComponent } from './task';
9
9
  import type { ApiVehicleComponent } from './vehicle';
10
- import type { ApiWheelAnalysis } from './wheelAnalysis';
11
10
  import { ApiVehiclePostPatch } from './vehicle';
12
- import { ApiTasksComponent } from './task';
11
+ import type { ApiWheelAnalysis } from './wheelAnalysis';
13
12
  export interface ApiInspectioAdditionalData extends ApiAdditionalData {
14
13
  is_video_capture?: boolean;
15
14
  use_3d_projection?: boolean;
@@ -27,30 +26,46 @@ export interface ApiInspectionGet {
27
26
  vehicle?: ApiVehicleComponent;
28
27
  wheel_analysis?: ApiWheelAnalysis;
29
28
  }
30
- interface ApiData extends Pick<ApiInspectionGet, 'id' | 'additional_data' | 'images' | 'damages' | 'pricing' | 'parts' | 'vehicle'> {
31
- pdf_url?: string;
32
- }
33
- interface ApiPaginationParams {
29
+ export type ApiPaginationOrder = 'asc' | 'desc';
30
+ export interface ApiPaginationParameters {
34
31
  limit?: number;
35
32
  before?: string;
36
33
  after?: string;
37
- pagination_order?: SortOrder;
34
+ pagination_order?: ApiPaginationOrder;
38
35
  }
39
- interface ApiCursors {
40
- before?: string;
36
+ export interface ApiCursors {
41
37
  after?: string;
42
- next?: ApiPaginationParams;
43
- previous?: ApiPaginationParams;
38
+ before?: string;
39
+ next?: ApiPaginationParameters;
40
+ previous?: ApiPaginationParameters;
44
41
  }
45
- interface ApiPagination {
46
- cursors: ApiCursors;
42
+ export interface ApiPagination {
43
+ cursors: ApiPaginationParameters;
47
44
  }
48
- export interface ApiInspectionsGet {
49
- data: ApiData[];
45
+ export interface ApiPaginatedResponse<T> {
46
+ data: T[];
50
47
  paging: ApiPagination;
51
48
  }
49
+ export interface ApiAllInspectionsGet {
50
+ id: string;
51
+ images: ApiImage[];
52
+ owner_id: string;
53
+ creator_id: string;
54
+ created_at: string;
55
+ deleted_at?: string;
56
+ additional_data?: ApiInspectioAdditionalData;
57
+ }
58
+ export interface ApiAllInspectionsVerboseGet extends ApiAllInspectionsGet {
59
+ pricing?: ApiPricingV2;
60
+ pdf_url?: string;
61
+ plate?: string;
62
+ damages: ApiDamageSimplifiedGet[];
63
+ parts: ApiPartSimplifiedGet[];
64
+ vehicle?: ApiVehicleComponent;
65
+ }
52
66
  export interface ApiInspectionsCountGet {
53
67
  total: number;
68
+ sub_count?: Record<string, number>;
54
69
  }
55
70
  export interface ApiDamageSeverity {
56
71
  output_format: ApiBusinessClients;
@@ -62,4 +77,3 @@ export interface ApiInspectionPost {
62
77
  vehicle?: ApiVehiclePostPatch;
63
78
  damage_severity?: ApiDamageSeverity;
64
79
  }
65
- export {};
@@ -6,5 +6,9 @@ export interface ApiPart {
6
6
  part_type: string;
7
7
  related_images?: ApiRelatedImages;
8
8
  }
9
+ export interface ApiPartSimplifiedGet {
10
+ id: string;
11
+ part_type: string;
12
+ }
9
13
  export type ApiParts = ApiPart[];
10
14
  export type ApiPartIds = string[];
@@ -20,13 +20,13 @@ export declare function useMonkApi(config: MonkApiConfig): {
20
20
  *
21
21
  * @param options The options of the request.
22
22
  */
23
- getInspections: (options: import("./inspection/mappers").GetInspectionsOptions) => Promise<import("./types").MonkApiResponse<import("./inspection").GetInspectionResponse, import("./models").ApiInspectionsGet>>;
23
+ getAllInspections: (options: import("./inspection/mappers").GetAllInspectionsOptions) => Promise<import("./types").MonkApiResponse<import("./inspection").GetAllInspectionsResponse, import("./models").ApiPaginatedResponse<import("./models").ApiAllInspectionsVerboseGet>>>;
24
24
  /**
25
25
  * Gets the count of inspections that match the given filters.
26
26
  *
27
27
  * @param options The options of the request.
28
28
  */
29
- getInspectionsCount: (options: import("./inspection/mappers").GetInspectionsOptions) => Promise<import("./types").MonkApiResponse<import("./inspection").GetInspectionsCountResponse, import("./models").ApiInspectionsCountGet>>;
29
+ getAllInspectionsCount: (options: import("./inspection/mappers").GetAllInspectionsOptions) => Promise<import("./types").MonkApiResponse<import("./inspection").GetAllInspectionsCountResponse, import("./models").ApiInspectionsCountGet>>;
30
30
  /**
31
31
  * Create a new inspection with the given options. See the `CreateInspectionOptions` interface for more details.
32
32
  *
@@ -57,13 +57,13 @@ function useMonkApi(config) {
57
57
  *
58
58
  * @param options The options of the request.
59
59
  */
60
- getInspections: reactify(api_1.MonkApi.getInspections, config, dispatch, handleError),
60
+ getAllInspections: reactify(api_1.MonkApi.getAllInspections, config, dispatch, handleError),
61
61
  /**
62
62
  * Gets the count of inspections that match the given filters.
63
63
  *
64
64
  * @param options The options of the request.
65
65
  */
66
- getInspectionsCount: reactify(api_1.MonkApi.getInspectionsCount, config, dispatch, handleError),
66
+ getAllInspectionsCount: reactify(api_1.MonkApi.getAllInspectionsCount, config, dispatch, handleError),
67
67
  /**
68
68
  * Create a new inspection with the given options. See the `CreateInspectionOptions` interface for more details.
69
69
  *
@@ -22,3 +22,7 @@ export type MonkApiResponse<T extends object = MonkId, K extends object = ApiIdC
22
22
  */
23
23
  body: K;
24
24
  };
25
+ export interface PaginationResponse {
26
+ before?: string;
27
+ after?: string;
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkvision/network",
3
- "version": "4.3.16",
3
+ "version": "4.4.0",
4
4
  "license": "BSD-3-Clause-Clear",
5
5
  "packageManager": "yarn@3.2.4",
6
6
  "description": "MonkJs core package used to communicate with the API",
@@ -28,8 +28,8 @@
28
28
  "lint:fix": "yarn run prettier:fix && yarn run eslint:fix"
29
29
  },
30
30
  "dependencies": {
31
- "@monkvision/common": "4.3.16",
32
- "@monkvision/sights": "4.3.16",
31
+ "@monkvision/common": "4.4.0",
32
+ "@monkvision/sights": "4.4.0",
33
33
  "jsonwebtoken": "^9.0.2",
34
34
  "jwt-decode": "^4.0.0",
35
35
  "ky": "^1.2.0",
@@ -42,12 +42,12 @@
42
42
  "react-router-dom": "^6.22.3"
43
43
  },
44
44
  "devDependencies": {
45
- "@monkvision/eslint-config-base": "4.3.16",
46
- "@monkvision/eslint-config-typescript": "4.3.16",
47
- "@monkvision/jest-config": "4.3.16",
48
- "@monkvision/prettier-config": "4.3.16",
49
- "@monkvision/types": "4.3.16",
50
- "@monkvision/typescript-config": "4.3.16",
45
+ "@monkvision/eslint-config-base": "4.4.0",
46
+ "@monkvision/eslint-config-typescript": "4.4.0",
47
+ "@monkvision/jest-config": "4.4.0",
48
+ "@monkvision/prettier-config": "4.4.0",
49
+ "@monkvision/types": "4.4.0",
50
+ "@monkvision/typescript-config": "4.4.0",
51
51
  "@types/jest": "^29.2.2",
52
52
  "@types/jsonwebtoken": "^9.0.5",
53
53
  "@types/node": "^18.11.9",
@@ -84,5 +84,5 @@
84
84
  "url": "https://github.com/monkvision/monkjs/issues"
85
85
  },
86
86
  "homepage": "https://github.com/monkvision/monkjs",
87
- "gitHead": "11cefd6d5fb34890088ecaf4ddf77d3af34cc3ef"
87
+ "gitHead": "8dbfbe2fd8b27ba6918c4901de90d32458efb691"
88
88
  }