mindee 4.20.0 → 4.22.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 (61) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +25 -11
  3. package/package.json +1 -1
  4. package/src/cli.js +2 -2
  5. package/src/client.d.ts +3 -3
  6. package/src/client.js +4 -4
  7. package/src/http/baseEndpoint.js +2 -2
  8. package/src/http/endpoint.js +2 -2
  9. package/src/http/workflowEndpoint.js +2 -2
  10. package/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.d.ts +1 -1
  11. package/src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.d.ts +1 -1
  12. package/src/input/index.d.ts +1 -2
  13. package/src/input/index.js +16 -15
  14. package/src/input/sources/base64Input.d.ts +12 -0
  15. package/src/input/sources/base64Input.js +22 -0
  16. package/src/input/sources/bufferInput.d.ts +10 -0
  17. package/src/input/sources/bufferInput.js +18 -0
  18. package/src/input/sources/bytesInput.d.ts +12 -0
  19. package/src/input/sources/bytesInput.js +21 -0
  20. package/src/input/sources/index.d.ts +8 -0
  21. package/src/input/sources/index.js +24 -0
  22. package/src/input/sources/inputSource.d.ts +16 -0
  23. package/src/input/sources/inputSource.js +17 -0
  24. package/src/input/sources/localInputSource.d.ts +20 -0
  25. package/src/input/{base.js → sources/localInputSource.js} +16 -26
  26. package/src/input/sources/pathInput.d.ts +11 -0
  27. package/src/input/sources/pathInput.js +27 -0
  28. package/src/input/sources/streamInput.d.ts +14 -0
  29. package/src/input/sources/streamInput.js +28 -0
  30. package/src/input/sources/urlInput.d.ts +32 -0
  31. package/src/input/sources/urlInput.js +98 -0
  32. package/src/product/fr/index.d.ts +0 -1
  33. package/src/product/fr/index.js +1 -3
  34. package/src/product/fr/internal.d.ts +0 -1
  35. package/src/product/fr/internal.js +1 -2
  36. package/src/product/ind/indianPassport/indianPassportV1Document.d.ts +1 -1
  37. package/src/product/ind/indianPassport/indianPassportV1Document.js +1 -1
  38. package/src/product/us/index.d.ts +1 -0
  39. package/src/product/us/index.js +3 -1
  40. package/src/product/us/usMail/index.d.ts +1 -0
  41. package/src/product/us/usMail/index.js +3 -1
  42. package/src/product/us/usMail/internal.d.ts +4 -0
  43. package/src/product/us/usMail/internal.js +9 -1
  44. package/src/product/{fr/carteVitale/carteVitaleV1.d.ts → us/usMail/usMailV3.d.ts} +5 -5
  45. package/src/product/us/usMail/usMailV3.js +27 -0
  46. package/src/product/us/usMail/usMailV3Document.d.ts +24 -0
  47. package/src/product/us/usMail/usMailV3Document.js +68 -0
  48. package/src/product/us/usMail/usMailV3RecipientAddress.d.ts +42 -0
  49. package/src/product/us/usMail/usMailV3RecipientAddress.js +128 -0
  50. package/src/product/us/usMail/usMailV3SenderAddress.d.ts +36 -0
  51. package/src/product/us/usMail/usMailV3SenderAddress.js +72 -0
  52. package/src/input/base.d.ts +0 -36
  53. package/src/input/sources.d.ts +0 -59
  54. package/src/input/sources.js +0 -133
  55. package/src/product/fr/carteVitale/carteVitaleV1.js +0 -27
  56. package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +0 -20
  57. package/src/product/fr/carteVitale/carteVitaleV1Document.js +0 -43
  58. package/src/product/fr/carteVitale/index.d.ts +0 -1
  59. package/src/product/fr/carteVitale/index.js +0 -5
  60. package/src/product/fr/carteVitale/internal.d.ts +0 -2
  61. package/src/product/fr/carteVitale/internal.js +0 -7
