From aa2fe2c1e6a05405dbb987f1bbbc96128358ddd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Thu, 12 Feb 2026 11:36:15 +0100 Subject: [PATCH 1/4] :coffin: remove payslip_fra_v2 & idcard_fr_v1 --- docs/code_samples/idcard_fr_v1.txt | 25 --- docs/code_samples/payslip_fra_v2_async.txt | 25 --- src/v1/product/fr/idCard/idCardV1.ts | 35 --- src/v1/product/fr/idCard/idCardV1Document.ts | 99 --------- src/v1/product/fr/idCard/idCardV1Page.ts | 25 --- src/v1/product/fr/idCard/index.ts | 3 - src/v1/product/fr/index.ts | 2 - src/v1/product/fr/payslip/index.ts | 10 - src/v1/product/fr/payslip/payslipV2.ts | 34 --- .../fr/payslip/payslipV2BankAccountDetail.ts | 71 ------ .../product/fr/payslip/payslipV2Document.ts | 106 --------- .../product/fr/payslip/payslipV2Employee.ts | 99 --------- .../product/fr/payslip/payslipV2Employer.ts | 99 --------- .../product/fr/payslip/payslipV2Employment.ts | 102 --------- .../product/fr/payslip/payslipV2PayDetail.ts | 210 ------------------ .../product/fr/payslip/payslipV2PayPeriod.ts | 85 ------- src/v1/product/fr/payslip/payslipV2Pto.ts | 99 --------- .../fr/payslip/payslipV2SalaryDetail.ts | 113 ---------- tests/v1/product/fr/idCard/idCardV1.spec.ts | 48 ---- tests/v1/product/fr/payslip/payslipV2.spec.ts | 72 ------ 20 files changed, 1362 deletions(-) delete mode 100644 docs/code_samples/idcard_fr_v1.txt delete mode 100644 docs/code_samples/payslip_fra_v2_async.txt delete mode 100644 src/v1/product/fr/idCard/idCardV1.ts delete mode 100644 src/v1/product/fr/idCard/idCardV1Document.ts delete mode 100644 src/v1/product/fr/idCard/idCardV1Page.ts delete mode 100644 src/v1/product/fr/payslip/payslipV2.ts delete mode 100644 src/v1/product/fr/payslip/payslipV2BankAccountDetail.ts delete mode 100644 src/v1/product/fr/payslip/payslipV2Document.ts delete mode 100644 src/v1/product/fr/payslip/payslipV2Employee.ts delete mode 100644 src/v1/product/fr/payslip/payslipV2Employer.ts delete mode 100644 src/v1/product/fr/payslip/payslipV2Employment.ts delete mode 100644 src/v1/product/fr/payslip/payslipV2PayDetail.ts delete mode 100644 src/v1/product/fr/payslip/payslipV2PayPeriod.ts delete mode 100644 src/v1/product/fr/payslip/payslipV2Pto.ts delete mode 100644 src/v1/product/fr/payslip/payslipV2SalaryDetail.ts delete mode 100644 tests/v1/product/fr/idCard/idCardV1.spec.ts delete mode 100644 tests/v1/product/fr/payslip/payslipV2.spec.ts diff --git a/docs/code_samples/idcard_fr_v1.txt b/docs/code_samples/idcard_fr_v1.txt deleted file mode 100644 index be7f748ba..000000000 --- a/docs/code_samples/idcard_fr_v1.txt +++ /dev/null @@ -1,25 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.v1.Client( - { apiKey: "my-api-key" } -); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.parse( - mindee.v1.product.fr.IdCardV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/payslip_fra_v2_async.txt b/docs/code_samples/payslip_fra_v2_async.txt deleted file mode 100644 index 4db98d329..000000000 --- a/docs/code_samples/payslip_fra_v2_async.txt +++ /dev/null @@ -1,25 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.v1.Client( - { apiKey: "my-api-key" } -); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.v1.product.fr.PayslipV2, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/src/v1/product/fr/idCard/idCardV1.ts b/src/v1/product/fr/idCard/idCardV1.ts deleted file mode 100644 index ef65fcd01..000000000 --- a/src/v1/product/fr/idCard/idCardV1.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; -import { IdCardV1Document } from "./idCardV1Document.js"; -import { IdCardV1Page } from "./idCardV1Page.js"; - -/** - * Carte Nationale d'Identité API version 1 inference prediction. - */ -export class IdCardV1 extends Inference { - /** The endpoint's name. */ - endpointName = "idcard_fr"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: IdCardV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new IdCardV1Document(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( - IdCardV1Page, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/v1/product/fr/idCard/idCardV1Document.ts b/src/v1/product/fr/idCard/idCardV1Document.ts deleted file mode 100644 index a2ab1e3e2..000000000 --- a/src/v1/product/fr/idCard/idCardV1Document.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString, -} from "@/v1/parsing/common/index.js"; -import { DateField, StringField } from "@/v1/parsing/standard/index.js"; - -/** - * Carte Nationale d'Identité API version 1.1 document data. - */ -export class IdCardV1Document implements Prediction { - /** The name of the issuing authority. */ - authority: StringField; - /** The date of birth of the card holder. */ - birthDate: DateField; - /** The place of birth of the card holder. */ - birthPlace: StringField; - /** The expiry date of the identification card. */ - expiryDate: DateField; - /** The gender of the card holder. */ - gender: StringField; - /** The given name(s) of the card holder. */ - givenNames: StringField[] = []; - /** The identification card number. */ - idNumber: StringField; - /** Machine Readable Zone, first line */ - mrz1: StringField; - /** Machine Readable Zone, second line */ - mrz2: StringField; - /** The surname of the card holder. */ - surname: StringField; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.authority = new StringField({ - prediction: rawPrediction["authority"], - pageId: pageId, - }); - this.birthDate = new DateField({ - prediction: rawPrediction["birth_date"], - pageId: pageId, - }); - this.birthPlace = new StringField({ - prediction: rawPrediction["birth_place"], - pageId: pageId, - }); - this.expiryDate = new DateField({ - prediction: rawPrediction["expiry_date"], - pageId: pageId, - }); - this.gender = new StringField({ - prediction: rawPrediction["gender"], - pageId: pageId, - }); - rawPrediction["given_names"] && - rawPrediction["given_names"].map( - (itemPrediction: StringDict) => - this.givenNames.push( - new StringField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.idNumber = new StringField({ - prediction: rawPrediction["id_number"], - pageId: pageId, - }); - this.mrz1 = new StringField({ - prediction: rawPrediction["mrz1"], - pageId: pageId, - }); - this.mrz2 = new StringField({ - prediction: rawPrediction["mrz2"], - pageId: pageId, - }); - this.surname = new StringField({ - prediction: rawPrediction["surname"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - const givenNames = this.givenNames.join("\n "); - const outStr = `:Identity Number: ${this.idNumber} -:Given Name(s): ${givenNames} -:Surname: ${this.surname} -:Date of Birth: ${this.birthDate} -:Place of Birth: ${this.birthPlace} -:Expiry Date: ${this.expiryDate} -:Issuing Authority: ${this.authority} -:Gender: ${this.gender} -:MRZ Line 1: ${this.mrz1} -:MRZ Line 2: ${this.mrz2}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/fr/idCard/idCardV1Page.ts b/src/v1/product/fr/idCard/idCardV1Page.ts deleted file mode 100644 index 2f12718eb..000000000 --- a/src/v1/product/fr/idCard/idCardV1Page.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { StringDict, cleanOutString } from "@/v1/parsing/common/index.js"; -import { ClassificationField } from "@/v1/parsing/standard/index.js"; -import { IdCardV1Document } from "./idCardV1Document.js"; - -/** - * Carte Nationale d'Identité API version 1.1 page data. - */ -export class IdCardV1Page extends IdCardV1Document { - /** The side of the document which is visible. */ - documentSide: ClassificationField; - - constructor(rawPrediction: StringDict, pageId?: number) { - super(rawPrediction, pageId); - - this.documentSide = new ClassificationField({ - prediction: rawPrediction["document_side"], - }); - } - - toString(): string { - let outStr = `:Document Side: ${this.documentSide}`.trimEnd(); - outStr += "\n" + super.toString(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/fr/idCard/index.ts b/src/v1/product/fr/idCard/index.ts index f8dc520e9..5e20b16da 100644 --- a/src/v1/product/fr/idCard/index.ts +++ b/src/v1/product/fr/idCard/index.ts @@ -1,6 +1,3 @@ -export { IdCardV1 } from "./idCardV1.js"; -export { IdCardV1Document } from "./idCardV1Document.js"; -export { IdCardV1Page } from "./idCardV1Page.js"; export { IdCardV2 } from "./idCardV2.js"; export { IdCardV2Document } from "./idCardV2Document.js"; export { IdCardV2Page } from "./idCardV2Page.js"; diff --git a/src/v1/product/fr/index.ts b/src/v1/product/fr/index.ts index da4a208c5..3960a99f5 100644 --- a/src/v1/product/fr/index.ts +++ b/src/v1/product/fr/index.ts @@ -2,9 +2,7 @@ export { BankAccountDetailsV1 } from "./bankAccountDetails/index.js"; export { BankAccountDetailsV2 } from "./bankAccountDetails/index.js"; export { EnergyBillV1 } from "./energyBill/index.js"; export { HealthCardV1 } from "./healthCard/index.js"; -export { IdCardV1 } from "./idCard/index.js"; export { IdCardV2 } from "./idCard/index.js"; -export { PayslipV2 } from "./payslip/index.js"; export { PayslipV3 } from "./payslip/index.js"; export { CarteGriseV1 } from "./carteGrise/index.js"; diff --git a/src/v1/product/fr/payslip/index.ts b/src/v1/product/fr/payslip/index.ts index f528d0352..81866fd57 100644 --- a/src/v1/product/fr/payslip/index.ts +++ b/src/v1/product/fr/payslip/index.ts @@ -1,13 +1,3 @@ -export { PayslipV2 } from "./payslipV2.js"; -export { PayslipV2BankAccountDetail } from "./payslipV2BankAccountDetail.js"; -export { PayslipV2Document } from "./payslipV2Document.js"; -export { PayslipV2Employee } from "./payslipV2Employee.js"; -export { PayslipV2Employer } from "./payslipV2Employer.js"; -export { PayslipV2Employment } from "./payslipV2Employment.js"; -export { PayslipV2PayDetail } from "./payslipV2PayDetail.js"; -export { PayslipV2PayPeriod } from "./payslipV2PayPeriod.js"; -export { PayslipV2Pto } from "./payslipV2Pto.js"; -export { PayslipV2SalaryDetail } from "./payslipV2SalaryDetail.js"; export { PayslipV3 } from "./payslipV3.js"; export { PayslipV3BankAccountDetail } from "./payslipV3BankAccountDetail.js"; export { PayslipV3Document } from "./payslipV3Document.js"; diff --git a/src/v1/product/fr/payslip/payslipV2.ts b/src/v1/product/fr/payslip/payslipV2.ts deleted file mode 100644 index c2a567479..000000000 --- a/src/v1/product/fr/payslip/payslipV2.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; -import { PayslipV2Document } from "./payslipV2Document.js"; - -/** - * Payslip API version 2 inference prediction. - */ -export class PayslipV2 extends Inference { - /** The endpoint's name. */ - endpointName = "payslip_fra"; - /** The endpoint's version. */ - endpointVersion = "2"; - /** The document-level prediction. */ - prediction: PayslipV2Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new PayslipV2Document(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( - PayslipV2Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/v1/product/fr/payslip/payslipV2BankAccountDetail.ts b/src/v1/product/fr/payslip/payslipV2BankAccountDetail.ts deleted file mode 100644 index 2242d3baa..000000000 --- a/src/v1/product/fr/payslip/payslipV2BankAccountDetail.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the employee's bank account. - */ -export class PayslipV2BankAccountDetail { - /** The name of the bank. */ - bankName: string | null; - /** The IBAN of the bank account. */ - iban: string | null; - /** The SWIFT code of the bank. */ - swift: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.bankName = prediction["bank_name"]; - this.iban = prediction["iban"]; - this.swift = prediction["swift"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - bankName: this.bankName ?? "", - iban: this.iban ?? "", - swift: this.swift ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Bank Name: " + - printable.bankName + - ", IBAN: " + - printable.iban + - ", SWIFT: " + - printable.swift - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Bank Name: ${printable.bankName} - :IBAN: ${printable.iban} - :SWIFT: ${printable.swift}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV2Document.ts b/src/v1/product/fr/payslip/payslipV2Document.ts deleted file mode 100644 index 06f27df6a..000000000 --- a/src/v1/product/fr/payslip/payslipV2Document.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString,lineSeparator, -} from "@/v1/parsing/common/index.js"; -import { PayslipV2Employee } from "./payslipV2Employee.js"; -import { PayslipV2Employer } from "./payslipV2Employer.js"; -import { PayslipV2BankAccountDetail } from "./payslipV2BankAccountDetail.js"; -import { PayslipV2Employment } from "./payslipV2Employment.js"; -import { PayslipV2SalaryDetail } from "./payslipV2SalaryDetail.js"; -import { PayslipV2PayDetail } from "./payslipV2PayDetail.js"; -import { PayslipV2Pto } from "./payslipV2Pto.js"; -import { PayslipV2PayPeriod } from "./payslipV2PayPeriod.js"; - - -/** - * Payslip API version 2.0 document data. - */ -export class PayslipV2Document implements Prediction { - /** Information about the employee's bank account. */ - bankAccountDetails: PayslipV2BankAccountDetail; - /** Information about the employee. */ - employee: PayslipV2Employee; - /** Information about the employer. */ - employer: PayslipV2Employer; - /** Information about the employment. */ - employment: PayslipV2Employment; - /** Detailed information about the pay. */ - payDetail: PayslipV2PayDetail; - /** Information about the pay period. */ - payPeriod: PayslipV2PayPeriod; - /** Information about paid time off. */ - pto: PayslipV2Pto; - /** Detailed information about the earnings. */ - salaryDetails: PayslipV2SalaryDetail[] = []; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.bankAccountDetails = new PayslipV2BankAccountDetail({ - prediction: rawPrediction["bank_account_details"], - pageId: pageId, - }); - this.employee = new PayslipV2Employee({ - prediction: rawPrediction["employee"], - pageId: pageId, - }); - this.employer = new PayslipV2Employer({ - prediction: rawPrediction["employer"], - pageId: pageId, - }); - this.employment = new PayslipV2Employment({ - prediction: rawPrediction["employment"], - pageId: pageId, - }); - this.payDetail = new PayslipV2PayDetail({ - prediction: rawPrediction["pay_detail"], - pageId: pageId, - }); - this.payPeriod = new PayslipV2PayPeriod({ - prediction: rawPrediction["pay_period"], - pageId: pageId, - }); - this.pto = new PayslipV2Pto({ - prediction: rawPrediction["pto"], - pageId: pageId, - }); - rawPrediction["salary_details"] && - rawPrediction["salary_details"].map( - (itemPrediction: StringDict) => - this.salaryDetails.push( - new PayslipV2SalaryDetail({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - } - - /** - * Default string representation. - */ - toString(): string { - let salaryDetailsSummary:string = ""; - if (this.salaryDetails && this.salaryDetails.length > 0) { - const salaryDetailsColSizes:number[] = [14, 11, 38, 11]; - salaryDetailsSummary += "\n" + lineSeparator(salaryDetailsColSizes, "-") + "\n "; - salaryDetailsSummary += "| Amount "; - salaryDetailsSummary += "| Base "; - salaryDetailsSummary += "| Description "; - salaryDetailsSummary += "| Rate "; - salaryDetailsSummary += "|\n" + lineSeparator(salaryDetailsColSizes, "="); - salaryDetailsSummary += this.salaryDetails.map( - (item) => - "\n " + item.toTableLine() + "\n" + lineSeparator(salaryDetailsColSizes, "-") - ).join(""); - } - const outStr = `:Employee: ${this.employee.toFieldList()} -:Employer: ${this.employer.toFieldList()} -:Bank Account Details: ${this.bankAccountDetails.toFieldList()} -:Employment: ${this.employment.toFieldList()} -:Salary Details: ${salaryDetailsSummary} -:Pay Detail: ${this.payDetail.toFieldList()} -:PTO: ${this.pto.toFieldList()} -:Pay Period: ${this.payPeriod.toFieldList()}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/fr/payslip/payslipV2Employee.ts b/src/v1/product/fr/payslip/payslipV2Employee.ts deleted file mode 100644 index c48387238..000000000 --- a/src/v1/product/fr/payslip/payslipV2Employee.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the employee. - */ -export class PayslipV2Employee { - /** The address of the employee. */ - address: string | null; - /** The date of birth of the employee. */ - dateOfBirth: string | null; - /** The first name of the employee. */ - firstName: string | null; - /** The last name of the employee. */ - lastName: string | null; - /** The phone number of the employee. */ - phoneNumber: string | null; - /** The registration number of the employee. */ - registrationNumber: string | null; - /** The social security number of the employee. */ - socialSecurityNumber: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.address = prediction["address"]; - this.dateOfBirth = prediction["date_of_birth"]; - this.firstName = prediction["first_name"]; - this.lastName = prediction["last_name"]; - this.phoneNumber = prediction["phone_number"]; - this.registrationNumber = prediction["registration_number"]; - this.socialSecurityNumber = prediction["social_security_number"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - address: this.address ?? "", - dateOfBirth: this.dateOfBirth ?? "", - firstName: this.firstName ?? "", - lastName: this.lastName ?? "", - phoneNumber: this.phoneNumber ?? "", - registrationNumber: this.registrationNumber ?? "", - socialSecurityNumber: this.socialSecurityNumber ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Address: " + - printable.address + - ", Date of Birth: " + - printable.dateOfBirth + - ", First Name: " + - printable.firstName + - ", Last Name: " + - printable.lastName + - ", Phone Number: " + - printable.phoneNumber + - ", Registration Number: " + - printable.registrationNumber + - ", Social Security Number: " + - printable.socialSecurityNumber - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Address: ${printable.address} - :Date of Birth: ${printable.dateOfBirth} - :First Name: ${printable.firstName} - :Last Name: ${printable.lastName} - :Phone Number: ${printable.phoneNumber} - :Registration Number: ${printable.registrationNumber} - :Social Security Number: ${printable.socialSecurityNumber}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV2Employer.ts b/src/v1/product/fr/payslip/payslipV2Employer.ts deleted file mode 100644 index 69e9d580f..000000000 --- a/src/v1/product/fr/payslip/payslipV2Employer.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the employer. - */ -export class PayslipV2Employer { - /** The address of the employer. */ - address: string | null; - /** The company ID of the employer. */ - companyId: string | null; - /** The site of the company. */ - companySite: string | null; - /** The NAF code of the employer. */ - nafCode: string | null; - /** The name of the employer. */ - name: string | null; - /** The phone number of the employer. */ - phoneNumber: string | null; - /** The URSSAF number of the employer. */ - urssafNumber: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.address = prediction["address"]; - this.companyId = prediction["company_id"]; - this.companySite = prediction["company_site"]; - this.nafCode = prediction["naf_code"]; - this.name = prediction["name"]; - this.phoneNumber = prediction["phone_number"]; - this.urssafNumber = prediction["urssaf_number"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - address: this.address ?? "", - companyId: this.companyId ?? "", - companySite: this.companySite ?? "", - nafCode: this.nafCode ?? "", - name: this.name ?? "", - phoneNumber: this.phoneNumber ?? "", - urssafNumber: this.urssafNumber ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Address: " + - printable.address + - ", Company ID: " + - printable.companyId + - ", Company Site: " + - printable.companySite + - ", NAF Code: " + - printable.nafCode + - ", Name: " + - printable.name + - ", Phone Number: " + - printable.phoneNumber + - ", URSSAF Number: " + - printable.urssafNumber - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Address: ${printable.address} - :Company ID: ${printable.companyId} - :Company Site: ${printable.companySite} - :NAF Code: ${printable.nafCode} - :Name: ${printable.name} - :Phone Number: ${printable.phoneNumber} - :URSSAF Number: ${printable.urssafNumber}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV2Employment.ts b/src/v1/product/fr/payslip/payslipV2Employment.ts deleted file mode 100644 index 1f2b0fe11..000000000 --- a/src/v1/product/fr/payslip/payslipV2Employment.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { floatToString } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the employment. - */ -export class PayslipV2Employment { - /** The category of the employment. */ - category: string | null; - /** The coefficient of the employment. */ - coefficient: number | null; - /** The collective agreement of the employment. */ - collectiveAgreement: string | null; - /** The job title of the employee. */ - jobTitle: string | null; - /** The position level of the employment. */ - positionLevel: string | null; - /** The start date of the employment. */ - startDate: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.category = prediction["category"]; - if ( - prediction["coefficient"] !== undefined && - prediction["coefficient"] !== null && - !isNaN(prediction["coefficient"]) - ) { - this.coefficient = +parseFloat(prediction["coefficient"]); - } else { - this.coefficient = null; - } - this.collectiveAgreement = prediction["collective_agreement"]; - this.jobTitle = prediction["job_title"]; - this.positionLevel = prediction["position_level"]; - this.startDate = prediction["start_date"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - category: this.category ?? "", - coefficient: - this.coefficient !== undefined ? floatToString(this.coefficient) : "", - collectiveAgreement: this.collectiveAgreement ?? "", - jobTitle: this.jobTitle ?? "", - positionLevel: this.positionLevel ?? "", - startDate: this.startDate ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Category: " + - printable.category + - ", Coefficient: " + - printable.coefficient + - ", Collective Agreement: " + - printable.collectiveAgreement + - ", Job Title: " + - printable.jobTitle + - ", Position Level: " + - printable.positionLevel + - ", Start Date: " + - printable.startDate - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Category: ${printable.category} - :Coefficient: ${printable.coefficient} - :Collective Agreement: ${printable.collectiveAgreement} - :Job Title: ${printable.jobTitle} - :Position Level: ${printable.positionLevel} - :Start Date: ${printable.startDate}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV2PayDetail.ts b/src/v1/product/fr/payslip/payslipV2PayDetail.ts deleted file mode 100644 index 56add1efe..000000000 --- a/src/v1/product/fr/payslip/payslipV2PayDetail.ts +++ /dev/null @@ -1,210 +0,0 @@ -import { floatToString } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Detailed information about the pay. - */ -export class PayslipV2PayDetail { - /** The gross salary of the employee. */ - grossSalary: number | null; - /** The year-to-date gross salary of the employee. */ - grossSalaryYtd: number | null; - /** The income tax rate of the employee. */ - incomeTaxRate: number | null; - /** The income tax withheld from the employee's pay. */ - incomeTaxWithheld: number | null; - /** The net paid amount of the employee. */ - netPaid: number | null; - /** The net paid amount before tax of the employee. */ - netPaidBeforeTax: number | null; - /** The net taxable amount of the employee. */ - netTaxable: number | null; - /** The year-to-date net taxable amount of the employee. */ - netTaxableYtd: number | null; - /** The total cost to the employer. */ - totalCostEmployer: number | null; - /** The total taxes and deductions of the employee. */ - totalTaxesAndDeductions: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["gross_salary"] !== undefined && - prediction["gross_salary"] !== null && - !isNaN(prediction["gross_salary"]) - ) { - this.grossSalary = +parseFloat(prediction["gross_salary"]); - } else { - this.grossSalary = null; - } - if ( - prediction["gross_salary_ytd"] !== undefined && - prediction["gross_salary_ytd"] !== null && - !isNaN(prediction["gross_salary_ytd"]) - ) { - this.grossSalaryYtd = +parseFloat(prediction["gross_salary_ytd"]); - } else { - this.grossSalaryYtd = null; - } - if ( - prediction["income_tax_rate"] !== undefined && - prediction["income_tax_rate"] !== null && - !isNaN(prediction["income_tax_rate"]) - ) { - this.incomeTaxRate = +parseFloat(prediction["income_tax_rate"]); - } else { - this.incomeTaxRate = null; - } - if ( - prediction["income_tax_withheld"] !== undefined && - prediction["income_tax_withheld"] !== null && - !isNaN(prediction["income_tax_withheld"]) - ) { - this.incomeTaxWithheld = +parseFloat(prediction["income_tax_withheld"]); - } else { - this.incomeTaxWithheld = null; - } - if ( - prediction["net_paid"] !== undefined && - prediction["net_paid"] !== null && - !isNaN(prediction["net_paid"]) - ) { - this.netPaid = +parseFloat(prediction["net_paid"]); - } else { - this.netPaid = null; - } - if ( - prediction["net_paid_before_tax"] !== undefined && - prediction["net_paid_before_tax"] !== null && - !isNaN(prediction["net_paid_before_tax"]) - ) { - this.netPaidBeforeTax = +parseFloat(prediction["net_paid_before_tax"]); - } else { - this.netPaidBeforeTax = null; - } - if ( - prediction["net_taxable"] !== undefined && - prediction["net_taxable"] !== null && - !isNaN(prediction["net_taxable"]) - ) { - this.netTaxable = +parseFloat(prediction["net_taxable"]); - } else { - this.netTaxable = null; - } - if ( - prediction["net_taxable_ytd"] !== undefined && - prediction["net_taxable_ytd"] !== null && - !isNaN(prediction["net_taxable_ytd"]) - ) { - this.netTaxableYtd = +parseFloat(prediction["net_taxable_ytd"]); - } else { - this.netTaxableYtd = null; - } - if ( - prediction["total_cost_employer"] !== undefined && - prediction["total_cost_employer"] !== null && - !isNaN(prediction["total_cost_employer"]) - ) { - this.totalCostEmployer = +parseFloat(prediction["total_cost_employer"]); - } else { - this.totalCostEmployer = null; - } - if ( - prediction["total_taxes_and_deductions"] !== undefined && - prediction["total_taxes_and_deductions"] !== null && - !isNaN(prediction["total_taxes_and_deductions"]) - ) { - this.totalTaxesAndDeductions = +parseFloat(prediction["total_taxes_and_deductions"]); - } else { - this.totalTaxesAndDeductions = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - grossSalary: - this.grossSalary !== undefined ? floatToString(this.grossSalary) : "", - grossSalaryYtd: - this.grossSalaryYtd !== undefined ? floatToString(this.grossSalaryYtd) : "", - incomeTaxRate: - this.incomeTaxRate !== undefined ? floatToString(this.incomeTaxRate) : "", - incomeTaxWithheld: - this.incomeTaxWithheld !== undefined ? floatToString(this.incomeTaxWithheld) : "", - netPaid: this.netPaid !== undefined ? floatToString(this.netPaid) : "", - netPaidBeforeTax: - this.netPaidBeforeTax !== undefined ? floatToString(this.netPaidBeforeTax) : "", - netTaxable: - this.netTaxable !== undefined ? floatToString(this.netTaxable) : "", - netTaxableYtd: - this.netTaxableYtd !== undefined ? floatToString(this.netTaxableYtd) : "", - totalCostEmployer: - this.totalCostEmployer !== undefined ? floatToString(this.totalCostEmployer) : "", - totalTaxesAndDeductions: - this.totalTaxesAndDeductions !== undefined ? floatToString(this.totalTaxesAndDeductions) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Gross Salary: " + - printable.grossSalary + - ", Gross Salary YTD: " + - printable.grossSalaryYtd + - ", Income Tax Rate: " + - printable.incomeTaxRate + - ", Income Tax Withheld: " + - printable.incomeTaxWithheld + - ", Net Paid: " + - printable.netPaid + - ", Net Paid Before Tax: " + - printable.netPaidBeforeTax + - ", Net Taxable: " + - printable.netTaxable + - ", Net Taxable YTD: " + - printable.netTaxableYtd + - ", Total Cost Employer: " + - printable.totalCostEmployer + - ", Total Taxes and Deductions: " + - printable.totalTaxesAndDeductions - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Gross Salary: ${printable.grossSalary} - :Gross Salary YTD: ${printable.grossSalaryYtd} - :Income Tax Rate: ${printable.incomeTaxRate} - :Income Tax Withheld: ${printable.incomeTaxWithheld} - :Net Paid: ${printable.netPaid} - :Net Paid Before Tax: ${printable.netPaidBeforeTax} - :Net Taxable: ${printable.netTaxable} - :Net Taxable YTD: ${printable.netTaxableYtd} - :Total Cost Employer: ${printable.totalCostEmployer} - :Total Taxes and Deductions: ${printable.totalTaxesAndDeductions}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV2PayPeriod.ts b/src/v1/product/fr/payslip/payslipV2PayPeriod.ts deleted file mode 100644 index 602946c69..000000000 --- a/src/v1/product/fr/payslip/payslipV2PayPeriod.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the pay period. - */ -export class PayslipV2PayPeriod { - /** The end date of the pay period. */ - endDate: string | null; - /** The month of the pay period. */ - month: string | null; - /** The date of payment for the pay period. */ - paymentDate: string | null; - /** The start date of the pay period. */ - startDate: string | null; - /** The year of the pay period. */ - year: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.endDate = prediction["end_date"]; - this.month = prediction["month"]; - this.paymentDate = prediction["payment_date"]; - this.startDate = prediction["start_date"]; - this.year = prediction["year"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - endDate: this.endDate ?? "", - month: this.month ?? "", - paymentDate: this.paymentDate ?? "", - startDate: this.startDate ?? "", - year: this.year ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "End Date: " + - printable.endDate + - ", Month: " + - printable.month + - ", Payment Date: " + - printable.paymentDate + - ", Start Date: " + - printable.startDate + - ", Year: " + - printable.year - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :End Date: ${printable.endDate} - :Month: ${printable.month} - :Payment Date: ${printable.paymentDate} - :Start Date: ${printable.startDate} - :Year: ${printable.year}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV2Pto.ts b/src/v1/product/fr/payslip/payslipV2Pto.ts deleted file mode 100644 index d31fd5841..000000000 --- a/src/v1/product/fr/payslip/payslipV2Pto.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { floatToString } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about paid time off. - */ -export class PayslipV2Pto { - /** The amount of paid time off accrued in this period. */ - accruedThisPeriod: number | null; - /** The balance of paid time off at the end of the period. */ - balanceEndOfPeriod: number | null; - /** The amount of paid time off used in this period. */ - usedThisPeriod: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["accrued_this_period"] !== undefined && - prediction["accrued_this_period"] !== null && - !isNaN(prediction["accrued_this_period"]) - ) { - this.accruedThisPeriod = +parseFloat(prediction["accrued_this_period"]); - } else { - this.accruedThisPeriod = null; - } - if ( - prediction["balance_end_of_period"] !== undefined && - prediction["balance_end_of_period"] !== null && - !isNaN(prediction["balance_end_of_period"]) - ) { - this.balanceEndOfPeriod = +parseFloat(prediction["balance_end_of_period"]); - } else { - this.balanceEndOfPeriod = null; - } - if ( - prediction["used_this_period"] !== undefined && - prediction["used_this_period"] !== null && - !isNaN(prediction["used_this_period"]) - ) { - this.usedThisPeriod = +parseFloat(prediction["used_this_period"]); - } else { - this.usedThisPeriod = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - accruedThisPeriod: - this.accruedThisPeriod !== undefined ? floatToString(this.accruedThisPeriod) : "", - balanceEndOfPeriod: - this.balanceEndOfPeriod !== undefined ? floatToString(this.balanceEndOfPeriod) : "", - usedThisPeriod: - this.usedThisPeriod !== undefined ? floatToString(this.usedThisPeriod) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Accrued This Period: " + - printable.accruedThisPeriod + - ", Balance End of Period: " + - printable.balanceEndOfPeriod + - ", Used This Period: " + - printable.usedThisPeriod - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Accrued This Period: ${printable.accruedThisPeriod} - :Balance End of Period: ${printable.balanceEndOfPeriod} - :Used This Period: ${printable.usedThisPeriod}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV2SalaryDetail.ts b/src/v1/product/fr/payslip/payslipV2SalaryDetail.ts deleted file mode 100644 index 5a231117b..000000000 --- a/src/v1/product/fr/payslip/payslipV2SalaryDetail.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Detailed information about the earnings. - */ -export class PayslipV2SalaryDetail { - /** The amount of the earnings. */ - amount: number | null; - /** The base value of the earnings. */ - base: number | null; - /** The description of the earnings. */ - description: string | null; - /** The rate of the earnings. */ - rate: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["amount"] !== undefined && - prediction["amount"] !== null && - !isNaN(prediction["amount"]) - ) { - this.amount = +parseFloat(prediction["amount"]); - } else { - this.amount = null; - } - if ( - prediction["base"] !== undefined && - prediction["base"] !== null && - !isNaN(prediction["base"]) - ) { - this.base = +parseFloat(prediction["base"]); - } else { - this.base = null; - } - this.description = prediction["description"]; - if ( - prediction["rate"] !== undefined && - prediction["rate"] !== null && - !isNaN(prediction["rate"]) - ) { - this.rate = +parseFloat(prediction["rate"]); - } else { - this.rate = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - amount: this.amount !== undefined ? floatToString(this.amount) : "", - base: this.base !== undefined ? floatToString(this.base) : "", - description: this.description ? - this.description.length <= 36 ? - cleanSpecialChars(this.description) : - cleanSpecialChars(this.description).slice(0, 33) + "..." : - "", - rate: this.rate !== undefined ? floatToString(this.rate) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Amount: " + - printable.amount + - ", Base: " + - printable.base + - ", Description: " + - printable.description + - ", Rate: " + - printable.rate - ); - } - - /** - * Output in a format suitable for inclusion in an rST table. - */ - toTableLine(): string { - const printable = this.#printableValues(); - return ( - "| " + - printable.amount.padEnd(12) + - " | " + - printable.base.padEnd(9) + - " | " + - printable.description.padEnd(36) + - " | " + - printable.rate.padEnd(9) + - " |" - ); - } -} diff --git a/tests/v1/product/fr/idCard/idCardV1.spec.ts b/tests/v1/product/fr/idCard/idCardV1.spec.ts deleted file mode 100644 index 0bb5892b1..000000000 --- a/tests/v1/product/fr/idCard/idCardV1.spec.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index.js"; -import { expect } from "chai"; -import * as mindee from "@/index.js"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "idcard_fr/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "idcard_fr/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "idcard_fr/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "idcard_fr/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - IdCardV1 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.v1.Document(mindee.v1.product.fr.IdCardV1, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.idNumber.value).to.be.undefined; - expect(docPrediction.givenNames.length).to.be.equals(0); - expect(docPrediction.surname.value).to.be.undefined; - expect(docPrediction.birthDate.value).to.be.undefined; - expect(docPrediction.birthPlace.value).to.be.undefined; - expect(docPrediction.expiryDate.value).to.be.undefined; - expect(docPrediction.authority.value).to.be.undefined; - expect(docPrediction.gender.value).to.be.undefined; - expect(docPrediction.mrz1.value).to.be.undefined; - expect(docPrediction.mrz2.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.v1.Document(mindee.v1.product.fr.IdCardV1, 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.v1.Document(mindee.v1.product.fr.IdCardV1, 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()); - }); -}); diff --git a/tests/v1/product/fr/payslip/payslipV2.spec.ts b/tests/v1/product/fr/payslip/payslipV2.spec.ts deleted file mode 100644 index 9dde43b0e..000000000 --- a/tests/v1/product/fr/payslip/payslipV2.spec.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index.js"; -import { expect } from "chai"; -import * as mindee from "@/index.js"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "payslip_fra/response_v2/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "payslip_fra/response_v2/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "payslip_fra/response_v2/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "payslip_fra/response_v2/summary_page0.rst"), -}; - -describe("MindeeV1 - PayslipV2 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.v1.Document(mindee.v1.product.fr.PayslipV2, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.employee.address).to.be.null; - expect(docPrediction.employee.dateOfBirth).to.be.null; - expect(docPrediction.employee.firstName).to.be.null; - expect(docPrediction.employee.lastName).to.be.null; - expect(docPrediction.employee.phoneNumber).to.be.null; - expect(docPrediction.employee.registrationNumber).to.be.null; - expect(docPrediction.employee.socialSecurityNumber).to.be.null; - expect(docPrediction.employer.address).to.be.null; - expect(docPrediction.employer.companyId).to.be.null; - expect(docPrediction.employer.companySite).to.be.null; - expect(docPrediction.employer.nafCode).to.be.null; - expect(docPrediction.employer.name).to.be.null; - expect(docPrediction.employer.phoneNumber).to.be.null; - expect(docPrediction.employer.urssafNumber).to.be.null; - expect(docPrediction.bankAccountDetails.bankName).to.be.null; - expect(docPrediction.bankAccountDetails.iban).to.be.null; - expect(docPrediction.bankAccountDetails.swift).to.be.null; - expect(docPrediction.employment.category).to.be.null; - expect(docPrediction.employment.coefficient).to.be.null; - expect(docPrediction.employment.collectiveAgreement).to.be.null; - expect(docPrediction.employment.jobTitle).to.be.null; - expect(docPrediction.employment.positionLevel).to.be.null; - expect(docPrediction.employment.startDate).to.be.null; - expect(docPrediction.salaryDetails.length).to.be.equals(0); - expect(docPrediction.payDetail.grossSalary).to.be.null; - expect(docPrediction.payDetail.grossSalaryYtd).to.be.null; - expect(docPrediction.payDetail.incomeTaxRate).to.be.null; - expect(docPrediction.payDetail.incomeTaxWithheld).to.be.null; - expect(docPrediction.payDetail.netPaid).to.be.null; - expect(docPrediction.payDetail.netPaidBeforeTax).to.be.null; - expect(docPrediction.payDetail.netTaxable).to.be.null; - expect(docPrediction.payDetail.netTaxableYtd).to.be.null; - expect(docPrediction.payDetail.totalCostEmployer).to.be.null; - expect(docPrediction.payDetail.totalTaxesAndDeductions).to.be.null; - expect(docPrediction.pto.accruedThisPeriod).to.be.null; - expect(docPrediction.pto.balanceEndOfPeriod).to.be.null; - expect(docPrediction.pto.usedThisPeriod).to.be.null; - expect(docPrediction.payPeriod.endDate).to.be.null; - expect(docPrediction.payPeriod.month).to.be.null; - expect(docPrediction.payPeriod.paymentDate).to.be.null; - expect(docPrediction.payPeriod.startDate).to.be.null; - expect(docPrediction.payPeriod.year).to.be.null; - }); - - 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.v1.Document(mindee.v1.product.fr.PayslipV2, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); From ac02bbbcb1a57fec975be3608d2fc2d43ca413b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Thu, 12 Feb 2026 12:02:53 +0100 Subject: [PATCH 2/4] :coffin: remove ind_passport_v1_async product --- docs/code_samples/ind_passport_v1_async.txt | 25 --- src/v1/product/cliProducts.ts | 10 - src/v1/product/ind/index.ts | 4 - src/v1/product/ind/indianPassport/index.ts | 2 - .../ind/indianPassport/indianPassportV1.ts | 34 ---- .../indianPassportV1Document.ts | 185 ------------------ src/v1/product/index.ts | 1 - .../indianPassport/indianPassportV1.spec.ts | 51 ----- 8 files changed, 312 deletions(-) delete mode 100644 docs/code_samples/ind_passport_v1_async.txt delete mode 100644 src/v1/product/ind/index.ts delete mode 100644 src/v1/product/ind/indianPassport/index.ts delete mode 100644 src/v1/product/ind/indianPassport/indianPassportV1.ts delete mode 100644 src/v1/product/ind/indianPassport/indianPassportV1Document.ts delete mode 100644 tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts diff --git a/docs/code_samples/ind_passport_v1_async.txt b/docs/code_samples/ind_passport_v1_async.txt deleted file mode 100644 index b8647a395..000000000 --- a/docs/code_samples/ind_passport_v1_async.txt +++ /dev/null @@ -1,25 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.v1.Client( - { apiKey: "my-api-key" } -); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.v1.product.ind.IndianPassportV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/src/v1/product/cliProducts.ts b/src/v1/product/cliProducts.ts index bae6c208c..67c97b7d1 100644 --- a/src/v1/product/cliProducts.ts +++ b/src/v1/product/cliProducts.ts @@ -118,16 +118,6 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: false, }, ], - [ - "ind-passport-india", - { - displayName: "IND Passport - India", - docClass: product.ind.IndianPassportV1, - allWords: false, - async: true, - sync: false, - }, - ], [ "international-id", { diff --git a/src/v1/product/ind/index.ts b/src/v1/product/ind/index.ts deleted file mode 100644 index 43cc766a9..000000000 --- a/src/v1/product/ind/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { IndianPassportV1 } from "./indianPassport/index.js"; - -// not sure if we want to export these -- advanced users can import them directly -export * as indianPassport from "./indianPassport/index.js"; diff --git a/src/v1/product/ind/indianPassport/index.ts b/src/v1/product/ind/indianPassport/index.ts deleted file mode 100644 index cafb04659..000000000 --- a/src/v1/product/ind/indianPassport/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { IndianPassportV1 } from "./indianPassportV1.js"; -export { IndianPassportV1Document } from "./indianPassportV1Document.js"; diff --git a/src/v1/product/ind/indianPassport/indianPassportV1.ts b/src/v1/product/ind/indianPassport/indianPassportV1.ts deleted file mode 100644 index a1d73c05f..000000000 --- a/src/v1/product/ind/indianPassport/indianPassportV1.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; -import { IndianPassportV1Document } from "./indianPassportV1Document.js"; - -/** - * Passport - India API version 1 inference prediction. - */ -export class IndianPassportV1 extends Inference { - /** The endpoint's name. */ - endpointName = "ind_passport"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: IndianPassportV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new IndianPassportV1Document(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( - IndianPassportV1Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/v1/product/ind/indianPassport/indianPassportV1Document.ts b/src/v1/product/ind/indianPassport/indianPassportV1Document.ts deleted file mode 100644 index b5559503d..000000000 --- a/src/v1/product/ind/indianPassport/indianPassportV1Document.ts +++ /dev/null @@ -1,185 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString, -} from "@/v1/parsing/common/index.js"; -import { - ClassificationField, - DateField, - StringField, -} from "@/v1/parsing/standard/index.js"; - -/** - * Passport - India API version 1.2 document data. - */ -export class IndianPassportV1Document implements Prediction { - /** The first line of the address of the passport holder. */ - address1: StringField; - /** The second line of the address of the passport holder. */ - address2: StringField; - /** The third line of the address of the passport holder. */ - address3: StringField; - /** The birth date of the passport holder, ISO format: YYYY-MM-DD. */ - birthDate: DateField; - /** The birth place of the passport holder. */ - birthPlace: StringField; - /** ISO 3166-1 alpha-3 country code (3 letters format). */ - country: StringField; - /** The date when the passport will expire, ISO format: YYYY-MM-DD. */ - expiryDate: DateField; - /** The file number of the passport document. */ - fileNumber: StringField; - /** The gender of the passport holder. */ - gender: ClassificationField; - /** The given names of the passport holder. */ - givenNames: StringField; - /** The identification number of the passport document. */ - idNumber: StringField; - /** The date when the passport was issued, ISO format: YYYY-MM-DD. */ - issuanceDate: DateField; - /** The place where the passport was issued. */ - issuancePlace: StringField; - /** The name of the legal guardian of the passport holder (if applicable). */ - legalGuardian: StringField; - /** The first line of the machine-readable zone (MRZ) of the passport document. */ - mrz1: StringField; - /** The second line of the machine-readable zone (MRZ) of the passport document. */ - mrz2: StringField; - /** The name of the mother of the passport holder. */ - nameOfMother: StringField; - /** The name of the spouse of the passport holder (if applicable). */ - nameOfSpouse: StringField; - /** The date of issue of the old passport (if applicable), ISO format: YYYY-MM-DD. */ - oldPassportDateOfIssue: DateField; - /** The number of the old passport (if applicable). */ - oldPassportNumber: StringField; - /** The place of issue of the old passport (if applicable). */ - oldPassportPlaceOfIssue: StringField; - /** The page number of the passport document. */ - pageNumber: ClassificationField; - /** The surname of the passport holder. */ - surname: StringField; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.address1 = new StringField({ - prediction: rawPrediction["address1"], - pageId: pageId, - }); - this.address2 = new StringField({ - prediction: rawPrediction["address2"], - pageId: pageId, - }); - this.address3 = new StringField({ - prediction: rawPrediction["address3"], - pageId: pageId, - }); - this.birthDate = new DateField({ - prediction: rawPrediction["birth_date"], - pageId: pageId, - }); - this.birthPlace = new StringField({ - prediction: rawPrediction["birth_place"], - pageId: pageId, - }); - this.country = new StringField({ - prediction: rawPrediction["country"], - pageId: pageId, - }); - this.expiryDate = new DateField({ - prediction: rawPrediction["expiry_date"], - pageId: pageId, - }); - this.fileNumber = new StringField({ - prediction: rawPrediction["file_number"], - pageId: pageId, - }); - this.gender = new ClassificationField({ - prediction: rawPrediction["gender"], - }); - this.givenNames = new StringField({ - prediction: rawPrediction["given_names"], - pageId: pageId, - }); - this.idNumber = new StringField({ - prediction: rawPrediction["id_number"], - pageId: pageId, - }); - this.issuanceDate = new DateField({ - prediction: rawPrediction["issuance_date"], - pageId: pageId, - }); - this.issuancePlace = new StringField({ - prediction: rawPrediction["issuance_place"], - pageId: pageId, - }); - this.legalGuardian = new StringField({ - prediction: rawPrediction["legal_guardian"], - pageId: pageId, - }); - this.mrz1 = new StringField({ - prediction: rawPrediction["mrz1"], - pageId: pageId, - }); - this.mrz2 = new StringField({ - prediction: rawPrediction["mrz2"], - pageId: pageId, - }); - this.nameOfMother = new StringField({ - prediction: rawPrediction["name_of_mother"], - pageId: pageId, - }); - this.nameOfSpouse = new StringField({ - prediction: rawPrediction["name_of_spouse"], - pageId: pageId, - }); - this.oldPassportDateOfIssue = new DateField({ - prediction: rawPrediction["old_passport_date_of_issue"], - pageId: pageId, - }); - this.oldPassportNumber = new StringField({ - prediction: rawPrediction["old_passport_number"], - pageId: pageId, - }); - this.oldPassportPlaceOfIssue = new StringField({ - prediction: rawPrediction["old_passport_place_of_issue"], - pageId: pageId, - }); - this.pageNumber = new ClassificationField({ - prediction: rawPrediction["page_number"], - }); - this.surname = new StringField({ - prediction: rawPrediction["surname"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - const outStr = `:Page Number: ${this.pageNumber} -:Country: ${this.country} -:ID Number: ${this.idNumber} -:Given Names: ${this.givenNames} -:Surname: ${this.surname} -:Birth Date: ${this.birthDate} -:Birth Place: ${this.birthPlace} -:Issuance Place: ${this.issuancePlace} -:Gender: ${this.gender} -:Issuance Date: ${this.issuanceDate} -:Expiry Date: ${this.expiryDate} -:MRZ Line 1: ${this.mrz1} -:MRZ Line 2: ${this.mrz2} -:Legal Guardian: ${this.legalGuardian} -:Name of Spouse: ${this.nameOfSpouse} -:Name of Mother: ${this.nameOfMother} -:Old Passport Date of Issue: ${this.oldPassportDateOfIssue} -:Old Passport Number: ${this.oldPassportNumber} -:Old Passport Place of Issue: ${this.oldPassportPlaceOfIssue} -:Address Line 1: ${this.address1} -:Address Line 2: ${this.address2} -:Address Line 3: ${this.address3} -:File Number: ${this.fileNumber}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/index.ts b/src/v1/product/index.ts index ac80c597f..32313f020 100644 --- a/src/v1/product/index.ts +++ b/src/v1/product/index.ts @@ -1,5 +1,4 @@ export * as fr from "./fr/index.js"; -export * as ind from "./ind/index.js"; export * as us from "./us/index.js"; export { BarcodeReaderV1 } from "./barcodeReader/index.js"; export { CropperV1 } from "./cropper/index.js"; diff --git a/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts b/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts deleted file mode 100644 index 360f151c3..000000000 --- a/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index.js"; -import { expect } from "chai"; -import * as mindee from "@/index.js"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "ind_passport/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "ind_passport/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "ind_passport/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "ind_passport/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - IndianPassportV1 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.v1.Document(mindee.v1.product.ind.IndianPassportV1, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.country.value).to.be.undefined; - expect(docPrediction.idNumber.value).to.be.undefined; - expect(docPrediction.givenNames.value).to.be.undefined; - expect(docPrediction.surname.value).to.be.undefined; - expect(docPrediction.birthDate.value).to.be.undefined; - expect(docPrediction.birthPlace.value).to.be.undefined; - expect(docPrediction.issuancePlace.value).to.be.undefined; - expect(docPrediction.issuanceDate.value).to.be.undefined; - expect(docPrediction.expiryDate.value).to.be.undefined; - expect(docPrediction.mrz1.value).to.be.undefined; - expect(docPrediction.mrz2.value).to.be.undefined; - expect(docPrediction.legalGuardian.value).to.be.undefined; - expect(docPrediction.nameOfSpouse.value).to.be.undefined; - expect(docPrediction.nameOfMother.value).to.be.undefined; - expect(docPrediction.oldPassportDateOfIssue.value).to.be.undefined; - expect(docPrediction.oldPassportNumber.value).to.be.undefined; - expect(docPrediction.oldPassportPlaceOfIssue.value).to.be.undefined; - expect(docPrediction.address1.value).to.be.undefined; - expect(docPrediction.address2.value).to.be.undefined; - expect(docPrediction.address3.value).to.be.undefined; - expect(docPrediction.fileNumber.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.v1.Document(mindee.v1.product.ind.IndianPassportV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); From b30269b1938387aaf2cfb9ab6f4047235aa0e22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Thu, 12 Feb 2026 13:21:50 +0100 Subject: [PATCH 3/4] :coffin: remove US Mail product --- docs/code_samples/us_mail_v3_async.txt | 25 --- src/v1/product/cliProducts.ts | 10 -- src/v1/product/us/index.ts | 4 - src/v1/product/us/usMail/index.ts | 4 - src/v1/product/us/usMail/usMailV3.ts | 34 ---- src/v1/product/us/usMail/usMailV3Document.ts | 90 ----------- .../us/usMail/usMailV3RecipientAddress.ts | 150 ------------------ .../us/usMail/usMailV3SenderAddress.ts | 85 ---------- tests/v1/product/us/usMail/usMailV3.spec.ts | 39 ----- 9 files changed, 441 deletions(-) delete mode 100644 docs/code_samples/us_mail_v3_async.txt delete mode 100644 src/v1/product/us/usMail/index.ts delete mode 100644 src/v1/product/us/usMail/usMailV3.ts delete mode 100644 src/v1/product/us/usMail/usMailV3Document.ts delete mode 100644 src/v1/product/us/usMail/usMailV3RecipientAddress.ts delete mode 100644 src/v1/product/us/usMail/usMailV3SenderAddress.ts delete mode 100644 tests/v1/product/us/usMail/usMailV3.spec.ts diff --git a/docs/code_samples/us_mail_v3_async.txt b/docs/code_samples/us_mail_v3_async.txt deleted file mode 100644 index f9881a899..000000000 --- a/docs/code_samples/us_mail_v3_async.txt +++ /dev/null @@ -1,25 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.v1.Client( - { apiKey: "my-api-key" } -); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.v1.product.us.UsMailV3, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/src/v1/product/cliProducts.ts b/src/v1/product/cliProducts.ts index 67c97b7d1..da81cd6dc 100644 --- a/src/v1/product/cliProducts.ts +++ b/src/v1/product/cliProducts.ts @@ -198,14 +198,4 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: true, }, ], - [ - "us-us-mail", - { - displayName: "US US Mail", - docClass: product.us.UsMailV3, - allWords: false, - async: true, - sync: false, - }, - ], ]); diff --git a/src/v1/product/us/index.ts b/src/v1/product/us/index.ts index fcf56cdfe..8eff96dc3 100644 --- a/src/v1/product/us/index.ts +++ b/src/v1/product/us/index.ts @@ -1,6 +1,2 @@ export { BankCheckV1 } from "./bankCheck/index.js"; -export { UsMailV3 } from "./usMail/index.js"; - -// not sure if we want to export these -- advanced users can import them directly export * as bankCheck from "./bankCheck/index.js"; -export * as usMail from "./usMail/index.js"; diff --git a/src/v1/product/us/usMail/index.ts b/src/v1/product/us/usMail/index.ts deleted file mode 100644 index 6ce0b54ce..000000000 --- a/src/v1/product/us/usMail/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { UsMailV3 } from "./usMailV3.js"; -export { UsMailV3Document } from "./usMailV3Document.js"; -export { UsMailV3RecipientAddress } from "./usMailV3RecipientAddress.js"; -export { UsMailV3SenderAddress } from "./usMailV3SenderAddress.js"; diff --git a/src/v1/product/us/usMail/usMailV3.ts b/src/v1/product/us/usMail/usMailV3.ts deleted file mode 100644 index 5444b5d41..000000000 --- a/src/v1/product/us/usMail/usMailV3.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; -import { UsMailV3Document } from "./usMailV3Document.js"; - -/** - * US Mail API version 3 inference prediction. - */ -export class UsMailV3 extends Inference { - /** The endpoint's name. */ - endpointName = "us_mail"; - /** The endpoint's version. */ - endpointVersion = "3"; - /** The document-level prediction. */ - prediction: UsMailV3Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new UsMailV3Document(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( - UsMailV3Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/v1/product/us/usMail/usMailV3Document.ts b/src/v1/product/us/usMail/usMailV3Document.ts deleted file mode 100644 index 67eb1a4d9..000000000 --- a/src/v1/product/us/usMail/usMailV3Document.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString,lineSeparator, -} from "@/v1/parsing/common/index.js"; -import { UsMailV3SenderAddress } from "./usMailV3SenderAddress.js"; -import { UsMailV3RecipientAddress } from "./usMailV3RecipientAddress.js"; -import { BooleanField, StringField } from "@/v1/parsing/standard/index.js"; - -/** - * US Mail API version 3.0 document data. - */ -export class UsMailV3Document implements Prediction { - /** Whether the mailing is marked as return to sender. */ - isReturnToSender: BooleanField; - /** The addresses of the recipients. */ - recipientAddresses: UsMailV3RecipientAddress[] = []; - /** The names of the recipients. */ - recipientNames: StringField[] = []; - /** The address of the sender. */ - senderAddress: UsMailV3SenderAddress; - /** The name of the sender. */ - senderName: StringField; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.isReturnToSender = new BooleanField({ - prediction: rawPrediction["is_return_to_sender"], - pageId: pageId, - }); - rawPrediction["recipient_addresses"] && - rawPrediction["recipient_addresses"].map( - (itemPrediction: StringDict) => - this.recipientAddresses.push( - new UsMailV3RecipientAddress({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - rawPrediction["recipient_names"] && - rawPrediction["recipient_names"].map( - (itemPrediction: StringDict) => - this.recipientNames.push( - new StringField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.senderAddress = new UsMailV3SenderAddress({ - prediction: rawPrediction["sender_address"], - pageId: pageId, - }); - this.senderName = new StringField({ - prediction: rawPrediction["sender_name"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - const recipientNames = this.recipientNames.join("\n "); - let recipientAddressesSummary:string = ""; - if (this.recipientAddresses && this.recipientAddresses.length > 0) { - const recipientAddressesColSizes:number[] = [17, 37, 19, 13, 24, 7, 27, 17]; - recipientAddressesSummary += "\n" + lineSeparator(recipientAddressesColSizes, "-") + "\n "; - recipientAddressesSummary += "| City "; - recipientAddressesSummary += "| Complete Address "; - recipientAddressesSummary += "| Is Address Change "; - recipientAddressesSummary += "| Postal Code "; - recipientAddressesSummary += "| Private Mailbox Number "; - recipientAddressesSummary += "| State "; - recipientAddressesSummary += "| Street "; - recipientAddressesSummary += "| Unit "; - recipientAddressesSummary += "|\n" + lineSeparator(recipientAddressesColSizes, "="); - recipientAddressesSummary += this.recipientAddresses.map( - (item) => - "\n " + item.toTableLine() + "\n" + lineSeparator(recipientAddressesColSizes, "-") - ).join(""); - } - const outStr = `:Sender Name: ${this.senderName} -:Sender Address: ${this.senderAddress.toFieldList()} -:Recipient Names: ${recipientNames} -:Recipient Addresses: ${recipientAddressesSummary} -:Return to Sender: ${this.isReturnToSender}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/us/usMail/usMailV3RecipientAddress.ts b/src/v1/product/us/usMail/usMailV3RecipientAddress.ts deleted file mode 100644 index c26ac5f5b..000000000 --- a/src/v1/product/us/usMail/usMailV3RecipientAddress.ts +++ /dev/null @@ -1,150 +0,0 @@ - -import { cleanSpecialChars } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * The addresses of the recipients. - */ -export class UsMailV3RecipientAddress { - /** The city of the recipient's address. */ - city: string | null; - /** The complete address of the recipient. */ - complete: string | null; - /** Indicates if the recipient's address is a change of address. */ - isAddressChange: boolean | null; - /** The postal code of the recipient's address. */ - postalCode: string | null; - /** The private mailbox number of the recipient's address. */ - privateMailboxNumber: string | null; - /** Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. */ - state: string | null; - /** The street of the recipient's address. */ - street: string | null; - /** The unit number of the recipient's address. */ - unit: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.city = prediction["city"]; - this.complete = prediction["complete"]; - this.isAddressChange = prediction["is_address_change"]; - this.postalCode = prediction["postal_code"]; - this.privateMailboxNumber = prediction["private_mailbox_number"]; - this.state = prediction["state"]; - this.street = prediction["street"]; - this.unit = prediction["unit"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - city: this.city ? - this.city.length <= 15 ? - cleanSpecialChars(this.city) : - cleanSpecialChars(this.city).slice(0, 12) + "..." : - "", - complete: this.complete ? - this.complete.length <= 35 ? - cleanSpecialChars(this.complete) : - cleanSpecialChars(this.complete).slice(0, 32) + "..." : - "", - isAddressChange: this.isAddressChange === true ? - "True" : - this.isAddressChange === false ? - "False" : - "", - postalCode: this.postalCode ? - this.postalCode.length <= 11 ? - cleanSpecialChars(this.postalCode) : - cleanSpecialChars(this.postalCode).slice(0, 8) + "..." : - "", - privateMailboxNumber: this.privateMailboxNumber ? - this.privateMailboxNumber.length <= 22 ? - cleanSpecialChars(this.privateMailboxNumber) : - cleanSpecialChars(this.privateMailboxNumber).slice(0, 19) + "..." : - "", - state: this.state ? - this.state.length <= 5 ? - cleanSpecialChars(this.state) : - cleanSpecialChars(this.state).slice(0, 2) + "..." : - "", - street: this.street ? - this.street.length <= 25 ? - cleanSpecialChars(this.street) : - cleanSpecialChars(this.street).slice(0, 22) + "..." : - "", - unit: this.unit ? - this.unit.length <= 15 ? - cleanSpecialChars(this.unit) : - cleanSpecialChars(this.unit).slice(0, 12) + "..." : - "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "City: " + - printable.city + - ", Complete Address: " + - printable.complete + - ", Is Address Change: " + - printable.isAddressChange + - ", Postal Code: " + - printable.postalCode + - ", Private Mailbox Number: " + - printable.privateMailboxNumber + - ", State: " + - printable.state + - ", Street: " + - printable.street + - ", Unit: " + - printable.unit - ); - } - - /** - * Output in a format suitable for inclusion in an rST table. - */ - toTableLine(): string { - const printable = this.#printableValues(); - return ( - "| " + - printable.city.padEnd(15) + - " | " + - printable.complete.padEnd(35) + - " | " + - printable.isAddressChange.padEnd(17) + - " | " + - printable.postalCode.padEnd(11) + - " | " + - printable.privateMailboxNumber.padEnd(22) + - " | " + - printable.state.padEnd(5) + - " | " + - printable.street.padEnd(25) + - " | " + - printable.unit.padEnd(15) + - " |" - ); - } -} diff --git a/src/v1/product/us/usMail/usMailV3SenderAddress.ts b/src/v1/product/us/usMail/usMailV3SenderAddress.ts deleted file mode 100644 index 13559239d..000000000 --- a/src/v1/product/us/usMail/usMailV3SenderAddress.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * The address of the sender. - */ -export class UsMailV3SenderAddress { - /** The city of the sender's address. */ - city: string | null; - /** The complete address of the sender. */ - complete: string | null; - /** The postal code of the sender's address. */ - postalCode: string | null; - /** Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. */ - state: string | null; - /** The street of the sender's address. */ - street: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.city = prediction["city"]; - this.complete = prediction["complete"]; - this.postalCode = prediction["postal_code"]; - this.state = prediction["state"]; - this.street = prediction["street"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - city: this.city ?? "", - complete: this.complete ?? "", - postalCode: this.postalCode ?? "", - state: this.state ?? "", - street: this.street ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "City: " + - printable.city + - ", Complete Address: " + - printable.complete + - ", Postal Code: " + - printable.postalCode + - ", State: " + - printable.state + - ", Street: " + - printable.street - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :City: ${printable.city} - :Complete Address: ${printable.complete} - :Postal Code: ${printable.postalCode} - :State: ${printable.state} - :Street: ${printable.street}`.trimEnd(); - } -} diff --git a/tests/v1/product/us/usMail/usMailV3.spec.ts b/tests/v1/product/us/usMail/usMailV3.spec.ts deleted file mode 100644 index fd51beb55..000000000 --- a/tests/v1/product/us/usMail/usMailV3.spec.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index.js"; -import { expect } from "chai"; -import * as mindee from "@/index.js"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "us_mail/response_v3/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "us_mail/response_v3/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "us_mail/response_v3/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "us_mail/response_v3/summary_page0.rst"), -}; - -describe("MindeeV1 - UsMailV3 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.v1.Document(mindee.v1.product.us.UsMailV3, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.senderName.value).to.be.undefined; - expect(docPrediction.senderAddress.city).to.be.null; - expect(docPrediction.senderAddress.complete).to.be.null; - expect(docPrediction.senderAddress.postalCode).to.be.null; - expect(docPrediction.senderAddress.state).to.be.null; - expect(docPrediction.senderAddress.street).to.be.null; - expect(docPrediction.recipientNames.length).to.be.equals(0); - expect(docPrediction.recipientAddresses.length).to.be.equals(0); - expect(docPrediction.isReturnToSender.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.v1.Document(mindee.v1.product.us.UsMailV3, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); From 2235aa8de3302d04795bba3abaec59552f38f3c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Thu, 12 Feb 2026 14:43:15 +0100 Subject: [PATCH 4/4] :coffin: remove energy_bill_fra_v1_async, french_healthcard_v1_async, payslip_fra_v3_async --- .../code_samples/energy_bill_fra_v1_async.txt | 25 --- .../french_healthcard_v1_async.txt | 25 --- docs/code_samples/payslip_fra_v3_async.txt | 25 --- src/v1/product/cliProducts.ts | 30 --- src/v1/product/fr/energyBill/energyBillV1.ts | 34 --- .../fr/energyBill/energyBillV1Document.ts | 201 ----------------- .../energyBill/energyBillV1EnergyConsumer.ts | 64 ------ .../energyBill/energyBillV1EnergySupplier.ts | 64 ------ .../fr/energyBill/energyBillV1EnergyUsage.ts | 166 -------------- .../fr/energyBill/energyBillV1MeterDetail.ts | 71 ------ .../fr/energyBill/energyBillV1Subscription.ts | 137 ------------ .../energyBillV1TaxesAndContribution.ts | 137 ------------ src/v1/product/fr/energyBill/index.ts | 8 - src/v1/product/fr/healthCard/healthCardV1.ts | 34 --- .../fr/healthCard/healthCardV1Document.ts | 57 ----- src/v1/product/fr/healthCard/index.ts | 2 - src/v1/product/fr/index.ts | 7 - src/v1/product/fr/payslip/index.ts | 10 - src/v1/product/fr/payslip/payslipV3.ts | 34 --- .../fr/payslip/payslipV3BankAccountDetail.ts | 71 ------ .../product/fr/payslip/payslipV3Document.ts | 128 ----------- .../product/fr/payslip/payslipV3Employee.ts | 99 --------- .../product/fr/payslip/payslipV3Employer.ts | 99 --------- .../product/fr/payslip/payslipV3Employment.ts | 99 --------- .../fr/payslip/payslipV3PaidTimeOff.ts | 125 ----------- .../product/fr/payslip/payslipV3PayDetail.ts | 210 ------------------ .../product/fr/payslip/payslipV3PayPeriod.ts | 85 ------- .../fr/payslip/payslipV3SalaryDetail.ts | 129 ----------- .../fr/energyBill/energyBillV1.spec.ts | 48 ---- .../fr/healthCard/healthCardV1.spec.ts | 34 --- tests/v1/product/fr/payslip/payslipV3.spec.ts | 71 ------ 31 files changed, 2329 deletions(-) delete mode 100644 docs/code_samples/energy_bill_fra_v1_async.txt delete mode 100644 docs/code_samples/french_healthcard_v1_async.txt delete mode 100644 docs/code_samples/payslip_fra_v3_async.txt delete mode 100644 src/v1/product/fr/energyBill/energyBillV1.ts delete mode 100644 src/v1/product/fr/energyBill/energyBillV1Document.ts delete mode 100644 src/v1/product/fr/energyBill/energyBillV1EnergyConsumer.ts delete mode 100644 src/v1/product/fr/energyBill/energyBillV1EnergySupplier.ts delete mode 100644 src/v1/product/fr/energyBill/energyBillV1EnergyUsage.ts delete mode 100644 src/v1/product/fr/energyBill/energyBillV1MeterDetail.ts delete mode 100644 src/v1/product/fr/energyBill/energyBillV1Subscription.ts delete mode 100644 src/v1/product/fr/energyBill/energyBillV1TaxesAndContribution.ts delete mode 100644 src/v1/product/fr/energyBill/index.ts delete mode 100644 src/v1/product/fr/healthCard/healthCardV1.ts delete mode 100644 src/v1/product/fr/healthCard/healthCardV1Document.ts delete mode 100644 src/v1/product/fr/healthCard/index.ts delete mode 100644 src/v1/product/fr/payslip/index.ts delete mode 100644 src/v1/product/fr/payslip/payslipV3.ts delete mode 100644 src/v1/product/fr/payslip/payslipV3BankAccountDetail.ts delete mode 100644 src/v1/product/fr/payslip/payslipV3Document.ts delete mode 100644 src/v1/product/fr/payslip/payslipV3Employee.ts delete mode 100644 src/v1/product/fr/payslip/payslipV3Employer.ts delete mode 100644 src/v1/product/fr/payslip/payslipV3Employment.ts delete mode 100644 src/v1/product/fr/payslip/payslipV3PaidTimeOff.ts delete mode 100644 src/v1/product/fr/payslip/payslipV3PayDetail.ts delete mode 100644 src/v1/product/fr/payslip/payslipV3PayPeriod.ts delete mode 100644 src/v1/product/fr/payslip/payslipV3SalaryDetail.ts delete mode 100644 tests/v1/product/fr/energyBill/energyBillV1.spec.ts delete mode 100644 tests/v1/product/fr/healthCard/healthCardV1.spec.ts delete mode 100644 tests/v1/product/fr/payslip/payslipV3.spec.ts diff --git a/docs/code_samples/energy_bill_fra_v1_async.txt b/docs/code_samples/energy_bill_fra_v1_async.txt deleted file mode 100644 index fb52aac3b..000000000 --- a/docs/code_samples/energy_bill_fra_v1_async.txt +++ /dev/null @@ -1,25 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.v1.Client( - { apiKey: "my-api-key" } -); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.v1.product.fr.EnergyBillV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/french_healthcard_v1_async.txt b/docs/code_samples/french_healthcard_v1_async.txt deleted file mode 100644 index 2433d2c09..000000000 --- a/docs/code_samples/french_healthcard_v1_async.txt +++ /dev/null @@ -1,25 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.v1.Client( - { apiKey: "my-api-key" } -); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.v1.product.fr.HealthCardV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/payslip_fra_v3_async.txt b/docs/code_samples/payslip_fra_v3_async.txt deleted file mode 100644 index 5f57040af..000000000 --- a/docs/code_samples/payslip_fra_v3_async.txt +++ /dev/null @@ -1,25 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.v1.Client( - { apiKey: "my-api-key" } -); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.v1.product.fr.PayslipV3, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/src/v1/product/cliProducts.ts b/src/v1/product/cliProducts.ts index da81cd6dc..fb7d82fc7 100644 --- a/src/v1/product/cliProducts.ts +++ b/src/v1/product/cliProducts.ts @@ -78,26 +78,6 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: true, }, ], - [ - "fr-energy-bill", - { - displayName: "FR Energy Bill", - docClass: product.fr.EnergyBillV1, - allWords: false, - async: true, - sync: false, - }, - ], - [ - "fr-health-card", - { - displayName: "FR Health Card", - docClass: product.fr.HealthCardV1, - allWords: false, - async: true, - sync: false, - }, - ], [ "fr-carte-nationale-d-identite", { @@ -108,16 +88,6 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: true, }, ], - [ - "fr-payslip", - { - displayName: "FR Payslip", - docClass: product.fr.PayslipV3, - allWords: false, - async: true, - sync: false, - }, - ], [ "international-id", { diff --git a/src/v1/product/fr/energyBill/energyBillV1.ts b/src/v1/product/fr/energyBill/energyBillV1.ts deleted file mode 100644 index aa65f8862..000000000 --- a/src/v1/product/fr/energyBill/energyBillV1.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; -import { EnergyBillV1Document } from "./energyBillV1Document.js"; - -/** - * Energy Bill API version 1 inference prediction. - */ -export class EnergyBillV1 extends Inference { - /** The endpoint's name. */ - endpointName = "energy_bill_fra"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: EnergyBillV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new EnergyBillV1Document(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( - EnergyBillV1Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/v1/product/fr/energyBill/energyBillV1Document.ts b/src/v1/product/fr/energyBill/energyBillV1Document.ts deleted file mode 100644 index 3431c38b1..000000000 --- a/src/v1/product/fr/energyBill/energyBillV1Document.ts +++ /dev/null @@ -1,201 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString,lineSeparator, -} from "@/v1/parsing/common/index.js"; -import { EnergyBillV1EnergySupplier } from "./energyBillV1EnergySupplier.js"; -import { EnergyBillV1EnergyConsumer } from "./energyBillV1EnergyConsumer.js"; -import { EnergyBillV1Subscription } from "./energyBillV1Subscription.js"; -import { EnergyBillV1EnergyUsage } from "./energyBillV1EnergyUsage.js"; -import { EnergyBillV1TaxesAndContribution } from "./energyBillV1TaxesAndContribution.js"; -import { EnergyBillV1MeterDetail } from "./energyBillV1MeterDetail.js"; -import { - AmountField, - DateField, - StringField, -} from "@/v1/parsing/standard/index.js"; - -/** - * Energy Bill API version 1.2 document data. - */ -export class EnergyBillV1Document implements Prediction { - /** The unique identifier associated with a specific contract. */ - contractId: StringField; - /** - * The unique identifier assigned to each electricity or gas consumption point. It specifies the exact location where - * the energy is delivered. - */ - deliveryPoint: StringField; - /** The date by which the payment for the energy invoice is due. */ - dueDate: DateField; - /** The entity that consumes the energy. */ - energyConsumer: EnergyBillV1EnergyConsumer; - /** The company that supplies the energy. */ - energySupplier: EnergyBillV1EnergySupplier; - /** Details of energy consumption. */ - energyUsage: EnergyBillV1EnergyUsage[] = []; - /** The date when the energy invoice was issued. */ - invoiceDate: DateField; - /** The unique identifier of the energy invoice. */ - invoiceNumber: StringField; - /** Information about the energy meter. */ - meterDetails: EnergyBillV1MeterDetail; - /** The subscription details fee for the energy service. */ - subscription: EnergyBillV1Subscription[] = []; - /** Details of Taxes and Contributions. */ - taxesAndContributions: EnergyBillV1TaxesAndContribution[] = []; - /** The total amount to be paid for the energy invoice. */ - totalAmount: AmountField; - /** The total amount to be paid for the energy invoice before taxes. */ - totalBeforeTaxes: AmountField; - /** Total of taxes applied to the invoice. */ - totalTaxes: AmountField; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.contractId = new StringField({ - prediction: rawPrediction["contract_id"], - pageId: pageId, - }); - this.deliveryPoint = new StringField({ - prediction: rawPrediction["delivery_point"], - pageId: pageId, - }); - this.dueDate = new DateField({ - prediction: rawPrediction["due_date"], - pageId: pageId, - }); - this.energyConsumer = new EnergyBillV1EnergyConsumer({ - prediction: rawPrediction["energy_consumer"], - pageId: pageId, - }); - this.energySupplier = new EnergyBillV1EnergySupplier({ - prediction: rawPrediction["energy_supplier"], - pageId: pageId, - }); - rawPrediction["energy_usage"] && - rawPrediction["energy_usage"].map( - (itemPrediction: StringDict) => - this.energyUsage.push( - new EnergyBillV1EnergyUsage({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.invoiceDate = new DateField({ - prediction: rawPrediction["invoice_date"], - pageId: pageId, - }); - this.invoiceNumber = new StringField({ - prediction: rawPrediction["invoice_number"], - pageId: pageId, - }); - this.meterDetails = new EnergyBillV1MeterDetail({ - prediction: rawPrediction["meter_details"], - pageId: pageId, - }); - rawPrediction["subscription"] && - rawPrediction["subscription"].map( - (itemPrediction: StringDict) => - this.subscription.push( - new EnergyBillV1Subscription({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - rawPrediction["taxes_and_contributions"] && - rawPrediction["taxes_and_contributions"].map( - (itemPrediction: StringDict) => - this.taxesAndContributions.push( - new EnergyBillV1TaxesAndContribution({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.totalAmount = new AmountField({ - prediction: rawPrediction["total_amount"], - pageId: pageId, - }); - this.totalBeforeTaxes = new AmountField({ - prediction: rawPrediction["total_before_taxes"], - pageId: pageId, - }); - this.totalTaxes = new AmountField({ - prediction: rawPrediction["total_taxes"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - let subscriptionSummary:string = ""; - if (this.subscription && this.subscription.length > 0) { - const subscriptionColSizes:number[] = [38, 12, 12, 10, 11, 12]; - subscriptionSummary += "\n" + lineSeparator(subscriptionColSizes, "-") + "\n "; - subscriptionSummary += "| Description "; - subscriptionSummary += "| End Date "; - subscriptionSummary += "| Start Date "; - subscriptionSummary += "| Tax Rate "; - subscriptionSummary += "| Total "; - subscriptionSummary += "| Unit Price "; - subscriptionSummary += "|\n" + lineSeparator(subscriptionColSizes, "="); - subscriptionSummary += this.subscription.map( - (item) => - "\n " + item.toTableLine() + "\n" + lineSeparator(subscriptionColSizes, "-") - ).join(""); - } - let energyUsageSummary:string = ""; - if (this.energyUsage && this.energyUsage.length > 0) { - const energyUsageColSizes:number[] = [13, 38, 12, 12, 10, 11, 17, 12]; - energyUsageSummary += "\n" + lineSeparator(energyUsageColSizes, "-") + "\n "; - energyUsageSummary += "| Consumption "; - energyUsageSummary += "| Description "; - energyUsageSummary += "| End Date "; - energyUsageSummary += "| Start Date "; - energyUsageSummary += "| Tax Rate "; - energyUsageSummary += "| Total "; - energyUsageSummary += "| Unit of Measure "; - energyUsageSummary += "| Unit Price "; - energyUsageSummary += "|\n" + lineSeparator(energyUsageColSizes, "="); - energyUsageSummary += this.energyUsage.map( - (item) => - "\n " + item.toTableLine() + "\n" + lineSeparator(energyUsageColSizes, "-") - ).join(""); - } - let taxesAndContributionsSummary:string = ""; - if (this.taxesAndContributions && this.taxesAndContributions.length > 0) { - const taxesAndContributionsColSizes:number[] = [38, 12, 12, 10, 11, 12]; - taxesAndContributionsSummary += "\n" + lineSeparator(taxesAndContributionsColSizes, "-") + "\n "; - taxesAndContributionsSummary += "| Description "; - taxesAndContributionsSummary += "| End Date "; - taxesAndContributionsSummary += "| Start Date "; - taxesAndContributionsSummary += "| Tax Rate "; - taxesAndContributionsSummary += "| Total "; - taxesAndContributionsSummary += "| Unit Price "; - taxesAndContributionsSummary += "|\n" + lineSeparator(taxesAndContributionsColSizes, "="); - taxesAndContributionsSummary += this.taxesAndContributions.map( - (item) => - "\n " + item.toTableLine() + "\n" + lineSeparator(taxesAndContributionsColSizes, "-") - ).join(""); - } - const outStr = `:Invoice Number: ${this.invoiceNumber} -:Contract ID: ${this.contractId} -:Delivery Point: ${this.deliveryPoint} -:Invoice Date: ${this.invoiceDate} -:Due Date: ${this.dueDate} -:Total Before Taxes: ${this.totalBeforeTaxes} -:Total Taxes: ${this.totalTaxes} -:Total Amount: ${this.totalAmount} -:Energy Supplier: ${this.energySupplier.toFieldList()} -:Energy Consumer: ${this.energyConsumer.toFieldList()} -:Subscription: ${subscriptionSummary} -:Energy Usage: ${energyUsageSummary} -:Taxes and Contributions: ${taxesAndContributionsSummary} -:Meter Details: ${this.meterDetails.toFieldList()}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/fr/energyBill/energyBillV1EnergyConsumer.ts b/src/v1/product/fr/energyBill/energyBillV1EnergyConsumer.ts deleted file mode 100644 index f20acbb8a..000000000 --- a/src/v1/product/fr/energyBill/energyBillV1EnergyConsumer.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * The entity that consumes the energy. - */ -export class EnergyBillV1EnergyConsumer { - /** The address of the energy consumer. */ - address: string | null; - /** The name of the energy consumer. */ - name: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.address = prediction["address"]; - this.name = prediction["name"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - address: this.address ?? "", - name: this.name ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Address: " + - printable.address + - ", Name: " + - printable.name - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Address: ${printable.address} - :Name: ${printable.name}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/energyBill/energyBillV1EnergySupplier.ts b/src/v1/product/fr/energyBill/energyBillV1EnergySupplier.ts deleted file mode 100644 index 76961d9f5..000000000 --- a/src/v1/product/fr/energyBill/energyBillV1EnergySupplier.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * The company that supplies the energy. - */ -export class EnergyBillV1EnergySupplier { - /** The address of the energy supplier. */ - address: string | null; - /** The name of the energy supplier. */ - name: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.address = prediction["address"]; - this.name = prediction["name"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - address: this.address ?? "", - name: this.name ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Address: " + - printable.address + - ", Name: " + - printable.name - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Address: ${printable.address} - :Name: ${printable.name}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/energyBill/energyBillV1EnergyUsage.ts b/src/v1/product/fr/energyBill/energyBillV1EnergyUsage.ts deleted file mode 100644 index f87d67fda..000000000 --- a/src/v1/product/fr/energyBill/energyBillV1EnergyUsage.ts +++ /dev/null @@ -1,166 +0,0 @@ -import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Details of energy consumption. - */ -export class EnergyBillV1EnergyUsage { - /** The price per unit of energy consumed. */ - consumption: number | null; - /** Description or details of the energy usage. */ - description: string | null; - /** The end date of the energy usage. */ - endDate: string | null; - /** The start date of the energy usage. */ - startDate: string | null; - /** The rate of tax applied to the total cost. */ - taxRate: number | null; - /** The total cost of energy consumed. */ - total: number | null; - /** The unit of measurement for energy consumption. */ - unit: string | null; - /** The price per unit of energy consumed. */ - unitPrice: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["consumption"] !== undefined && - prediction["consumption"] !== null && - !isNaN(prediction["consumption"]) - ) { - this.consumption = +parseFloat(prediction["consumption"]); - } else { - this.consumption = null; - } - this.description = prediction["description"]; - this.endDate = prediction["end_date"]; - this.startDate = prediction["start_date"]; - if ( - prediction["tax_rate"] !== undefined && - prediction["tax_rate"] !== null && - !isNaN(prediction["tax_rate"]) - ) { - this.taxRate = +parseFloat(prediction["tax_rate"]); - } else { - this.taxRate = null; - } - if ( - prediction["total"] !== undefined && - prediction["total"] !== null && - !isNaN(prediction["total"]) - ) { - this.total = +parseFloat(prediction["total"]); - } else { - this.total = null; - } - this.unit = prediction["unit"]; - if ( - prediction["unit_price"] !== undefined && - prediction["unit_price"] !== null && - !isNaN(prediction["unit_price"]) - ) { - this.unitPrice = +parseFloat(prediction["unit_price"]); - } else { - this.unitPrice = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - consumption: - this.consumption !== undefined ? floatToString(this.consumption) : "", - description: this.description ? - this.description.length <= 36 ? - cleanSpecialChars(this.description) : - cleanSpecialChars(this.description).slice(0, 33) + "..." : - "", - endDate: this.endDate ? - this.endDate.length <= 10 ? - cleanSpecialChars(this.endDate) : - cleanSpecialChars(this.endDate).slice(0, 7) + "..." : - "", - startDate: this.startDate ? - this.startDate.length <= 10 ? - cleanSpecialChars(this.startDate) : - cleanSpecialChars(this.startDate).slice(0, 7) + "..." : - "", - taxRate: this.taxRate !== undefined ? floatToString(this.taxRate) : "", - total: this.total !== undefined ? floatToString(this.total) : "", - unit: this.unit ? - this.unit.length <= 15 ? - cleanSpecialChars(this.unit) : - cleanSpecialChars(this.unit).slice(0, 12) + "..." : - "", - unitPrice: this.unitPrice !== undefined ? floatToString(this.unitPrice) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Consumption: " + - printable.consumption + - ", Description: " + - printable.description + - ", End Date: " + - printable.endDate + - ", Start Date: " + - printable.startDate + - ", Tax Rate: " + - printable.taxRate + - ", Total: " + - printable.total + - ", Unit of Measure: " + - printable.unit + - ", Unit Price: " + - printable.unitPrice - ); - } - - /** - * Output in a format suitable for inclusion in an rST table. - */ - toTableLine(): string { - const printable = this.#printableValues(); - return ( - "| " + - printable.consumption.padEnd(11) + - " | " + - printable.description.padEnd(36) + - " | " + - printable.endDate.padEnd(10) + - " | " + - printable.startDate.padEnd(10) + - " | " + - printable.taxRate.padEnd(8) + - " | " + - printable.total.padEnd(9) + - " | " + - printable.unit.padEnd(15) + - " | " + - printable.unitPrice.padEnd(10) + - " |" - ); - } -} diff --git a/src/v1/product/fr/energyBill/energyBillV1MeterDetail.ts b/src/v1/product/fr/energyBill/energyBillV1MeterDetail.ts deleted file mode 100644 index 50f4ec4a7..000000000 --- a/src/v1/product/fr/energyBill/energyBillV1MeterDetail.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the energy meter. - */ -export class EnergyBillV1MeterDetail { - /** The unique identifier of the energy meter. */ - meterNumber: string | null; - /** The type of energy meter. */ - meterType: string | null; - /** The unit of power for energy consumption. */ - unit: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.meterNumber = prediction["meter_number"]; - this.meterType = prediction["meter_type"]; - this.unit = prediction["unit"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - meterNumber: this.meterNumber ?? "", - meterType: this.meterType ?? "", - unit: this.unit ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Meter Number: " + - printable.meterNumber + - ", Meter Type: " + - printable.meterType + - ", Unit of Power: " + - printable.unit - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Meter Number: ${printable.meterNumber} - :Meter Type: ${printable.meterType} - :Unit of Power: ${printable.unit}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/energyBill/energyBillV1Subscription.ts b/src/v1/product/fr/energyBill/energyBillV1Subscription.ts deleted file mode 100644 index 631c5c0f4..000000000 --- a/src/v1/product/fr/energyBill/energyBillV1Subscription.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * The subscription details fee for the energy service. - */ -export class EnergyBillV1Subscription { - /** Description or details of the subscription. */ - description: string | null; - /** The end date of the subscription. */ - endDate: string | null; - /** The start date of the subscription. */ - startDate: string | null; - /** The rate of tax applied to the total cost. */ - taxRate: number | null; - /** The total cost of subscription. */ - total: number | null; - /** The price per unit of subscription. */ - unitPrice: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.description = prediction["description"]; - this.endDate = prediction["end_date"]; - this.startDate = prediction["start_date"]; - if ( - prediction["tax_rate"] !== undefined && - prediction["tax_rate"] !== null && - !isNaN(prediction["tax_rate"]) - ) { - this.taxRate = +parseFloat(prediction["tax_rate"]); - } else { - this.taxRate = null; - } - if ( - prediction["total"] !== undefined && - prediction["total"] !== null && - !isNaN(prediction["total"]) - ) { - this.total = +parseFloat(prediction["total"]); - } else { - this.total = null; - } - if ( - prediction["unit_price"] !== undefined && - prediction["unit_price"] !== null && - !isNaN(prediction["unit_price"]) - ) { - this.unitPrice = +parseFloat(prediction["unit_price"]); - } else { - this.unitPrice = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - description: this.description ? - this.description.length <= 36 ? - cleanSpecialChars(this.description) : - cleanSpecialChars(this.description).slice(0, 33) + "..." : - "", - endDate: this.endDate ? - this.endDate.length <= 10 ? - cleanSpecialChars(this.endDate) : - cleanSpecialChars(this.endDate).slice(0, 7) + "..." : - "", - startDate: this.startDate ? - this.startDate.length <= 10 ? - cleanSpecialChars(this.startDate) : - cleanSpecialChars(this.startDate).slice(0, 7) + "..." : - "", - taxRate: this.taxRate !== undefined ? floatToString(this.taxRate) : "", - total: this.total !== undefined ? floatToString(this.total) : "", - unitPrice: this.unitPrice !== undefined ? floatToString(this.unitPrice) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Description: " + - printable.description + - ", End Date: " + - printable.endDate + - ", Start Date: " + - printable.startDate + - ", Tax Rate: " + - printable.taxRate + - ", Total: " + - printable.total + - ", Unit Price: " + - printable.unitPrice - ); - } - - /** - * Output in a format suitable for inclusion in an rST table. - */ - toTableLine(): string { - const printable = this.#printableValues(); - return ( - "| " + - printable.description.padEnd(36) + - " | " + - printable.endDate.padEnd(10) + - " | " + - printable.startDate.padEnd(10) + - " | " + - printable.taxRate.padEnd(8) + - " | " + - printable.total.padEnd(9) + - " | " + - printable.unitPrice.padEnd(10) + - " |" - ); - } -} diff --git a/src/v1/product/fr/energyBill/energyBillV1TaxesAndContribution.ts b/src/v1/product/fr/energyBill/energyBillV1TaxesAndContribution.ts deleted file mode 100644 index f6c8393b5..000000000 --- a/src/v1/product/fr/energyBill/energyBillV1TaxesAndContribution.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Details of Taxes and Contributions. - */ -export class EnergyBillV1TaxesAndContribution { - /** Description or details of the Taxes and Contributions. */ - description: string | null; - /** The end date of the Taxes and Contributions. */ - endDate: string | null; - /** The start date of the Taxes and Contributions. */ - startDate: string | null; - /** The rate of tax applied to the total cost. */ - taxRate: number | null; - /** The total cost of Taxes and Contributions. */ - total: number | null; - /** The price per unit of Taxes and Contributions. */ - unitPrice: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.description = prediction["description"]; - this.endDate = prediction["end_date"]; - this.startDate = prediction["start_date"]; - if ( - prediction["tax_rate"] !== undefined && - prediction["tax_rate"] !== null && - !isNaN(prediction["tax_rate"]) - ) { - this.taxRate = +parseFloat(prediction["tax_rate"]); - } else { - this.taxRate = null; - } - if ( - prediction["total"] !== undefined && - prediction["total"] !== null && - !isNaN(prediction["total"]) - ) { - this.total = +parseFloat(prediction["total"]); - } else { - this.total = null; - } - if ( - prediction["unit_price"] !== undefined && - prediction["unit_price"] !== null && - !isNaN(prediction["unit_price"]) - ) { - this.unitPrice = +parseFloat(prediction["unit_price"]); - } else { - this.unitPrice = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - description: this.description ? - this.description.length <= 36 ? - cleanSpecialChars(this.description) : - cleanSpecialChars(this.description).slice(0, 33) + "..." : - "", - endDate: this.endDate ? - this.endDate.length <= 10 ? - cleanSpecialChars(this.endDate) : - cleanSpecialChars(this.endDate).slice(0, 7) + "..." : - "", - startDate: this.startDate ? - this.startDate.length <= 10 ? - cleanSpecialChars(this.startDate) : - cleanSpecialChars(this.startDate).slice(0, 7) + "..." : - "", - taxRate: this.taxRate !== undefined ? floatToString(this.taxRate) : "", - total: this.total !== undefined ? floatToString(this.total) : "", - unitPrice: this.unitPrice !== undefined ? floatToString(this.unitPrice) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Description: " + - printable.description + - ", End Date: " + - printable.endDate + - ", Start Date: " + - printable.startDate + - ", Tax Rate: " + - printable.taxRate + - ", Total: " + - printable.total + - ", Unit Price: " + - printable.unitPrice - ); - } - - /** - * Output in a format suitable for inclusion in an rST table. - */ - toTableLine(): string { - const printable = this.#printableValues(); - return ( - "| " + - printable.description.padEnd(36) + - " | " + - printable.endDate.padEnd(10) + - " | " + - printable.startDate.padEnd(10) + - " | " + - printable.taxRate.padEnd(8) + - " | " + - printable.total.padEnd(9) + - " | " + - printable.unitPrice.padEnd(10) + - " |" - ); - } -} diff --git a/src/v1/product/fr/energyBill/index.ts b/src/v1/product/fr/energyBill/index.ts deleted file mode 100644 index 15d42df0d..000000000 --- a/src/v1/product/fr/energyBill/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { EnergyBillV1 } from "./energyBillV1.js"; -export { EnergyBillV1Document } from "./energyBillV1Document.js"; -export { EnergyBillV1EnergyConsumer } from "./energyBillV1EnergyConsumer.js"; -export { EnergyBillV1EnergySupplier } from "./energyBillV1EnergySupplier.js"; -export { EnergyBillV1EnergyUsage } from "./energyBillV1EnergyUsage.js"; -export { EnergyBillV1MeterDetail } from "./energyBillV1MeterDetail.js"; -export { EnergyBillV1Subscription } from "./energyBillV1Subscription.js"; -export { EnergyBillV1TaxesAndContribution } from "./energyBillV1TaxesAndContribution.js"; diff --git a/src/v1/product/fr/healthCard/healthCardV1.ts b/src/v1/product/fr/healthCard/healthCardV1.ts deleted file mode 100644 index e89f8840a..000000000 --- a/src/v1/product/fr/healthCard/healthCardV1.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; -import { HealthCardV1Document } from "./healthCardV1Document.js"; - -/** - * Health Card API version 1 inference prediction. - */ -export class HealthCardV1 extends Inference { - /** The endpoint's name. */ - endpointName = "french_healthcard"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: HealthCardV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new HealthCardV1Document(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( - HealthCardV1Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/v1/product/fr/healthCard/healthCardV1Document.ts b/src/v1/product/fr/healthCard/healthCardV1Document.ts deleted file mode 100644 index 17f0a5495..000000000 --- a/src/v1/product/fr/healthCard/healthCardV1Document.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString, -} from "@/v1/parsing/common/index.js"; -import { DateField, StringField } from "@/v1/parsing/standard/index.js"; - -/** - * Health Card API version 1.0 document data. - */ -export class HealthCardV1Document implements Prediction { - /** The given names of the card holder. */ - givenNames: StringField[] = []; - /** The date when the carte vitale document was issued. */ - issuanceDate: DateField; - /** The social security number of the card holder. */ - socialSecurity: StringField; - /** The surname of the card holder. */ - surname: StringField; - - constructor(rawPrediction: StringDict, pageId?: number) { - rawPrediction["given_names"] && - rawPrediction["given_names"].map( - (itemPrediction: StringDict) => - this.givenNames.push( - new StringField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.issuanceDate = new DateField({ - prediction: rawPrediction["issuance_date"], - pageId: pageId, - }); - this.socialSecurity = new StringField({ - prediction: rawPrediction["social_security"], - pageId: pageId, - }); - this.surname = new StringField({ - prediction: rawPrediction["surname"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - const givenNames = this.givenNames.join("\n "); - const outStr = `:Given Name(s): ${givenNames} -:Surname: ${this.surname} -:Social Security Number: ${this.socialSecurity} -:Issuance Date: ${this.issuanceDate}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/fr/healthCard/index.ts b/src/v1/product/fr/healthCard/index.ts deleted file mode 100644 index 0cf330a5e..000000000 --- a/src/v1/product/fr/healthCard/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { HealthCardV1 } from "./healthCardV1.js"; -export { HealthCardV1Document } from "./healthCardV1Document.js"; diff --git a/src/v1/product/fr/index.ts b/src/v1/product/fr/index.ts index 3960a99f5..d8fa1eebc 100644 --- a/src/v1/product/fr/index.ts +++ b/src/v1/product/fr/index.ts @@ -1,14 +1,7 @@ export { BankAccountDetailsV1 } from "./bankAccountDetails/index.js"; export { BankAccountDetailsV2 } from "./bankAccountDetails/index.js"; -export { EnergyBillV1 } from "./energyBill/index.js"; -export { HealthCardV1 } from "./healthCard/index.js"; export { IdCardV2 } from "./idCard/index.js"; -export { PayslipV3 } from "./payslip/index.js"; export { CarteGriseV1 } from "./carteGrise/index.js"; -// not sure if we want to export these -- advanced users can import them directly export * as bankAccountDetails from "./bankAccountDetails/index.js"; -export * as energyBill from "./energyBill/index.js"; -export * as healthCard from "./healthCard/index.js"; export * as idCard from "./idCard/index.js"; -export * as payslip from "./payslip/index.js"; diff --git a/src/v1/product/fr/payslip/index.ts b/src/v1/product/fr/payslip/index.ts deleted file mode 100644 index 81866fd57..000000000 --- a/src/v1/product/fr/payslip/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export { PayslipV3 } from "./payslipV3.js"; -export { PayslipV3BankAccountDetail } from "./payslipV3BankAccountDetail.js"; -export { PayslipV3Document } from "./payslipV3Document.js"; -export { PayslipV3Employee } from "./payslipV3Employee.js"; -export { PayslipV3Employer } from "./payslipV3Employer.js"; -export { PayslipV3Employment } from "./payslipV3Employment.js"; -export { PayslipV3PaidTimeOff } from "./payslipV3PaidTimeOff.js"; -export { PayslipV3PayDetail } from "./payslipV3PayDetail.js"; -export { PayslipV3PayPeriod } from "./payslipV3PayPeriod.js"; -export { PayslipV3SalaryDetail } from "./payslipV3SalaryDetail.js"; diff --git a/src/v1/product/fr/payslip/payslipV3.ts b/src/v1/product/fr/payslip/payslipV3.ts deleted file mode 100644 index 4a72be110..000000000 --- a/src/v1/product/fr/payslip/payslipV3.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; -import { PayslipV3Document } from "./payslipV3Document.js"; - -/** - * Payslip API version 3 inference prediction. - */ -export class PayslipV3 extends Inference { - /** The endpoint's name. */ - endpointName = "payslip_fra"; - /** The endpoint's version. */ - endpointVersion = "3"; - /** The document-level prediction. */ - prediction: PayslipV3Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new PayslipV3Document(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( - PayslipV3Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/v1/product/fr/payslip/payslipV3BankAccountDetail.ts b/src/v1/product/fr/payslip/payslipV3BankAccountDetail.ts deleted file mode 100644 index 12c902ef5..000000000 --- a/src/v1/product/fr/payslip/payslipV3BankAccountDetail.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the employee's bank account. - */ -export class PayslipV3BankAccountDetail { - /** The name of the bank. */ - bankName: string | null; - /** The IBAN of the bank account. */ - iban: string | null; - /** The SWIFT code of the bank. */ - swift: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.bankName = prediction["bank_name"]; - this.iban = prediction["iban"]; - this.swift = prediction["swift"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - bankName: this.bankName ?? "", - iban: this.iban ?? "", - swift: this.swift ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Bank Name: " + - printable.bankName + - ", IBAN: " + - printable.iban + - ", SWIFT: " + - printable.swift - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Bank Name: ${printable.bankName} - :IBAN: ${printable.iban} - :SWIFT: ${printable.swift}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV3Document.ts b/src/v1/product/fr/payslip/payslipV3Document.ts deleted file mode 100644 index babf3276b..000000000 --- a/src/v1/product/fr/payslip/payslipV3Document.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString,lineSeparator, -} from "@/v1/parsing/common/index.js"; -import { PayslipV3PayPeriod } from "./payslipV3PayPeriod.js"; -import { PayslipV3Employee } from "./payslipV3Employee.js"; -import { PayslipV3Employer } from "./payslipV3Employer.js"; -import { PayslipV3BankAccountDetail } from "./payslipV3BankAccountDetail.js"; -import { PayslipV3Employment } from "./payslipV3Employment.js"; -import { PayslipV3SalaryDetail } from "./payslipV3SalaryDetail.js"; -import { PayslipV3PayDetail } from "./payslipV3PayDetail.js"; -import { PayslipV3PaidTimeOff } from "./payslipV3PaidTimeOff.js"; - - -/** - * Payslip API version 3.0 document data. - */ -export class PayslipV3Document implements Prediction { - /** Information about the employee's bank account. */ - bankAccountDetails: PayslipV3BankAccountDetail; - /** Information about the employee. */ - employee: PayslipV3Employee; - /** Information about the employer. */ - employer: PayslipV3Employer; - /** Information about the employment. */ - employment: PayslipV3Employment; - /** Information about paid time off. */ - paidTimeOff: PayslipV3PaidTimeOff[] = []; - /** Detailed information about the pay. */ - payDetail: PayslipV3PayDetail; - /** Information about the pay period. */ - payPeriod: PayslipV3PayPeriod; - /** Detailed information about the earnings. */ - salaryDetails: PayslipV3SalaryDetail[] = []; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.bankAccountDetails = new PayslipV3BankAccountDetail({ - prediction: rawPrediction["bank_account_details"], - pageId: pageId, - }); - this.employee = new PayslipV3Employee({ - prediction: rawPrediction["employee"], - pageId: pageId, - }); - this.employer = new PayslipV3Employer({ - prediction: rawPrediction["employer"], - pageId: pageId, - }); - this.employment = new PayslipV3Employment({ - prediction: rawPrediction["employment"], - pageId: pageId, - }); - rawPrediction["paid_time_off"] && - rawPrediction["paid_time_off"].map( - (itemPrediction: StringDict) => - this.paidTimeOff.push( - new PayslipV3PaidTimeOff({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.payDetail = new PayslipV3PayDetail({ - prediction: rawPrediction["pay_detail"], - pageId: pageId, - }); - this.payPeriod = new PayslipV3PayPeriod({ - prediction: rawPrediction["pay_period"], - pageId: pageId, - }); - rawPrediction["salary_details"] && - rawPrediction["salary_details"].map( - (itemPrediction: StringDict) => - this.salaryDetails.push( - new PayslipV3SalaryDetail({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - } - - /** - * Default string representation. - */ - toString(): string { - let salaryDetailsSummary:string = ""; - if (this.salaryDetails && this.salaryDetails.length > 0) { - const salaryDetailsColSizes:number[] = [14, 11, 38, 8, 11]; - salaryDetailsSummary += "\n" + lineSeparator(salaryDetailsColSizes, "-") + "\n "; - salaryDetailsSummary += "| Amount "; - salaryDetailsSummary += "| Base "; - salaryDetailsSummary += "| Description "; - salaryDetailsSummary += "| Number "; - salaryDetailsSummary += "| Rate "; - salaryDetailsSummary += "|\n" + lineSeparator(salaryDetailsColSizes, "="); - salaryDetailsSummary += this.salaryDetails.map( - (item) => - "\n " + item.toTableLine() + "\n" + lineSeparator(salaryDetailsColSizes, "-") - ).join(""); - } - let paidTimeOffSummary:string = ""; - if (this.paidTimeOff && this.paidTimeOff.length > 0) { - const paidTimeOffColSizes:number[] = [11, 8, 13, 11, 11]; - paidTimeOffSummary += "\n" + lineSeparator(paidTimeOffColSizes, "-") + "\n "; - paidTimeOffSummary += "| Accrued "; - paidTimeOffSummary += "| Period "; - paidTimeOffSummary += "| Type "; - paidTimeOffSummary += "| Remaining "; - paidTimeOffSummary += "| Used "; - paidTimeOffSummary += "|\n" + lineSeparator(paidTimeOffColSizes, "="); - paidTimeOffSummary += this.paidTimeOff.map( - (item) => - "\n " + item.toTableLine() + "\n" + lineSeparator(paidTimeOffColSizes, "-") - ).join(""); - } - const outStr = `:Pay Period: ${this.payPeriod.toFieldList()} -:Employee: ${this.employee.toFieldList()} -:Employer: ${this.employer.toFieldList()} -:Bank Account Details: ${this.bankAccountDetails.toFieldList()} -:Employment: ${this.employment.toFieldList()} -:Salary Details: ${salaryDetailsSummary} -:Pay Detail: ${this.payDetail.toFieldList()} -:Paid Time Off: ${paidTimeOffSummary}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/fr/payslip/payslipV3Employee.ts b/src/v1/product/fr/payslip/payslipV3Employee.ts deleted file mode 100644 index 284930d8c..000000000 --- a/src/v1/product/fr/payslip/payslipV3Employee.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the employee. - */ -export class PayslipV3Employee { - /** The address of the employee. */ - address: string | null; - /** The date of birth of the employee. */ - dateOfBirth: string | null; - /** The first name of the employee. */ - firstName: string | null; - /** The last name of the employee. */ - lastName: string | null; - /** The phone number of the employee. */ - phoneNumber: string | null; - /** The registration number of the employee. */ - registrationNumber: string | null; - /** The social security number of the employee. */ - socialSecurityNumber: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.address = prediction["address"]; - this.dateOfBirth = prediction["date_of_birth"]; - this.firstName = prediction["first_name"]; - this.lastName = prediction["last_name"]; - this.phoneNumber = prediction["phone_number"]; - this.registrationNumber = prediction["registration_number"]; - this.socialSecurityNumber = prediction["social_security_number"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - address: this.address ?? "", - dateOfBirth: this.dateOfBirth ?? "", - firstName: this.firstName ?? "", - lastName: this.lastName ?? "", - phoneNumber: this.phoneNumber ?? "", - registrationNumber: this.registrationNumber ?? "", - socialSecurityNumber: this.socialSecurityNumber ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Address: " + - printable.address + - ", Date of Birth: " + - printable.dateOfBirth + - ", First Name: " + - printable.firstName + - ", Last Name: " + - printable.lastName + - ", Phone Number: " + - printable.phoneNumber + - ", Registration Number: " + - printable.registrationNumber + - ", Social Security Number: " + - printable.socialSecurityNumber - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Address: ${printable.address} - :Date of Birth: ${printable.dateOfBirth} - :First Name: ${printable.firstName} - :Last Name: ${printable.lastName} - :Phone Number: ${printable.phoneNumber} - :Registration Number: ${printable.registrationNumber} - :Social Security Number: ${printable.socialSecurityNumber}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV3Employer.ts b/src/v1/product/fr/payslip/payslipV3Employer.ts deleted file mode 100644 index b682f3e5b..000000000 --- a/src/v1/product/fr/payslip/payslipV3Employer.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the employer. - */ -export class PayslipV3Employer { - /** The address of the employer. */ - address: string | null; - /** The company ID of the employer. */ - companyId: string | null; - /** The site of the company. */ - companySite: string | null; - /** The NAF code of the employer. */ - nafCode: string | null; - /** The name of the employer. */ - name: string | null; - /** The phone number of the employer. */ - phoneNumber: string | null; - /** The URSSAF number of the employer. */ - urssafNumber: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.address = prediction["address"]; - this.companyId = prediction["company_id"]; - this.companySite = prediction["company_site"]; - this.nafCode = prediction["naf_code"]; - this.name = prediction["name"]; - this.phoneNumber = prediction["phone_number"]; - this.urssafNumber = prediction["urssaf_number"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - address: this.address ?? "", - companyId: this.companyId ?? "", - companySite: this.companySite ?? "", - nafCode: this.nafCode ?? "", - name: this.name ?? "", - phoneNumber: this.phoneNumber ?? "", - urssafNumber: this.urssafNumber ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Address: " + - printable.address + - ", Company ID: " + - printable.companyId + - ", Company Site: " + - printable.companySite + - ", NAF Code: " + - printable.nafCode + - ", Name: " + - printable.name + - ", Phone Number: " + - printable.phoneNumber + - ", URSSAF Number: " + - printable.urssafNumber - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Address: ${printable.address} - :Company ID: ${printable.companyId} - :Company Site: ${printable.companySite} - :NAF Code: ${printable.nafCode} - :Name: ${printable.name} - :Phone Number: ${printable.phoneNumber} - :URSSAF Number: ${printable.urssafNumber}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV3Employment.ts b/src/v1/product/fr/payslip/payslipV3Employment.ts deleted file mode 100644 index 5fd91d45e..000000000 --- a/src/v1/product/fr/payslip/payslipV3Employment.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the employment. - */ -export class PayslipV3Employment { - /** The category of the employment. */ - category: string | null; - /** The coefficient of the employment. */ - coefficient: string | null; - /** The collective agreement of the employment. */ - collectiveAgreement: string | null; - /** The job title of the employee. */ - jobTitle: string | null; - /** The position level of the employment. */ - positionLevel: string | null; - /** The seniority date of the employment. */ - seniorityDate: string | null; - /** The start date of the employment. */ - startDate: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.category = prediction["category"]; - this.coefficient = prediction["coefficient"]; - this.collectiveAgreement = prediction["collective_agreement"]; - this.jobTitle = prediction["job_title"]; - this.positionLevel = prediction["position_level"]; - this.seniorityDate = prediction["seniority_date"]; - this.startDate = prediction["start_date"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - category: this.category ?? "", - coefficient: this.coefficient ?? "", - collectiveAgreement: this.collectiveAgreement ?? "", - jobTitle: this.jobTitle ?? "", - positionLevel: this.positionLevel ?? "", - seniorityDate: this.seniorityDate ?? "", - startDate: this.startDate ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Category: " + - printable.category + - ", Coefficient: " + - printable.coefficient + - ", Collective Agreement: " + - printable.collectiveAgreement + - ", Job Title: " + - printable.jobTitle + - ", Position Level: " + - printable.positionLevel + - ", Seniority Date: " + - printable.seniorityDate + - ", Start Date: " + - printable.startDate - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Category: ${printable.category} - :Coefficient: ${printable.coefficient} - :Collective Agreement: ${printable.collectiveAgreement} - :Job Title: ${printable.jobTitle} - :Position Level: ${printable.positionLevel} - :Seniority Date: ${printable.seniorityDate} - :Start Date: ${printable.startDate}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV3PaidTimeOff.ts b/src/v1/product/fr/payslip/payslipV3PaidTimeOff.ts deleted file mode 100644 index c537e8208..000000000 --- a/src/v1/product/fr/payslip/payslipV3PaidTimeOff.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about paid time off. - */ -export class PayslipV3PaidTimeOff { - /** The amount of paid time off accrued in the period. */ - accrued: number | null; - /** The paid time off period. */ - period: string | null; - /** The type of paid time off. */ - ptoType: string | null; - /** The remaining amount of paid time off at the end of the period. */ - remaining: number | null; - /** The amount of paid time off used in the period. */ - used: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["accrued"] !== undefined && - prediction["accrued"] !== null && - !isNaN(prediction["accrued"]) - ) { - this.accrued = +parseFloat(prediction["accrued"]); - } else { - this.accrued = null; - } - this.period = prediction["period"]; - this.ptoType = prediction["pto_type"]; - if ( - prediction["remaining"] !== undefined && - prediction["remaining"] !== null && - !isNaN(prediction["remaining"]) - ) { - this.remaining = +parseFloat(prediction["remaining"]); - } else { - this.remaining = null; - } - if ( - prediction["used"] !== undefined && - prediction["used"] !== null && - !isNaN(prediction["used"]) - ) { - this.used = +parseFloat(prediction["used"]); - } else { - this.used = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - accrued: this.accrued !== undefined ? floatToString(this.accrued) : "", - period: this.period ? - this.period.length <= 6 ? - cleanSpecialChars(this.period) : - cleanSpecialChars(this.period).slice(0, 3) + "..." : - "", - ptoType: this.ptoType ? - this.ptoType.length <= 11 ? - cleanSpecialChars(this.ptoType) : - cleanSpecialChars(this.ptoType).slice(0, 8) + "..." : - "", - remaining: this.remaining !== undefined ? floatToString(this.remaining) : "", - used: this.used !== undefined ? floatToString(this.used) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Accrued: " + - printable.accrued + - ", Period: " + - printable.period + - ", Type: " + - printable.ptoType + - ", Remaining: " + - printable.remaining + - ", Used: " + - printable.used - ); - } - - /** - * Output in a format suitable for inclusion in an rST table. - */ - toTableLine(): string { - const printable = this.#printableValues(); - return ( - "| " + - printable.accrued.padEnd(9) + - " | " + - printable.period.padEnd(6) + - " | " + - printable.ptoType.padEnd(11) + - " | " + - printable.remaining.padEnd(9) + - " | " + - printable.used.padEnd(9) + - " |" - ); - } -} diff --git a/src/v1/product/fr/payslip/payslipV3PayDetail.ts b/src/v1/product/fr/payslip/payslipV3PayDetail.ts deleted file mode 100644 index 2d1d66c4a..000000000 --- a/src/v1/product/fr/payslip/payslipV3PayDetail.ts +++ /dev/null @@ -1,210 +0,0 @@ -import { floatToString } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Detailed information about the pay. - */ -export class PayslipV3PayDetail { - /** The gross salary of the employee. */ - grossSalary: number | null; - /** The year-to-date gross salary of the employee. */ - grossSalaryYtd: number | null; - /** The income tax rate of the employee. */ - incomeTaxRate: number | null; - /** The income tax withheld from the employee's pay. */ - incomeTaxWithheld: number | null; - /** The net paid amount of the employee. */ - netPaid: number | null; - /** The net paid amount before tax of the employee. */ - netPaidBeforeTax: number | null; - /** The net taxable amount of the employee. */ - netTaxable: number | null; - /** The year-to-date net taxable amount of the employee. */ - netTaxableYtd: number | null; - /** The total cost to the employer. */ - totalCostEmployer: number | null; - /** The total taxes and deductions of the employee. */ - totalTaxesAndDeductions: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["gross_salary"] !== undefined && - prediction["gross_salary"] !== null && - !isNaN(prediction["gross_salary"]) - ) { - this.grossSalary = +parseFloat(prediction["gross_salary"]); - } else { - this.grossSalary = null; - } - if ( - prediction["gross_salary_ytd"] !== undefined && - prediction["gross_salary_ytd"] !== null && - !isNaN(prediction["gross_salary_ytd"]) - ) { - this.grossSalaryYtd = +parseFloat(prediction["gross_salary_ytd"]); - } else { - this.grossSalaryYtd = null; - } - if ( - prediction["income_tax_rate"] !== undefined && - prediction["income_tax_rate"] !== null && - !isNaN(prediction["income_tax_rate"]) - ) { - this.incomeTaxRate = +parseFloat(prediction["income_tax_rate"]); - } else { - this.incomeTaxRate = null; - } - if ( - prediction["income_tax_withheld"] !== undefined && - prediction["income_tax_withheld"] !== null && - !isNaN(prediction["income_tax_withheld"]) - ) { - this.incomeTaxWithheld = +parseFloat(prediction["income_tax_withheld"]); - } else { - this.incomeTaxWithheld = null; - } - if ( - prediction["net_paid"] !== undefined && - prediction["net_paid"] !== null && - !isNaN(prediction["net_paid"]) - ) { - this.netPaid = +parseFloat(prediction["net_paid"]); - } else { - this.netPaid = null; - } - if ( - prediction["net_paid_before_tax"] !== undefined && - prediction["net_paid_before_tax"] !== null && - !isNaN(prediction["net_paid_before_tax"]) - ) { - this.netPaidBeforeTax = +parseFloat(prediction["net_paid_before_tax"]); - } else { - this.netPaidBeforeTax = null; - } - if ( - prediction["net_taxable"] !== undefined && - prediction["net_taxable"] !== null && - !isNaN(prediction["net_taxable"]) - ) { - this.netTaxable = +parseFloat(prediction["net_taxable"]); - } else { - this.netTaxable = null; - } - if ( - prediction["net_taxable_ytd"] !== undefined && - prediction["net_taxable_ytd"] !== null && - !isNaN(prediction["net_taxable_ytd"]) - ) { - this.netTaxableYtd = +parseFloat(prediction["net_taxable_ytd"]); - } else { - this.netTaxableYtd = null; - } - if ( - prediction["total_cost_employer"] !== undefined && - prediction["total_cost_employer"] !== null && - !isNaN(prediction["total_cost_employer"]) - ) { - this.totalCostEmployer = +parseFloat(prediction["total_cost_employer"]); - } else { - this.totalCostEmployer = null; - } - if ( - prediction["total_taxes_and_deductions"] !== undefined && - prediction["total_taxes_and_deductions"] !== null && - !isNaN(prediction["total_taxes_and_deductions"]) - ) { - this.totalTaxesAndDeductions = +parseFloat(prediction["total_taxes_and_deductions"]); - } else { - this.totalTaxesAndDeductions = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - grossSalary: - this.grossSalary !== undefined ? floatToString(this.grossSalary) : "", - grossSalaryYtd: - this.grossSalaryYtd !== undefined ? floatToString(this.grossSalaryYtd) : "", - incomeTaxRate: - this.incomeTaxRate !== undefined ? floatToString(this.incomeTaxRate) : "", - incomeTaxWithheld: - this.incomeTaxWithheld !== undefined ? floatToString(this.incomeTaxWithheld) : "", - netPaid: this.netPaid !== undefined ? floatToString(this.netPaid) : "", - netPaidBeforeTax: - this.netPaidBeforeTax !== undefined ? floatToString(this.netPaidBeforeTax) : "", - netTaxable: - this.netTaxable !== undefined ? floatToString(this.netTaxable) : "", - netTaxableYtd: - this.netTaxableYtd !== undefined ? floatToString(this.netTaxableYtd) : "", - totalCostEmployer: - this.totalCostEmployer !== undefined ? floatToString(this.totalCostEmployer) : "", - totalTaxesAndDeductions: - this.totalTaxesAndDeductions !== undefined ? floatToString(this.totalTaxesAndDeductions) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Gross Salary: " + - printable.grossSalary + - ", Gross Salary YTD: " + - printable.grossSalaryYtd + - ", Income Tax Rate: " + - printable.incomeTaxRate + - ", Income Tax Withheld: " + - printable.incomeTaxWithheld + - ", Net Paid: " + - printable.netPaid + - ", Net Paid Before Tax: " + - printable.netPaidBeforeTax + - ", Net Taxable: " + - printable.netTaxable + - ", Net Taxable YTD: " + - printable.netTaxableYtd + - ", Total Cost Employer: " + - printable.totalCostEmployer + - ", Total Taxes and Deductions: " + - printable.totalTaxesAndDeductions - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Gross Salary: ${printable.grossSalary} - :Gross Salary YTD: ${printable.grossSalaryYtd} - :Income Tax Rate: ${printable.incomeTaxRate} - :Income Tax Withheld: ${printable.incomeTaxWithheld} - :Net Paid: ${printable.netPaid} - :Net Paid Before Tax: ${printable.netPaidBeforeTax} - :Net Taxable: ${printable.netTaxable} - :Net Taxable YTD: ${printable.netTaxableYtd} - :Total Cost Employer: ${printable.totalCostEmployer} - :Total Taxes and Deductions: ${printable.totalTaxesAndDeductions}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV3PayPeriod.ts b/src/v1/product/fr/payslip/payslipV3PayPeriod.ts deleted file mode 100644 index 950af3e4d..000000000 --- a/src/v1/product/fr/payslip/payslipV3PayPeriod.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Information about the pay period. - */ -export class PayslipV3PayPeriod { - /** The end date of the pay period. */ - endDate: string | null; - /** The month of the pay period. */ - month: string | null; - /** The date of payment for the pay period. */ - paymentDate: string | null; - /** The start date of the pay period. */ - startDate: string | null; - /** The year of the pay period. */ - year: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.endDate = prediction["end_date"]; - this.month = prediction["month"]; - this.paymentDate = prediction["payment_date"]; - this.startDate = prediction["start_date"]; - this.year = prediction["year"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - endDate: this.endDate ?? "", - month: this.month ?? "", - paymentDate: this.paymentDate ?? "", - startDate: this.startDate ?? "", - year: this.year ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "End Date: " + - printable.endDate + - ", Month: " + - printable.month + - ", Payment Date: " + - printable.paymentDate + - ", Start Date: " + - printable.startDate + - ", Year: " + - printable.year - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :End Date: ${printable.endDate} - :Month: ${printable.month} - :Payment Date: ${printable.paymentDate} - :Start Date: ${printable.startDate} - :Year: ${printable.year}`.trimEnd(); - } -} diff --git a/src/v1/product/fr/payslip/payslipV3SalaryDetail.ts b/src/v1/product/fr/payslip/payslipV3SalaryDetail.ts deleted file mode 100644 index bbc0e9482..000000000 --- a/src/v1/product/fr/payslip/payslipV3SalaryDetail.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; -import { StringDict } from "@/parsing/stringDict.js"; -import { Polygon } from "@/geometry/index.js"; - -/** - * Detailed information about the earnings. - */ -export class PayslipV3SalaryDetail { - /** The amount of the earning. */ - amount: number | null; - /** The base rate value of the earning. */ - base: number | null; - /** The description of the earnings. */ - description: string | null; - /** The number of units in the earning. */ - number: number | null; - /** The rate of the earning. */ - rate: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["amount"] !== undefined && - prediction["amount"] !== null && - !isNaN(prediction["amount"]) - ) { - this.amount = +parseFloat(prediction["amount"]); - } else { - this.amount = null; - } - if ( - prediction["base"] !== undefined && - prediction["base"] !== null && - !isNaN(prediction["base"]) - ) { - this.base = +parseFloat(prediction["base"]); - } else { - this.base = null; - } - this.description = prediction["description"]; - if ( - prediction["number"] !== undefined && - prediction["number"] !== null && - !isNaN(prediction["number"]) - ) { - this.number = +parseFloat(prediction["number"]); - } else { - this.number = null; - } - if ( - prediction["rate"] !== undefined && - prediction["rate"] !== null && - !isNaN(prediction["rate"]) - ) { - this.rate = +parseFloat(prediction["rate"]); - } else { - this.rate = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - amount: this.amount !== undefined ? floatToString(this.amount) : "", - base: this.base !== undefined ? floatToString(this.base) : "", - description: this.description ? - this.description.length <= 36 ? - cleanSpecialChars(this.description) : - cleanSpecialChars(this.description).slice(0, 33) + "..." : - "", - number: this.number !== undefined ? floatToString(this.number) : "", - rate: this.rate !== undefined ? floatToString(this.rate) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Amount: " + - printable.amount + - ", Base: " + - printable.base + - ", Description: " + - printable.description + - ", Number: " + - printable.number + - ", Rate: " + - printable.rate - ); - } - - /** - * Output in a format suitable for inclusion in an rST table. - */ - toTableLine(): string { - const printable = this.#printableValues(); - return ( - "| " + - printable.amount.padEnd(12) + - " | " + - printable.base.padEnd(9) + - " | " + - printable.description.padEnd(36) + - " | " + - printable.number.padEnd(6) + - " | " + - printable.rate.padEnd(9) + - " |" - ); - } -} diff --git a/tests/v1/product/fr/energyBill/energyBillV1.spec.ts b/tests/v1/product/fr/energyBill/energyBillV1.spec.ts deleted file mode 100644 index e7a41cc6c..000000000 --- a/tests/v1/product/fr/energyBill/energyBillV1.spec.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index.js"; -import { expect } from "chai"; -import * as mindee from "@/index.js"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "energy_bill_fra/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "energy_bill_fra/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "energy_bill_fra/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "energy_bill_fra/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - EnergyBillV1 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.v1.Document(mindee.v1.product.fr.EnergyBillV1, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.invoiceNumber.value).to.be.undefined; - expect(docPrediction.contractId.value).to.be.undefined; - expect(docPrediction.deliveryPoint.value).to.be.undefined; - expect(docPrediction.invoiceDate.value).to.be.undefined; - expect(docPrediction.dueDate.value).to.be.undefined; - expect(docPrediction.totalBeforeTaxes.value).to.be.undefined; - expect(docPrediction.totalTaxes.value).to.be.undefined; - expect(docPrediction.totalAmount.value).to.be.undefined; - expect(docPrediction.energySupplier.address).to.be.null; - expect(docPrediction.energySupplier.name).to.be.null; - expect(docPrediction.energyConsumer.address).to.be.null; - expect(docPrediction.energyConsumer.name).to.be.null; - expect(docPrediction.subscription.length).to.be.equals(0); - expect(docPrediction.energyUsage.length).to.be.equals(0); - expect(docPrediction.taxesAndContributions.length).to.be.equals(0); - expect(docPrediction.meterDetails.meterNumber).to.be.null; - expect(docPrediction.meterDetails.meterType).to.be.null; - expect(docPrediction.meterDetails.unit).to.be.null; - }); - - 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.v1.Document(mindee.v1.product.fr.EnergyBillV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); diff --git a/tests/v1/product/fr/healthCard/healthCardV1.spec.ts b/tests/v1/product/fr/healthCard/healthCardV1.spec.ts deleted file mode 100644 index bdf2ba948..000000000 --- a/tests/v1/product/fr/healthCard/healthCardV1.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index.js"; -import { expect } from "chai"; -import * as mindee from "@/index.js"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "french_healthcard/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "french_healthcard/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "french_healthcard/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "french_healthcard/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - HealthCardV1 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.v1.Document(mindee.v1.product.fr.HealthCardV1, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.givenNames.length).to.be.equals(0); - expect(docPrediction.surname.value).to.be.undefined; - expect(docPrediction.socialSecurity.value).to.be.undefined; - expect(docPrediction.issuanceDate.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.v1.Document(mindee.v1.product.fr.HealthCardV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); diff --git a/tests/v1/product/fr/payslip/payslipV3.spec.ts b/tests/v1/product/fr/payslip/payslipV3.spec.ts deleted file mode 100644 index d8034a58c..000000000 --- a/tests/v1/product/fr/payslip/payslipV3.spec.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index.js"; -import { expect } from "chai"; -import * as mindee from "@/index.js"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "payslip_fra/response_v3/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "payslip_fra/response_v3/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "payslip_fra/response_v3/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "payslip_fra/response_v3/summary_page0.rst"), -}; - -describe("MindeeV1 - PayslipV3 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.v1.Document(mindee.v1.product.fr.PayslipV3, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.payPeriod.endDate).to.be.null; - expect(docPrediction.payPeriod.month).to.be.null; - expect(docPrediction.payPeriod.paymentDate).to.be.null; - expect(docPrediction.payPeriod.startDate).to.be.null; - expect(docPrediction.payPeriod.year).to.be.null; - expect(docPrediction.employee.address).to.be.null; - expect(docPrediction.employee.dateOfBirth).to.be.null; - expect(docPrediction.employee.firstName).to.be.null; - expect(docPrediction.employee.lastName).to.be.null; - expect(docPrediction.employee.phoneNumber).to.be.null; - expect(docPrediction.employee.registrationNumber).to.be.null; - expect(docPrediction.employee.socialSecurityNumber).to.be.null; - expect(docPrediction.employer.address).to.be.null; - expect(docPrediction.employer.companyId).to.be.null; - expect(docPrediction.employer.companySite).to.be.null; - expect(docPrediction.employer.nafCode).to.be.null; - expect(docPrediction.employer.name).to.be.null; - expect(docPrediction.employer.phoneNumber).to.be.null; - expect(docPrediction.employer.urssafNumber).to.be.null; - expect(docPrediction.bankAccountDetails.bankName).to.be.null; - expect(docPrediction.bankAccountDetails.iban).to.be.null; - expect(docPrediction.bankAccountDetails.swift).to.be.null; - expect(docPrediction.employment.category).to.be.null; - expect(docPrediction.employment.coefficient).to.be.null; - expect(docPrediction.employment.collectiveAgreement).to.be.null; - expect(docPrediction.employment.jobTitle).to.be.null; - expect(docPrediction.employment.positionLevel).to.be.null; - expect(docPrediction.employment.seniorityDate).to.be.null; - expect(docPrediction.employment.startDate).to.be.null; - expect(docPrediction.salaryDetails.length).to.be.equals(0); - expect(docPrediction.payDetail.grossSalary).to.be.null; - expect(docPrediction.payDetail.grossSalaryYtd).to.be.null; - expect(docPrediction.payDetail.incomeTaxRate).to.be.null; - expect(docPrediction.payDetail.incomeTaxWithheld).to.be.null; - expect(docPrediction.payDetail.netPaid).to.be.null; - expect(docPrediction.payDetail.netPaidBeforeTax).to.be.null; - expect(docPrediction.payDetail.netTaxable).to.be.null; - expect(docPrediction.payDetail.netTaxableYtd).to.be.null; - expect(docPrediction.payDetail.totalCostEmployer).to.be.null; - expect(docPrediction.payDetail.totalTaxesAndDeductions).to.be.null; - expect(docPrediction.paidTimeOff.length).to.be.equals(0); - }); - - 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.v1.Document(mindee.v1.product.fr.PayslipV3, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -});