@monkvision/network 4.0.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/LICENSE +32 -0
- package/README.md +225 -0
- package/lib/package.json +84 -0
- package/lib/src/api/api.d.ts +18 -0
- package/lib/src/api/api.js +22 -0
- package/lib/src/api/api.js.map +1 -0
- package/lib/src/api/config.d.ts +20 -0
- package/lib/src/api/config.js +41 -0
- package/lib/src/api/config.js.map +1 -0
- package/lib/src/api/error.d.ts +34 -0
- package/lib/src/api/error.js +118 -0
- package/lib/src/api/error.js.map +1 -0
- package/lib/src/api/hooks/index.d.ts +1 -0
- package/lib/src/api/hooks/index.js +18 -0
- package/lib/src/api/hooks/index.js.map +1 -0
- package/lib/src/api/hooks/useInspectionPoll.d.ts +34 -0
- package/lib/src/api/hooks/useInspectionPoll.js +21 -0
- package/lib/src/api/hooks/useInspectionPoll.js.map +1 -0
- package/lib/src/api/image/index.d.ts +1 -0
- package/lib/src/api/image/index.js +18 -0
- package/lib/src/api/image/index.js.map +1 -0
- package/lib/src/api/image/mappers.d.ts +3 -0
- package/lib/src/api/image/mappers.js +166 -0
- package/lib/src/api/image/mappers.js.map +1 -0
- package/lib/src/api/image/requests.d.ts +141 -0
- package/lib/src/api/image/requests.js +312 -0
- package/lib/src/api/image/requests.js.map +1 -0
- package/lib/src/api/index.d.ts +10 -0
- package/lib/src/api/index.js +27 -0
- package/lib/src/api/index.js.map +1 -0
- package/lib/src/api/inspection/index.d.ts +1 -0
- package/lib/src/api/inspection/index.js +18 -0
- package/lib/src/api/inspection/index.js.map +1 -0
- package/lib/src/api/inspection/mappers.d.ts +5 -0
- package/lib/src/api/inspection/mappers.js +392 -0
- package/lib/src/api/inspection/mappers.js.map +1 -0
- package/lib/src/api/inspection/requests.d.ts +47 -0
- package/lib/src/api/inspection/requests.js +122 -0
- package/lib/src/api/inspection/requests.js.map +1 -0
- package/lib/src/api/liveConfigs/index.d.ts +1 -0
- package/lib/src/api/liveConfigs/index.js +18 -0
- package/lib/src/api/liveConfigs/index.js.map +1 -0
- package/lib/src/api/liveConfigs/requests.d.ts +7 -0
- package/lib/src/api/liveConfigs/requests.js +66 -0
- package/lib/src/api/liveConfigs/requests.js.map +1 -0
- package/lib/src/api/models/common.d.ts +13 -0
- package/lib/src/api/models/common.js +3 -0
- package/lib/src/api/models/common.js.map +1 -0
- package/lib/src/api/models/compliance.d.ts +58 -0
- package/lib/src/api/models/compliance.js +3 -0
- package/lib/src/api/models/compliance.js.map +1 -0
- package/lib/src/api/models/damage.d.ts +11 -0
- package/lib/src/api/models/damage.js +3 -0
- package/lib/src/api/models/damage.js.map +1 -0
- package/lib/src/api/models/image.d.ts +76 -0
- package/lib/src/api/models/image.js +3 -0
- package/lib/src/api/models/image.js.map +1 -0
- package/lib/src/api/models/index.d.ts +13 -0
- package/lib/src/api/models/index.js +30 -0
- package/lib/src/api/models/index.js.map +1 -0
- package/lib/src/api/models/inspection.d.ts +40 -0
- package/lib/src/api/models/inspection.js +3 -0
- package/lib/src/api/models/inspection.js.map +1 -0
- package/lib/src/api/models/part.d.ts +10 -0
- package/lib/src/api/models/part.js +3 -0
- package/lib/src/api/models/part.js.map +1 -0
- package/lib/src/api/models/pricingV2.d.ts +15 -0
- package/lib/src/api/models/pricingV2.js +3 -0
- package/lib/src/api/models/pricingV2.js.map +1 -0
- package/lib/src/api/models/renderedOutput.d.ts +8 -0
- package/lib/src/api/models/renderedOutput.js +3 -0
- package/lib/src/api/models/renderedOutput.js.map +1 -0
- package/lib/src/api/models/severityResult.d.ts +37 -0
- package/lib/src/api/models/severityResult.js +3 -0
- package/lib/src/api/models/severityResult.js.map +1 -0
- package/lib/src/api/models/task.d.ts +76 -0
- package/lib/src/api/models/task.js +3 -0
- package/lib/src/api/models/task.js.map +1 -0
- package/lib/src/api/models/vehicle.d.ts +58 -0
- package/lib/src/api/models/vehicle.js +3 -0
- package/lib/src/api/models/vehicle.js.map +1 -0
- package/lib/src/api/models/view.d.ts +24 -0
- package/lib/src/api/models/view.js +3 -0
- package/lib/src/api/models/view.js.map +1 -0
- package/lib/src/api/models/wheelAnalysis.d.ts +13 -0
- package/lib/src/api/models/wheelAnalysis.js +3 -0
- package/lib/src/api/models/wheelAnalysis.js.map +1 -0
- package/lib/src/api/react.d.ts +69 -0
- package/lib/src/api/react.js +105 -0
- package/lib/src/api/react.js.map +1 -0
- package/lib/src/api/task/index.d.ts +1 -0
- package/lib/src/api/task/index.js +18 -0
- package/lib/src/api/task/index.js.map +1 -0
- package/lib/src/api/task/requests.d.ts +67 -0
- package/lib/src/api/task/requests.js +135 -0
- package/lib/src/api/task/requests.js.map +1 -0
- package/lib/src/api/types.d.ts +24 -0
- package/lib/src/api/types.js +3 -0
- package/lib/src/api/types.js.map +1 -0
- package/lib/src/api/utils.d.ts +9 -0
- package/lib/src/api/utils.js +22 -0
- package/lib/src/api/utils.js.map +1 -0
- package/lib/src/api/vehicle/index.d.ts +1 -0
- package/lib/src/api/vehicle/index.js +18 -0
- package/lib/src/api/vehicle/index.js.map +1 -0
- package/lib/src/api/vehicle/mappers.d.ts +3 -0
- package/lib/src/api/vehicle/mappers.js +33 -0
- package/lib/src/api/vehicle/mappers.js.map +1 -0
- package/lib/src/api/vehicle/requests.d.ts +31 -0
- package/lib/src/api/vehicle/requests.js +88 -0
- package/lib/src/api/vehicle/requests.js.map +1 -0
- package/lib/src/auth/hooks.d.ts +34 -0
- package/lib/src/auth/hooks.js +112 -0
- package/lib/src/auth/hooks.js.map +1 -0
- package/lib/src/auth/index.d.ts +2 -0
- package/lib/src/auth/index.js +19 -0
- package/lib/src/auth/index.js.map +1 -0
- package/lib/src/auth/token.d.ts +25 -0
- package/lib/src/auth/token.js +36 -0
- package/lib/src/auth/token.js.map +1 -0
- package/lib/src/index.d.ts +2 -0
- package/lib/src/index.js +19 -0
- package/lib/src/index.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ApiRenderedOutputs } from './renderedOutput';
|
|
2
|
+
export interface ApiBoundingBox {
|
|
3
|
+
xmin: number;
|
|
4
|
+
ymin: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
export type ApiPolygons = number[][][];
|
|
9
|
+
export interface ApiSpecification {
|
|
10
|
+
bounding_box?: ApiBoundingBox;
|
|
11
|
+
polygons?: ApiPolygons;
|
|
12
|
+
}
|
|
13
|
+
export interface ApiImageRegion {
|
|
14
|
+
id: string;
|
|
15
|
+
image_id: string;
|
|
16
|
+
specification: ApiSpecification;
|
|
17
|
+
}
|
|
18
|
+
export interface ApiView {
|
|
19
|
+
element_id: string;
|
|
20
|
+
id: string;
|
|
21
|
+
image_region: ApiImageRegion;
|
|
22
|
+
rendered_outputs: ApiRenderedOutputs;
|
|
23
|
+
}
|
|
24
|
+
export type ApiViews = ApiView[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../../../src/api/models/view.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ApiLabelPrediction } from './common';
|
|
2
|
+
export type ApiWheelType = 'wheel_front_left' | 'wheel_front_right' | 'wheel_back_left' | 'wheel_back_right';
|
|
3
|
+
export interface ApiWheelAnalysisWithImageId {
|
|
4
|
+
hubcap_condition: ApiLabelPrediction;
|
|
5
|
+
hubcap_over_rim: ApiLabelPrediction;
|
|
6
|
+
hubcap_visual_aspect: ApiLabelPrediction;
|
|
7
|
+
image_id?: string;
|
|
8
|
+
rim_condition: ApiLabelPrediction;
|
|
9
|
+
rim_material: ApiLabelPrediction;
|
|
10
|
+
rim_visual_aspect: ApiLabelPrediction;
|
|
11
|
+
wheel_name?: ApiWheelType;
|
|
12
|
+
}
|
|
13
|
+
export type ApiWheelAnalysis = ApiWheelAnalysisWithImageId[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wheelAnalysis.js","sourceRoot":"","sources":["../../../../src/api/models/wheelAnalysis.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { MonkApiConfig } from './config';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook that returns a MonkApi object in which all the requests don't need a config param (since it is provided
|
|
4
|
+
* as a prop to this hook), and automatically update the state (using the MonkState hook) when a state has been
|
|
5
|
+
* received.
|
|
6
|
+
*
|
|
7
|
+
* **Note: This hook needs to have the MonkContext set up and defined in order to work properly.**
|
|
8
|
+
*
|
|
9
|
+
* @see MonkApi
|
|
10
|
+
*/
|
|
11
|
+
export declare function useMonkApi(config: MonkApiConfig): {
|
|
12
|
+
/**
|
|
13
|
+
* Fetch the details of an inspection using its ID.
|
|
14
|
+
*
|
|
15
|
+
* @param options The options of the request.
|
|
16
|
+
*/
|
|
17
|
+
getInspection: (options: import("./inspection").GetInspectionOptions) => Promise<import("./types").MonkApiResponse<import("./inspection").GetInspectionResponse, import("./models").ApiInspectionGet>>;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new inspection with the given options. See the `CreateInspectionOptions` interface for more details.
|
|
20
|
+
*
|
|
21
|
+
* @param options The options of the inspection.
|
|
22
|
+
* @see CreateInspectionOptions
|
|
23
|
+
*/
|
|
24
|
+
createInspection: (options: import("@monkvision/types").CreateInspectionOptions) => Promise<import("./types").MonkApiResponse<import("./types").MonkId, import("./models").ApiIdColumn>>;
|
|
25
|
+
/**
|
|
26
|
+
* Add a new image to an inspection.
|
|
27
|
+
*
|
|
28
|
+
* @param options Upload options for the image.
|
|
29
|
+
*/
|
|
30
|
+
addImage: (options: import("./image").AddImageOptions) => Promise<import("./types").MonkApiResponse<import("./image").AddImageResponse, import("./models").ApiImage>>;
|
|
31
|
+
/**
|
|
32
|
+
* Update the progress status of an inspection task.
|
|
33
|
+
*
|
|
34
|
+
* **Note : This API call is known to sometimes fail for unknown reasons. In order to fix this, we added a retry
|
|
35
|
+
* config to this API request : when failing, this request will retry itself up to 4 times (5 API calls in total),
|
|
36
|
+
* with exponentially increasing delay between each request (max delay : 1.5s).**
|
|
37
|
+
*
|
|
38
|
+
* @param options The options of the request.
|
|
39
|
+
*/
|
|
40
|
+
updateTaskStatus: (options: import("./task").UpdateTaskStatusOptions) => Promise<import("./types").MonkApiResponse<import("./types").MonkId, import("./models").ApiIdColumn>>;
|
|
41
|
+
/**
|
|
42
|
+
* Start some inspection tasks that were in the NOT_STARTED status. This function actually makes one API call for
|
|
43
|
+
* each task provided using the `updateTaskStatus`.
|
|
44
|
+
*
|
|
45
|
+
* **Note : This API call is known to sometimes fail for unknown reasons. Please take note of the details provided
|
|
46
|
+
* in the TSDoc of the `updateTaskStatus` function.**
|
|
47
|
+
*
|
|
48
|
+
* @param options The options of the request.
|
|
49
|
+
*
|
|
50
|
+
* @see updateTaskStatus
|
|
51
|
+
*/
|
|
52
|
+
startInspectionTasks: (options: import("./task").StartInspectionTasksOptions) => Promise<import("./types").MonkApiResponse<import("./types").MonkId, import("./models").ApiIdColumn>[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Fetch a webapp live configuration from the API.
|
|
55
|
+
*
|
|
56
|
+
* @param id The ID of the live config to get.
|
|
57
|
+
*/
|
|
58
|
+
getLiveConfig: (id: string) => Promise<void | import("@monkvision/types").LiveConfig>;
|
|
59
|
+
/**
|
|
60
|
+
* Update the vehicle of an inspection.
|
|
61
|
+
*
|
|
62
|
+
* @param options The options of the request.
|
|
63
|
+
*/
|
|
64
|
+
updateInspectionVehicle: (options: import("./vehicle").UpdateInspectionVehicleOptions) => Promise<{
|
|
65
|
+
id: string;
|
|
66
|
+
response: import("ky").KyResponse;
|
|
67
|
+
body: import("./models").ApiIdColumn;
|
|
68
|
+
}>;
|
|
69
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useMonkApi = void 0;
|
|
13
|
+
var react_1 = require("react");
|
|
14
|
+
var common_1 = require("@monkvision/common");
|
|
15
|
+
var monitoring_1 = require("@monkvision/monitoring");
|
|
16
|
+
var api_1 = require("./api");
|
|
17
|
+
function handleAPIError(err, handleError) {
|
|
18
|
+
var body = err.body;
|
|
19
|
+
handleError(err, {
|
|
20
|
+
extras: {
|
|
21
|
+
body: body,
|
|
22
|
+
completeResponse: JSON.stringify(body),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
27
|
+
function reactify(request, config, dispatch, handleError) {
|
|
28
|
+
return (0, react_1.useCallback)(function () {
|
|
29
|
+
var params = [];
|
|
30
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
31
|
+
params[_i] = arguments[_i];
|
|
32
|
+
}
|
|
33
|
+
return request.apply(void 0, __spreadArray(__spreadArray([], params, false), [config, dispatch], false)).catch(function (err) { return handleAPIError(err, handleError); });
|
|
34
|
+
}, []);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Custom hook that returns a MonkApi object in which all the requests don't need a config param (since it is provided
|
|
38
|
+
* as a prop to this hook), and automatically update the state (using the MonkState hook) when a state has been
|
|
39
|
+
* received.
|
|
40
|
+
*
|
|
41
|
+
* **Note: This hook needs to have the MonkContext set up and defined in order to work properly.**
|
|
42
|
+
*
|
|
43
|
+
* @see MonkApi
|
|
44
|
+
*/
|
|
45
|
+
function useMonkApi(config) {
|
|
46
|
+
var dispatch = (0, common_1.useMonkState)().dispatch;
|
|
47
|
+
var handleError = (0, monitoring_1.useMonitoring)().handleError;
|
|
48
|
+
return {
|
|
49
|
+
/**
|
|
50
|
+
* Fetch the details of an inspection using its ID.
|
|
51
|
+
*
|
|
52
|
+
* @param options The options of the request.
|
|
53
|
+
*/
|
|
54
|
+
getInspection: reactify(api_1.MonkApi.getInspection, config, dispatch, handleError),
|
|
55
|
+
/**
|
|
56
|
+
* Create a new inspection with the given options. See the `CreateInspectionOptions` interface for more details.
|
|
57
|
+
*
|
|
58
|
+
* @param options The options of the inspection.
|
|
59
|
+
* @see CreateInspectionOptions
|
|
60
|
+
*/
|
|
61
|
+
createInspection: reactify(api_1.MonkApi.createInspection, config, dispatch, handleError),
|
|
62
|
+
/**
|
|
63
|
+
* Add a new image to an inspection.
|
|
64
|
+
*
|
|
65
|
+
* @param options Upload options for the image.
|
|
66
|
+
*/
|
|
67
|
+
addImage: reactify(api_1.MonkApi.addImage, config, dispatch, handleError),
|
|
68
|
+
/**
|
|
69
|
+
* Update the progress status of an inspection task.
|
|
70
|
+
*
|
|
71
|
+
* **Note : This API call is known to sometimes fail for unknown reasons. In order to fix this, we added a retry
|
|
72
|
+
* config to this API request : when failing, this request will retry itself up to 4 times (5 API calls in total),
|
|
73
|
+
* with exponentially increasing delay between each request (max delay : 1.5s).**
|
|
74
|
+
*
|
|
75
|
+
* @param options The options of the request.
|
|
76
|
+
*/
|
|
77
|
+
updateTaskStatus: reactify(api_1.MonkApi.updateTaskStatus, config, dispatch, handleError),
|
|
78
|
+
/**
|
|
79
|
+
* Start some inspection tasks that were in the NOT_STARTED status. This function actually makes one API call for
|
|
80
|
+
* each task provided using the `updateTaskStatus`.
|
|
81
|
+
*
|
|
82
|
+
* **Note : This API call is known to sometimes fail for unknown reasons. Please take note of the details provided
|
|
83
|
+
* in the TSDoc of the `updateTaskStatus` function.**
|
|
84
|
+
*
|
|
85
|
+
* @param options The options of the request.
|
|
86
|
+
*
|
|
87
|
+
* @see updateTaskStatus
|
|
88
|
+
*/
|
|
89
|
+
startInspectionTasks: reactify(api_1.MonkApi.startInspectionTasks, config, dispatch, handleError),
|
|
90
|
+
/**
|
|
91
|
+
* Fetch a webapp live configuration from the API.
|
|
92
|
+
*
|
|
93
|
+
* @param id The ID of the live config to get.
|
|
94
|
+
*/
|
|
95
|
+
getLiveConfig: (0, react_1.useCallback)(function (id) { return api_1.MonkApi.getLiveConfig(id).catch(function (err) { return handleAPIError(err, handleError); }); }, [handleError]),
|
|
96
|
+
/**
|
|
97
|
+
* Update the vehicle of an inspection.
|
|
98
|
+
*
|
|
99
|
+
* @param options The options of the request.
|
|
100
|
+
*/
|
|
101
|
+
updateInspectionVehicle: reactify(api_1.MonkApi.updateInspectionVehicle, config, dispatch, handleError),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
exports.useMonkApi = useMonkApi;
|
|
105
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/api/react.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA8C;AAC9C,6CAA8D;AAC9D,qDAAmE;AAEnE,6BAAgC;AAOhC,SAAS,cAAc,CACrB,GAAY,EACZ,WAAwE;IAEhE,IAAA,IAAI,GAAK,GAAoB,KAAzB,CAA0B;IACtC,WAAW,CAAC,GAAG,EAAE;QACf,MAAM,EAAE;YACN,IAAI,MAAA;YACJ,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SACvC;KACF,CAAC,CAAC;IACH,MAAM,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,QAAQ,CACf,OAAgC,EAChC,MAAqB,EACrB,QAA8B,EAC9B,WAAwE;IAExE,OAAO,IAAA,mBAAW,EAChB;QAAC,gBAAY;aAAZ,UAAY,EAAZ,qBAAY,EAAZ,IAAY;YAAZ,2BAAY;;QACX,OAAA,OAAO,+CAAI,MAAM,WAAE,MAAM,EAAE,QAAQ,WAAE,KAAK,CAAC,UAAC,GAAG,IAAK,OAAA,cAAc,CAAC,GAAG,EAAE,WAAW,CAAC,EAAhC,CAAgC,CAAM;IAA1F,CAA0F,EAC5F,EAAE,CACH,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,UAAU,CAAC,MAAqB;IACtC,IAAA,QAAQ,GAAK,IAAA,qBAAY,GAAE,SAAnB,CAAoB;IAC5B,IAAA,WAAW,GAAK,IAAA,0BAAa,GAAE,YAApB,CAAqB;IAExC,OAAO;QACL;;;;WAIG;QACH,aAAa,EAAE,QAAQ,CAAC,aAAO,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC;QAC7E;;;;;WAKG;QACH,gBAAgB,EAAE,QAAQ,CAAC,aAAO,CAAC,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC;QACnF;;;;WAIG;QACH,QAAQ,EAAE,QAAQ,CAAC,aAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC;QACnE;;;;;;;;WAQG;QACH,gBAAgB,EAAE,QAAQ,CAAC,aAAO,CAAC,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC;QACnF;;;;;;;;;;WAUG;QACH,oBAAoB,EAAE,QAAQ,CAAC,aAAO,CAAC,oBAAoB,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC;QAC3F;;;;WAIG;QACH,aAAa,EAAE,IAAA,mBAAW,EACxB,UAAC,EAAU,IAAK,OAAA,aAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,UAAC,GAAG,IAAK,OAAA,cAAc,CAAC,GAAG,EAAE,WAAW,CAAC,EAAhC,CAAgC,CAAC,EAA1E,CAA0E,EAC1F,CAAC,WAAW,CAAC,CACd;QACD;;;;WAIG;QACH,uBAAuB,EAAE,QAAQ,CAC/B,aAAO,CAAC,uBAAuB,EAC/B,MAAM,EACN,QAAQ,EACR,WAAW,CACZ;KACF,CAAC;AACJ,CAAC;AAnED,gCAmEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './requests';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./requests"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/task/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { MonkUpdatedManyTasksAction } from '@monkvision/common';
|
|
2
|
+
import { ProgressStatus, TaskName } from '@monkvision/types';
|
|
3
|
+
import { Dispatch } from 'react';
|
|
4
|
+
import { MonkApiConfig } from '../config';
|
|
5
|
+
import { MonkApiResponse } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* The different progress statuses that can be specified when updating the status of a task.
|
|
8
|
+
*/
|
|
9
|
+
export type UpdateProgressStatus = ProgressStatus.NOT_STARTED | ProgressStatus.TODO | ProgressStatus.DONE | ProgressStatus.VALIDATED;
|
|
10
|
+
/**
|
|
11
|
+
* Options used to specify how to update the status of an inspection task.
|
|
12
|
+
*/
|
|
13
|
+
export interface UpdateTaskStatusOptions {
|
|
14
|
+
/**
|
|
15
|
+
* The ID of the inspection.
|
|
16
|
+
*/
|
|
17
|
+
inspectionId: string;
|
|
18
|
+
/**
|
|
19
|
+
* The name of the task to update the progress status of.
|
|
20
|
+
*/
|
|
21
|
+
name: TaskName;
|
|
22
|
+
/**
|
|
23
|
+
* The new progress status of the task.
|
|
24
|
+
*/
|
|
25
|
+
status: UpdateProgressStatus;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Update the progress status of an inspection task.
|
|
29
|
+
*
|
|
30
|
+
* **Note : This API call is known to sometimes fail for unknown reasons. In order to fix this, we added a retry config
|
|
31
|
+
* to this API request : when failing, this request will retry itself up to 4 times (5 API calls in total), with
|
|
32
|
+
* exponentially increasing delay between each request (max delay : 1.5s).**
|
|
33
|
+
*
|
|
34
|
+
* @param options The options of the request.
|
|
35
|
+
* @param config The API config.
|
|
36
|
+
* @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
|
|
37
|
+
* state management for you.
|
|
38
|
+
*/
|
|
39
|
+
export declare function updateTaskStatus(options: UpdateTaskStatusOptions, config: MonkApiConfig, dispatch?: Dispatch<MonkUpdatedManyTasksAction>): Promise<MonkApiResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Options passed to the `startInspectionTasks` API request.
|
|
42
|
+
*/
|
|
43
|
+
export interface StartInspectionTasksOptions {
|
|
44
|
+
/**
|
|
45
|
+
* The ID of the inspection.
|
|
46
|
+
*/
|
|
47
|
+
inspectionId: string;
|
|
48
|
+
/**
|
|
49
|
+
* The names of the tasks to start.
|
|
50
|
+
*/
|
|
51
|
+
names: TaskName[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Start some inspection tasks that were in the NOT_STARTED status. This function actually makes one API call for each
|
|
55
|
+
* task provided using the `updateTaskStatus`.
|
|
56
|
+
*
|
|
57
|
+
* **Note : This API call is known to sometimes fail for unknown reasons. Please take note of the details provided in
|
|
58
|
+
* the TSDoc of the `updateTaskStatus` function.**
|
|
59
|
+
*
|
|
60
|
+
* @param options The options of the request.
|
|
61
|
+
* @param config The API config.
|
|
62
|
+
* @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
|
|
63
|
+
* state management for you.
|
|
64
|
+
*
|
|
65
|
+
* @see updateTaskStatus
|
|
66
|
+
*/
|
|
67
|
+
export declare function startInspectionTasks(options: StartInspectionTasksOptions, config: MonkApiConfig, dispatch?: Dispatch<MonkUpdatedManyTasksAction>): Promise<MonkApiResponse[]>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.startInspectionTasks = exports.updateTaskStatus = void 0;
|
|
54
|
+
var ky_1 = __importDefault(require("ky"));
|
|
55
|
+
var common_1 = require("@monkvision/common");
|
|
56
|
+
var types_1 = require("@monkvision/types");
|
|
57
|
+
var config_1 = require("../config");
|
|
58
|
+
/**
|
|
59
|
+
* Update the progress status of an inspection task.
|
|
60
|
+
*
|
|
61
|
+
* **Note : This API call is known to sometimes fail for unknown reasons. In order to fix this, we added a retry config
|
|
62
|
+
* to this API request : when failing, this request will retry itself up to 4 times (5 API calls in total), with
|
|
63
|
+
* exponentially increasing delay between each request (max delay : 1.5s).**
|
|
64
|
+
*
|
|
65
|
+
* @param options The options of the request.
|
|
66
|
+
* @param config The API config.
|
|
67
|
+
* @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
|
|
68
|
+
* state management for you.
|
|
69
|
+
*/
|
|
70
|
+
function updateTaskStatus(options, config, dispatch) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var kyOptions, response, body;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
kyOptions = (0, config_1.getDefaultOptions)(config);
|
|
77
|
+
return [4 /*yield*/, ky_1.default.patch("inspections/".concat(options.inspectionId, "/tasks/").concat(options.name), __assign(__assign({}, kyOptions), { json: { status: options.status }, retry: {
|
|
78
|
+
methods: ['patch'],
|
|
79
|
+
limit: 4,
|
|
80
|
+
backoffLimit: 1500,
|
|
81
|
+
} }))];
|
|
82
|
+
case 1:
|
|
83
|
+
response = _a.sent();
|
|
84
|
+
return [4 /*yield*/, response.json()];
|
|
85
|
+
case 2:
|
|
86
|
+
body = _a.sent();
|
|
87
|
+
dispatch === null || dispatch === void 0 ? void 0 : dispatch({
|
|
88
|
+
type: common_1.MonkActionType.UPDATED_MANY_TASKS,
|
|
89
|
+
payload: [{ id: body.id, status: options.status }],
|
|
90
|
+
});
|
|
91
|
+
return [2 /*return*/, {
|
|
92
|
+
id: body.id,
|
|
93
|
+
response: response,
|
|
94
|
+
body: body,
|
|
95
|
+
}];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
exports.updateTaskStatus = updateTaskStatus;
|
|
101
|
+
/**
|
|
102
|
+
* Start some inspection tasks that were in the NOT_STARTED status. This function actually makes one API call for each
|
|
103
|
+
* task provided using the `updateTaskStatus`.
|
|
104
|
+
*
|
|
105
|
+
* **Note : This API call is known to sometimes fail for unknown reasons. Please take note of the details provided in
|
|
106
|
+
* the TSDoc of the `updateTaskStatus` function.**
|
|
107
|
+
*
|
|
108
|
+
* @param options The options of the request.
|
|
109
|
+
* @param config The API config.
|
|
110
|
+
* @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
|
|
111
|
+
* state management for you.
|
|
112
|
+
*
|
|
113
|
+
* @see updateTaskStatus
|
|
114
|
+
*/
|
|
115
|
+
function startInspectionTasks(options, config, dispatch) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
+
var responses;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0: return [4 /*yield*/, Promise.all(options.names.map(function (name) {
|
|
121
|
+
return updateTaskStatus({ inspectionId: options.inspectionId, name: name, status: types_1.ProgressStatus.TODO }, config);
|
|
122
|
+
}))];
|
|
123
|
+
case 1:
|
|
124
|
+
responses = _a.sent();
|
|
125
|
+
dispatch === null || dispatch === void 0 ? void 0 : dispatch({
|
|
126
|
+
type: common_1.MonkActionType.UPDATED_MANY_TASKS,
|
|
127
|
+
payload: responses.map(function (response) { return ({ id: response.id, status: types_1.ProgressStatus.TODO }); }),
|
|
128
|
+
});
|
|
129
|
+
return [2 /*return*/, responses];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
exports.startInspectionTasks = startInspectionTasks;
|
|
135
|
+
//# sourceMappingURL=requests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.js","sourceRoot":"","sources":["../../../../src/api/task/requests.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAoB;AACpB,6CAAgF;AAChF,2CAA6D;AAE7D,oCAA6D;AA+B7D;;;;;;;;;;;GAWG;AACH,SAAsB,gBAAgB,CACpC,OAAgC,EAChC,MAAqB,EACrB,QAA+C;;;;;;oBAEzC,SAAS,GAAG,IAAA,0BAAiB,EAAC,MAAM,CAAC,CAAC;oBAC3B,qBAAM,YAAE,CAAC,KAAK,CAAC,sBAAe,OAAO,CAAC,YAAY,oBAAU,OAAO,CAAC,IAAI,CAAE,wBACtF,SAAS,KACZ,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EAChC,KAAK,EAAE;gCACL,OAAO,EAAE,CAAC,OAAO,CAAC;gCAClB,KAAK,EAAE,CAAC;gCACR,YAAY,EAAE,IAAI;6BACnB,IACD,EAAA;;oBARI,QAAQ,GAAG,SAQf;oBACW,qBAAM,QAAQ,CAAC,IAAI,EAAe,EAAA;;oBAAzC,IAAI,GAAG,SAAkC;oBAC/C,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG;wBACT,IAAI,EAAE,uBAAc,CAAC,kBAAkB;wBACvC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;qBACnD,CAAC,CAAC;oBACH,sBAAO;4BACL,EAAE,EAAE,IAAI,CAAC,EAAE;4BACX,QAAQ,UAAA;4BACR,IAAI,MAAA;yBACL,EAAC;;;;CACH;AAzBD,4CAyBC;AAgBD;;;;;;;;;;;;;GAaG;AACH,SAAsB,oBAAoB,CACxC,OAAoC,EACpC,MAAqB,EACrB,QAA+C;;;;;wBAE7B,qBAAM,OAAO,CAAC,GAAG,CACjC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI;wBACrB,OAAA,gBAAgB,CACd,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,IAAI,MAAA,EAAE,MAAM,EAAE,sBAAc,CAAC,IAAI,EAAE,EACzE,MAAM,CACP;oBAHD,CAGC,CACF,CACF,EAAA;;oBAPK,SAAS,GAAG,SAOjB;oBACD,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG;wBACT,IAAI,EAAE,uBAAc,CAAC,kBAAkB;wBACvC,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,UAAC,QAAQ,IAAK,OAAA,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,sBAAc,CAAC,IAAI,EAAE,CAAC,EAAlD,CAAkD,CAAC;qBACzF,CAAC,CAAC;oBACH,sBAAO,SAAS,EAAC;;;;CAClB;AAlBD,oDAkBC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { KyResponse } from 'ky';
|
|
2
|
+
import { ApiIdColumn } from './models';
|
|
3
|
+
/**
|
|
4
|
+
* Default return type of Monk API Request, containing just the ID of the affected entity.
|
|
5
|
+
*/
|
|
6
|
+
export interface MonkId {
|
|
7
|
+
/**
|
|
8
|
+
* The ID of the entity that was affected by the API request.
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generic type definition for the response returned by a Monk API Request.
|
|
14
|
+
*/
|
|
15
|
+
export type MonkApiResponse<T extends object = MonkId, K extends object = ApiIdColumn> = T & {
|
|
16
|
+
/**
|
|
17
|
+
* The raw HTTP response object.
|
|
18
|
+
*/
|
|
19
|
+
response: KyResponse;
|
|
20
|
+
/**
|
|
21
|
+
* The body of the response.
|
|
22
|
+
*/
|
|
23
|
+
body: K;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PixelDimensions } from '@monkvision/types';
|
|
2
|
+
/**
|
|
3
|
+
* The ratio used to resize the dimensions of the thumbnail.
|
|
4
|
+
*/
|
|
5
|
+
export declare const THUMBNAIL_RESIZE_RATIO = 0.1;
|
|
6
|
+
/**
|
|
7
|
+
* Util function that generate a thumbnail url.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getThumbnailUrl(thumbnailDomain: string, path: string, dimensions: PixelDimensions): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getThumbnailUrl = exports.THUMBNAIL_RESIZE_RATIO = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The ratio used to resize the dimensions of the thumbnail.
|
|
6
|
+
*/
|
|
7
|
+
exports.THUMBNAIL_RESIZE_RATIO = 0.1;
|
|
8
|
+
function getResizedDimension(originalDimension) {
|
|
9
|
+
return Math.round(originalDimension * exports.THUMBNAIL_RESIZE_RATIO);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Util function that generate a thumbnail url.
|
|
13
|
+
*/
|
|
14
|
+
function getThumbnailUrl(thumbnailDomain, path, dimensions) {
|
|
15
|
+
var baseThumbnailUrl = "https://".concat(thumbnailDomain).concat(thumbnailDomain.endsWith('/') ? '' : '/');
|
|
16
|
+
var imageUrlParam = "image_url=".concat(encodeURIComponent(path));
|
|
17
|
+
var widthUrlParam = "width=".concat(getResizedDimension(dimensions.width));
|
|
18
|
+
var heightUrlParam = "height=".concat(getResizedDimension(dimensions.height));
|
|
19
|
+
return "".concat(baseThumbnailUrl, "?").concat(imageUrlParam, "&").concat(widthUrlParam, "&").concat(heightUrlParam);
|
|
20
|
+
}
|
|
21
|
+
exports.getThumbnailUrl = getThumbnailUrl;
|
|
22
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/api/utils.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,sBAAsB,GAAG,GAAG,CAAC;AAE1C,SAAS,mBAAmB,CAAC,iBAAyB;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,GAAG,8BAAsB,CAAC,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAC7B,eAAuB,EACvB,IAAY,EACZ,UAA2B;IAE3B,IAAM,gBAAgB,GAAG,kBAAW,eAAe,SAAG,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAE,CAAC;IACjG,IAAM,aAAa,GAAG,oBAAa,kBAAkB,CAAC,IAAI,CAAC,CAAE,CAAC;IAC9D,IAAM,aAAa,GAAG,gBAAS,mBAAmB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAE,CAAC;IACvE,IAAM,cAAc,GAAG,iBAAU,mBAAmB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAE,CAAC;IAE1E,OAAO,UAAG,gBAAgB,cAAI,aAAa,cAAI,aAAa,cAAI,cAAc,CAAE,CAAC;AACnF,CAAC;AAXD,0CAWC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './requests';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./requests"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/vehicle/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapApiVehiclePatch = void 0;
|
|
4
|
+
function mapApiVehiclePatch(options) {
|
|
5
|
+
return {
|
|
6
|
+
brand: options.brand,
|
|
7
|
+
model: options.model,
|
|
8
|
+
plate: options.plate,
|
|
9
|
+
vehicle_type: options.type,
|
|
10
|
+
mileage: options.mileageValue && options.mileageUnit
|
|
11
|
+
? {
|
|
12
|
+
value: options.mileageValue,
|
|
13
|
+
unit: options.mileageUnit,
|
|
14
|
+
}
|
|
15
|
+
: undefined,
|
|
16
|
+
market_value: options.marketValue && options.marketValueUnit
|
|
17
|
+
? { value: options.marketValue, unit: options.marketValueUnit }
|
|
18
|
+
: undefined,
|
|
19
|
+
vin: options.vin,
|
|
20
|
+
color: options.color,
|
|
21
|
+
exterior_cleanliness: options.exteriorCleanliness,
|
|
22
|
+
interior_cleanliness: options.interiorCleanliness,
|
|
23
|
+
date_of_circulation: options.dateOfCirculation,
|
|
24
|
+
duplicate_keys: options.duplicateKeys,
|
|
25
|
+
expertise_requested: options.expertiseRequested,
|
|
26
|
+
car_registration: options.carRegistration,
|
|
27
|
+
vehicle_quotation: options.vehicleQuotation,
|
|
28
|
+
trade_in_offer: options.tradeInOffer,
|
|
29
|
+
owner_info: options.ownerInfo,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.mapApiVehiclePatch = mapApiVehiclePatch;
|
|
33
|
+
//# sourceMappingURL=mappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mappers.js","sourceRoot":"","sources":["../../../../src/api/vehicle/mappers.ts"],"names":[],"mappings":";;;AAGA,SAAgB,kBAAkB,CAAC,OAAyB;IAC1D,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,YAAY,EAAE,OAAO,CAAC,IAAI;QAC1B,OAAO,EACL,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,WAAW;YACzC,CAAC,CAAC;gBACE,KAAK,EAAE,OAAO,CAAC,YAAY;gBAC3B,IAAI,EAAE,OAAO,CAAC,WAAW;aAC1B;YACH,CAAC,CAAC,SAAS;QACf,YAAY,EACV,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,eAAe;YAC5C,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE;YAC/D,CAAC,CAAC,SAAS;QACf,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,oBAAoB,EAAE,OAAO,CAAC,mBAAmB;QACjD,oBAAoB,EAAE,OAAO,CAAC,mBAAmB;QACjD,mBAAmB,EAAE,OAAO,CAAC,iBAAiB;QAC9C,cAAc,EAAE,OAAO,CAAC,aAAa;QACrC,mBAAmB,EAAE,OAAO,CAAC,kBAAkB;QAC/C,gBAAgB,EAAE,OAAO,CAAC,eAAe;QACzC,iBAAiB,EAAE,OAAO,CAAC,gBAAgB;QAC3C,cAAc,EAAE,OAAO,CAAC,YAAY;QACpC,UAAU,EAAE,OAAO,CAAC,SAAS;KAC9B,CAAC;AACJ,CAAC;AA7BD,gDA6BC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MonkAction } from '@monkvision/common';
|
|
2
|
+
import { Vehicle } from '@monkvision/types';
|
|
3
|
+
import { Dispatch } from 'react';
|
|
4
|
+
import { MonkApiConfig } from '../config';
|
|
5
|
+
import { ApiIdColumn } from '../models';
|
|
6
|
+
/**
|
|
7
|
+
* Options used to specify how to update the vehicle of an inspection.
|
|
8
|
+
*/
|
|
9
|
+
export interface UpdateInspectionVehicleOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The ID of the inspection.
|
|
12
|
+
*/
|
|
13
|
+
inspectionId: string;
|
|
14
|
+
/**
|
|
15
|
+
* The vehicle details to update.
|
|
16
|
+
*/
|
|
17
|
+
vehicle: Partial<Vehicle>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Update the vehicle of an inspection.
|
|
21
|
+
*
|
|
22
|
+
* @param options The options of the request.
|
|
23
|
+
* @param config The API config.
|
|
24
|
+
* @param [_dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
|
|
25
|
+
* state management for you.
|
|
26
|
+
*/
|
|
27
|
+
export declare function updateInspectionVehicle(options: UpdateInspectionVehicleOptions, config: MonkApiConfig, _dispatch?: Dispatch<MonkAction>): Promise<{
|
|
28
|
+
id: string;
|
|
29
|
+
response: import("ky").KyResponse;
|
|
30
|
+
body: ApiIdColumn;
|
|
31
|
+
}>;
|