Socket
Socket
Sign inDemoInstall

mindee

Package Overview
Dependencies
Maintainers
7
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mindee - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

6

CHANGELOG.md
# CHANGELOG
## v1.2.0
### Fixes
- fix: 🐛 Get `words` values when `includeWords` parameter is `true`
## v1.1.2

@@ -4,0 +10,0 @@

6

mindee/api/financialDocument.js

@@ -40,6 +40,6 @@ const APIObject = require("./object");

inputFile.fileExtension === "application/pdf"
? "/invoices/v3/predict"
: "/expense_receipts/v3/predict";
? `/invoices/v${version}/predict`
: `/expense_receipts/v${version}/predict`;
super.parse();
return await super._request(url, inputFile, version, includeWords);
return super._request(url, inputFile, includeWords);
}

@@ -46,0 +46,0 @@ }

@@ -13,3 +13,3 @@ const Response = require("./response");

this.apiToken = apiToken;
this.baseUrl = "https://api.mindee.net/v1/products/mindee/";
this.baseUrl = "https://api.mindee.net/v1/products/mindee";
this.apiName = apiName;

@@ -16,0 +16,0 @@ }

@@ -9,3 +9,3 @@ const https = require("https");

return new Promise(function (resolve, reject) {
const form = new FormData();
let form = new FormData();
let body;

@@ -12,0 +12,0 @@

@@ -35,2 +35,3 @@ const Receipt = require("../documents").receipt;

formatResponse() {
let http_data_document = this.httpResponse.data.document;
const constructors = {

@@ -41,7 +42,20 @@ receipt: (params) => new Receipt(params),

};
const predictions = this.httpResponse.data.document.inference.pages.entries();
const predictions = http_data_document.inference.pages.entries();
this[`${this.documentType}s`] = [];
let document_words_content = [];
// Create a list of Document (Receipt, Invoice...) for each page of the input document
for (const [pageNumber, prediction] of predictions) {
let page_words_content = [];
if (
"ocr" in http_data_document &&
Object.keys(http_data_document.ocr).length > 0
) {
page_words_content =
http_data_document.ocr["mvision-v1"].pages[pageNumber].all_words;
document_words_content.push(
...http_data_document.ocr["mvision-v1"].pages[pageNumber].all_words
);
}
this[`${this.documentType}s`].push(

@@ -52,2 +66,3 @@ constructors[this.documentType]({

pageNumber: pageNumber,
words: page_words_content,
})

@@ -59,6 +74,7 @@ );

this[this.documentType] = constructors[this.documentType]({
apiPrediction: this.httpResponse.data.document.inference.prediction,
apiPrediction: http_data_document.inference.prediction,
inputFile: this.input,
pageNumber: this.httpResponse.data.document.n_pages,
pageNumber: http_data_document.n_pages,
level: "document",
words: document_words_content,
});

@@ -65,0 +81,0 @@ }

@@ -57,2 +57,3 @@ const Document = require("./document");

customerCompanyRegistration = undefined,
words = undefined,
pageNumber = 0,

@@ -86,3 +87,3 @@ level = "page",

} else {
this.#initFromApiPrediction(apiPrediction, inputFile, pageNumber);
this.#initFromApiPrediction(apiPrediction, inputFile, pageNumber, words);
}

@@ -150,3 +151,3 @@ this.#checklist();

#initFromApiPrediction(apiPrediction, inputFile, pageNumber) {
#initFromApiPrediction(apiPrediction, inputFile, pageNumber, words) {
if (Object.keys(apiPrediction).includes("invoice_number")) {

@@ -158,2 +159,3 @@ const invoice = new Invoice({

level: this.level,
words: words,
});

@@ -173,2 +175,3 @@ this.locale = invoice.locale;

this.totalTax = invoice.totalTax;
if (invoice.words) this.words = invoice.words;
this.time = new Field({

@@ -186,2 +189,3 @@ prediction: { value: undefined, confidence: 0.0 },

level: this.level,
words: words,
});

@@ -217,2 +221,3 @@ this.orientation = receipt.orientation;

this.customerCompanyRegistration = [];
if (receipt.words) this.words = receipt.words;
}

@@ -219,0 +224,0 @@ }

@@ -53,2 +53,3 @@ const Document = require("./document");

customerCompanyRegistration = undefined,
words = undefined,
pageNumber = 0,

@@ -84,3 +85,3 @@ level = "page",

} else {
this.#initFromApiPrediction(apiPrediction, pageNumber);
this.#initFromApiPrediction(apiPrediction, pageNumber, words);
}

@@ -147,4 +148,3 @@ this.#checklist();

#initFromApiPrediction(apiPrediction, pageNumber) {
this.words = [];
#initFromApiPrediction(apiPrediction, pageNumber, words) {
this.locale = new Locale({ prediction: apiPrediction.locale, pageNumber });

@@ -249,4 +249,3 @@ this.totalIncl = new Amount({

}
// document.inference.ocr
if ("mvision" in apiPrediction) this.words = apiPrediction.mvision;
if (words && words.length > 0) this.words = words;
}

@@ -253,0 +252,0 @@

@@ -40,2 +40,3 @@ const Document = require("./document");

totalExcl = undefined,
words = undefined,
pageNumber = 0,

@@ -64,3 +65,3 @@ level = "page",

} else {
this.#initFromApiPrediction(apiPrediction, pageNumber);
this.#initFromApiPrediction(apiPrediction, pageNumber, words);
}

@@ -113,4 +114,3 @@ this.#checklist();

*/
#initFromApiPrediction(apiPrediction, pageNumber) {
this.words = [];
#initFromApiPrediction(apiPrediction, pageNumber, words) {
this.locale = new Locale({ prediction: apiPrediction.locale, pageNumber });

@@ -177,3 +177,3 @@ this.totalIncl = new Amount({

}
if ("mvision" in apiPrediction) this.words = apiPrediction.mvision;
if (words && words.length > 0) this.words = words;
}

@@ -180,0 +180,0 @@

{
"name": "mindee",
"version": "1.1.2",
"version": "1.2.0",
"description": "Mindee API SDK for Node.js",

@@ -5,0 +5,0 @@ "main": "mindee/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc