@monkvision/network 4.3.5 → 4.3.7
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 +14 -0
- package/lib/package.json +9 -9
- package/lib/src/api/api.d.ts +2 -1
- package/lib/src/api/api.js +1 -0
- package/lib/src/api/inspection/mappers.d.ts +1 -7
- package/lib/src/api/inspection/mappers.js +10 -10
- package/lib/src/api/inspection/requests.d.ts +19 -1
- package/lib/src/api/inspection/requests.js +28 -1
- package/lib/src/api/models/inspection.d.ts +3 -0
- package/lib/src/api/models/vehicle.d.ts +10 -12
- package/lib/src/api/react.d.ts +6 -0
- package/lib/src/api/react.js +6 -0
- package/lib/src/api/vehicle/mappers.js +3 -3
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -224,6 +224,20 @@ a list of all entities that match the specified criteria.
|
|
|
224
224
|
|-----------|-----------------------|-----------------------------|----------|
|
|
225
225
|
| options | getInspectionsOptions | The options of the request. | ✔️ |
|
|
226
226
|
|
|
227
|
+
|
|
228
|
+
### getInspectionsCount
|
|
229
|
+
```typescript
|
|
230
|
+
import { MonkApi } from '@monkvision/network';
|
|
231
|
+
|
|
232
|
+
MonkApi.getInspectionsCount(options, apiConfig, dispatch);
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Gets the count of inspections that match the given filters.
|
|
236
|
+
|
|
237
|
+
| Parameter | Type | Description | Required |
|
|
238
|
+
|-----------|-----------------------|-----------------------------|----------|
|
|
239
|
+
| options | getInspectionsOptions | The options of the request. | ✔️ |
|
|
240
|
+
|
|
227
241
|
# React Tools
|
|
228
242
|
In order to simply integrate the Monk Api requests into your React app, you can make use of the `useMonkApi` hook. This
|
|
229
243
|
custom hook returns a custom version of the `MonkApi` object described in the section above, in which the requests do
|
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monkvision/network",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.6",
|
|
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.
|
|
32
|
-
"@monkvision/sights": "4.3.
|
|
31
|
+
"@monkvision/common": "4.3.6",
|
|
32
|
+
"@monkvision/sights": "4.3.6",
|
|
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.
|
|
46
|
-
"@monkvision/eslint-config-typescript": "4.3.
|
|
47
|
-
"@monkvision/jest-config": "4.3.
|
|
48
|
-
"@monkvision/prettier-config": "4.3.
|
|
49
|
-
"@monkvision/types": "4.3.
|
|
50
|
-
"@monkvision/typescript-config": "4.3.
|
|
45
|
+
"@monkvision/eslint-config-base": "4.3.6",
|
|
46
|
+
"@monkvision/eslint-config-typescript": "4.3.6",
|
|
47
|
+
"@monkvision/jest-config": "4.3.6",
|
|
48
|
+
"@monkvision/prettier-config": "4.3.6",
|
|
49
|
+
"@monkvision/types": "4.3.6",
|
|
50
|
+
"@monkvision/typescript-config": "4.3.6",
|
|
51
51
|
"@types/jest": "^29.2.2",
|
|
52
52
|
"@types/jsonwebtoken": "^9.0.5",
|
|
53
53
|
"@types/node": "^18.11.9",
|
package/lib/src/api/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getInspection, createInspection, updateAdditionalData, getInspections } from './inspection';
|
|
1
|
+
import { getInspection, createInspection, updateAdditionalData, getInspections, getInspectionsCount } from './inspection';
|
|
2
2
|
import { addImage } from './image';
|
|
3
3
|
import { startInspectionTasks, updateTaskStatus } from './task';
|
|
4
4
|
import { getLiveConfig } from './liveConfigs';
|
|
@@ -12,6 +12,7 @@ import { createDamage, deleteDamage } from './damage';
|
|
|
12
12
|
export declare const MonkApi: {
|
|
13
13
|
getInspection: typeof getInspection;
|
|
14
14
|
getInspections: typeof getInspections;
|
|
15
|
+
getInspectionsCount: typeof getInspectionsCount;
|
|
15
16
|
createInspection: typeof createInspection;
|
|
16
17
|
addImage: typeof addImage;
|
|
17
18
|
updateTaskStatus: typeof updateTaskStatus;
|
package/lib/src/api/api.js
CHANGED
|
@@ -15,6 +15,7 @@ var damage_1 = require("./damage");
|
|
|
15
15
|
exports.MonkApi = {
|
|
16
16
|
getInspection: inspection_1.getInspection,
|
|
17
17
|
getInspections: inspection_1.getInspections,
|
|
18
|
+
getInspectionsCount: inspection_1.getInspectionsCount,
|
|
18
19
|
createInspection: inspection_1.createInspection,
|
|
19
20
|
addImage: image_1.addImage,
|
|
20
21
|
updateTaskStatus: task_1.updateTaskStatus,
|
|
@@ -39,15 +39,9 @@ export interface SortRequestParams {
|
|
|
39
39
|
sortOrder?: SortOrder;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* Options passed to the `getInspections` API request.
|
|
42
|
+
* Options passed to the `getInspections` or `getInspectionsCount` API request.
|
|
43
43
|
*/
|
|
44
44
|
export interface GetInspectionsOptions {
|
|
45
|
-
/**
|
|
46
|
-
* If true, only the total count of inspections will be returned.
|
|
47
|
-
*
|
|
48
|
-
* @default false
|
|
49
|
-
*/
|
|
50
|
-
count?: boolean;
|
|
51
45
|
/**
|
|
52
46
|
* The filter request parameters.
|
|
53
47
|
*/
|
|
@@ -221,6 +221,7 @@ function mapTasks(response) {
|
|
|
221
221
|
return { taskIds: taskIds, tasks: tasks };
|
|
222
222
|
}
|
|
223
223
|
function mapVehicle(response) {
|
|
224
|
+
var _a, _b, _c, _d;
|
|
224
225
|
return (response === null || response === void 0 ? void 0 : response.vehicle)
|
|
225
226
|
? {
|
|
226
227
|
id: response.vehicle.id,
|
|
@@ -231,10 +232,10 @@ function mapVehicle(response) {
|
|
|
231
232
|
serie: response.vehicle.serie,
|
|
232
233
|
plate: response.vehicle.plate,
|
|
233
234
|
type: response.vehicle.vehicle_type,
|
|
234
|
-
mileageUnit: response.vehicle.mileage_unit,
|
|
235
|
-
mileageValue: response.vehicle.mileage_value,
|
|
236
|
-
marketValueUnit: response.vehicle.market_value_unit,
|
|
237
|
-
marketValue: response.vehicle.market_value_value,
|
|
235
|
+
mileageUnit: (_a = response.vehicle.mileage) === null || _a === void 0 ? void 0 : _a.mileage_unit,
|
|
236
|
+
mileageValue: (_b = response.vehicle.mileage) === null || _b === void 0 ? void 0 : _b.mileage_value,
|
|
237
|
+
marketValueUnit: (_c = response.vehicle.market_value) === null || _c === void 0 ? void 0 : _c.market_value_unit,
|
|
238
|
+
marketValue: (_d = response.vehicle.market_value) === null || _d === void 0 ? void 0 : _d.market_value_value,
|
|
238
239
|
vin: response.vehicle.vin,
|
|
239
240
|
color: response.vehicle.color,
|
|
240
241
|
exteriorCleanliness: response.vehicle.exterior_cleanliness,
|
|
@@ -454,14 +455,14 @@ function mapApiInspectionPost(options) {
|
|
|
454
455
|
vehicle_type: options.vehicle.type,
|
|
455
456
|
mileage: options.vehicle.mileageUnit && options.vehicle.mileageValue
|
|
456
457
|
? {
|
|
457
|
-
|
|
458
|
-
|
|
458
|
+
mileage_value: options.vehicle.mileageValue,
|
|
459
|
+
mileage_unit: options.vehicle.mileageUnit,
|
|
459
460
|
}
|
|
460
461
|
: undefined,
|
|
461
462
|
market_value: options.vehicle.marketValueUnit && options.vehicle.marketValue
|
|
462
463
|
? {
|
|
463
|
-
|
|
464
|
-
|
|
464
|
+
market_value_value: options.vehicle.marketValue,
|
|
465
|
+
market_value_unit: options.vehicle.marketValueUnit,
|
|
465
466
|
}
|
|
466
467
|
: undefined,
|
|
467
468
|
vin: options.vehicle.vin,
|
|
@@ -485,8 +486,7 @@ function mapApiInspectionPost(options) {
|
|
|
485
486
|
exports.mapApiInspectionPost = mapApiInspectionPost;
|
|
486
487
|
function mapApiInspectionsUrlParamsGet(options) {
|
|
487
488
|
var params = new URLSearchParams();
|
|
488
|
-
var url = options.
|
|
489
|
-
url = options.filters || options.pagination ? "".concat(url, "?") : url;
|
|
489
|
+
var url = options.filters || options.pagination ? '?' : '';
|
|
490
490
|
if (options.filters) {
|
|
491
491
|
Object.entries(options.filters).forEach(function (_a) {
|
|
492
492
|
var key = _a[0], value = _a[1];
|
|
@@ -2,7 +2,7 @@ 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, ApiInspectionsGet } from '../models';
|
|
5
|
+
import { ApiInspectionGet, ApiInspectionsCountGet, ApiInspectionsGet } from '../models';
|
|
6
6
|
import { GetInspectionsOptions } from './mappers';
|
|
7
7
|
import { MonkApiResponse } from '../types';
|
|
8
8
|
/**
|
|
@@ -27,6 +27,15 @@ export interface GetInspectionResponse {
|
|
|
27
27
|
*/
|
|
28
28
|
entities: MonkState;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Type definition for the result of the `getInspectionsCount` API request.
|
|
32
|
+
*/
|
|
33
|
+
export interface GetInspectionsCountResponse {
|
|
34
|
+
/**
|
|
35
|
+
* The total number of inspections that match the given filters.
|
|
36
|
+
*/
|
|
37
|
+
count: number;
|
|
38
|
+
}
|
|
30
39
|
/**
|
|
31
40
|
* Fetch the details of an inspection using its ID.
|
|
32
41
|
*
|
|
@@ -79,3 +88,12 @@ export declare function updateAdditionalData(options: UpdateAdditionalDataOption
|
|
|
79
88
|
* state management for you.
|
|
80
89
|
*/
|
|
81
90
|
export declare function getInspections(options: GetInspectionsOptions, config: MonkApiConfig, dispatch?: Dispatch<MonkGotOneInspectionAction>): Promise<MonkApiResponse<GetInspectionResponse, ApiInspectionsGet>>;
|
|
91
|
+
/**
|
|
92
|
+
* Gets the count of inspections that match the given filters.
|
|
93
|
+
*
|
|
94
|
+
* @param options The options of the request.
|
|
95
|
+
* @param config The API config.
|
|
96
|
+
* @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
|
|
97
|
+
* state management for you.
|
|
98
|
+
*/
|
|
99
|
+
export declare function getInspectionsCount(options: GetInspectionsOptions, config: MonkApiConfig, _dispatch?: Dispatch<MonkAction>): Promise<MonkApiResponse<GetInspectionsCountResponse, 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.getInspections = exports.updateAdditionalData = exports.createInspection = exports.getInspection = void 0;
|
|
53
|
+
exports.getInspectionsCount = exports.getInspections = 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");
|
|
@@ -198,3 +198,30 @@ function getInspections(options, config, dispatch) {
|
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
exports.getInspections = getInspections;
|
|
201
|
+
/**
|
|
202
|
+
* Gets the count of inspections that match the given filters.
|
|
203
|
+
*
|
|
204
|
+
* @param options The options of the request.
|
|
205
|
+
* @param config The API config.
|
|
206
|
+
* @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
|
|
207
|
+
* state management for you.
|
|
208
|
+
*/
|
|
209
|
+
function getInspectionsCount(options, config, _dispatch) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
+
var kyOptions, response, body;
|
|
212
|
+
return __generator(this, function (_a) {
|
|
213
|
+
switch (_a.label) {
|
|
214
|
+
case 0:
|
|
215
|
+
kyOptions = (0, config_1.getDefaultOptions)(config);
|
|
216
|
+
return [4 /*yield*/, ky_1.default.get("inspections/count".concat((0, mappers_1.mapApiInspectionsUrlParamsGet)(options)), kyOptions)];
|
|
217
|
+
case 1:
|
|
218
|
+
response = _a.sent();
|
|
219
|
+
return [4 /*yield*/, response.json()];
|
|
220
|
+
case 2:
|
|
221
|
+
body = _a.sent();
|
|
222
|
+
return [2 /*return*/, { count: body.total, response: response, body: body }];
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
exports.getInspectionsCount = getInspectionsCount;
|
|
@@ -2,6 +2,14 @@ import type { ApiAdditionalData } from './common';
|
|
|
2
2
|
export type ApiOwnerInfo = Record<string, unknown>;
|
|
3
3
|
export type ApiMileageUnit = 'km' | 'miles';
|
|
4
4
|
export type ApiMarketValueUnit = 'USD' | 'EUR';
|
|
5
|
+
export interface ApiMileage {
|
|
6
|
+
mileage_value: number;
|
|
7
|
+
mileage_unit: ApiMileageUnit;
|
|
8
|
+
}
|
|
9
|
+
export interface ApiMarketValue {
|
|
10
|
+
market_value_value: number;
|
|
11
|
+
market_value_unit: ApiMarketValueUnit;
|
|
12
|
+
}
|
|
5
13
|
export interface ApiVehicleComponent {
|
|
6
14
|
additional_data?: ApiAdditionalData;
|
|
7
15
|
brand?: string;
|
|
@@ -14,10 +22,8 @@ export interface ApiVehicleComponent {
|
|
|
14
22
|
exterior_cleanliness?: string;
|
|
15
23
|
id: string;
|
|
16
24
|
interior_cleanliness?: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
mileage_unit?: ApiMileageUnit;
|
|
20
|
-
mileage_value?: number;
|
|
25
|
+
mileage?: ApiMileage;
|
|
26
|
+
market_value?: ApiMarketValue;
|
|
21
27
|
model?: string;
|
|
22
28
|
serie?: string;
|
|
23
29
|
owner_info?: ApiOwnerInfo;
|
|
@@ -27,14 +33,6 @@ export interface ApiVehicleComponent {
|
|
|
27
33
|
vehicle_type?: string;
|
|
28
34
|
vin?: string;
|
|
29
35
|
}
|
|
30
|
-
export interface ApiMileage {
|
|
31
|
-
value: number;
|
|
32
|
-
unit: ApiMileageUnit;
|
|
33
|
-
}
|
|
34
|
-
export interface ApiMarketValue {
|
|
35
|
-
value: number;
|
|
36
|
-
unit: ApiMarketValueUnit;
|
|
37
|
-
}
|
|
38
36
|
export interface ApiVehiclePostPatch {
|
|
39
37
|
brand?: string;
|
|
40
38
|
model?: string;
|
package/lib/src/api/react.d.ts
CHANGED
|
@@ -21,6 +21,12 @@ export declare function useMonkApi(config: MonkApiConfig): {
|
|
|
21
21
|
* @param options The options of the request.
|
|
22
22
|
*/
|
|
23
23
|
getInspections: (options: import("./inspection/mappers").GetInspectionsOptions) => Promise<import("./types").MonkApiResponse<import("./inspection").GetInspectionResponse, import("./models").ApiInspectionsGet>>;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the count of inspections that match the given filters.
|
|
26
|
+
*
|
|
27
|
+
* @param options The options of the request.
|
|
28
|
+
*/
|
|
29
|
+
getInspectionsCount: (options: import("./inspection/mappers").GetInspectionsOptions) => Promise<import("./types").MonkApiResponse<import("./inspection").GetInspectionsCountResponse, import("./models").ApiInspectionsCountGet>>;
|
|
24
30
|
/**
|
|
25
31
|
* Create a new inspection with the given options. See the `CreateInspectionOptions` interface for more details.
|
|
26
32
|
*
|
package/lib/src/api/react.js
CHANGED
|
@@ -58,6 +58,12 @@ function useMonkApi(config) {
|
|
|
58
58
|
* @param options The options of the request.
|
|
59
59
|
*/
|
|
60
60
|
getInspections: reactify(api_1.MonkApi.getInspections, config, dispatch, handleError),
|
|
61
|
+
/**
|
|
62
|
+
* Gets the count of inspections that match the given filters.
|
|
63
|
+
*
|
|
64
|
+
* @param options The options of the request.
|
|
65
|
+
*/
|
|
66
|
+
getInspectionsCount: reactify(api_1.MonkApi.getInspectionsCount, config, dispatch, handleError),
|
|
61
67
|
/**
|
|
62
68
|
* Create a new inspection with the given options. See the `CreateInspectionOptions` interface for more details.
|
|
63
69
|
*
|
|
@@ -9,12 +9,12 @@ function mapApiVehiclePatch(options) {
|
|
|
9
9
|
vehicle_type: options.type,
|
|
10
10
|
mileage: options.mileageValue && options.mileageUnit
|
|
11
11
|
? {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
mileage_value: options.mileageValue,
|
|
13
|
+
mileage_unit: options.mileageUnit,
|
|
14
14
|
}
|
|
15
15
|
: undefined,
|
|
16
16
|
market_value: options.marketValue && options.marketValueUnit
|
|
17
|
-
? {
|
|
17
|
+
? { market_value_value: options.marketValue, market_value_unit: options.marketValueUnit }
|
|
18
18
|
: undefined,
|
|
19
19
|
vin: options.vin,
|
|
20
20
|
color: options.color,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monkvision/network",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.7",
|
|
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.
|
|
32
|
-
"@monkvision/sights": "4.3.
|
|
31
|
+
"@monkvision/common": "4.3.7",
|
|
32
|
+
"@monkvision/sights": "4.3.7",
|
|
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.
|
|
46
|
-
"@monkvision/eslint-config-typescript": "4.3.
|
|
47
|
-
"@monkvision/jest-config": "4.3.
|
|
48
|
-
"@monkvision/prettier-config": "4.3.
|
|
49
|
-
"@monkvision/types": "4.3.
|
|
50
|
-
"@monkvision/typescript-config": "4.3.
|
|
45
|
+
"@monkvision/eslint-config-base": "4.3.7",
|
|
46
|
+
"@monkvision/eslint-config-typescript": "4.3.7",
|
|
47
|
+
"@monkvision/jest-config": "4.3.7",
|
|
48
|
+
"@monkvision/prettier-config": "4.3.7",
|
|
49
|
+
"@monkvision/types": "4.3.7",
|
|
50
|
+
"@monkvision/typescript-config": "4.3.7",
|
|
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": "
|
|
87
|
+
"gitHead": "04dad018a2eab4da78912e328670e9b9b55cde94"
|
|
88
88
|
}
|