diff --git a/docs/code_samples/proof_of_address_v1.txt b/docs/code_samples/proof_of_address_v1.txt deleted file mode 100644 index 34c5b52e0..000000000 --- a/docs/code_samples/proof_of_address_v1.txt +++ /dev/null @@ -1,21 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); - -// Load a file from disk -const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext"); - -// Parse the file -const apiResponse = mindeeClient.parse( - mindee.product.ProofOfAddressV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/us_w9_v1.txt b/docs/code_samples/us_w9_v1.txt deleted file mode 100644 index b881f8330..000000000 --- a/docs/code_samples/us_w9_v1.txt +++ /dev/null @@ -1,21 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); - -// Load a file from disk -const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext"); - -// Parse the file -const apiResponse = mindeeClient.parse( - mindee.product.us.W9V1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/expense_receipts_v5.md b/docs/expense_receipts_v5.md index 0ff076325..10144de03 100644 --- a/docs/expense_receipts_v5.md +++ b/docs/expense_receipts_v5.md @@ -197,6 +197,7 @@ Aside from the basic `Field` attributes, the tax field `TaxField` also implement * **rate** (`number`): the tax rate applied to an item can be expressed as a percentage. Can be `undefined`. * **code** (`string`): tax code (or equivalent, depending on the origin of the document). Can be `undefined`. * **base** (`number`): base amount used for the tax. Can be `undefined`. +* **value** (`number`): the value of the tax. Can be `null`. > Note: currently `TaxField` is not used on its own, and is accessed through a parent `Taxes` object, an array-like structure. diff --git a/docs/financial_document_v1.md b/docs/financial_document_v1.md index e70d65ecc..658bb7c53 100644 --- a/docs/financial_document_v1.md +++ b/docs/financial_document_v1.md @@ -241,6 +241,7 @@ Aside from the basic `Field` attributes, the tax field `TaxField` also implement * **rate** (`number`): the tax rate applied to an item can be expressed as a percentage. Can be `undefined`. * **code** (`string`): tax code (or equivalent, depending on the origin of the document). Can be `undefined`. * **base** (`number`): base amount used for the tax. Can be `undefined`. +* **value** (`number`): the value of the tax. Can be `null`. > Note: currently `TaxField` is not used on its own, and is accessed through a parent `Taxes` object, an array-like structure. diff --git a/docs/invoices_v4.md b/docs/invoices_v4.md index d05cb4fed..75f49c90c 100644 --- a/docs/invoices_v4.md +++ b/docs/invoices_v4.md @@ -229,6 +229,7 @@ Aside from the basic `Field` attributes, the tax field `TaxField` also implement * **rate** (`number`): the tax rate applied to an item can be expressed as a percentage. Can be `undefined`. * **code** (`string`): tax code (or equivalent, depending on the origin of the document). Can be `undefined`. * **base** (`number`): base amount used for the tax. Can be `undefined`. +* **value** (`number`): the value of the tax. Can be `null`. > Note: currently `TaxField` is not used on its own, and is accessed through a parent `Taxes` object, an array-like structure. diff --git a/docs/proof_of_address_v1.md b/docs/proof_of_address_v1.md deleted file mode 100644 index 5de2b3edd..000000000 --- a/docs/proof_of_address_v1.md +++ /dev/null @@ -1,214 +0,0 @@ ---- -title: Proof of Address OCR Node.js -category: 622b805aaec68102ea7fcbc2 -slug: nodejs-proof-of-address-ocr -parentDoc: 609809574212d40077a040f1 ---- -The Node.js OCR SDK supports the [Proof of Address API](https://platform.mindee.com/mindee/proof_of_address). - -Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/proof_of_address/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK. -![Proof of Address sample](https://github.com/mindee/client-lib-test-data/blob/main/products/proof_of_address/default_sample.jpg?raw=true) - -# Quick-Start -```js -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); - -// Load a file from disk -const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext"); - -// Parse the file -const apiResponse = mindeeClient.parse( - mindee.product.ProofOfAddressV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); -``` - -**Output (RST):** -```rst -######## -Document -######## -:Mindee ID: 5d2361e9-405e-4fc1-8531-f92a3aef0c38 -:Filename: default_sample.jpg - -Inference -######### -:Product: mindee/proof_of_address v1.1 -:Rotation applied: Yes - -Prediction -========== -:Locale: en; en; USD; -:Issuer Name: PPL ELECTRIC UTILITIES -:Issuer Company Registrations: -:Issuer Address: 2 NORTH 9TH STREET CPC-GENN1 ALLENTOWN.PA 18101-1175 -:Recipient Name: -:Recipient Company Registrations: -:Recipient Address: 123 MAIN ST ANYTOWN,PA 18062 -:Dates: 2011-07-27 - 2011-07-06 - 2011-08-03 - 2011-07-27 - 2011-06-01 - 2011-07-01 - 2010-07-01 - 2010-08-01 - 2011-07-01 - 2009-08-01 - 2010-07-01 - 2011-07-27 -:Date of Issue: 2011-07-27 - -Page Predictions -================ - -Page 0 ------- -:Locale: en; en; USD; -:Issuer Name: PPL ELECTRIC UTILITIES -:Issuer Company Registrations: -:Issuer Address: 2 NORTH 9TH STREET CPC-GENN1 ALLENTOWN.PA 18101-1175 -:Recipient Name: -:Recipient Company Registrations: -:Recipient Address: 123 MAIN ST ANYTOWN,PA 18062 -:Dates: 2011-07-27 - 2011-07-06 - 2011-08-03 - 2011-07-27 - 2011-06-01 - 2011-07-01 - 2010-07-01 - 2010-08-01 - 2011-07-01 - 2009-08-01 - 2010-07-01 - 2011-07-27 -:Date of Issue: 2011-07-27 -``` - -# Field Types -## Standard Fields -These fields are generic and used in several products. - -### Basic Field -Each prediction object contains a set of fields that inherit from the generic `Field` class. -A typical `Field` object will have the following attributes: - -* **value** (`number | string`): corresponds to the field value. Can be `undefined` if no value was extracted. -* **confidence** (`number`): the confidence score of the field prediction. -* **boundingBox** (`[Point, Point, Point, Point]`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document. -* **polygon** (`Point[]`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image. -* **pageId** (`number`): the ID of the page, always `undefined` when at document-level. -* **reconstructed** (`boolean`): indicates whether an object was reconstructed (not extracted as the API gave it). - -> **Note:** A `Point` simply refers to an array of two numbers (`[number, number]`). - - -Aside from the previous attributes, all basic fields have access to a `toString()` method that can be used to print their value as a string. - - -### Company Registration Field -Aside from the basic `Field` attributes, the company registration field `CompanyRegistrationField` also implements the following: - -* **type** (`string`): the type of company. - -### Date Field -Aside from the basic `Field` attributes, the date field `DateField` also implements the following: - -* **dateObject** (`Date`): an accessible representation of the value as a JavaScript object. - -### Locale Field -The locale field `LocaleField` only implements the **value**, **confidence** and **pageId** base `Field` attributes, but it comes with its own: - -* **language** (`string`): ISO 639-1 language code (e.g.: `en` for English). Can be `undefined`. -* **country** (`string`): ISO 3166-1 alpha-2 or ISO 3166-1 alpha-3 code for countries (e.g.: `GRB` or `GB` for "Great Britain"). Can be `undefined`. -* **currency** (`string`): ISO 4217 code for currencies (e.g.: `USD` for "US Dollars"). Can be `undefined`. - -### String Field -The text field `StringField` only has one constraint: its **value** is a `string` (or `undefined`). - -# Attributes -The following fields are extracted for Proof of Address V1: - -## Date of Issue -**date** ([DateField](#date-field)): The date the document was issued. - -```js -console.log(result.document.inference.prediction.date.value); -``` - -## Dates -**dates** ([DateField](#date-field)[]): List of dates found on the document. - -```js -for (const datesElem of result.document.inference.prediction.dates) { - console.log(datesElem.value); -} -``` - -## Issuer Address -**issuerAddress** ([StringField](#string-field)): The address of the document's issuer. - -```js -console.log(result.document.inference.prediction.issuerAddress.value); -``` - -## Issuer Company Registrations -**issuerCompanyRegistration** ([CompanyRegistrationField](#company-registration-field)[]): List of company registrations found for the issuer. - -```js -for (const issuerCompanyRegistrationElem of result.document.inference.prediction.issuerCompanyRegistration) { - console.log(issuerCompanyRegistrationElem.value); -} -``` - -## Issuer Name -**issuerName** ([StringField](#string-field)): The name of the person or company issuing the document. - -```js -console.log(result.document.inference.prediction.issuerName.value); -``` - -## Locale -**locale** ([LocaleField](#locale-field)): The locale detected on the document. - -```js -console.log(result.document.inference.prediction.locale.value); -``` - -## Recipient Address -**recipientAddress** ([StringField](#string-field)): The address of the recipient. - -```js -console.log(result.document.inference.prediction.recipientAddress.value); -``` - -## Recipient Company Registrations -**recipientCompanyRegistration** ([CompanyRegistrationField](#company-registration-field)[]): List of company registrations found for the recipient. - -```js -for (const recipientCompanyRegistrationElem of result.document.inference.prediction.recipientCompanyRegistration) { - console.log(recipientCompanyRegistrationElem.value); -} -``` - -## Recipient Name -**recipientName** ([StringField](#string-field)): The name of the person or company receiving the document. - -```js -console.log(result.document.inference.prediction.recipientName.value); -``` - -# Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/docs/us_w9_v1.md b/docs/us_w9_v1.md deleted file mode 100644 index 469230bdc..000000000 --- a/docs/us_w9_v1.md +++ /dev/null @@ -1,217 +0,0 @@ ---- -title: US W9 OCR Node.js -category: 622b805aaec68102ea7fcbc2 -slug: nodejs-us-w9-ocr -parentDoc: 609809574212d40077a040f1 ---- -The Node.js OCR SDK supports the [W9 API](https://platform.mindee.com/mindee/us_w9). - -Using the [sample below](https://github.com/mindee/client-lib-test-data/blob/main/products/us_w9/default_sample.jpg), we are going to illustrate how to extract the data that we want using the OCR SDK. -![W9 sample](https://github.com/mindee/client-lib-test-data/blob/main/products/us_w9/default_sample.jpg?raw=true) - -# Quick-Start -```js -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); - -// Load a file from disk -const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext"); - -// Parse the file -const apiResponse = mindeeClient.parse( - mindee.product.us.W9V1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); -``` - -**Output (RST):** -```rst -######## -Document -######## -:Mindee ID: d7c5b25f-e0d3-4491-af54-6183afa1aaab -:Filename: default_sample.jpg - -Inference -######### -:Product: mindee/us_w9 v1.0 -:Rotation applied: Yes - -Prediction -========== - -Page Predictions -================ - -Page 0 ------- -:Name: Stephen W Hawking -:SSN: 560758145 -:Address: Somewhere In Milky Way -:City State Zip: Probably Still At Cambridge P O Box CB1 -:Business Name: -:EIN: 942203664 -:Tax Classification: individual -:Tax Classification Other Details: -:W9 Revision Date: august 2013 -:Signature Position: Polygon with 4 points. -:Signature Date Position: -:Tax Classification LLC: -``` - -# Field Types -## Standard Fields -These fields are generic and used in several products. - -### Basic Field -Each prediction object contains a set of fields that inherit from the generic `Field` class. -A typical `Field` object will have the following attributes: - -* **value** (`number | string`): corresponds to the field value. Can be `undefined` if no value was extracted. -* **confidence** (`number`): the confidence score of the field prediction. -* **boundingBox** (`[Point, Point, Point, Point]`): contains exactly 4 relative vertices (points) coordinates of a right rectangle containing the field in the document. -* **polygon** (`Point[]`): contains the relative vertices coordinates (`Point`) of a polygon containing the field in the image. -* **pageId** (`number`): the ID of the page, always `undefined` when at document-level. -* **reconstructed** (`boolean`): indicates whether an object was reconstructed (not extracted as the API gave it). - -> **Note:** A `Point` simply refers to an array of two numbers (`[number, number]`). - - -Aside from the previous attributes, all basic fields have access to a `toString()` method that can be used to print their value as a string. - - -### Position Field -The position field `PositionField` does not implement all the basic `Field` attributes, only **boundingBox**, **polygon** and **pageId**. On top of these, it has access to: - -* **rectangle** (`[Point, Point, Point, Point]`): a Polygon with four points that may be oriented (even beyond canvas). -* **quadrangle** (`[Point, Point, Point, Point]`): a free polygon made up of four points. - -### String Field -The text field `StringField` only has one constraint: its **value** is a `string` (or `undefined`). - -## Page-Level Fields -Some fields are constrained to the page level, and so will not be retrievable at document level. - -# Attributes -The following fields are extracted for W9 V1: - -## Address -[📄](#page-level-fields "This field is only present on individual pages.")**address** ([StringField](#string-field)): The street address (number, street, and apt. or suite no.) of the applicant. - -```js -for (const addressElem of result.document.address) { - console.log(addressElem.value); -} -``` - -## Business Name -[📄](#page-level-fields "This field is only present on individual pages.")**businessName** ([StringField](#string-field)): The business name or disregarded entity name, if different from Name. - -```js -for (const businessNameElem of result.document.businessName) { - console.log(businessNameElem.value); -} -``` - -## City State Zip -[📄](#page-level-fields "This field is only present on individual pages.")**cityStateZip** ([StringField](#string-field)): The city, state, and ZIP code of the applicant. - -```js -for (const cityStateZipElem of result.document.cityStateZip) { - console.log(cityStateZipElem.value); -} -``` - -## EIN -[📄](#page-level-fields "This field is only present on individual pages.")**ein** ([StringField](#string-field)): The employer identification number. - -```js -for (const einElem of result.document.ein) { - console.log(einElem.value); -} -``` - -## Name -[📄](#page-level-fields "This field is only present on individual pages.")**name** ([StringField](#string-field)): Name as shown on the applicant's income tax return. - -```js -for (const nameElem of result.document.name) { - console.log(nameElem.value); -} -``` - -## Signature Date Position -[📄](#page-level-fields "This field is only present on individual pages.")**signatureDatePosition** ([PositionField](#position-field)): Position of the signature date on the document. - -```js -for (const signatureDatePositionElem of result.document.signatureDatePosition) { - console.log(signatureDatePositionElem.polygon); -} -``` - -## Signature Position -[📄](#page-level-fields "This field is only present on individual pages.")**signaturePosition** ([PositionField](#position-field)): Position of the signature on the document. - -```js -for (const signaturePositionElem of result.document.signaturePosition) { - console.log(signaturePositionElem.polygon); -} -``` - -## SSN -[📄](#page-level-fields "This field is only present on individual pages.")**ssn** ([StringField](#string-field)): The applicant's social security number. - -```js -for (const ssnElem of result.document.ssn) { - console.log(ssnElem.value); -} -``` - -## Tax Classification -[📄](#page-level-fields "This field is only present on individual pages.")**taxClassification** ([StringField](#string-field)): The federal tax classification, which can vary depending on the revision date. - -```js -for (const taxClassificationElem of result.document.taxClassification) { - console.log(taxClassificationElem.value); -} -``` - -## Tax Classification LLC -[📄](#page-level-fields "This field is only present on individual pages.")**taxClassificationLlc** ([StringField](#string-field)): Depending on revision year, among S, C, P or D for Limited Liability Company Classification. - -```js -for (const taxClassificationLlcElem of result.document.taxClassificationLlc) { - console.log(taxClassificationLlcElem.value); -} -``` - -## Tax Classification Other Details -[📄](#page-level-fields "This field is only present on individual pages.")**taxClassificationOtherDetails** ([StringField](#string-field)): Tax Classification Other Details. - -```js -for (const taxClassificationOtherDetailsElem of result.document.taxClassificationOtherDetails) { - console.log(taxClassificationOtherDetailsElem.value); -} -``` - -## W9 Revision Date -[📄](#page-level-fields "This field is only present on individual pages.")**w9RevisionDate** ([StringField](#string-field)): The Revision month and year of the W9 form. - -```js -for (const w9RevisionDateElem of result.document.w9RevisionDate) { - console.log(w9RevisionDateElem.value); -} -``` - -# Questions? -[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g) diff --git a/src/cliProducts.ts b/src/cliProducts.ts index 9e848333d..0dcb9400a 100644 --- a/src/cliProducts.ts +++ b/src/cliProducts.ts @@ -239,16 +239,6 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: true, }, ], - [ - "proof-of-address", - { - displayName: "Proof of Address", - docClass: product.ProofOfAddressV1, - allWords: false, - async: false, - sync: true, - }, - ], [ "receipt", { @@ -299,14 +289,4 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: false, }, ], - [ - "us-w9", - { - displayName: "US W9", - docClass: product.us.W9V1, - allWords: false, - async: false, - sync: true, - }, - ], ]); diff --git a/src/product/index.ts b/src/product/index.ts index 6a3f4704a..286822f0e 100644 --- a/src/product/index.ts +++ b/src/product/index.ts @@ -16,6 +16,5 @@ export { InvoiceV4 } from "./invoice/invoiceV4"; export { MultiReceiptsDetectorV1 } from "./multiReceiptsDetector/multiReceiptsDetectorV1"; export { NutritionFactsLabelV1 } from "./nutritionFactsLabel/nutritionFactsLabelV1"; export { PassportV1 } from "./passport/passportV1"; -export { ProofOfAddressV1 } from "./proofOfAddress/proofOfAddressV1"; export { ReceiptV5 } from "./receipt/receiptV5"; export { ResumeV1 } from "./resume/resumeV1"; diff --git a/src/product/internal.ts b/src/product/internal.ts index 89bb7861e..2e181bc32 100644 --- a/src/product/internal.ts +++ b/src/product/internal.ts @@ -15,7 +15,6 @@ export * as invoiceSplitter from "./invoiceSplitter/internal"; export * as multiReceiptsDetector from "./multiReceiptsDetector/internal"; export * as nutritionFactsLabel from "./nutritionFactsLabel/internal"; export * as passport from "./passport/internal"; -export * as proofOfAddress from "./proofOfAddress/internal"; export * as receipt from "./receipt/internal"; export * as resume from "./resume/internal"; export * as us from "./us/internal"; diff --git a/src/product/proofOfAddress/index.ts b/src/product/proofOfAddress/index.ts deleted file mode 100644 index 9c7b4334e..000000000 --- a/src/product/proofOfAddress/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ProofOfAddressV1 } from "./proofOfAddressV1"; diff --git a/src/product/proofOfAddress/internal.ts b/src/product/proofOfAddress/internal.ts deleted file mode 100644 index e1d62dbde..000000000 --- a/src/product/proofOfAddress/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { ProofOfAddressV1 } from "./proofOfAddressV1"; -export { ProofOfAddressV1Document } from "./proofOfAddressV1Document"; diff --git a/src/product/proofOfAddress/proofOfAddressV1.ts b/src/product/proofOfAddress/proofOfAddressV1.ts deleted file mode 100644 index 91744b5a9..000000000 --- a/src/product/proofOfAddress/proofOfAddressV1.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { ProofOfAddressV1Document } from "./proofOfAddressV1Document"; - -/** - * Proof of Address API version 1 inference prediction. - */ -export class ProofOfAddressV1 extends Inference { - /** The endpoint's name. */ - endpointName = "proof_of_address"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: ProofOfAddressV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new ProofOfAddressV1Document(rawPrediction["prediction"]); - rawPrediction["pages"].forEach( - (page: StringDict) => { - if (page.prediction !== undefined && page.prediction !== null && - Object.keys(page.prediction).length > 0) { - this.pages.push(new Page( - ProofOfAddressV1Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/product/proofOfAddress/proofOfAddressV1Document.ts b/src/product/proofOfAddress/proofOfAddressV1Document.ts deleted file mode 100644 index 4d261ace1..000000000 --- a/src/product/proofOfAddress/proofOfAddressV1Document.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString, -} from "../../parsing/common"; -import { - CompanyRegistrationField, - DateField, - LocaleField, - StringField, -} from "../../parsing/standard"; - -/** - * Proof of Address API version 1.1 document data. - */ -export class ProofOfAddressV1Document implements Prediction { - /** The date the document was issued. */ - date: DateField; - /** List of dates found on the document. */ - dates: DateField[] = []; - /** The address of the document's issuer. */ - issuerAddress: StringField; - /** List of company registrations found for the issuer. */ - issuerCompanyRegistration: CompanyRegistrationField[] = []; - /** The name of the person or company issuing the document. */ - issuerName: StringField; - /** The locale detected on the document. */ - locale: LocaleField; - /** The address of the recipient. */ - recipientAddress: StringField; - /** List of company registrations found for the recipient. */ - recipientCompanyRegistration: CompanyRegistrationField[] = []; - /** The name of the person or company receiving the document. */ - recipientName: StringField; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.date = new DateField({ - prediction: rawPrediction["date"], - pageId: pageId, - }); - rawPrediction["dates"] && - rawPrediction["dates"].map( - (itemPrediction: StringDict) => - this.dates.push( - new DateField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.issuerAddress = new StringField({ - prediction: rawPrediction["issuer_address"], - pageId: pageId, - }); - rawPrediction["issuer_company_registration"] && - rawPrediction["issuer_company_registration"].map( - (itemPrediction: StringDict) => - this.issuerCompanyRegistration.push( - new CompanyRegistrationField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.issuerName = new StringField({ - prediction: rawPrediction["issuer_name"], - pageId: pageId, - }); - this.locale = new LocaleField({ - prediction: rawPrediction["locale"], - }); - this.recipientAddress = new StringField({ - prediction: rawPrediction["recipient_address"], - pageId: pageId, - }); - rawPrediction["recipient_company_registration"] && - rawPrediction["recipient_company_registration"].map( - (itemPrediction: StringDict) => - this.recipientCompanyRegistration.push( - new CompanyRegistrationField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.recipientName = new StringField({ - prediction: rawPrediction["recipient_name"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - const issuerCompanyRegistration = this.issuerCompanyRegistration.join("\n "); - const recipientCompanyRegistration = this.recipientCompanyRegistration.join("\n "); - const dates = this.dates.join("\n "); - const outStr = `:Locale: ${this.locale} -:Issuer Name: ${this.issuerName} -:Issuer Company Registrations: ${issuerCompanyRegistration} -:Issuer Address: ${this.issuerAddress} -:Recipient Name: ${this.recipientName} -:Recipient Company Registrations: ${recipientCompanyRegistration} -:Recipient Address: ${this.recipientAddress} -:Dates: ${dates} -:Date of Issue: ${this.date}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/product/us/index.ts b/src/product/us/index.ts index d3c7aee1c..c431949f9 100644 --- a/src/product/us/index.ts +++ b/src/product/us/index.ts @@ -2,4 +2,3 @@ export { BankCheckV1 } from "./bankCheck/bankCheckV1"; export { HealthcareCardV1 } from "./healthcareCard/healthcareCardV1"; export { UsMailV2 } from "./usMail/usMailV2"; export { UsMailV3 } from "./usMail/usMailV3"; -export { W9V1 } from "./w9/w9V1"; diff --git a/src/product/us/internal.ts b/src/product/us/internal.ts index 1231e431c..849fc79cd 100644 --- a/src/product/us/internal.ts +++ b/src/product/us/internal.ts @@ -1,4 +1,3 @@ export * as bankCheck from "./bankCheck/internal"; export * as healthcareCard from "./healthcareCard/internal"; export * as usMail from "./usMail/internal"; -export * as w9 from "./w9/internal"; diff --git a/src/product/us/w9/index.ts b/src/product/us/w9/index.ts deleted file mode 100644 index 6fbecda4c..000000000 --- a/src/product/us/w9/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { W9V1 } from "./w9V1"; diff --git a/src/product/us/w9/internal.ts b/src/product/us/w9/internal.ts deleted file mode 100644 index b9305b5a7..000000000 --- a/src/product/us/w9/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { W9V1 } from "./w9V1"; -export { W9V1Document } from "./w9V1Document"; -export { W9V1Page } from "./w9V1Page"; diff --git a/src/product/us/w9/w9V1.ts b/src/product/us/w9/w9V1.ts deleted file mode 100644 index b1d80efa6..000000000 --- a/src/product/us/w9/w9V1.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { W9V1Document } from "./w9V1Document"; -import { W9V1Page } from "./w9V1Page"; - -/** - * W9 API version 1 inference prediction. - */ -export class W9V1 extends Inference { - /** The endpoint's name. */ - endpointName = "us_w9"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: W9V1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new W9V1Document(); - rawPrediction["pages"].forEach( - (page: StringDict) => { - if (page.prediction !== undefined && page.prediction !== null && - Object.keys(page.prediction).length > 0) { - this.pages.push(new Page( - W9V1Page, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/product/us/w9/w9V1Document.ts b/src/product/us/w9/w9V1Document.ts deleted file mode 100644 index ea9ec1a41..000000000 --- a/src/product/us/w9/w9V1Document.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Prediction } from "../../../parsing/common"; - - -/** - * W9 API version 1.0 document data. - */ -export class W9V1Document implements Prediction { - /** - * Default string representation. - */ - toString(): string { - return ""; - } -} diff --git a/src/product/us/w9/w9V1Page.ts b/src/product/us/w9/w9V1Page.ts deleted file mode 100644 index 14c3d1c68..000000000 --- a/src/product/us/w9/w9V1Page.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { StringDict, cleanOutString } from "../../../parsing/common"; -import { PositionField, StringField } from "../../../parsing/standard"; - -import { W9V1Document } from "./w9V1Document"; - -/** - * W9 API version 1.0 page data. - */ -export class W9V1Page extends W9V1Document { - /** The street address (number, street, and apt. or suite no.) of the applicant. */ - address: StringField; - /** The business name or disregarded entity name, if different from Name. */ - businessName: StringField; - /** The city, state, and ZIP code of the applicant. */ - cityStateZip: StringField; - /** The employer identification number. */ - ein: StringField; - /** Name as shown on the applicant's income tax return. */ - name: StringField; - /** Position of the signature date on the document. */ - signatureDatePosition: PositionField; - /** Position of the signature on the document. */ - signaturePosition: PositionField; - /** The applicant's social security number. */ - ssn: StringField; - /** The federal tax classification, which can vary depending on the revision date. */ - taxClassification: StringField; - /** Depending on revision year, among S, C, P or D for Limited Liability Company Classification. */ - taxClassificationLlc: StringField; - /** Tax Classification Other Details. */ - taxClassificationOtherDetails: StringField; - /** The Revision month and year of the W9 form. */ - w9RevisionDate: StringField; - - constructor(rawPrediction: StringDict, pageId?: number) { - super(); - - this.address = new StringField({ - prediction: rawPrediction["address"], - pageId: pageId, - }); - this.businessName = new StringField({ - prediction: rawPrediction["business_name"], - pageId: pageId, - }); - this.cityStateZip = new StringField({ - prediction: rawPrediction["city_state_zip"], - pageId: pageId, - }); - this.ein = new StringField({ - prediction: rawPrediction["ein"], - pageId: pageId, - }); - this.name = new StringField({ - prediction: rawPrediction["name"], - pageId: pageId, - }); - this.signatureDatePosition = new PositionField({ - prediction: rawPrediction["signature_date_position"], - pageId: pageId, - }); - this.signaturePosition = new PositionField({ - prediction: rawPrediction["signature_position"], - pageId: pageId, - }); - this.ssn = new StringField({ - prediction: rawPrediction["ssn"], - pageId: pageId, - }); - this.taxClassification = new StringField({ - prediction: rawPrediction["tax_classification"], - pageId: pageId, - }); - this.taxClassificationLlc = new StringField({ - prediction: rawPrediction["tax_classification_llc"], - pageId: pageId, - }); - this.taxClassificationOtherDetails = new StringField({ - prediction: rawPrediction["tax_classification_other_details"], - pageId: pageId, - }); - this.w9RevisionDate = new StringField({ - prediction: rawPrediction["w9_revision_date"], - pageId: pageId, - }); - } - - toString(): string { - const outStr = `:Name: ${this.name} -:SSN: ${this.ssn} -:Address: ${this.address} -:City State Zip: ${this.cityStateZip} -:Business Name: ${this.businessName} -:EIN: ${this.ein} -:Tax Classification: ${this.taxClassification} -:Tax Classification Other Details: ${this.taxClassificationOtherDetails} -:W9 Revision Date: ${this.w9RevisionDate} -:Signature Position: ${this.signaturePosition} -:Signature Date Position: ${this.signatureDatePosition} -:Tax Classification LLC: ${this.taxClassificationLlc}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/tests/product/proofOfAddress/proofOfAddressV1.spec.ts b/tests/product/proofOfAddress/proofOfAddressV1.spec.ts deleted file mode 100644 index aa5d2bcb5..000000000 --- a/tests/product/proofOfAddress/proofOfAddressV1.spec.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { promises as fs } from "fs"; -import * as path from "path"; -import { expect } from "chai"; -import * as mindee from "../../../src"; - - -const dataPath = { - complete: "tests/data/products/proof_of_address/response_v1/complete.json", - empty: "tests/data/products/proof_of_address/response_v1/empty.json", - docString: "tests/data/products/proof_of_address/response_v1/summary_full.rst", - page0String: "tests/data/products/proof_of_address/response_v1/summary_page0.rst", -}; - -describe("ProofOfAddressV1 Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.empty)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.ProofOfAddressV1, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.locale.value).to.be.undefined; - expect(docPrediction.issuerName.value).to.be.undefined; - expect(docPrediction.issuerCompanyRegistration.length).to.be.equals(0); - expect(docPrediction.issuerAddress.value).to.be.undefined; - expect(docPrediction.recipientName.value).to.be.undefined; - expect(docPrediction.recipientCompanyRegistration.length).to.be.equals(0); - expect(docPrediction.recipientAddress.value).to.be.undefined; - expect(docPrediction.dates.length).to.be.equals(0); - expect(docPrediction.date.value).to.be.undefined; - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.ProofOfAddressV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); diff --git a/tests/product/us/w9/w9V1.spec.ts b/tests/product/us/w9/w9V1.spec.ts deleted file mode 100644 index 4131a51b5..000000000 --- a/tests/product/us/w9/w9V1.spec.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { promises as fs } from "fs"; -import * as path from "path"; -import { expect } from "chai"; -import * as mindee from "../../../../src"; - - -const dataPath = { - complete: "tests/data/products/us_w9/response_v1/complete.json", - empty: "tests/data/products/us_w9/response_v1/empty.json", - docString: "tests/data/products/us_w9/response_v1/summary_full.rst", - page0String: "tests/data/products/us_w9/response_v1/summary_page0.rst", -}; - -describe("W9V1 Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.empty)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.us.W9V1, response.document); - const pagePrediction = doc.inference.pages[0].prediction; - expect(pagePrediction.name.value).to.be.undefined; - expect(pagePrediction.ssn.value).to.be.undefined; - expect(pagePrediction.address.value).to.be.undefined; - expect(pagePrediction.cityStateZip.value).to.be.undefined; - expect(pagePrediction.businessName.value).to.be.undefined; - expect(pagePrediction.ein.value).to.be.undefined; - expect(pagePrediction.taxClassification.value).to.be.undefined; - expect(pagePrediction.taxClassificationOtherDetails.value).to.be.undefined; - expect(pagePrediction.w9RevisionDate.value).to.be.undefined; - expect(pagePrediction.signaturePosition.polygon.length).to.be.equals(0); - expect(pagePrediction.signatureDatePosition.polygon.length).to.be.equals(0); - expect(pagePrediction.taxClassificationLlc.value).to.be.undefined; - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.us.W9V1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); - it("should load a complete page 0 prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.us.W9V1, response.document); - const page0 = doc.inference.pages[0]; - const docString = await fs.readFile(path.join(dataPath.page0String)); - expect(page0.toString()).to.be.equals(docString.toString()); - }); -});