From 249f8b56d73cd7bd44f30e10f68c19b53d452fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Tue, 13 Jan 2026 12:08:41 +0100 Subject: [PATCH] :bug: fix examples --- .../invoiceSplitterCustomSplitsTutorial.js | 25 +++++++++------ example/invoiceSplitterTutorial.js | 27 +++++++++------- example/multiReceiptsTutorial.js | 32 ++++++++++++------- 3 files changed, 51 insertions(+), 33 deletions(-) diff --git a/example/invoiceSplitterCustomSplitsTutorial.js b/example/invoiceSplitterCustomSplitsTutorial.js index 0028a6ee..95c2df57 100644 --- a/example/invoiceSplitterCustomSplitsTutorial.js +++ b/example/invoiceSplitterCustomSplitsTutorial.js @@ -1,26 +1,31 @@ -const { Client, product, imageOperations, PathInput } = require("mindee"); const { setTimeout } = require("node:timers/promises"); +const mindee = require("mindee"); -async function parseInvoicesWithCustomSplitsThreshold(customSplits) { +async function parseInvoicesWithCustomSplitsThreshold(inputPath, customSplits) { // fill in your API key or add it as an environment variable - const mindeeClient = new Client(); + const mindeeClient = new mindee.v1.Client(); // Load a file from disk - const inputSource = new PathInput( - { inputPath: "/path/to/the/file.ext" } + const inputSource = new mindee.PathInput( + { inputPath: inputPath } ); - let invoices = await imageOperations.extractInvoices(inputSource, customSplits); + let invoices = await mindee.v1.extraction.extractInvoices(inputSource, customSplits); for (const invoice of invoices) { // optional: save the documents locally invoice.saveToFile(`/tmp/invoice_p_${invoice.pageIdMin}-${invoice.pageIdMax}.pdf`); - const respInvoice = await mindeeClient.parse(product.InvoiceV4, invoice.asSource()); + const respInvoice = await mindeeClient.parse( + mindee.v1.product.InvoiceV4, invoice.asSource() + ); console.log(respInvoice.document.toString()); - await setTimeout(1000); // wait some time between requests as to not overload the server + // wait some time between requests as to not overload the server + await setTimeout(1000); } - } const customSplits = [[0, 1], [1, 2]]; -parseInvoicesWithCustomSplitsThreshold(customSplits); +parseInvoicesWithCustomSplitsThreshold( + "/path/to/the/file.ext", + customSplits +); diff --git a/example/invoiceSplitterTutorial.js b/example/invoiceSplitterTutorial.js index 03b69c08..8bdece0e 100644 --- a/example/invoiceSplitterTutorial.js +++ b/example/invoiceSplitterTutorial.js @@ -1,27 +1,32 @@ -const { Client, product, imageOperations, PathInput } = require("mindee"); const { setTimeout } = require("node:timers/promises"); +const mindee = require("mindee"); -async function parseInvoices() { +async function parseInvoices(inputPath) { // fill in your API key or add it as an environment variable - const mindeeClient = new Client(); + const mindeeClient = new mindee.v1.Client(); // Load a file from disk - const inputSource = new PathInput( - { inputPath: "/path/to/the/file.ext" } + const inputSource = new mindee.PathInput( + { inputPath: inputPath } ); const resp = await mindeeClient.enqueueAndParse( - product.InvoiceSplitterV1, inputSource + mindee.v1.product.InvoiceSplitterV1, + inputSource + ); + let invoices = await mindee.v1.extraction.extractInvoices( + inputSource, resp.document.inference ); - let invoices = await imageOperations.extractInvoices(inputSource, resp.document.inference); for (const invoice of invoices) { // optional: save the documents locally invoice.saveToFile(`/tmp/invoice_p_${invoice.pageIdMin}-${invoice.pageIdMax}.pdf`); - const respInvoice = await mindeeClient.parse(product.InvoiceV4, invoice.asSource()); + const respInvoice = await mindeeClient.parse( + mindee.v1.product.InvoiceV4, invoice.asSource() + ); console.log(respInvoice.document.toString()); - await setTimeout(1000); // wait some time between requests as to not overload the server + // wait some time between requests as to not overload the server + await setTimeout(1000); } - } -parseInvoices(); +parseInvoices("/path/to/the/file.ext"); diff --git a/example/multiReceiptsTutorial.js b/example/multiReceiptsTutorial.js index 96f77c6e..f52654a8 100644 --- a/example/multiReceiptsTutorial.js +++ b/example/multiReceiptsTutorial.js @@ -1,24 +1,32 @@ -const { Client, product, imageOperations, PathInput } = require("mindee"); const { setTimeout } = require("node:timers/promises"); +const mindee = require("mindee"); -async function parseReceipts() { +async function parseReceipts(inputPath) { // fill in your API key or add it as an environment variable - const mindeeClient = new Client(); + const mindeeClient = new mindee.v1.Client(); // Load a file from disk - const inputSource = new PathInput( - { inputPath: "/path/to/the/file.ext" } + const inputSource = new mindee.PathInput( + { inputPath: inputPath } ); - const resp = await mindeeClient.parse(product.MultiReceiptsDetectorV1, inputSource); - let receipts = await imageOperations.extractReceipts(inputSource, resp.document.inference); + const resp = await mindeeClient.parse( + mindee.v1.product.MultiReceiptsDetectorV1, inputSource + ); + let receipts = await mindee.v1.extraction.extractReceipts( + inputSource, resp.document.inference + ); for (const receipt of receipts) { - const respReceipt = await mindeeClient.parse(product.ReceiptV5, receipt.asSource()); + const respReceipt = await mindeeClient.parse( + mindee.v1.product.ReceiptV5, receipt.asSource() + ); console.log(respReceipt.document.toString()); - receipt.saveToFile(`/tmp/receipt_p${receipt.pageId}_${receipt.receiptId}.pdf`); //optional: save to a file - await setTimeout(1000); // wait some time between requests as to not overload the server - } + // optional: save to a file + receipt.saveToFile(`/tmp/receipt_p${receipt.pageId}_${receipt.receiptId}.pdf`); + // wait some time between requests as to not overload the server + await setTimeout(1000); + } } -parseReceipts(); +parseReceipts("/path/to/the/file.ext");