@monkvision/network 4.3.4 → 4.3.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/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 +1 -2
- package/lib/src/api/inspection/requests.d.ts +20 -2
- package/lib/src/api/inspection/requests.js +28 -1
- package/lib/src/api/models/inspection.d.ts +3 -0
- package/lib/src/api/react.d.ts +7 -1
- package/lib/src/api/react.js +6 -0
- 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.5",
|
|
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.5",
|
|
32
|
+
"@monkvision/sights": "4.3.5",
|
|
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.5",
|
|
46
|
+
"@monkvision/eslint-config-typescript": "4.3.5",
|
|
47
|
+
"@monkvision/jest-config": "4.3.5",
|
|
48
|
+
"@monkvision/prettier-config": "4.3.5",
|
|
49
|
+
"@monkvision/types": "4.3.5",
|
|
50
|
+
"@monkvision/typescript-config": "4.3.5",
|
|
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
|
*/
|
|
@@ -485,8 +485,7 @@ function mapApiInspectionPost(options) {
|
|
|
485
485
|
exports.mapApiInspectionPost = mapApiInspectionPost;
|
|
486
486
|
function mapApiInspectionsUrlParamsGet(options) {
|
|
487
487
|
var params = new URLSearchParams();
|
|
488
|
-
var url = options.
|
|
489
|
-
url = options.filters || options.pagination ? "".concat(url, "?") : url;
|
|
488
|
+
var url = options.filters || options.pagination ? '?' : '';
|
|
490
489
|
if (options.filters) {
|
|
491
490
|
Object.entries(options.filters).forEach(function (_a) {
|
|
492
491
|
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
|
*
|
|
@@ -78,4 +87,13 @@ export declare function updateAdditionalData(options: UpdateAdditionalDataOption
|
|
|
78
87
|
* @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
|
|
79
88
|
* state management for you.
|
|
80
89
|
*/
|
|
81
|
-
export declare function getInspections(options: GetInspectionsOptions, config: MonkApiConfig, dispatch?: Dispatch<MonkGotOneInspectionAction>): Promise<MonkApiResponse
|
|
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;
|
package/lib/src/api/react.d.ts
CHANGED
|
@@ -20,7 +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("./
|
|
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
|
*
|
package/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",
|
|
@@ -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": "7b897900c91febbb572a1778eab68b52da4af810"
|
|
88
88
|
}
|