@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.
Files changed (124) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +225 -0
  3. package/lib/package.json +84 -0
  4. package/lib/src/api/api.d.ts +18 -0
  5. package/lib/src/api/api.js +22 -0
  6. package/lib/src/api/api.js.map +1 -0
  7. package/lib/src/api/config.d.ts +20 -0
  8. package/lib/src/api/config.js +41 -0
  9. package/lib/src/api/config.js.map +1 -0
  10. package/lib/src/api/error.d.ts +34 -0
  11. package/lib/src/api/error.js +118 -0
  12. package/lib/src/api/error.js.map +1 -0
  13. package/lib/src/api/hooks/index.d.ts +1 -0
  14. package/lib/src/api/hooks/index.js +18 -0
  15. package/lib/src/api/hooks/index.js.map +1 -0
  16. package/lib/src/api/hooks/useInspectionPoll.d.ts +34 -0
  17. package/lib/src/api/hooks/useInspectionPoll.js +21 -0
  18. package/lib/src/api/hooks/useInspectionPoll.js.map +1 -0
  19. package/lib/src/api/image/index.d.ts +1 -0
  20. package/lib/src/api/image/index.js +18 -0
  21. package/lib/src/api/image/index.js.map +1 -0
  22. package/lib/src/api/image/mappers.d.ts +3 -0
  23. package/lib/src/api/image/mappers.js +166 -0
  24. package/lib/src/api/image/mappers.js.map +1 -0
  25. package/lib/src/api/image/requests.d.ts +141 -0
  26. package/lib/src/api/image/requests.js +312 -0
  27. package/lib/src/api/image/requests.js.map +1 -0
  28. package/lib/src/api/index.d.ts +10 -0
  29. package/lib/src/api/index.js +27 -0
  30. package/lib/src/api/index.js.map +1 -0
  31. package/lib/src/api/inspection/index.d.ts +1 -0
  32. package/lib/src/api/inspection/index.js +18 -0
  33. package/lib/src/api/inspection/index.js.map +1 -0
  34. package/lib/src/api/inspection/mappers.d.ts +5 -0
  35. package/lib/src/api/inspection/mappers.js +392 -0
  36. package/lib/src/api/inspection/mappers.js.map +1 -0
  37. package/lib/src/api/inspection/requests.d.ts +47 -0
  38. package/lib/src/api/inspection/requests.js +122 -0
  39. package/lib/src/api/inspection/requests.js.map +1 -0
  40. package/lib/src/api/liveConfigs/index.d.ts +1 -0
  41. package/lib/src/api/liveConfigs/index.js +18 -0
  42. package/lib/src/api/liveConfigs/index.js.map +1 -0
  43. package/lib/src/api/liveConfigs/requests.d.ts +7 -0
  44. package/lib/src/api/liveConfigs/requests.js +66 -0
  45. package/lib/src/api/liveConfigs/requests.js.map +1 -0
  46. package/lib/src/api/models/common.d.ts +13 -0
  47. package/lib/src/api/models/common.js +3 -0
  48. package/lib/src/api/models/common.js.map +1 -0
  49. package/lib/src/api/models/compliance.d.ts +58 -0
  50. package/lib/src/api/models/compliance.js +3 -0
  51. package/lib/src/api/models/compliance.js.map +1 -0
  52. package/lib/src/api/models/damage.d.ts +11 -0
  53. package/lib/src/api/models/damage.js +3 -0
  54. package/lib/src/api/models/damage.js.map +1 -0
  55. package/lib/src/api/models/image.d.ts +76 -0
  56. package/lib/src/api/models/image.js +3 -0
  57. package/lib/src/api/models/image.js.map +1 -0
  58. package/lib/src/api/models/index.d.ts +13 -0
  59. package/lib/src/api/models/index.js +30 -0
  60. package/lib/src/api/models/index.js.map +1 -0
  61. package/lib/src/api/models/inspection.d.ts +40 -0
  62. package/lib/src/api/models/inspection.js +3 -0
  63. package/lib/src/api/models/inspection.js.map +1 -0
  64. package/lib/src/api/models/part.d.ts +10 -0
  65. package/lib/src/api/models/part.js +3 -0
  66. package/lib/src/api/models/part.js.map +1 -0
  67. package/lib/src/api/models/pricingV2.d.ts +15 -0
  68. package/lib/src/api/models/pricingV2.js +3 -0
  69. package/lib/src/api/models/pricingV2.js.map +1 -0
  70. package/lib/src/api/models/renderedOutput.d.ts +8 -0
  71. package/lib/src/api/models/renderedOutput.js +3 -0
  72. package/lib/src/api/models/renderedOutput.js.map +1 -0
  73. package/lib/src/api/models/severityResult.d.ts +37 -0
  74. package/lib/src/api/models/severityResult.js +3 -0
  75. package/lib/src/api/models/severityResult.js.map +1 -0
  76. package/lib/src/api/models/task.d.ts +76 -0
  77. package/lib/src/api/models/task.js +3 -0
  78. package/lib/src/api/models/task.js.map +1 -0
  79. package/lib/src/api/models/vehicle.d.ts +58 -0
  80. package/lib/src/api/models/vehicle.js +3 -0
  81. package/lib/src/api/models/vehicle.js.map +1 -0
  82. package/lib/src/api/models/view.d.ts +24 -0
  83. package/lib/src/api/models/view.js +3 -0
  84. package/lib/src/api/models/view.js.map +1 -0
  85. package/lib/src/api/models/wheelAnalysis.d.ts +13 -0
  86. package/lib/src/api/models/wheelAnalysis.js +3 -0
  87. package/lib/src/api/models/wheelAnalysis.js.map +1 -0
  88. package/lib/src/api/react.d.ts +69 -0
  89. package/lib/src/api/react.js +105 -0
  90. package/lib/src/api/react.js.map +1 -0
  91. package/lib/src/api/task/index.d.ts +1 -0
  92. package/lib/src/api/task/index.js +18 -0
  93. package/lib/src/api/task/index.js.map +1 -0
  94. package/lib/src/api/task/requests.d.ts +67 -0
  95. package/lib/src/api/task/requests.js +135 -0
  96. package/lib/src/api/task/requests.js.map +1 -0
  97. package/lib/src/api/types.d.ts +24 -0
  98. package/lib/src/api/types.js +3 -0
  99. package/lib/src/api/types.js.map +1 -0
  100. package/lib/src/api/utils.d.ts +9 -0
  101. package/lib/src/api/utils.js +22 -0
  102. package/lib/src/api/utils.js.map +1 -0
  103. package/lib/src/api/vehicle/index.d.ts +1 -0
  104. package/lib/src/api/vehicle/index.js +18 -0
  105. package/lib/src/api/vehicle/index.js.map +1 -0
  106. package/lib/src/api/vehicle/mappers.d.ts +3 -0
  107. package/lib/src/api/vehicle/mappers.js +33 -0
  108. package/lib/src/api/vehicle/mappers.js.map +1 -0
  109. package/lib/src/api/vehicle/requests.d.ts +31 -0
  110. package/lib/src/api/vehicle/requests.js +88 -0
  111. package/lib/src/api/vehicle/requests.js.map +1 -0
  112. package/lib/src/auth/hooks.d.ts +34 -0
  113. package/lib/src/auth/hooks.js +112 -0
  114. package/lib/src/auth/hooks.js.map +1 -0
  115. package/lib/src/auth/index.d.ts +2 -0
  116. package/lib/src/auth/index.js +19 -0
  117. package/lib/src/auth/index.js.map +1 -0
  118. package/lib/src/auth/token.d.ts +25 -0
  119. package/lib/src/auth/token.js +36 -0
  120. package/lib/src/auth/token.js.map +1 -0
  121. package/lib/src/index.d.ts +2 -0
  122. package/lib/src/index.js +19 -0
  123. package/lib/src/index.js.map +1 -0
  124. package/package.json +85 -0
