mindee 3.10.2 → 4.0.1

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 (265) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +103 -41
  3. package/package.json +4 -5
  4. package/src/cli.js +96 -70
  5. package/src/client.d.ts +34 -65
  6. package/src/client.js +108 -172
  7. package/src/geometry/boundingBox.d.ts +5 -0
  8. package/src/geometry/boundingBox.js +2 -0
  9. package/src/geometry/boundingBoxUtils.d.ts +22 -0
  10. package/src/geometry/boundingBoxUtils.js +66 -0
  11. package/src/geometry/index.d.ts +6 -0
  12. package/src/geometry/index.js +21 -0
  13. package/src/geometry/minMax.d.ts +4 -0
  14. package/src/geometry/minMax.js +2 -0
  15. package/src/geometry/point.d.ts +2 -0
  16. package/src/geometry/point.js +2 -0
  17. package/src/geometry/polygon.d.ts +4 -0
  18. package/src/geometry/polygon.js +7 -0
  19. package/src/{geometry.d.ts → geometry/polygonUtils.d.ts} +7 -32
  20. package/src/{geometry.js → geometry/polygonUtils.js} +41 -64
  21. package/src/http/endpoint.d.ts +44 -0
  22. package/src/http/endpoint.js +188 -0
  23. package/src/http/error.d.ts +2 -0
  24. package/src/http/error.js +9 -0
  25. package/src/http/index.d.ts +3 -0
  26. package/src/http/index.js +11 -0
  27. package/src/http/mindeeApi.d.ts +20 -0
  28. package/src/http/mindeeApi.js +73 -0
  29. package/src/index.d.ts +4 -4
  30. package/src/index.js +33 -26
  31. package/src/{inputs → input}/base.d.ts +4 -3
  32. package/src/{inputs → input}/base.js +9 -7
  33. package/src/{inputs → input}/index.d.ts +1 -1
  34. package/src/{inputs → input}/index.js +1 -2
  35. package/src/{inputs → input}/sources.d.ts +10 -11
  36. package/src/{inputs → input}/sources.js +9 -9
  37. package/src/parsing/common/apiRequest.d.ts +10 -0
  38. package/src/parsing/common/apiRequest.js +13 -0
  39. package/src/parsing/common/apiResponse.d.ts +6 -0
  40. package/src/parsing/common/apiResponse.js +10 -0
  41. package/src/parsing/common/asyncPredictResponse.d.ts +21 -0
  42. package/src/parsing/common/asyncPredictResponse.js +39 -0
  43. package/src/parsing/common/document.d.ts +13 -0
  44. package/src/parsing/common/document.js +34 -0
  45. package/src/parsing/common/extras/cropperExtra.d.ts +8 -0
  46. package/src/parsing/common/extras/cropperExtra.js +26 -0
  47. package/src/parsing/common/extras/extras.d.ts +11 -0
  48. package/src/parsing/common/extras/extras.js +18 -0
  49. package/src/parsing/common/index.d.ts +9 -0
  50. package/src/parsing/common/index.js +20 -0
  51. package/src/parsing/common/inference.d.ts +26 -0
  52. package/src/parsing/common/inference.js +56 -0
  53. package/src/parsing/common/mvisionV1.d.ts +8 -0
  54. package/src/parsing/common/mvisionV1.js +17 -0
  55. package/src/parsing/common/ocr.d.ts +8 -0
  56. package/src/parsing/common/ocr.js +13 -0
  57. package/src/parsing/common/ocrPage.d.ts +16 -0
  58. package/src/parsing/common/ocrPage.js +66 -0
  59. package/src/{fields → parsing/common}/orientation.d.ts +2 -2
  60. package/src/{fields → parsing/common}/orientation.js +4 -4
  61. package/src/parsing/common/page.d.ts +12 -0
  62. package/src/parsing/common/page.js +40 -0
  63. package/src/parsing/common/predictResponse.d.ts +6 -0
  64. package/src/parsing/common/predictResponse.js +12 -0
  65. package/src/parsing/common/prediction.d.ts +2 -0
  66. package/src/parsing/common/prediction.js +6 -0
  67. package/src/parsing/common/product.d.ts +4 -0
  68. package/src/parsing/common/product.js +2 -0
  69. package/src/parsing/common/stringDict.d.ts +3 -0
  70. package/src/parsing/common/stringDict.js +2 -0
  71. package/src/parsing/common/summaryHelper.d.ts +8 -0
  72. package/src/parsing/common/summaryHelper.js +22 -0
  73. package/src/parsing/custom/classificationField.d.ts +16 -0
  74. package/src/parsing/custom/classificationField.js +14 -0
  75. package/src/parsing/custom/index.d.ts +3 -0
  76. package/src/parsing/custom/index.js +12 -0
  77. package/src/{documents/custom/lineitems.d.ts → parsing/custom/lineItems.d.ts} +4 -4
  78. package/src/{documents/custom/lineitems.js → parsing/custom/lineItems.js} +11 -9
  79. package/src/{documents/custom/fields.d.ts → parsing/custom/listField.d.ts} +3 -16
  80. package/src/{documents/custom/fields.js → parsing/custom/listField.js} +4 -14
  81. package/src/parsing/index.d.ts +3 -0
  82. package/src/parsing/index.js +29 -0
  83. package/src/{fields → parsing/standard}/amount.d.ts +2 -2
  84. package/src/{fields → parsing/standard}/amount.js +5 -5
  85. package/src/{fields → parsing/standard}/base.d.ts +5 -5
  86. package/src/{fields → parsing/standard}/base.js +3 -2
  87. package/src/{fields → parsing/standard}/classification.d.ts +1 -1
  88. package/src/{fields → parsing/standard}/classification.js +3 -3
  89. package/src/{fields → parsing/standard}/companyRegistration.d.ts +1 -1
  90. package/src/parsing/standard/companyRegistration.js +14 -0
  91. package/src/{fields → parsing/standard}/date.d.ts +1 -1
  92. package/src/{fields → parsing/standard}/date.js +2 -2
  93. package/src/{fields → parsing/standard}/field.d.ts +3 -4
  94. package/src/{fields → parsing/standard}/field.js +6 -7
  95. package/src/parsing/standard/index.d.ts +12 -0
  96. package/src/parsing/standard/index.js +27 -0
  97. package/src/{fields → parsing/standard}/locale.d.ts +4 -4
  98. package/src/parsing/standard/locale.js +42 -0
  99. package/src/{fields → parsing/standard}/paymentDetails.d.ts +3 -3
  100. package/src/{fields → parsing/standard}/paymentDetails.js +11 -11
  101. package/src/{fields → parsing/standard}/position.d.ts +2 -2
  102. package/src/{fields → parsing/standard}/position.js +5 -5
  103. package/src/{fields → parsing/standard}/tax.d.ts +3 -3
  104. package/src/{fields → parsing/standard}/tax.js +3 -3
  105. package/src/{fields → parsing/standard}/text.d.ts +2 -2
  106. package/src/{fields → parsing/standard}/text.js +4 -4
  107. package/src/parsing/standard/word.d.ts +10 -0
  108. package/src/parsing/standard/word.js +2 -0
  109. package/src/pdf/pdfOperation.d.ts +1 -1
  110. package/src/pdf/pdfOperation.js +3 -3
  111. package/src/product/cropper/cropperV1.d.ts +9 -0
  112. package/src/product/cropper/cropperV1.js +16 -0
  113. package/src/product/cropper/cropperV1Document.d.ts +8 -0
  114. package/src/product/cropper/cropperV1Document.js +26 -0
  115. package/src/product/custom/customV1.d.ts +10 -0
  116. package/src/product/custom/customV1.js +17 -0
  117. package/src/product/custom/customV1Document.d.ts +9 -0
  118. package/src/product/custom/customV1Document.js +43 -0
  119. package/src/product/custom/customV1Page.d.ts +7 -0
  120. package/src/product/custom/customV1Page.js +24 -0
  121. package/src/product/eu/licensePlate/licensePlateV1.d.ts +9 -0
  122. package/src/product/eu/licensePlate/licensePlateV1.js +16 -0
  123. package/src/product/eu/licensePlate/licensePlateV1Document.d.ts +11 -0
  124. package/src/product/eu/licensePlate/licensePlateV1Document.js +25 -0
  125. package/src/product/financialDocument/financialDocumentV1.d.ts +9 -0
  126. package/src/product/financialDocument/financialDocumentV1.js +16 -0
  127. package/src/{documents/financialDocument/financialDocumentV1.d.ts → product/financialDocument/financialDocumentV1Document.d.ts} +43 -44
  128. package/src/product/financialDocument/financialDocumentV1Document.js +158 -0
  129. package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.d.ts +8 -8
  130. package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.js +35 -34
  131. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +9 -0
  132. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +16 -0
  133. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +15 -0
  134. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +31 -0
  135. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +9 -0
  136. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +16 -0
  137. package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +5 -5
  138. package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +1 -1
  139. package/src/{documents/fr/bankAccountDetails/bankAccountDetailsV2.d.ts → product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts} +7 -7
  140. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +37 -0
  141. package/src/product/fr/carteVitale/carteVitaleV1.d.ts +9 -0
  142. package/src/product/fr/carteVitale/carteVitaleV1.js +16 -0
  143. package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +17 -0
  144. package/src/product/fr/carteVitale/carteVitaleV1Document.js +40 -0
  145. package/src/product/fr/idCard/idCardV1.d.ts +10 -0
  146. package/src/product/fr/idCard/idCardV1.js +17 -0
  147. package/src/product/fr/idCard/idCardV1Document.d.ts +29 -0
  148. package/src/product/fr/idCard/idCardV1Document.js +70 -0
  149. package/src/product/fr/idCard/idCardV1Page.d.ts +12 -0
  150. package/src/product/fr/idCard/idCardV1Page.js +23 -0
  151. package/src/{documents → product}/index.d.ts +2 -7
  152. package/src/{documents → product}/index.js +3 -14
  153. package/src/product/invoice/invoiceV4.d.ts +9 -0
  154. package/src/product/invoice/invoiceV4.js +16 -0
  155. package/src/product/invoice/invoiceV4Document.d.ts +44 -0
  156. package/src/product/invoice/invoiceV4Document.js +146 -0
  157. package/src/{documents/invoice/invoiceLineItem.d.ts → product/invoice/invoiceV4LineItem.d.ts} +10 -8
  158. package/src/product/invoice/invoiceV4LineItem.js +101 -0
  159. package/src/product/invoiceSplitter/invoiceSplitterV1.d.ts +9 -0
  160. package/src/product/invoiceSplitter/invoiceSplitterV1.js +16 -0
  161. package/src/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +8 -0
  162. package/src/product/invoiceSplitter/invoiceSplitterV1Document.js +23 -0
  163. package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.d.ts +7 -0
  164. package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.js +14 -0
  165. package/src/product/passport/passportV1.d.ts +9 -0
  166. package/src/product/passport/passportV1.js +16 -0
  167. package/src/product/passport/passportV1Document.d.ts +31 -0
  168. package/src/product/passport/passportV1Document.js +75 -0
  169. package/src/product/proofOfAddress/proofOfAddressV1.d.ts +9 -0
  170. package/src/product/proofOfAddress/proofOfAddressV1.js +16 -0
  171. package/src/product/proofOfAddress/proofOfAddressV1Document.d.ts +27 -0
  172. package/src/product/proofOfAddress/proofOfAddressV1Document.js +72 -0
  173. package/src/product/receipt/receiptV4.d.ts +9 -0
  174. package/src/product/receipt/receiptV4.js +15 -0
  175. package/src/{documents/receipt/receiptV4.d.ts → product/receipt/receiptV4Document.d.ts} +12 -12
  176. package/src/product/receipt/receiptV4Document.js +67 -0
  177. package/src/product/receipt/receiptV5.d.ts +9 -0
  178. package/src/product/receipt/receiptV5.js +16 -0
  179. package/src/{documents/receipt/receiptV5.d.ts → product/receipt/receiptV5Document.d.ts} +16 -17
  180. package/src/product/receipt/receiptV5Document.js +108 -0
  181. package/src/{documents → product}/receipt/receiptV5LineItem.d.ts +5 -5
  182. package/src/{documents → product}/receipt/receiptV5LineItem.js +20 -19
  183. package/src/product/us/bankCheck/bankCheckV1.d.ts +10 -0
  184. package/src/product/us/bankCheck/bankCheckV1.js +17 -0
  185. package/src/product/us/bankCheck/bankCheckV1Document.d.ts +21 -0
  186. package/src/product/us/bankCheck/bankCheckV1Document.js +50 -0
  187. package/src/product/us/bankCheck/bankCheckV1Page.d.ts +14 -0
  188. package/src/product/us/bankCheck/bankCheckV1Page.js +32 -0
  189. package/src/product/us/driverLicense/driverLicenseV1.d.ts +10 -0
  190. package/src/product/us/driverLicense/driverLicenseV1.js +17 -0
  191. package/src/product/us/driverLicense/driverLicenseV1Document.d.ts +43 -0
  192. package/src/product/us/driverLicense/driverLicenseV1Document.js +101 -0
  193. package/src/product/us/driverLicense/driverLicenseV1Page.d.ts +14 -0
  194. package/src/product/us/driverLicense/driverLicenseV1Page.js +29 -0
  195. package/src/product/us/index.d.ts +2 -0
  196. package/src/product/us/index.js +7 -0
  197. package/src/api/documentResponse.d.ts +0 -25
  198. package/src/api/documentResponse.js +0 -50
  199. package/src/api/endpoint.d.ts +0 -63
  200. package/src/api/endpoint.js +0 -216
  201. package/src/api/index.d.ts +0 -3
  202. package/src/api/index.js +0 -13
  203. package/src/api/predictResponse.d.ts +0 -33
  204. package/src/api/predictResponse.js +0 -52
  205. package/src/documents/cropper/cropperV1.d.ts +0 -7
  206. package/src/documents/cropper/cropperV1.js +0 -35
  207. package/src/documents/custom/customV1.d.ts +0 -10
  208. package/src/documents/custom/customV1.js +0 -53
  209. package/src/documents/document.d.ts +0 -47
  210. package/src/documents/document.js +0 -76
  211. package/src/documents/documentConfig.d.ts +0 -42
  212. package/src/documents/documentConfig.js +0 -118
  213. package/src/documents/eu/licensePlate/licensePlateV1.d.ts +0 -8
  214. package/src/documents/eu/licensePlate/licensePlateV1.js +0 -32
  215. package/src/documents/financialDocument/financialDocumentV0.d.ts +0 -28
  216. package/src/documents/financialDocument/financialDocumentV0.js +0 -140
  217. package/src/documents/financialDocument/financialDocumentV1.js +0 -197
  218. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +0 -13
  219. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +0 -39
  220. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.js +0 -48
  221. package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +0 -14
  222. package/src/documents/fr/carteVitale/carteVitaleV1.js +0 -45
  223. package/src/documents/fr/idCard/idCardV1.d.ts +0 -28
  224. package/src/documents/fr/idCard/idCardV1.js +0 -79
  225. package/src/documents/invoice/checks.d.ts +0 -5
  226. package/src/documents/invoice/checks.js +0 -87
  227. package/src/documents/invoice/invoiceLineItem.js +0 -66
  228. package/src/documents/invoice/invoiceV3.d.ts +0 -49
  229. package/src/documents/invoice/invoiceV3.js +0 -156
  230. package/src/documents/invoice/invoiceV4.d.ts +0 -45
  231. package/src/documents/invoice/invoiceV4.js +0 -166
  232. package/src/documents/invoice/reconstruction.d.ts +0 -6
  233. package/src/documents/invoice/reconstruction.js +0 -78
  234. package/src/documents/invoiceSplitter/invoiceSplitterV1.d.ts +0 -14
  235. package/src/documents/invoiceSplitter/invoiceSplitterV1.js +0 -47
  236. package/src/documents/mindeeVision/mindeeVisionV1.d.ts +0 -8
  237. package/src/documents/mindeeVision/mindeeVisionV1.js +0 -29
  238. package/src/documents/passport/passportV1.d.ts +0 -43
  239. package/src/documents/passport/passportV1.js +0 -220
  240. package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +0 -24
  241. package/src/documents/proofOfAddress/proofOfAddressV1.js +0 -77
  242. package/src/documents/receipt/receiptV3.d.ts +0 -25
  243. package/src/documents/receipt/receiptV3.js +0 -136
  244. package/src/documents/receipt/receiptV4.js +0 -78
  245. package/src/documents/receipt/receiptV5.js +0 -137
  246. package/src/documents/us/bankCheck/bankCheckV1.d.ts +0 -22
  247. package/src/documents/us/bankCheck/bankCheckV1.js +0 -63
  248. package/src/documents/us/index.d.ts +0 -1
  249. package/src/documents/us/index.js +0 -5
  250. package/src/fields/companyRegistration.js +0 -14
  251. package/src/fields/fullText.d.ts +0 -27
  252. package/src/fields/fullText.js +0 -92
  253. package/src/fields/index.d.ts +0 -12
  254. package/src/fields/index.js +0 -28
  255. package/src/fields/locale.js +0 -45
  256. package/src/math/index.d.ts +0 -1
  257. package/src/math/index.js +0 -5
  258. package/src/math/precision.d.ts +0 -1
  259. package/src/math/precision.js +0 -13
  260. /package/src/{inputs → input}/pageOptions.d.ts +0 -0
  261. /package/src/{inputs → input}/pageOptions.js +0 -0
  262. /package/src/{documents → product}/eu/index.d.ts +0 -0
  263. /package/src/{documents → product}/eu/index.js +0 -0
  264. /package/src/{documents → product}/fr/index.d.ts +0 -0
  265. /package/src/{documents → product}/fr/index.js +0 -0
