mindee 3.1.1 → 3.3.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 (57) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +4 -4
  3. package/package.json +1 -1
  4. package/src/api/endpoint.d.ts +2 -0
  5. package/src/api/endpoint.js +12 -3
  6. package/src/cli.js +70 -53
  7. package/src/client.d.ts +41 -5
  8. package/src/client.js +20 -4
  9. package/src/documents/cropper/cropperV1.d.ts +2 -2
  10. package/src/documents/cropper/cropperV1.js +1 -1
  11. package/src/documents/document.d.ts +2 -2
  12. package/src/documents/document.js +1 -1
  13. package/src/documents/eu/index.d.ts +1 -0
  14. package/src/documents/eu/index.js +5 -0
  15. package/src/documents/eu/licensePlate/licensePlateV1.d.ts +8 -0
  16. package/src/documents/eu/licensePlate/licensePlateV1.js +29 -0
  17. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +12 -0
  18. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +37 -0
  19. package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +14 -0
  20. package/src/documents/fr/carteVitale/carteVitaleV1.js +44 -0
  21. package/src/documents/fr/idCard/idCardV1.d.ts +11 -0
  22. package/src/documents/fr/idCard/idCardV1.js +1 -0
  23. package/src/documents/fr/index.d.ts +2 -0
  24. package/src/documents/fr/index.js +5 -1
  25. package/src/documents/index.d.ts +3 -0
  26. package/src/documents/index.js +6 -1
  27. package/src/documents/invoice/checks.d.ts +5 -0
  28. package/src/documents/invoice/checks.js +87 -0
  29. package/src/documents/invoice/invoiceLineItem.d.ts +29 -0
  30. package/src/documents/invoice/invoiceLineItem.js +66 -0
  31. package/src/documents/invoice/invoiceV3.d.ts +27 -8
  32. package/src/documents/invoice/invoiceV3.js +33 -159
  33. package/src/documents/invoice/invoiceV4.d.ts +44 -0
  34. package/src/documents/invoice/invoiceV4.js +168 -0
  35. package/src/documents/invoice/reconstruction.d.ts +6 -0
  36. package/src/documents/invoice/reconstruction.js +77 -0
  37. package/src/documents/passport/passportV1.d.ts +13 -0
  38. package/src/documents/passport/passportV1.js +1 -0
  39. package/src/documents/receipt/receiptV3.d.ts +9 -1
  40. package/src/documents/receipt/receiptV3.js +1 -0
  41. package/src/documents/shipping_container/shippingContainerV1.d.ts +12 -0
  42. package/src/documents/shipping_container/shippingContainerV1.js +37 -0
  43. package/src/documents/us/bankCheck/bankCheckV1.d.ts +20 -1
  44. package/src/documents/us/bankCheck/bankCheckV1.js +57 -0
  45. package/src/fields/amount.d.ts +1 -0
  46. package/src/fields/apiBuilder.d.ts +1 -0
  47. package/src/fields/companyRegistration.d.ts +1 -1
  48. package/src/fields/field.d.ts +1 -0
  49. package/src/fields/field.js +1 -0
  50. package/src/fields/index.d.ts +1 -1
  51. package/src/fields/index.js +3 -3
  52. package/src/fields/locale.d.ts +3 -0
  53. package/src/fields/paymentDetails.d.ts +4 -0
  54. package/src/fields/{cropper.d.ts → position.d.ts} +8 -3
  55. package/src/fields/{cropper.js → position.js} +4 -6
  56. package/src/index.d.ts +1 -1
  57. package/src/index.js +4 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v3.3.0 - 2022-12-01
4
+ ### Changes
5
+ * :sparkles: Add Invoice V4 with line items
6
+ * :sparkles: An env variable can be used to change the Mindee base API url
7
+
8
+ ## v3.2.0 - 2022-11-14
9
+ ### Changes
10
+ * :sparkles: Add support for shipping container API V1
11
+ * :sparkles: Add support for EU license plate V1
12
+ * :bug: Fix page removal in CLI
13
+ * :sparkles: Add support for Carte Vitale V1
14
+ * :sparkles: Add support for FR Bank Account Details V1
15
+ * :memo: Export and add comments for method parameters.
16
+ * :sparkles: Add support for US Bank Check V1
17
+
3
18
  ## v3.1.1 - 2022-11-08