@@ -0,0 +1,34 @@
1
+ import { MonkState } from '@monkvision/common';
2
+ import { ComplianceOptions } from '@monkvision/types';
3
+ import { MonkApiConfig } from '../config';
4
+ /**
5
+ * Parameters passed to the `useInspectionPoll` hook.
6
+ */
7
+ export interface UseInspectionPollParams {
8
+ /**
9
+ * The ID of the inspection to fetch.
10
+ */
11
+ id: string;
12
+ /**
13
+ * The delay in milliseconds between each inspection fetch. Note that if the previous API call is still running, a new
14
+ * one won't be made. Set this value to `null` to stop the API calls.
15
+ */
16
+ delay: number | null;
17
+ /**
18
+ * The API config used to communicate with the API.
19
+ */
20
+ apiConfig: MonkApiConfig;
21
+ /**
22
+ * Callback called when the fetch inspection is successful.
23
+ */
24
+ onSuccess?: (state: MonkState) => void;
25
+ /**
26
+ * Additional options used to configure the compliance locally.
27
+ */
28
+ compliance?: ComplianceOptions;
29
+ }
30
+ /**
31
+ * Custom hook used to fetch an inspection every `delay` milliseconds using the `getInspection` API request. To stop the
32
+ * hook from making requests, simply pass a `null` vlaue for the `delay` param.
33
+ */
34
+ export declare function useInspectionPoll({ id, delay, apiConfig, onSuccess, compliance, }: UseInspectionPollParams): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useInspectionPoll = void 0;
4
+ var common_1 = require("@monkvision/common");
5
+ var monitoring_1 = require("@monkvision/monitoring");
6
+ var react_1 = require("../react");
7
+ /**
8
+ * Custom hook used to fetch an inspection every `delay` milliseconds using the `getInspection` API request. To stop the
9
+ * hook from making requests, simply pass a `null` vlaue for the `delay` param.
10
+ */
11
+ function useInspectionPoll(_a) {
12
+ var id = _a.id, delay = _a.delay, apiConfig = _a.apiConfig, onSuccess = _a.onSuccess, compliance = _a.compliance;
13
+ var getInspection = (0, react_1.useMonkApi)(apiConfig).getInspection;
14
+ var handleError = (0, monitoring_1.useMonitoring)().handleError;
15
+ (0, common_1.useAsyncInterval)(function () { return getInspection({ id: id, compliance: compliance }); }, delay, {
16
+ onResolve: function (res) { return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res.entities); },
17
+ onReject: handleError,
18
+ });
19
+ }
20
+ exports.useInspectionPoll = useInspectionPoll;
21
+ //# sourceMappingURL=useInspectionPoll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInspectionPoll.js","sourceRoot":"","sources":["../../../../src/api/hooks/useInspectionPoll.ts"],"names":[],"mappings":";;;AAAA,6CAAiE;AAEjE,qDAAuD;AAEvD,kCAAsC;AA6BtC;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,EAMR;QALxB,EAAE,QAAA,EACF,KAAK,WAAA,EACL,SAAS,eAAA,EACT,SAAS,eAAA,EACT,UAAU,gBAAA;IAEF,IAAA,aAAa,GAAK,IAAA,kBAAU,EAAC,SAAS,CAAC,cAA1B,CAA2B;IACxC,IAAA,WAAW,GAAK,IAAA,0BAAa,GAAE,YAApB,CAAqB;IAExC,IAAA,yBAAgB,EAAC,cAAM,OAAA,aAAa,CAAC,EAAE,EAAE,IAAA,EAAE,UAAU,YAAA,EAAE,CAAC,EAAjC,CAAiC,EAAE,KAAK,EAAE;QAC/D,SAAS,EAAE,UAAC,GAAG,IAAK,OAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,GAAG,CAAC,QAAQ,CAAC,EAAzB,CAAyB;QAC7C,QAAQ,EAAE,WAAW;KACtB,CAAC,CAAC;AACL,CAAC;AAdD,8CAcC"}
@@ -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/image/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
@@ -0,0 +1,3 @@
1
+ import { ComplianceOptions, Image } from '@monkvision/types';
2
+ import { ApiImage } from '../models';
3
+ export declare function mapApiImage(image: ApiImage, inspectionId: string, thumbnailDomain: string, complianceOptions?: ComplianceOptions): Image;
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapApiImage = void 0;
4
+ var types_1 = require("@monkvision/types");
5
+ var utils_1 = require("../utils");
6
+ var DEFAULT_COMPLIANCE_OPTIONS = {
7
+ enableCompliance: true,
8
+ complianceIssues: types_1.DEFAULT_COMPLIANCE_ISSUES,
9
+ };
10
+ function getActiveComplianceOptions(sightId, complianceOptions) {
11
+ var _a, _b, _c, _d;
12
+ var enableComplianceGlobal = (_a = complianceOptions === null || complianceOptions === void 0 ? void 0 : complianceOptions.enableCompliance) !== null && _a !== void 0 ? _a : DEFAULT_COMPLIANCE_OPTIONS.enableCompliance;
13
+ var enableCompliance = sightId && (complianceOptions === null || complianceOptions === void 0 ? void 0 : complianceOptions.enableCompliancePerSight)
14
+ ? complianceOptions.enableCompliancePerSight.includes(sightId)
15
+ : enableComplianceGlobal;
16
+ var complianceIssuesGlobal = (_b = complianceOptions === null || complianceOptions === void 0 ? void 0 : complianceOptions.complianceIssues) !== null && _b !== void 0 ? _b : DEFAULT_COMPLIANCE_OPTIONS.complianceIssues;
17
+ var complianceIssues = sightId && ((_c = complianceOptions === null || complianceOptions === void 0 ? void 0 : complianceOptions.complianceIssuesPerSight) === null || _c === void 0 ? void 0 : _c[sightId])
18
+ ? complianceOptions.complianceIssuesPerSight[sightId]
19
+ : complianceIssuesGlobal;
20
+ var customComplianceThresholds = sightId
21
+ ? (_d = complianceOptions === null || complianceOptions === void 0 ? void 0 : complianceOptions.customComplianceThresholdsPerSight) === null || _d === void 0 ? void 0 : _d[sightId]
22
+ : complianceOptions === null || complianceOptions === void 0 ? void 0 : complianceOptions.customComplianceThresholds;
23
+ return { enableCompliance: enableCompliance, complianceIssues: complianceIssues, customComplianceThresholds: customComplianceThresholds };
24
+ }
25
+ function getComplianceIssue(thresholdName) {
26
+ switch (thresholdName) {
27
+ case 'blurriness':
28
+ return types_1.ComplianceIssue.BLURRINESS;
29
+ case 'overexposure':
30
+ return types_1.ComplianceIssue.OVEREXPOSURE;
31
+ case 'underexposure':
32
+ return types_1.ComplianceIssue.UNDEREXPOSURE;
33
+ case 'lensFlare':
34
+ return types_1.ComplianceIssue.LENS_FLARE;
35
+ case 'wetness':
36
+ return types_1.ComplianceIssue.WETNESS;
37
+ case 'snowness':
38
+ return types_1.ComplianceIssue.SNOWNESS;
39
+ case 'dirtiness':
40
+ return types_1.ComplianceIssue.DIRTINESS;
41
+ case 'reflections':
42
+ return types_1.ComplianceIssue.REFLECTIONS;
43
+ default:
44
+ return undefined;
45
+ }
46
+ }
47
+ function getComplianceScore(thresholdName, complianceResult) {
48
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
49
+ switch (thresholdName) {
50
+ case 'blurriness':
51
+ return (_a = complianceResult === null || complianceResult === void 0 ? void 0 : complianceResult.image_analysis) === null || _a === void 0 ? void 0 : _a.blurriness;
52
+ case 'overexposure':
53
+ return (_b = complianceResult === null || complianceResult === void 0 ? void 0 : complianceResult.image_analysis) === null || _b === void 0 ? void 0 : _b.overexposure;
54
+ case 'underexposure':
55
+ return (_c = complianceResult === null || complianceResult === void 0 ? void 0 : complianceResult.image_analysis) === null || _c === void 0 ? void 0 : _c.underexposure;
56
+ case 'lensFlare':
57
+ return (_d = complianceResult === null || complianceResult === void 0 ? void 0 : complianceResult.image_analysis) === null || _d === void 0 ? void 0 : _d.lens_flare;
58
+ case 'wetness':
59
+ return (_e = complianceResult === null || complianceResult === void 0 ? void 0 : complianceResult.vehicle_analysis) === null || _e === void 0 ? void 0 : _e.wetness;
60
+ case 'snowness':
61
+ return (_f = complianceResult === null || complianceResult === void 0 ? void 0 : complianceResult.vehicle_analysis) === null || _f === void 0 ? void 0 : _f.snowness;
62
+ case 'dirtiness':
63
+ return (_g = complianceResult === null || complianceResult === void 0 ? void 0 : complianceResult.vehicle_analysis) === null || _g === void 0 ? void 0 : _g.dirtiness;
64
+ case 'reflections':
65
+ return (_h = complianceResult === null || complianceResult === void 0 ? void 0 : complianceResult.vehicle_analysis) === null || _h === void 0 ? void 0 : _h.reflections;
66
+ case 'zoom':
67
+ return (_j = complianceResult === null || complianceResult === void 0 ? void 0 : complianceResult.image_analysis) === null || _j === void 0 ? void 0 : _j.zoom;
68
+ default:
69
+ return undefined;
70
+ }
71
+ }
72
+ function applyCustomComplianceThresholds(issues, complianceResult, customComplianceThresholds) {
73
+ var complianceIssues = issues !== null && issues !== void 0 ? issues : [];
74
+ if (!customComplianceThresholds) {
75
+ return complianceIssues;
76
+ }
77
+ Object.keys(customComplianceThresholds).forEach(function (key) {
78
+ var thresholdName = key;
79
+ var complianceScore = getComplianceScore(thresholdName, complianceResult);
80
+ if (thresholdName === 'zoom' && complianceScore && customComplianceThresholds.zoom) {
81
+ complianceIssues = complianceIssues.filter(function (issue) { return ![types_1.ComplianceIssue.TOO_ZOOMED, types_1.ComplianceIssue.NOT_ZOOMED_ENOUGH].includes(issue); });
82
+ if (complianceScore < customComplianceThresholds.zoom.min) {
83
+ complianceIssues.push(types_1.ComplianceIssue.TOO_ZOOMED);
84
+ }
85
+ else if (complianceScore > customComplianceThresholds.zoom.max) {
86
+ complianceIssues.push(types_1.ComplianceIssue.NOT_ZOOMED_ENOUGH);
87
+ }
88
+ return;
89
+ }
90
+ var customThreshold = customComplianceThresholds[thresholdName];
91
+ var complianceIssue = getComplianceIssue(thresholdName);
92
+ if (complianceScore && complianceIssue && customThreshold !== undefined) {
93
+ complianceIssues = complianceIssues.filter(function (issue) { return issue !== complianceIssue; });
94
+ if (complianceScore < customThreshold) {
95
+ complianceIssues.push(complianceIssue);
96
+ }
97
+ }
98
+ });
99
+ return complianceIssues;
100
+ }
101
+ function filterCompliances(issues, validIssues) {
102
+ return issues.filter(function (issue) { return validIssues.includes(issue); });
103
+ }
104
+ function compareComplianceIssues(a, b) {
105
+ return types_1.COMPLIANCE_ISSUES_PRIORITY.indexOf(a) - types_1.COMPLIANCE_ISSUES_PRIORITY.indexOf(b);
106
+ }
107
+ function mapCompliance(sightId, complianceResult, complianceOptions) {
108
+ var _a = getActiveComplianceOptions(sightId, complianceOptions), enableCompliance = _a.enableCompliance, complianceIssues = _a.complianceIssues, customComplianceThresholds = _a.customComplianceThresholds;
109
+ if (!enableCompliance) {
110
+ return { status: types_1.ImageStatus.SUCCESS };
111
+ }
112
+ if (!complianceResult) {
113
+ return { status: types_1.ImageStatus.COMPLIANCE_RUNNING };
114
+ }
115
+ var newIssuesAfterCustomThresholds = applyCustomComplianceThresholds(complianceResult.compliance_issues, complianceResult, customComplianceThresholds);
116
+ var filteredCompliances = filterCompliances(newIssuesAfterCustomThresholds, complianceIssues);
117
+ if (filteredCompliances.length === 0) {
118
+ return { status: types_1.ImageStatus.SUCCESS };
119
+ }
120
+ return {
121
+ status: types_1.ImageStatus.NOT_COMPLIANT,
122
+ complianceIssues: filteredCompliances.sort(compareComplianceIssues),
123
+ };
124
+ }
125
+ function mapApiImage(image, inspectionId, thumbnailDomain, complianceOptions) {
126
+ var _a, _b, _c;
127
+ var sightId = (_a = image.additional_data) === null || _a === void 0 ? void 0 : _a.sight_id;
128
+ var _d = mapCompliance(sightId, image.compliances, complianceOptions), status = _d.status, complianceIssues = _d.complianceIssues;
129
+ return {
130
+ id: image.id,
131
+ entityType: types_1.MonkEntityType.IMAGE,
132
+ inspectionId: inspectionId,
133
+ label: (_b = image.additional_data) === null || _b === void 0 ? void 0 : _b.label,
134
+ sightId: sightId,
135
+ createdAt: ((_c = image.additional_data) === null || _c === void 0 ? void 0 : _c.created_at)
136
+ ? Date.parse(image.additional_data.created_at)
137
+ : undefined,
138
+ path: image.path,
139
+ thumbnailPath: (0, utils_1.getThumbnailUrl)(thumbnailDomain, image.path, {
140
+ height: image.image_height,
141
+ width: image.image_width,
142
+ }),
143
+ width: image.image_width,
144
+ height: image.image_height,
145
+ size: image.binary_size,
146
+ mimetype: image.mimetype,
147
+ type: image.image_type,
148
+ subtype: image.image_subtype,
149
+ status: status,
150
+ complianceIssues: complianceIssues,
151
+ siblingKey: image.image_sibling_key,
152
+ viewpoint: image.viewpoint,
153
+ detailedViewpoint: image.detailed_viewpoint
154
+ ? {
155
+ isExterior: image.detailed_viewpoint.is_exterior,
156
+ distance: image.detailed_viewpoint.distance,
157
+ centersOn: image.detailed_viewpoint.centers_on,
158
+ }
159
+ : undefined,
160
+ additionalData: image.additional_data,
161
+ renderedOutputs: [],
162
+ views: [],
163
+ };
164
+ }
165
+ exports.mapApiImage = mapApiImage;
166
+ //# sourceMappingURL=mappers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mappers.js","sourceRoot":"","sources":["../../../../src/api/image/mappers.ts"],"names":[],"mappings":";;;AAAA,2CAa2B;AAE3B,kCAA2C;AAE3C,IAAM,0BAA0B,GAAG;IACjC,gB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E,KAAK,CAAC,YAAY;QAC1B,IAAI,EAAE,KAAK,CAAC,WAAW;QACvB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,IAAI,EAAE,KAAK,CAAC,UAAuB;QACnC,OAAO,EAAE,KAAK,CAAC,aAAyC;QACxD,MAAM,QAAA;QACN,gBAAgB,kBAAA;QAChB,UAAU,EAAE,KAAK,CAAC,iBAAiB;QACnC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,iBAAiB,EAAE,KAAK,CAAC,kBAAkB;YACzC,CAAC,CAAC;gBACE,UAAU,EAAE,KAAK,CAAC,kBAAkB,CAAC,WAAW;gBAChD,QAAQ,EAAE,KAAK,CAAC,kBAAkB,CAAC,QAAQ;gBAC3C,SAAS,EAAE,KAAK,CAAC,kBAAkB,CAAC,UAEvB;aACd;YACH,CAAC,CAAC,SAAS;QACb,cAAc,EAAE,KAAK,CAAC,eAAe;QACrC,eAAe,EAAE,EAAE;QACnB,KAAK,EAAE,EAAE;KACV,CAAC;AACJ,CAAC;AA7CD,kCA6CC"}
@@ -0,0 +1,141 @@
1
+ import { Dispatch } from 'react';
2
+ import { MonkCreatedOneImageAction } from '@monkvision/common';
3
+ import { ComplianceOptions, Image, MonkPicture, TaskName } from '@monkvision/types';
4
+ import { MonkApiConfig } from '../config';
5
+ import { ApiImage } from '../models';
6
+ import { MonkApiResponse } from '../types';
7
+ /**
8
+ * The different upload types for inspection images.
9
+ */
10
+ export declare enum ImageUploadType {
11
+ /**
12
+ * Upload type corresponding to a sight image in the PhotoCapture process (beauty shot image).
13
+ */
14
+ BEAUTY_SHOT = "beauty_shot",
15
+ /**
16
+ * Upload type corresponding to a close-up picture (add-damage) in the PhotoCapture process, when using the 2-shot
17
+ * add damage workflow.
18
+ */
19
+ CLOSE_UP_2_SHOT = "close_up_2_shot",
20
+ /**
21
+ * Upload type corresponding to a video frame in the VideoCapture process.
22
+ */
23
+ VIDEO_FRAME = "video_frame"
24
+ }
25
+ /**
26
+ * Options specififed when adding a beauty shot (normal "sight" image) to an inspection.
27
+ */
28
+ export interface AddBeautyShotImageOptions {
29
+ /**
30
+ * The type of the image upload : `ImageUploadType.BEAUTY_SHOT`;
31
+ */
32
+ uploadType: ImageUploadType.BEAUTY_SHOT;
33
+ /**
34
+ * The picture to add to the inspection.
35
+ */
36
+ picture: MonkPicture;
37
+ /**
38
+ * The ID of the inspection to add the image to.
39
+ */
40
+ inspectionId: string;
41
+ /**
42
+ * The ID of the sight of the image.
43
+ */
44
+ sightId: string;
45
+ /**
46
+ * The list of tasks to run for this image.
47
+ */
48
+ tasks: TaskName[];
49
+ /**
50
+ * Boolean indicating if a thumbnail request will be sent when addImage is called.
51
+ */
52
+ useThumbnailCaching?: boolean;
53
+ /**
54
+ * Additional options used to configure the compliance locally.
55
+ */
56
+ compliance?: ComplianceOptions;
57
+ }
58
+ /**
59
+ * Options specififed when adding a close up (an "add damage" image) to an inspection using the 2-shot process.
60
+ */
61
+ export interface Add2ShotCloseUpImageOptions {
62
+ /**
63
+ * The type of the image upload : `ImageUploadType.CLOSE_UP_2_SHOT`;
64
+ */
65
+ uploadType: ImageUploadType.CLOSE_UP_2_SHOT;
66
+ /**
67
+ * The picture to add to the inspection.
68
+ */
69
+ picture: MonkPicture;
70
+ /**
71
+ * The ID of the inspection to add the image to.
72
+ */
73
+ inspectionId: string;
74
+ /**
75
+ * This parameter is used to link two close up pictures together. In the 2-shot process, you first upload a zoomed-out
76
+ * picture of the damage, and then a close-up zoomed picture. In order to link these two pictures together, you need
77
+ * to specify the same `siblingKey` parameter when uploading them. This key must be unique per pair of pictures in the
78
+ * same inspection.
79
+ */
80
+ siblingKey: string;
81
+ /**
82
+ * Boolean indicating if this picture is the first picture or the second picture of the 2-shot process.
83
+ */
84
+ firstShot: boolean;
85
+ /**
86
+ * Boolean indicating if a thumbnail request will be sent when addImage is called.
87
+ */
88
+ useThumbnailCaching?: boolean;
89
+ /**
90
+ * Additional options used to configure the compliance locally.
91
+ */
92
+ compliance?: ComplianceOptions;
93
+ }
94
+ /**
95
+ * Options specififed when adding a video frame to a VideoCapture inspection.
96
+ */
97
+ export interface AddVideoFrameOptions {
98
+ /**
99
+ * The type of the image upload : `ImageUploadType.VIDEO_FRAME`;
100
+ */
101
+ uploadType: ImageUploadType.VIDEO_FRAME;
102
+ /**
103
+ * The picture to add to the inspection.
104
+ */
105
+ picture: MonkPicture;
106
+ /**
107
+ * The ID of the inspection to add the video frame to.
108
+ */
109
+ inspectionId: string;
110
+ /**
111
+ * The index of the frame in the video. This index starts at 0 and increases by 1 for each video frame uploaded.
112
+ */
113
+ frameIndex: number;
114
+ /**
115
+ * The duration (in milliseconds) between this video frame capture time and the previous one. For the first frame of
116
+ * the video, this value is equal to 0.
117
+ */
118
+ timestamp: number;
119
+ }
120
+ /**
121
+ * Union type describing the different options that can be specified when adding a picture to an inspection.
122
+ */
123
+ export type AddImageOptions = AddBeautyShotImageOptions | Add2ShotCloseUpImageOptions | AddVideoFrameOptions;
124
+ /**
125
+ * Type definition for the result of the `addImage` API request.
126
+ */
127
+ export interface AddImageResponse {
128
+ /**
129
+ * The image object that has been created.
130
+ */
131
+ image: Image;
132
+ }
133
+ /**
134
+ * Add a new image to an inspection.
135
+ *
136
+ * @param options Upload options for the image.
137
+ * @param config The API config.
138
+ * @param [dispatch] Optional MonkState dispatch function that you can pass if you want this request to handle React
139
+ * state management for you.
140
+ */
141
+ export declare function addImage(options: AddImageOptions, config: MonkApiConfig, dispatch?: Dispatch<MonkCreatedOneImageAction>): Promise<MonkApiResponse<AddImageResponse, ApiImage>>;