@@ -0,0 +1,72 @@
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 _UsMailV3SenderAddress_instances, _UsMailV3SenderAddress_printableValues;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.UsMailV3SenderAddress = void 0;
10
+ /**
11
+ * The address of the sender.
12
+ */
13
+ class UsMailV3SenderAddress {
14
+ constructor({ prediction = {} }) {
15
+ _UsMailV3SenderAddress_instances.add(this);
16
+ /** Confidence score */
17
+ this.confidence = 0.0;
18
+ /**
19
+ * Contains the relative vertices coordinates (points) of a polygon containing
20
+ * the field in the document.
21
+ */
22
+ this.polygon = [];
23
+ this.city = prediction["city"];
24
+ this.complete = prediction["complete"];
25
+ this.postalCode = prediction["postal_code"];
26
+ this.state = prediction["state"];
27
+ this.street = prediction["street"];
28
+ this.pageId = prediction["page_id"];
29
+ this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
30
+ if (prediction["polygon"]) {
31
+ this.polygon = prediction.polygon;
32
+ }
33
+ }
34
+ /**
35
+ * Default string representation.
36
+ */
37
+ toString() {
38
+ const printable = __classPrivateFieldGet(this, _UsMailV3SenderAddress_instances, "m", _UsMailV3SenderAddress_printableValues).call(this);
39
+ return ("City: " +
40
+ printable.city +
41
+ ", Complete Address: " +
42
+ printable.complete +
43
+ ", Postal Code: " +
44
+ printable.postalCode +
45
+ ", State: " +
46
+ printable.state +
47
+ ", Street: " +
48
+ printable.street);
49
+ }
50
+ /**
51
+ * Output in a format suitable for inclusion in a field list.
52
+ */
53
+ toFieldList() {
54
+ const printable = __classPrivateFieldGet(this, _UsMailV3SenderAddress_instances, "m", _UsMailV3SenderAddress_printableValues).call(this);
55
+ return `
56
+ :City: ${printable.city}
57
+ :Complete Address: ${printable.complete}
58
+ :Postal Code: ${printable.postalCode}
59
+ :State: ${printable.state}
60
+ :Street: ${printable.street}`.trimEnd();
61
+ }
62
+ }
63
+ exports.UsMailV3SenderAddress = UsMailV3SenderAddress;
64
+ _UsMailV3SenderAddress_instances = new WeakSet(), _UsMailV3SenderAddress_printableValues = function _UsMailV3SenderAddress_printableValues() {
65
+ return {
66
+ city: this.city ?? "",
67
+ complete: this.complete ?? "",
68
+ postalCode: this.postalCode ?? "",
69
+ state: this.state ?? "",
70
+ street: this.street ?? "",
71
+ };
72
+ };
@@ -1,36 +0,0 @@
1
- import { PageOptions } from "./pageOptions";
2
- /**
3
- * @param {string} inputType - the type of input used in file ("base64", "path", "dummy").
4
- * NB: dummy is only used for tests purposes
5
- */
6
- interface InputConstructor {
7
- inputType: string;
8
- }
9
- export declare const INPUT_TYPE_STREAM = "stream";
10
- export declare const INPUT_TYPE_BASE64 = "base64";
11
- export declare const INPUT_TYPE_BYTES = "bytes";
12
- export declare const INPUT_TYPE_PATH = "path";
13
- export declare const INPUT_TYPE_BUFFER = "buffer";
14
- export declare abstract class InputSource {
15
- fileObject: Buffer | string;
16
- init(): Promise<void>;
17
- }
18
- export declare abstract class LocalInputSource extends InputSource {
19
- inputType: string;
20
- filename: string;
21
- filepath?: string;
22
- mimeType: string;
23
- fileObject: Buffer | string;
24
- /**
25
- * @param {InputConstructor} constructor Constructor parameters.
26
- */
27
- protected constructor({ inputType }: InputConstructor);
28
- isPdf(): boolean;
29
- checkMimetype(): Promise<string>;
30
- /**
31
- * Cut PDF pages.
32
- * @param pageOptions
33
- */
34
- cutPdf(pageOptions: PageOptions): Promise<void>;
35
- }
36
- export {};
@@ -1,59 +0,0 @@
1
- import { Readable } from "stream";
2
- import { Buffer } from "buffer";
3
- import { LocalInputSource, InputSource } from "./base";
4
- interface PathInputProps {
5
- inputPath: string;
6
- }
7
- export declare class PathInput extends LocalInputSource {
8
- readonly inputPath: string;
9
- fileObject: Buffer;
10
- constructor({ inputPath }: PathInputProps);
11
- init(): Promise<void>;
12
- }
13
- interface Base64InputProps {
14
- inputString: string;
15
- filename: string;
16
- }
17
- export declare class Base64Input extends LocalInputSource {
18
- private inputString;
19
- fileObject: Buffer;
20
- constructor({ inputString, filename }: Base64InputProps);
21
- init(): Promise<void>;
22
- }
23
- interface StreamInputProps {
24
- inputStream: Readable;
25
- filename: string;
26
- }
27
- export declare class StreamInput extends LocalInputSource {
28
- private readonly inputStream;
29
- fileObject: Buffer;
30
- constructor({ inputStream, filename }: StreamInputProps);
31
- init(): Promise<void>;
32
- stream2buffer(stream: Readable): Promise<Buffer>;
33
- }
34
- interface BytesInputProps {
35
- inputBytes: string;
36
- filename: string;
37
- }
38
- export declare class BytesInput extends LocalInputSource {
39
- private inputBytes;
40
- fileObject: Buffer;
41
- constructor({ inputBytes, filename }: BytesInputProps);
42
- init(): Promise<void>;
43
- }
44
- export declare class UrlInput extends InputSource {
45
- private readonly url;
46
- constructor({ url }: {
47
- url: string;
48
- });
49
- init(): Promise<void>;
50
- }
51
- interface BufferInputProps {
52
- buffer: Buffer;
53
- filename: string;
54
- }
55
- export declare class BufferInput extends LocalInputSource {
56
- constructor({ buffer, filename }: BufferInputProps);
57
- init(): Promise<void>;
58
- }
59
- export {};
@@ -1,133 +0,0 @@
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.BufferInput = exports.UrlInput = exports.BytesInput = exports.StreamInput = exports.Base64Input = exports.PathInput = void 0;
27
- const fs_1 = require("fs");
28
- const path = __importStar(require("path"));
29
- const buffer_1 = require("buffer");
30
- const logger_1 = require("../logger");
31
- const base_1 = require("./base");
32
- class PathInput extends base_1.LocalInputSource {
33
- constructor({ inputPath }) {
34
- super({
35
- inputType: base_1.INPUT_TYPE_PATH,
36
- });
37
- this.fileObject = buffer_1.Buffer.alloc(0);
38
- this.inputPath = inputPath;
39
- this.filename = path.basename(this.inputPath);
40
- }
41
- async init() {
42
- logger_1.logger.debug(`Loading from: ${this.inputPath}`);
43
- this.fileObject = buffer_1.Buffer.from(await fs_1.promises.readFile(this.inputPath));
44
- this.mimeType = await this.checkMimetype();
45
- }
46
- }
47
- exports.PathInput = PathInput;
48
- class Base64Input extends base_1.LocalInputSource {
49
- constructor({ inputString, filename }) {
50
- super({
51
- inputType: base_1.INPUT_TYPE_BASE64,
52
- });
53
- this.fileObject = buffer_1.Buffer.alloc(0);
54
- this.filename = filename;
55
- this.inputString = inputString;
56
- }
57
- async init() {
58
- this.fileObject = buffer_1.Buffer.from(this.inputString, "base64");
59
- this.mimeType = await this.checkMimetype();
60
- // clear out the string
61
- this.inputString = "";
62
- }
63
- }
64
- exports.Base64Input = Base64Input;
65
- class StreamInput extends base_1.LocalInputSource {
66
- constructor({ inputStream, filename }) {
67
- super({
68
- inputType: base_1.INPUT_TYPE_STREAM,
69
- });
70
- this.fileObject = buffer_1.Buffer.alloc(0);
71
- this.filename = filename;
72
- this.inputStream = inputStream;
73
- }
74
- async init() {
75
- this.fileObject = await this.stream2buffer(this.inputStream);
76
- this.mimeType = await this.checkMimetype();
77
- }
78
- async stream2buffer(stream) {
79
- return new Promise((resolve, reject) => {
80
- const _buf = Array();
81
- stream.on("data", (chunk) => _buf.push(chunk));
82
- stream.on("end", () => resolve(buffer_1.Buffer.concat(_buf)));
83
- stream.on("error", (err) => reject(`Error converting stream - ${err}`));
84
- });
85
- }
86
- }
87
- exports.StreamInput = StreamInput;
88
- class BytesInput extends base_1.LocalInputSource {
89
- constructor({ inputBytes, filename }) {
90
- super({
91
- inputType: base_1.INPUT_TYPE_BYTES,
92
- });
93
- this.fileObject = buffer_1.Buffer.alloc(0);
94
- this.filename = filename;
95
- this.inputBytes = inputBytes;
96
- }
97
- async init() {
98
- this.fileObject = buffer_1.Buffer.from(this.inputBytes, "hex");
99
- this.mimeType = await this.checkMimetype();
100
- // clear out the string
101
- this.inputBytes = "";
102
- }
103
- }
104
- exports.BytesInput = BytesInput;
105
- //
106
- // URL
107
- //
108
- class UrlInput extends base_1.InputSource {
109
- constructor({ url }) {
110
- super();
111
- this.url = url;
112
- }
113
- async init() {
114
- if (!this.url.toLowerCase().startsWith("https")) {
115
- throw new Error("URL must be HTTPS");
116
- }
117
- this.fileObject = this.url;
118
- }
119
- }
120
- exports.UrlInput = UrlInput;
121
- class BufferInput extends base_1.LocalInputSource {
122
- constructor({ buffer, filename }) {
123
- super({
124
- inputType: base_1.INPUT_TYPE_BUFFER,
125
- });
126
- this.fileObject = buffer;
127
- this.filename = filename;
128
- }
129
- async init() {
130
- this.mimeType = await this.checkMimetype();
131
- }
132
- }
133
- exports.BufferInput = BufferInput;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CarteVitaleV1 = void 0;
4
- const common_1 = require("../../../parsing/common");
5
- const carteVitaleV1Document_1 = require("./carteVitaleV1Document");
6
- /**
7
- * Carte Vitale API version 1 inference prediction.
8
- */
9
- class CarteVitaleV1 extends common_1.Inference {
10
- constructor(rawPrediction) {
11
- super(rawPrediction);
12
- /** The endpoint's name. */
13
- this.endpointName = "carte_vitale";
14
- /** The endpoint's version. */
15
- this.endpointVersion = "1";
16
- /** The document's pages. */
17
- this.pages = [];
18
- this.prediction = new carteVitaleV1Document_1.CarteVitaleV1Document(rawPrediction["prediction"]);
19
- rawPrediction["pages"].forEach((page) => {
20
- if (page.prediction !== undefined && page.prediction !== null &&
21
- Object.keys(page.prediction).length > 0) {
22
- this.pages.push(new common_1.Page(carteVitaleV1Document_1.CarteVitaleV1Document, page, page["id"], page["orientation"]));
23
- }
24
- });
25
- }
26
- }
27
- exports.CarteVitaleV1 = CarteVitaleV1;
@@ -1,20 +0,0 @@
1
- import { Prediction, StringDict } from "../../../parsing/common";
2
- import { DateField, StringField } from "../../../parsing/standard";
3
- /**
4
- * Carte Vitale API version 1.1 document data.
5
- */
6
- export declare class CarteVitaleV1Document implements Prediction {
7
- /** The given name(s) of the card holder. */
8
- givenNames: StringField[];
9
- /** The date the card was issued. */
10
- issuanceDate: DateField;
11
- /** The Social Security Number (Numéro de Sécurité Sociale) of the card holder */
12
- socialSecurity: StringField;
13
- /** The surname of the card holder. */
14
- surname: StringField;
15
- constructor(rawPrediction: StringDict, pageId?: number);
16
- /**
17
- * Default string representation.
18
- */
19
- toString(): string;
20
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CarteVitaleV1Document = void 0;
4
- const common_1 = require("../../../parsing/common");
5
- const standard_1 = require("../../../parsing/standard");
6
- /**
7
- * Carte Vitale API version 1.1 document data.
8
- */
9
- class CarteVitaleV1Document {
10
- constructor(rawPrediction, pageId) {
11
- /** The given name(s) of the card holder. */
12
- this.givenNames = [];
13
- rawPrediction["given_names"] &&
14
- rawPrediction["given_names"].map((itemPrediction) => this.givenNames.push(new standard_1.StringField({
15
- prediction: itemPrediction,
16
- pageId: pageId,
17
- })));
18
- this.issuanceDate = new standard_1.DateField({
19
- prediction: rawPrediction["issuance_date"],
20
- pageId: pageId,
21
- });
22
- this.socialSecurity = new standard_1.StringField({
23
- prediction: rawPrediction["social_security"],
24
- pageId: pageId,
25
- });
26
- this.surname = new standard_1.StringField({
27
- prediction: rawPrediction["surname"],
28
- pageId: pageId,
29
- });
30
- }
31
- /**
32
- * Default string representation.
33
- */
34
- toString() {
35
- const givenNames = this.givenNames.join("\n ");
36
- const outStr = `:Given Name(s): ${givenNames}
37
- :Surname: ${this.surname}
38
- :Social Security Number: ${this.socialSecurity}
39
- :Issuance Date: ${this.issuanceDate}`.trimEnd();
40
- return (0, common_1.cleanOutString)(outStr);
41
- }
42
- }
43
- exports.CarteVitaleV1Document = CarteVitaleV1Document;
@@ -1 +0,0 @@
1
- export { CarteVitaleV1 } from "./carteVitaleV1";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CarteVitaleV1 = void 0;
4
- var carteVitaleV1_1 = require("./carteVitaleV1");
5
- Object.defineProperty(exports, "CarteVitaleV1", { enumerable: true, get: function () { return carteVitaleV1_1.CarteVitaleV1; } });
@@ -1,2 +0,0 @@
1
- export { CarteVitaleV1 } from "./carteVitaleV1";
2
- export { CarteVitaleV1Document } from "./carteVitaleV1Document";
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CarteVitaleV1Document = exports.CarteVitaleV1 = void 0;
4
- var carteVitaleV1_1 = require("./carteVitaleV1");
5
- Object.defineProperty(exports, "CarteVitaleV1", { enumerable: true, get: function () { return carteVitaleV1_1.CarteVitaleV1; } });
6
- var carteVitaleV1Document_1 = require("./carteVitaleV1Document");
7
- Object.defineProperty(exports, "CarteVitaleV1Document", { enumerable: true, get: function () { return carteVitaleV1Document_1.CarteVitaleV1Document; } });