@@ -0,0 +1,4 @@
1
+ export type MinMax = {
2
+ min: number;
3
+ max: number;
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ /** A point on the document defined by 2 coordinates: X, Y */
2
+ export type Point = [number, number];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { Point } from "./point";
2
+ /** A polygon, composed of several Points. */
3
+ export declare class Polygon extends Array<Point> {
4
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Polygon = void 0;
4
+ /** A polygon, composed of several Points. */
5
+ class Polygon extends Array {
6
+ }
7
+ exports.Polygon = Polygon;
@@ -1,35 +1,6 @@
1
- export type MinMax = {
2
- min: number;
3
- max: number;
4
- };
5
- /** A point on the document defined by 2 coordinates: X, Y */
6
- export type Point = [number, number];
7
- /** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
8
- export type BBox = [number, number, number, number];
9
- /** A bounding box defined by 4 points. */
10
- export type BoundingBox = [Point, Point, Point, Point];
11
- /** A polygon, composed of several Points. */
12
- export type Polygon = Array<Point>;
13
- /**
14
- * Given a Polygon, calculate a polygon that encompasses all points.
15
- */
16
- export declare function getBoundingBox(polygon: Polygon): BoundingBox;
17
- /**
18
- * Given a BBox, generate the associated bounding box.
19
- */
20
- export declare function getBoundingBoxFromBBox(bbox: BBox): BoundingBox;
21
- /**
22
- * Given 2 bbox, merge them.
23
- */
24
- export declare function mergeBbox(bbox1: BBox, bbox2: BBox): BBox;
25
- /**
26
- * Given a Polygon, calculate a bounding box that encompasses all points.
27
- */
28
- export declare function getBbox(polygon: Polygon): BBox;
29
- /**
30
- * Given polygons, calculate a bounding box that encompasses all points.
31
- */
32
- export declare function getBBoxForPolygons(polygons: Polygon[]): BBox;
1
+ import { MinMax } from "./minMax";
2
+ import { Point } from "./point";
3
+ import { Polygon } from "./polygon";
33
4
  /**
34
5
  * Get the central point (centroid) given a list of points.
35
6
  */
@@ -70,3 +41,7 @@ export declare function isPointInPolygonX(centroid: Point, polygon: Polygon): bo
70
41
  * Can be used to order (sort) words in the same line.
71
42
  */
72
43
  export declare function relativeX(polygon: Polygon): number;
44
+ export declare function getMinYCoordinate(polygon: Polygon): number;
45
+ export declare function getMinXCoordinate(polygon: Polygon): number;
46
+ export declare function compareOnY(polygon1: Polygon, polygon2: Polygon): number;
47
+ export declare function compareOnX(polygon1: Polygon, polygon2: Polygon): number;
@@ -1,69 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.relativeX = exports.isPointInPolygonX = exports.getMinMaxX = exports.isPointInX = exports.relativeY = exports.isPointInPolygonY = exports.getMinMaxY = exports.isPointInY = exports.getCentroid = exports.getBBoxForPolygons = exports.getBbox = exports.mergeBbox = exports.getBoundingBoxFromBBox = exports.getBoundingBox = void 0;
4
- /**
5
- * Given a Polygon, calculate a polygon that encompasses all points.
6
- */
7
- function getBoundingBox(polygon) {
8
- const bbox = getBbox(polygon);
9
- return [
10
- [bbox[0], bbox[1]],
11
- [bbox[2], bbox[1]],
12
- [bbox[2], bbox[3]],
13
- [bbox[0], bbox[3]],
14
- ];
15
- }
16
- exports.getBoundingBox = getBoundingBox;
17
- /**
18
- * Given a BBox, generate the associated bounding box.
19
- */
20
- function getBoundingBoxFromBBox(bbox) {
21
- return [
22
- [bbox[0], bbox[1]],
23
- [bbox[2], bbox[1]],
24
- [bbox[2], bbox[3]],
25
- [bbox[0], bbox[3]],
26
- ];
27
- }
28
- exports.getBoundingBoxFromBBox = getBoundingBoxFromBBox;
29
- /**
30
- * Given 2 bbox, merge them.
31
- */
32
- function mergeBbox(bbox1, bbox2) {
33
- return [
34
- Math.min(bbox1[0], bbox2[0]),
35
- Math.min(bbox1[1], bbox2[1]),
36
- Math.max(bbox1[2], bbox2[2]),
37
- Math.max(bbox1[3], bbox2[3]),
38
- ];
39
- }
40
- exports.mergeBbox = mergeBbox;
41
- /**
42
- * Given a Polygon, calculate a bounding box that encompasses all points.
43
- */
44
- function getBbox(polygon) {
45
- const allY = polygon.map((point) => point[1]);
46
- const allX = polygon.map((point) => point[0]);
47
- const yMin = Math.min(...allY);
48
- const yMax = Math.max(...allY);
49
- const xMin = Math.min(...allX);
50
- const xMax = Math.max(...allX);
51
- return [xMin, yMin, xMax, yMax];
52
- }
53
- exports.getBbox = getBbox;
54
- /**
55
- * Given polygons, calculate a bounding box that encompasses all points.
56
- */
57
- function getBBoxForPolygons(polygons) {
58
- const allY = polygons.flatMap((polygon) => polygon.map((point) => point[1]));
59
- const allX = polygons.flatMap((polygon) => polygon.map((point) => point[0]));
60
- const yMin = Math.min(...allY);
61
- const yMax = Math.max(...allY);
62
- const xMin = Math.min(...allX);
63
- const xMax = Math.max(...allX);
64
- return [xMin, yMin, xMax, yMax];
65
- }
66
- exports.getBBoxForPolygons = getBBoxForPolygons;
3
+ exports.compareOnX = exports.compareOnY = exports.getMinXCoordinate = exports.getMinYCoordinate = exports.relativeX = exports.isPointInPolygonX = exports.getMinMaxX = exports.isPointInX = exports.relativeY = exports.isPointInPolygonY = exports.getMinMaxY = exports.isPointInY = exports.getCentroid = void 0;
67
4
  /**
68
5
  * Get the central point (centroid) given a list of points.
69
6
  */
@@ -148,3 +85,43 @@ function relativeX(polygon) {
148
85
  return polygon.length * sum;
149
86
  }
150
87
  exports.relativeX = relativeX;
88
+ function getMinYCoordinate(polygon) {
89
+ return polygon.sort((point1, point2) => {
90
+ if (point1[1] < point2[1]) {
91
+ return -1;
92
+ }
93
+ else if (point1[1] > point2[1]) {
94
+ return 1;
95
+ }
96
+ return 0;
97
+ })[0][1];
98
+ }
99
+ exports.getMinYCoordinate = getMinYCoordinate;
100
+ function getMinXCoordinate(polygon) {
101
+ return polygon.sort((point1, point2) => {
102
+ if (point1[0] < point2[0]) {
103
+ return -1;
104
+ }
105
+ else if (point1[0] > point2[0]) {
106
+ return 1;
107
+ }
108
+ return 0;
109
+ })[0][0];
110
+ }
111
+ exports.getMinXCoordinate = getMinXCoordinate;
112
+ function compareOnY(polygon1, polygon2) {
113
+ const sort = getMinYCoordinate(polygon1) - getMinYCoordinate(polygon2);
114
+ if (sort === 0) {
115
+ return 0;
116
+ }
117
+ return sort < 0 ? -1 : 1;
118
+ }
119
+ exports.compareOnY = compareOnY;
120
+ function compareOnX(polygon1, polygon2) {
121
+ const sort = getMinXCoordinate(polygon1) - getMinXCoordinate(polygon2);
122
+ if (sort === 0) {
123
+ return 0;
124
+ }
125
+ return sort < 0 ? -1 : 1;
126
+ }
127
+ exports.compareOnX = compareOnX;
@@ -0,0 +1,44 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { RequestOptions } from "https";
4
+ import { InputSource } from "../input";
5
+ import { IncomingMessage, ClientRequest } from "http";
6
+ import { PageOptions } from "../input";
7
+ import { MindeeApi } from "./mindeeApi";
8
+ export interface EndpointResponse {
9
+ messageObj: IncomingMessage;
10
+ data: {
11
+ [key: string]: any;
12
+ };
13
+ }
14
+ export declare class Endpoint {
15
+ #private;
16
+ urlName: string;
17
+ owner: string;
18
+ version: string;
19
+ urlRoot: string;
20
+ settings: MindeeApi;
21
+ constructor(urlName: string, owner: string, version: string, settings: MindeeApi);
22
+ predict(params: {
23
+ inputDoc: InputSource;
24
+ includeWords: boolean;
25
+ pageOptions?: PageOptions;
26
+ cropper: boolean;
27
+ }): Promise<EndpointResponse>;
28
+ predictAsync(params: {
29
+ inputDoc: InputSource;
30
+ includeWords: boolean;
31
+ pageOptions?: PageOptions;
32
+ cropper: boolean;
33
+ }): Promise<EndpointResponse>;
34
+ getQueuedDocument(queueId: string): Promise<EndpointResponse>;
35
+ /**
36
+ * Send a file to a prediction API.
37
+ * @param input
38
+ * @param predictUrl
39
+ * @param includeWords
40
+ * @param cropper
41
+ */
42
+ protected sendFileForPrediction(input: InputSource, predictUrl: string, includeWords?: boolean, cropper?: boolean): Promise<EndpointResponse>;
43
+ protected readResponse(options: RequestOptions, resolve: (value: EndpointResponse | PromiseLike<EndpointResponse>) => void, reject: (reason?: any) => void): ClientRequest;
44
+ }
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ var _Endpoint_instances, _Endpoint_cutDocPages, _Endpoint_predictReqPost, _Endpoint_predictAsyncReqPost, _Endpoint_documentQueueReqGet, _Endpoint_documentGetReq;
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Endpoint = void 0;
13
+ const https_1 = require("https");
14
+ const url_1 = require("url");
15
+ const form_data_1 = __importDefault(require("form-data"));
16
+ const logger_1 = require("../logger");
17
+ const base_1 = require("../input/base");
18
+ const error_1 = require("./error");
19
+ class Endpoint {
20
+ constructor(urlName, owner, version, settings) {
21
+ _Endpoint_instances.add(this);
22
+ this.owner = owner;
23
+ this.urlName = urlName;
24
+ this.version = version;
25
+ this.settings = settings;
26
+ this.urlRoot = `/v1/products/${owner}/${urlName}/v${version}`;
27
+ }
28
+ async predict(params) {
29
+ await params.inputDoc.init();
30
+ if (params.pageOptions !== undefined) {
31
+ await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_cutDocPages).call(this, params.inputDoc, params.pageOptions);
32
+ }
33
+ const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_predictReqPost).call(this, params.inputDoc, params.includeWords, params.cropper);
34
+ const statusCode = response.messageObj.statusCode;
35
+ if (statusCode === undefined || statusCode > 400) {
36
+ (0, error_1.handleError)(this.urlName, response, statusCode);
37
+ }
38
+ return response;
39
+ }
40
+ async predictAsync(params) {
41
+ await params.inputDoc.init();
42
+ if (params.pageOptions !== undefined) {
43
+ await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_cutDocPages).call(this, params.inputDoc, params.pageOptions);
44
+ }
45
+ const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_predictAsyncReqPost).call(this, params.inputDoc, params.includeWords, params.cropper);
46
+ const statusCode = response.messageObj.statusCode;
47
+ if (statusCode === undefined || statusCode > 400) {
48
+ (0, error_1.handleError)(this.urlName, response, statusCode);
49
+ }
50
+ return response;
51
+ }
52
+ async getQueuedDocument(queueId) {
53
+ const queueResponse = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_documentQueueReqGet).call(this, queueId);
54
+ const queueStatusCode = queueResponse.messageObj.statusCode;
55
+ if (queueStatusCode === undefined ||
56
+ queueStatusCode < 200 ||
57
+ queueStatusCode > 400) {
58
+ (0, error_1.handleError)(this.urlName, queueResponse, queueStatusCode);
59
+ }
60
+ if (queueStatusCode === 302 &&
61
+ queueResponse.messageObj.headers.location !== undefined) {
62
+ const docId = queueResponse.messageObj.headers.location.split("/").pop();
63
+ if (docId !== undefined) {
64
+ return await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_documentGetReq).call(this, docId);
65
+ }
66
+ }
67
+ return queueResponse;
68
+ }
69
+ /**
70
+ * Send a file to a prediction API.
71
+ * @param input
72
+ * @param predictUrl
73
+ * @param includeWords
74
+ * @param cropper
75
+ */
76
+ sendFileForPrediction(input, predictUrl, includeWords = false, cropper = false) {
77
+ return new Promise((resolve, reject) => {
78
+ const searchParams = new url_1.URLSearchParams();
79
+ if (cropper) {
80
+ searchParams.append("cropper", "true");
81
+ }
82
+ const form = new form_data_1.default();
83
+ if (input instanceof base_1.LocalInputSource) {
84
+ if (input.fileObject instanceof Buffer) {
85
+ form.append("document", input.fileObject, {
86
+ filename: input.filename,
87
+ });
88
+ }
89
+ else {
90
+ form.append("document", input.fileObject);
91
+ }
92
+ }
93
+ if (includeWords) {
94
+ form.append("include_mvision", "true");
95
+ }
96
+ const headers = { ...this.settings.baseHeaders, ...form.getHeaders() };
97
+ let path = `${this.urlRoot}/${predictUrl}`;
98
+ if (searchParams.keys.length > 0) {
99
+ path += `?${searchParams}`;
100
+ }
101
+ const options = {
102
+ method: "POST",
103
+ headers: headers,
104
+ hostname: this.settings.hostname,
105
+ path: path,
106
+ };
107
+ const req = this.readResponse(options, resolve, reject);
108
+ form.pipe(req);
109
+ // potential ECONNRESET if we don't end the request.
110
+ req.end();
111
+ });
112
+ }
113
+ readResponse(options, resolve, reject) {
114
+ logger_1.logger.debug(`${options.method}: https://${options.hostname}${options.path}`);
115
+ const req = (0, https_1.request)(options, function (res) {
116
+ // when the encoding is set, data chunks will be strings
117
+ res.setEncoding("utf-8");
118
+ let responseBody = "";
119
+ res.on("data", function (chunk) {
120
+ logger_1.logger.debug("Receiving data ...");
121
+ responseBody += chunk;
122
+ });
123
+ res.on("end", function () {
124
+ logger_1.logger.debug("Parsing the response ...");
125
+ // handle empty responses from server, for example in the case of redirects
126
+ if (!responseBody) {
127
+ responseBody = "{}";
128
+ }
129
+ try {
130
+ const parsedResponse = JSON.parse(responseBody);
131
+ try {
132
+ resolve({
133
+ messageObj: res,
134
+ data: parsedResponse,
135
+ });
136
+ }
137
+ catch (error) {
138
+ logger_1.logger.error("Could not construct the return object.");
139
+ reject(error);
140
+ }
141
+ }
142
+ catch (error) {
143
+ logger_1.logger.error("Could not parse the return as JSON.");
144
+ logger_1.logger.debug(responseBody);
145
+ reject(error);
146
+ }
147
+ });
148
+ });
149
+ req.on("error", (err) => {
150
+ reject(err);
151
+ });
152
+ return req;
153
+ }
154
+ }
155
+ exports.Endpoint = Endpoint;
156
+ _Endpoint_instances = new WeakSet(), _Endpoint_cutDocPages = async function _Endpoint_cutDocPages(inputDoc, pageOptions) {
157
+ if (inputDoc instanceof base_1.LocalInputSource && inputDoc.isPdf()) {
158
+ await inputDoc.cutPdf(pageOptions);
159
+ }
160
+ }, _Endpoint_predictReqPost = function _Endpoint_predictReqPost(input, includeWords = false, cropper = false) {
161
+ return this.sendFileForPrediction(input, "predict", includeWords, cropper);
162
+ }, _Endpoint_predictAsyncReqPost = function _Endpoint_predictAsyncReqPost(input, includeWords = false, cropper = false) {
163
+ return this.sendFileForPrediction(input, "predict_async", includeWords, cropper);
164
+ }, _Endpoint_documentQueueReqGet = function _Endpoint_documentQueueReqGet(queueId) {
165
+ return new Promise((resolve, reject) => {
166
+ const options = {
167
+ method: "GET",
168
+ headers: this.settings.baseHeaders,
169
+ hostname: this.settings.hostname,
170
+ path: `${this.urlRoot}/documents/queue/${queueId}`,
171
+ };
172
+ const req = this.readResponse(options, resolve, reject);
173
+ // potential ECONNRESET if we don't end the request.
174
+ req.end();
175
+ });
176
+ }, _Endpoint_documentGetReq = function _Endpoint_documentGetReq(documentId) {
177
+ return new Promise((resolve, reject) => {
178
+ const options = {
179
+ method: "GET",
180
+ headers: this.settings.baseHeaders,
181
+ hostname: this.settings.hostname,
182
+ path: `${this.urlRoot}/documents/${documentId}`,
183
+ };
184
+ const req = this.readResponse(options, resolve, reject);
185
+ // potential ECONNRESET if we don't end the request.
186
+ req.end();
187
+ });
188
+ };
@@ -0,0 +1,2 @@
1
+ import { EndpointResponse } from "./endpoint";
2
+ export declare function handleError(url: string, response: EndpointResponse, statusCode?: number): void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleError = void 0;
4
+ const handler_1 = require("../errors/handler");
5
+ function handleError(url, response, statusCode) {
6
+ const errorMessage = JSON.stringify(response.data, null, 2);
7
+ handler_1.errorHandler.throw(new Error(`${url} API ${statusCode} HTTP error: ${errorMessage}`));
8
+ }
9
+ exports.handleError = handleError;
@@ -0,0 +1,3 @@
1
+ export { Endpoint, EndpointResponse } from "./endpoint";
2
+ export { STANDARD_API_OWNER, API_KEY_ENVVAR_NAME, MindeeApi, } from "./mindeeApi";
3
+ export { handleError } from "./error";
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleError = exports.MindeeApi = exports.API_KEY_ENVVAR_NAME = exports.STANDARD_API_OWNER = exports.Endpoint = void 0;
4
+ var endpoint_1 = require("./endpoint");
5
+ Object.defineProperty(exports, "Endpoint", { enumerable: true, get: function () { return endpoint_1.Endpoint; } });
6
+ var mindeeApi_1 = require("./mindeeApi");
7
+ Object.defineProperty(exports, "STANDARD_API_OWNER", { enumerable: true, get: function () { return mindeeApi_1.STANDARD_API_OWNER; } });
8
+ Object.defineProperty(exports, "API_KEY_ENVVAR_NAME", { enumerable: true, get: function () { return mindeeApi_1.API_KEY_ENVVAR_NAME; } });
9
+ Object.defineProperty(exports, "MindeeApi", { enumerable: true, get: function () { return mindeeApi_1.MindeeApi; } });
10
+ var error_1 = require("./error");
11
+ Object.defineProperty(exports, "handleError", { enumerable: true, get: function () { return error_1.handleError; } });
@@ -0,0 +1,20 @@
1
+ export declare const API_KEY_ENVVAR_NAME = "MINDEE_API_KEY";
2
+ export declare const API_HOST_ENVVAR_NAME = "MINDEE_API_HOST";
3
+ export declare const STANDARD_API_OWNER = "mindee";
4
+ interface MindeeApiConstructorProps {
5
+ apiKey: string;
6
+ urlName: string;
7
+ version: string;
8
+ owner: string;
9
+ }
10
+ export declare class MindeeApi {
11
+ apiKey: string;
12
+ baseHeaders: Record<string, string>;
13
+ hostname: string;
14
+ private readonly urlName;
15
+ private readonly version;
16
+ constructor({ apiKey, urlName, version, owner, }: MindeeApiConstructorProps);
17
+ protected apiKeyFromEnv(): string;
18
+ protected hostnameFromEnv(): string;
19
+ }
20
+ export {};
@@ -0,0 +1,73 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.MindeeApi = exports.STANDARD_API_OWNER = exports.API_HOST_ENVVAR_NAME = exports.API_KEY_ENVVAR_NAME = void 0;
27
+ const logger_1 = require("../logger");
28
+ const package_json_1 = require("../../package.json");
29
+ const os = __importStar(require("os"));
30
+ exports.API_KEY_ENVVAR_NAME = "MINDEE_API_KEY";
31
+ exports.API_HOST_ENVVAR_NAME = "MINDEE_API_HOST";
32
+ exports.STANDARD_API_OWNER = "mindee";
33
+ const DEFAULT_MINDEE_API_HOST = "api.mindee.net";
34
+ const USER_AGENT = `mindee-api-nodejs@v${package_json_1.version} nodejs-${process.version} ${os.type().toLowerCase()}`;
35
+ class MindeeApi {
36
+ constructor({ apiKey = "", urlName, version, owner, }) {
37
+ if (!apiKey || apiKey.length === 0) {
38
+ if (!process.env[exports.API_KEY_ENVVAR_NAME] ||
39
+ process.env[exports.API_KEY_ENVVAR_NAME].length === 0) {
40
+ throw new Error(`Missing API key for ${urlName} v${version} (belonging to ${owner}) check your Client Configuration.
41
+ You can set this using the ${exports.API_KEY_ENVVAR_NAME} environment variable.`);
42
+ }
43
+ this.apiKey = process.env[exports.API_KEY_ENVVAR_NAME];
44
+ }
45
+ else {
46
+ this.apiKey = apiKey;
47
+ }
48
+ this.baseHeaders = {
49
+ "User-Agent": USER_AGENT,
50
+ Authorization: `Token ${this.apiKey}`,
51
+ };
52
+ this.hostname = this.hostnameFromEnv();
53
+ this.urlName = urlName;
54
+ this.version = version;
55
+ }
56
+ apiKeyFromEnv() {
57
+ const envVarValue = process.env[exports.API_KEY_ENVVAR_NAME];
58
+ if (envVarValue) {
59
+ logger_1.logger.debug(`Set ${this.urlName} v${this.version} API key from environment: ${exports.API_KEY_ENVVAR_NAME}`);
60
+ return envVarValue;
61
+ }
62
+ return "";
63
+ }
64
+ hostnameFromEnv() {
65
+ const envVarValue = process.env[exports.API_HOST_ENVVAR_NAME];
66
+ if (envVarValue) {
67
+ logger_1.logger.debug(`Set the API hostname to ${envVarValue}`);
68
+ return envVarValue;
69
+ }
70
+ return DEFAULT_MINDEE_API_HOST;
71
+ }
72
+ }
73
+ exports.MindeeApi = MindeeApi;
package/src/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { CustomV1, Document, FinancialDocumentV0, FinancialDocumentV1, InvoiceV3, InvoiceV4, InvoiceSplitterV1, PassportV1, ReceiptV3, ReceiptV4, ReceiptV5, CropperV1, MindeeVisionV1, ProofOfAddressV1, fr, us, eu, } from "./documents";
2
- export { Client, ClientOptions, CustomConfigParams, DocumentClient, PredictOptions, } from "./client";
3
- export { ResponseSig, Response, AsyncPredictResponse } from "./api";
4
- export { InputSource, PageOptionsOperation } from "./inputs";
1
+ export * as product from "./product";
2
+ export { Client, CustomConfigParams, PredictOptions } from "./client";
3
+ export { AsyncPredictResponse, PredictResponse, Document, Page, } from "./parsing/common";
4
+ export { InputSource, PageOptionsOperation } from "./input";
package/src/index.js CHANGED
@@ -1,30 +1,37 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PageOptionsOperation = exports.InputSource = exports.AsyncPredictResponse = exports.Response = exports.DocumentClient = exports.Client = exports.eu = exports.us = exports.fr = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.CropperV1 = exports.ReceiptV5 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.Document = exports.CustomV1 = void 0;
4
- var documents_1 = require("./documents");
5
- Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return documents_1.CustomV1; } });
6
- Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return documents_1.Document; } });
7
- Object.defineProperty(exports, "FinancialDocumentV0", { enumerable: true, get: function () { return documents_1.FinancialDocumentV0; } });
8
- Object.defineProperty(exports, "FinancialDocumentV1", { enumerable: true, get: function () { return documents_1.FinancialDocumentV1; } });
9
- Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return documents_1.InvoiceV3; } });
10
- Object.defineProperty(exports, "InvoiceV4", { enumerable: true, get: function () { return documents_1.InvoiceV4; } });
11
- Object.defineProperty(exports, "InvoiceSplitterV1", { enumerable: true, get: function () { return documents_1.InvoiceSplitterV1; } });
12
- Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function () { return documents_1.PassportV1; } });
13
- Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function () { return documents_1.ReceiptV3; } });
14
- Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return documents_1.ReceiptV4; } });
15
- Object.defineProperty(exports, "ReceiptV5", { enumerable: true, get: function () { return documents_1.ReceiptV5; } });
16
- Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return documents_1.CropperV1; } });
17
- Object.defineProperty(exports, "MindeeVisionV1", { enumerable: true, get: function () { return documents_1.MindeeVisionV1; } });
18
- Object.defineProperty(exports, "ProofOfAddressV1", { enumerable: true, get: function () { return documents_1.ProofOfAddressV1; } });
19
- Object.defineProperty(exports, "fr", { enumerable: true, get: function () { return documents_1.fr; } });
20
- Object.defineProperty(exports, "us", { enumerable: true, get: function () { return documents_1.us; } });
21
- Object.defineProperty(exports, "eu", { enumerable: true, get: function () { return documents_1.eu; } });
26
+ exports.PageOptionsOperation = exports.InputSource = exports.Page = exports.Document = exports.PredictResponse = exports.AsyncPredictResponse = exports.Client = exports.product = void 0;
27
+ exports.product = __importStar(require("./product"));
22
28
  var client_1 = require("./client");