4
19
  ### Changes
5
20
  * :bug: fix proper import and documentation of region-specific documents
package/README.md CHANGED
@@ -66,11 +66,11 @@ const apiResponse = mindeeClient
66
66
 
67
67
  ### Handling the Return
68
68
  ```js
69
- // Print a brief summary of the parsed data
70
- invoiceResponse.then((resp) => {
69
+ // Handle the response Promise
70
+ apiResponse.then((resp) => {
71
71
 
72
- // The document property can be undefined:
73
- // * TypeScript will throw an error without this guard clause
72
+ // The `document` property can be undefined:
73
+ // * TypeScript will not compile without this guard clause
74
74
  // (or consider using the '?' notation)
75
75
  // * JavaScript will be very happy to produce subtle bugs
76
76
  // without this guard clause
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "3.1.1",
3
+ "version": "3.3.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
@@ -3,6 +3,7 @@ import { InputSource } from "../inputs";
3
3
  import { IncomingMessage } from "http";
4
4
  export declare const STANDARD_API_OWNER = "mindee";
5
5
  export declare const API_KEY_ENVVAR_NAME = "MINDEE_API_KEY";
6
+ export declare const API_BASE_URL_ENVVAR_NAME = "MINDEE_BASE_URL";
6
7
  export interface predictResponse {
7
8
  messageObj: IncomingMessage;
8
9
  data: {
@@ -25,6 +26,7 @@ export declare class Endpoint {
25
26
  */
26
27
  predictReqPost(input: InputSource, includeWords?: boolean, cropper?: boolean): Promise<predictResponse>;
27
28
  protected apiKeyFromEnv(): string;
29
+ protected baseUrlFromEnv(): string;
28
30
  }
29
31
  export declare class StandardEndpoint extends Endpoint {
30
32
  constructor(endpointName: string, version: string, apiKey: string);
@@ -26,24 +26,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.CustomEndpoint = exports.StandardEndpoint = exports.Endpoint = exports.API_KEY_ENVVAR_NAME = exports.STANDARD_API_OWNER = void 0;
29
+ exports.CustomEndpoint = exports.StandardEndpoint = exports.Endpoint = exports.API_BASE_URL_ENVVAR_NAME = exports.API_KEY_ENVVAR_NAME = exports.STANDARD_API_OWNER = void 0;
30
30
  const https = __importStar(require("https"));
31
31
  const os = __importStar(require("os"));
32
32
  const package_json_1 = require("../../package.json");
33
33
  const url_1 = require("url");
34
34
  const form_data_1 = __importDefault(require("form-data"));
35
35
  const logger_1 = require("../logger");
36
- const MINDEE_API_URL = "https://api.mindee.net/v1";
36
+ const DEFAULT_MINDEE_API_URL = "https://api.mindee.net/v1";
37
37
  const USER_AGENT = `mindee-api-nodejs@v${package_json_1.version} nodejs-${process.version} ${os.type().toLowerCase()}`;
38
38
  exports.STANDARD_API_OWNER = "mindee";
39
39
  exports.API_KEY_ENVVAR_NAME = "MINDEE_API_KEY";
40
+ exports.API_BASE_URL_ENVVAR_NAME = "MINDEE_BASE_URL";
40
41
  class Endpoint {
41
42
  constructor(owner, urlName, version, apiKey) {
42
43
  this.owner = owner;
43
44
  this.urlName = urlName;
44
45
  this.version = version;
45
46
  this.apiKey = apiKey || this.apiKeyFromEnv();
46
- this.urlRoot = `${MINDEE_API_URL}/products/${owner}/${urlName}/v${version}`;
47
+ this.urlRoot = `${this.baseUrlFromEnv()}/products/${owner}/${urlName}/v${version}`;
47
48
  this.baseHeaders = {
48
49
  "User-Agent": USER_AGENT,
49
50
  Authorization: `Token ${this.apiKey}`,
@@ -112,6 +113,14 @@ class Endpoint {
112
113
  }
113
114
  return "";
114
115
  }
116
+ baseUrlFromEnv() {
117
+ const envVarValue = process.env[exports.API_BASE_URL_ENVVAR_NAME];
118
+ if (envVarValue) {
119
+ logger_1.logger.debug(`Set the API base URL to ${envVarValue}`);
120
+ return envVarValue;
121
+ }
122
+ return DEFAULT_MINDEE_API_URL;
123
+ }
115
124
  }
116
125
  exports.Endpoint = Endpoint;
117
126
  class StandardEndpoint extends Endpoint {
package/src/cli.js CHANGED
@@ -3,62 +3,99 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cli = void 0;
4
4
  const commander_1 = require("commander");
5
5
  const documents_1 = require("./documents");
6
- const fr_1 = require("./documents/fr");
7
6
  const api_1 = require("./api");
8
7
  const client_1 = require("./client");
8
+ const inputs_1 = require("./inputs");
9
9
  const program = new commander_1.Command();
10
- const COMMAND_INVOICE = "invoice";
11
- const COMMAND_RECEIPT = "receipt";
12
- const COMMAND_PASSPORT = "passport";
13
- const COMMAND_FINANCIAL = "financial";
14
- const COMMAND_FR_ID_CARD = "fr-id-card";
15
10
  const COMMAND_CUSTOM = "custom";
11
+ // The Map's key is the command name as it will appear on the console.
12
+ //
16
13
  const CLI_COMMAND_CONFIG = new Map([
17
14
  [
18
- COMMAND_INVOICE,
15
+ COMMAND_CUSTOM,
16
+ {
17
+ description: "A custom document",
18
+ docClass: documents_1.CustomV1,
19
+ fullText: false,
20
+ },
21
+ ],
22
+ [
23
+ "invoice",
19
24
  {
20
- description: "Invoice V3",
21
- docType: documents_1.InvoiceV3.name,
25
+ description: "Invoice V4",
26
+ docClass: documents_1.InvoiceV4,
22
27
  fullText: true,
23
28
  },
24
29
  ],
25
30
  [
26
- COMMAND_RECEIPT,
31
+ "receipt",
27
32
  {
28
33
  description: "Expense Receipt V4",
29
- docType: documents_1.ReceiptV4.name,
34
+ docClass: documents_1.ReceiptV4,
30
35
  fullText: true,
31
36
  },
32
37
  ],
33
38
  [
34
- COMMAND_PASSPORT,
39
+ "passport",
35
40
  {
36
41
  description: "Passport V1",
37
- docType: documents_1.PassportV1.name,
42
+ docClass: documents_1.PassportV1,
38
43
  fullText: false,
39
44
  },
40
45
  ],
41
46
  [
42
- COMMAND_FINANCIAL,
47
+ "financial",
43
48
  {
44
49
  description: "Financial Document V1 (receipt or invoice)",
45
- docType: documents_1.FinancialDocumentV1.name,
50
+ docClass: documents_1.FinancialDocumentV1,
46
51
  fullText: true,
47
52
  },
48
53
  ],
49
54
  [
50
- COMMAND_FR_ID_CARD,
55
+ "fr-id-card",
51
56
  {
52
57
  description: "FR ID Card V1",
53
- docType: fr_1.IdCardV1.name,
58
+ docClass: documents_1.fr.IdCardV1,
54
59
  fullText: false,
55
60
  },
56
61
  ],
57
62
  [
58
- COMMAND_CUSTOM,
63
+ "fr-bank-account-details",
59
64
  {
60
- description: "A custom document",
61
- docType: documents_1.CustomV1.name,
65
+ description: "FR Bank Account Details V1",
66
+ docClass: documents_1.fr.BankAccountDetailsV1,
67
+ fullText: false,
68
+ },
69
+ ],
70
+ [
71
+ "fr-carte-vitale",
72
+ {
73
+ description: "FR Carte Vitale V1",
74
+ docClass: documents_1.fr.CarteVitaleV1,
75
+ fullText: false,
76
+ },
77
+ ],
78
+ [
79
+ "eu-license-plate",
80
+ {
81
+ description: "EU License Plate V1",
82
+ docClass: documents_1.eu.LicensePlateV1,
83
+ fullText: false,
84
+ },
85
+ ],
86
+ [
87
+ "us-bank-check",
88
+ {
89
+ description: "US Bank Check V1",
90
+ docClass: documents_1.us.BankCheckV1,
91
+ fullText: false,
92
+ },
93
+ ],
94
+ [
95
+ "shipping-container",
96
+ {
97
+ description: "Shipping container V1",
98
+ docClass: documents_1.ShippingContainerV1,
62
99
  fullText: false,
63
100
  },
64
101
  ],
@@ -79,41 +116,21 @@ async function predictCall(command, inputPath, options) {
79
116
  });
80
117
  }
81
118
  const doc = mindeeClient.docFromPath(inputPath);
119
+ let pageOptions = undefined;
120
+ if (options.cutPages) {
121
+ pageOptions = {
122
+ operation: inputs_1.PageOptionsOperation.KeepOnly,
123
+ pageIndexes: [0, 1, 2, 3, 4],
124
+ onMinPages: 5,
125
+ };
126
+ }
82
127
  const predictParams = {
83
- docType: command === COMMAND_CUSTOM ? options.documentType : conf.docType,
84
- username: command === COMMAND_CUSTOM ? options.user : api_1.STANDARD_API_OWNER,
85
- cutPages: options.cutPages,
128
+ endpointName: command === COMMAND_CUSTOM ? options.documentType : conf.docClass.name,
129
+ accountName: command === COMMAND_CUSTOM ? options.user : api_1.STANDARD_API_OWNER,
86
130
  fullText: options.fullText,
131
+ pageOptions: pageOptions,
87
132
  };
88
- // Tried setting the response by using the responseClass property in constants.PRODUCTS_CONFIG
89
- // This compiled, but threw an exception:
90
- // TypeError: responseType is not a constructor
91
- //
92
- // So using a switch to explicitly set the response class parameter. Ugly, but works.
93
- // Improvements welcome!
94
- let response;
95
- switch (command) {
96
- case COMMAND_INVOICE:
97
- response = await doc.parse(documents_1.InvoiceV3, predictParams);
98
- break;
99
- case COMMAND_RECEIPT:
100
- response = await doc.parse(documents_1.ReceiptV4, predictParams);
101
- break;
102
- case COMMAND_FINANCIAL:
103
- response = await doc.parse(documents_1.FinancialDocumentV1, predictParams);
104
- break;
105
- case COMMAND_PASSPORT:
106
- response = await doc.parse(documents_1.PassportV1, predictParams);
107
- break;
108
- case COMMAND_FR_ID_CARD:
109
- response = await doc.parse(fr_1.IdCardV1, predictParams);
110
- break;
111
- case COMMAND_CUSTOM:
112
- response = await doc.parse(documents_1.CustomV1, predictParams);
113
- break;
114
- default:
115
- throw `Unhandled command: ${command}`;
116
- }
133
+ const response = await doc.parse(conf.docClass, predictParams);
117
134
  if (options.fullText) {
118
135
  response.pages.forEach((page) => {
119
136
  console.log(page.fullText?.toString());
@@ -135,7 +152,7 @@ function cli() {
135
152
  const prog = program.command(name);
136
153
  prog.description(info.description);
137
154
  prog.option("-k, --api-key <api_key>", "API key for document endpoint");
138
- prog.option("-C, --no-cut-pages", "Don't cut document pages");
155
+ prog.option("-c, --cut-pages", "Keep only the first 5 pages of the document.");
139
156
  prog.option("-p, --pages", "Show pages content");
140
157
  if (info.fullText) {
141
158
  prog.option("-t, --full-text", "Include full document text in response");
package/src/client.d.ts CHANGED
@@ -6,11 +6,38 @@ import { Document, DocumentSig } from "./documents";
6
6
  import { DocumentConfig } from "./documents/documentConfig";
7
7
  import { ReadStream } from "fs";
8
8
  declare type DocConfigs = Map<string[], DocumentConfig<any>>;
9
- interface PredictOptions {
9
+ export interface PredictOptions {
10
+ /**
11
+ * For custom endpoints, the "API name" field in the "Settings" page of the API Builder.
12
+ *
13
+ * Do not set for standard (off the shelf) endpoints.
14
+ */
10
15
  endpointName?: string;
16
+ /**
17
+ * For custom endpoints, your account or organization's username on the API Builder.
18
+ * This is normally not required unless you have a custom endpoint which has the
19
+ * same name as standard (off the shelf) endpoint.
20
+ *
21
+ * Do not set for standard (off the shelf) endpoints.
22
+ */
11
23
  accountName?: string;
24
+ /**
25
+ * Whether to include the full text for each page.
26
+ *
27
+ * This performs a full OCR operation on the server and will increase response time.
28
+ */
12
29
  fullText?: boolean;
30
+ /**
31
+ * Whether to include cropper results for each page.
32
+ *
33
+ * This performs a cropping operation on the server and will increase response time.
34
+ */
13
35
  cropper?: boolean;
36
+ /**
37
+ * If set, remove pages from the document as specified.
38
+ *
39
+ * This is done before sending the file to the server and is useful to avoid page limitations.
40
+ */
14
41
  pageOptions?: PageOptions;
15
42
  }
16
43
  declare class DocumentClient {
@@ -24,14 +51,23 @@ declare class DocumentClient {
24
51
  */
25
52
  parse<DocType extends Document>(documentClass: DocumentSig<DocType>, params?: PredictOptions): Promise<Response<DocType>>;
26
53
  }
27
- interface customConfigParams {
54
+ export interface CustomConfigParams {
55
+ /** Your organization's username on the API Builder. */
28
56
  accountName: string;
57
+ /** The "API name" field in the "Settings" page of the API Builder. */
29
58
  endpointName: string;
59
+ /**
60
+ * If set, locks the version of the model to use.
61
+ * If not set, use the latest version of the model.
62
+ */
30
63
  version?: string;
31
64
  }
32
- interface ClientOptions {
65
+ export interface ClientOptions {
66
+ /** Your API key for all endpoints. */
33
67
  apiKey?: string;
68
+ /** Raise an `Error` on errors. */
34
69
  throwOnError?: boolean;
70
+ /** Log debug messages. */
35
71
  debug?: boolean;
36
72
  }
37
73
  /**
@@ -43,7 +79,7 @@ export declare class Client {
43
79
  /**
44
80
  * @param options
45
81
  */
46
- constructor(options?: ClientOptions);
82
+ constructor({ apiKey, throwOnError, debug, }: ClientOptions);
47
83
  protected addStandardEndpoints(): void;
48
84
  /**
49
85
  * Add a custom endpoint to the client.
@@ -51,7 +87,7 @@ export declare class Client {
51
87
  * @param endpointName
52
88
  * @param version
53
89
  */
54
- addEndpoint({ accountName, endpointName, version, }: customConfigParams): this;
90
+ addEndpoint({ accountName, endpointName, version, }: CustomConfigParams): this;
55
91
  /**
56
92
  * Load an input document from a local path.
57
93
  * @param inputPath
package/src/client.js CHANGED
@@ -66,11 +66,9 @@ class Client {
66
66
  /**
67
67
  * @param options
68
68
  */
69
- constructor(options) {
70
- const throwOnError = options?.throwOnError === undefined ? true : options.throwOnError;
71
- const debug = options?.debug === undefined ? false : options.debug;
72
- this.apiKey = options?.apiKey === undefined ? "" : options.apiKey;
69
+ constructor({ apiKey = "", throwOnError = true, debug = false, }) {
73
70
  this.docConfigs = new Map();
71
+ this.apiKey = apiKey;
74
72
  handler_1.errorHandler.throwOnError = throwOnError;
75
73
  logger_1.logger.level =
76
74
  debug ?? process.env.MINDEE_DEBUG
@@ -85,6 +83,9 @@ class Client {
85
83
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.InvoiceV3.name], new documentConfig_1.DocumentConfig(documents_1.InvoiceV3, [
86
84
  new api_1.StandardEndpoint("invoices", "3", this.apiKey),
87
85
  ]));
86
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.InvoiceV4.name], new documentConfig_1.DocumentConfig(documents_1.InvoiceV4, [
87
+ new api_1.StandardEndpoint("invoices", "4", this.apiKey),
88
+ ]));
88
89
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ReceiptV3.name], new documentConfig_1.DocumentConfig(documents_1.ReceiptV3, [
89
90
  new api_1.StandardEndpoint("expense_receipts", "3", this.apiKey),
90
91
  ]));
@@ -100,6 +101,21 @@ class Client {
100
101
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.IdCardV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.IdCardV1, [
101
102
  new api_1.StandardEndpoint("idcard_fr", "1", this.apiKey),
102
103
  ]));
104
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.us.BankCheckV1.name], new documentConfig_1.DocumentConfig(documents_1.us.BankCheckV1, [
105
+ new api_1.StandardEndpoint("bank_check", "1", this.apiKey),
106
+ ]));
107
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.BankAccountDetailsV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.BankAccountDetailsV1, [
108
+ new api_1.StandardEndpoint("bank_account_details", "1", this.apiKey),
109
+ ]));
110
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.CarteVitaleV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.CarteVitaleV1, [
111
+ new api_1.StandardEndpoint("carte_vitale", "1", this.apiKey),
112
+ ]));
113
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.eu.LicensePlateV1.name], new documentConfig_1.DocumentConfig(documents_1.eu.LicensePlateV1, [
114
+ new api_1.StandardEndpoint("license_plates", "1", this.apiKey),
115
+ ]));
116
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ShippingContainerV1.name], new documentConfig_1.DocumentConfig(documents_1.ShippingContainerV1, [
117
+ new api_1.StandardEndpoint("shipping_containers", "1", this.apiKey),
118
+ ]));
103
119
  }
104
120
  /**
105
121
  * Add a custom endpoint to the client.
@@ -1,7 +1,7 @@
1
1
  import { Document, DocumentConstructorProps } from "../document";
2
- import { CropperField } from "../../fields";
2
+ import { PositionField } from "../../fields";
3
3
  export declare class CropperV1 extends Document {
4
- cropping: CropperField[];
4
+ cropping: PositionField[];
5
5
  constructor({ prediction, orientation, inputSource, pageId, }: DocumentConstructorProps);
6
6
  toString(): string;
7
7
  }
@@ -13,7 +13,7 @@ class CropperV1 extends document_1.Document {
13
13
  this.cropping = [];
14
14
  if (pageId !== undefined) {
15
15
  prediction.cropping.forEach((crop) => {
16
- this.cropping.push(new fields_1.CropperField({
16
+ this.cropping.push(new fields_1.PositionField({
17
17
  prediction: crop,
18
18
  pageId: pageId,
19
19
  }));
@@ -1,5 +1,5 @@
1
1
  import { InputSource } from "../inputs";
2
- import { CropperField, FullText, OrientationField, stringDict } from "../fields";
2
+ import { PositionField, FullText, OrientationField, stringDict } from "../fields";
3
3
  export declare type DocumentSig<DocType extends Document> = {
4
4
  new ({ prediction, orientation, extras, inputSource, pageId, fullText, documentType, }: DocumentConstructorProps): DocType;
5
5
  };
@@ -30,7 +30,7 @@ export declare class Document {
30
30
  fullText?: FullText;
31
31
  pageId?: number | undefined;
32
32
  orientation?: OrientationField;
33
- cropper: CropperField[];
33
+ cropper: PositionField[];
34
34
  readonly docType: string;
35
35
  constructor({ orientation, extras, inputSource, fullText, pageId, documentType, }: BaseDocumentConstructorProps);
36
36
  clone(): any;
@@ -23,7 +23,7 @@ class Document {
23
23
  if (extras !== undefined) {
24
24
  if (extras.cropper !== undefined) {
25
25
  extras.cropper.cropping.forEach((crop) => {
26
- this.cropper.push(new fields_1.CropperField({
26
+ this.cropper.push(new fields_1.PositionField({
27
27
  prediction: crop,
28
28
  pageId: pageId,
29
29
  }));
@@ -0,0 +1 @@
1
+ export { LicensePlateV1 } from "./licensePlate/licensePlateV1";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LicensePlateV1 = void 0;
4
+ var licensePlateV1_1 = require("./licensePlate/licensePlateV1");
5
+ Object.defineProperty(exports, "LicensePlateV1", { enumerable: true, get: function () { return licensePlateV1_1.LicensePlateV1; } });
@@ -0,0 +1,8 @@
1
+ import { Document, DocumentConstructorProps } from "../../document";
2
+ import { Field } from "../../../fields";
3
+ export declare class LicensePlateV1 extends Document {
4
+ /** A list of license plates values. */
5
+ licensePlates: Field[];
6
+ constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
7
+ toString(): string;
8
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LicensePlateV1 = void 0;
4
+ const document_1 = require("../../document");
5
+ const fields_1 = require("../../../fields");
6
+ class LicensePlateV1 extends document_1.Document {
7
+ constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
8
+ super({
9
+ inputSource: inputSource,
10
+ pageId: pageId,
11
+ orientation: orientation,
12
+ extras: extras,
13
+ });
14
+ /** A list of license plates values. */
15
+ this.licensePlates = [];
16
+ prediction.license_plates.map((prediction) => this.licensePlates.push(new fields_1.Field({
17
+ prediction: prediction,
18
+ pageId: pageId,
19
+ })));
20
+ }
21
+ toString() {
22
+ const outStr = `----- EU License plate V1 -----
23
+ Licence plates: ${this.licensePlates.map((plate) => plate.value).join(", ")}
24
+ ----------------------
25
+ `;
26
+ return LicensePlateV1.cleanOutString(outStr);
27
+ }
28
+ }
29
+ exports.LicensePlateV1 = LicensePlateV1;
@@ -0,0 +1,12 @@
1
+ import { Document, DocumentConstructorProps } from "../../document";
2
+ import { Field } from "../../../fields";
3
+ export declare class BankAccountDetailsV1 extends Document {
4
+ /** The IBAN number. */
5
+ iban: Field;
6
+ /** The account holder name. */
7
+ accountHolderName: Field;
8
+ /** The SWIFT value. */
9
+ swift: Field;
10
+ constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
11
+ toString(): string;
12
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BankAccountDetailsV1 = void 0;
4
+ const document_1 = require("../../document");
5
+ const fields_1 = require("../../../fields");
6
+ class BankAccountDetailsV1 extends document_1.Document {
7
+ constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
8
+ super({
9
+ inputSource: inputSource,
10
+ pageId: pageId,
11
+ orientation: orientation,
12
+ extras: extras,
13
+ });
14
+ this.iban = new fields_1.Field({
15
+ prediction: prediction.iban,
16
+ pageId: pageId,
17
+ });
18
+ this.accountHolderName = new fields_1.Field({
19
+ prediction: prediction.account_holder_name,
20
+ pageId: pageId,
21
+ });
22
+ this.swift = new fields_1.Field({
23
+ prediction: prediction.swift,
24
+ pageId: pageId,
25
+ });
26
+ }
27
+ toString() {
28
+ const outStr = `----- FR Bank Account Details V1 -----
29
+ IBAN: ${this.iban}
30
+ Account holder name: ${this.accountHolderName}
31
+ SWIFT: ${this.swift}
32
+ ----------------------
33
+ `;
34
+ return BankAccountDetailsV1.cleanOutString(outStr);
35
+ }
36
+ }
37
+ exports.BankAccountDetailsV1 = BankAccountDetailsV1;
@@ -0,0 +1,14 @@
1
+ import { Document, DocumentConstructorProps } from "../../document";
2
+ import { Field, DateField } from "../../../fields";
3
+ export declare class CarteVitaleV1 extends Document {
4
+ /** The list of the names of the person. */
5
+ givenNames: Field[];
6
+ /** The surname of the person. */
7
+ surname: Field;
8
+ /** The ID number of the card. */
9
+ idNumber: Field;
10
+ /** The issuance date of the card. */
11
+ issuanceDate: DateField;
12
+ constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
13
+ toString(): string;
14
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CarteVitaleV1 = void 0;
4
+ const document_1 = require("../../document");
5
+ const fields_1 = require("../../../fields");
6
+ class CarteVitaleV1 extends document_1.Document {
7
+ constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
8
+ super({
9
+ inputSource: inputSource,
10
+ pageId: pageId,
11
+ orientation: orientation,
12
+ extras: extras,
13
+ });
14
+ /** The list of the names of the person. */
15
+ this.givenNames = [];
16
+ this.idNumber = new fields_1.Field({
17
+ prediction: prediction.social_security,
18
+ pageId: pageId,
19
+ });
20
+ this.issuanceDate = new fields_1.DateField({
21
+ prediction: prediction.issuance_date,
22
+ pageId: pageId,
23
+ });
24
+ this.surname = new fields_1.Field({
25
+ prediction: prediction.surname,
26
+ pageId: pageId,
27
+ });
28
+ prediction.given_names.map((prediction) => this.givenNames.push(new fields_1.Field({
29
+ prediction: prediction,
30
+ pageId: pageId,
31
+ })));
32
+ }
33
+ toString() {
34
+ const outStr = `----- FR Carte Vitale V1 -----
35
+ Given names: ${this.givenNames.map((name) => name.value).join(" ")}
36
+ Surname: ${this.surname}
37
+ ID Number: ${this.idNumber}
38
+ Issuance date: ${this.issuanceDate}
39
+ ----------------------
40
+ `;
41
+ return CarteVitaleV1.cleanOutString(outStr);
42
+ }
43
+ }
44
+ exports.CarteVitaleV1 = CarteVitaleV1;
@@ -1,16 +1,27 @@
1
1
  import { Document, DocumentConstructorProps } from "../../document";
2
2
  import { Field, DateField, BaseField } from "../../../fields";
3
3
  export declare class IdCardV1 extends Document {
4
+ /** The authority which has issued the card. */
4
5
  authority: Field;
6
+ /** Indicates if it is the recto, the verso or the both of it. */
5
7
  documentSide: BaseField;
8
+ /** The id number of the card. */
6
9
  idNumber: Field;
10
+ /** The birth date of the person. */
7
11
  birthDate: DateField;
12
+ /** The expiry date of the card. */
8
13
  expiryDate: DateField;
14
+ /** The birth place of the person. */
9
15
  birthPlace: Field;
16
+ /** The gender of the person. */
10
17
  gender: Field;
18
+ /** The first mrz value. */
11
19
  mrz1: Field;
20
+ /** The second mrz value. */
12
21
  mrz2: Field;
22
+ /** The surname of the person. */
13
23
  surname: Field;
24
+ /** The list of the names of the person. */
14
25
  givenNames: Field[];
15
26
  constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
16
27
  toString(): string;