23
29
  Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
24
- Object.defineProperty(exports, "DocumentClient", { enumerable: true, get: function () { return client_1.DocumentClient; } });
25
- var api_1 = require("./api");
26
- Object.defineProperty(exports, "Response", { enumerable: true, get: function () { return api_1.Response; } });
27
- Object.defineProperty(exports, "AsyncPredictResponse", { enumerable: true, get: function () { return api_1.AsyncPredictResponse; } });
28
- var inputs_1 = require("./inputs");
29
- Object.defineProperty(exports, "InputSource", { enumerable: true, get: function () { return inputs_1.InputSource; } });
30
- Object.defineProperty(exports, "PageOptionsOperation", { enumerable: true, get: function () { return inputs_1.PageOptionsOperation; } });
30
+ var common_1 = require("./parsing/common");
31
+ Object.defineProperty(exports, "AsyncPredictResponse", { enumerable: true, get: function () { return common_1.AsyncPredictResponse; } });
32
+ Object.defineProperty(exports, "PredictResponse", { enumerable: true, get: function () { return common_1.PredictResponse; } });
33
+ Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return common_1.Document; } });
34
+ Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return common_1.Page; } });
35
+ var input_1 = require("./input");
36
+ Object.defineProperty(exports, "InputSource", { enumerable: true, get: function () { return input_1.InputSource; } });
37
+ Object.defineProperty(exports, "PageOptionsOperation", { enumerable: true, get: function () { return input_1.PageOptionsOperation; } });
@@ -7,9 +7,11 @@ export declare const INPUT_TYPE_STREAM = "stream";
7
7
  export declare const INPUT_TYPE_BASE64 = "base64";
8
8
  export declare const INPUT_TYPE_BYTES = "bytes";
9
9
  export declare const INPUT_TYPE_PATH = "path";
10
- export declare const INPUT_TYPE_URL = "URL";
11
10
  export declare const INPUT_TYPE_BUFFER = "buffer";
12
- export declare class InputSource {
11
+ export declare abstract class InputSource {
12
+ init(): Promise<void>;
13
+ }
14
+ export declare abstract class LocalInputSource extends InputSource {
13
15
  inputType: string;
14
16
  filename: string;
15
17
  filepath?: string;
@@ -22,7 +24,6 @@ export declare class InputSource {
22
24
  * NB: Because of async calls, init() should be called after creating the object
23
25
  */
24
26
  constructor({ inputType }: InputProps);
25
- init(): Promise<void>;
26
27
  isPdf(): boolean;
27
28
  checkMimetype(): Promise<string>;
28
29
  /**