Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mindee

Package Overview
Dependencies
Maintainers
7
Versions
73
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 4.5.0 to 4.6.0

src/imageOperations/extractedInvoiceSplitterDocument.d.ts

9

CHANGELOG.md
# CHANGELOG
## v4.6.0 - 2023-12-11
### Changes
* :sparkles: add invoice-splitter auto-splitting feature
* :memo: add examples to illustrate auto-splitting feature
* :recycle: add unit tests for auto-splitting feature
* :recycle: rename `exemple` folder to `example`
* :arrow_up: update testing library
## v4.5.0 - 2023-11-29

@@ -4,0 +13,0 @@ ### Changes

2

package.json
{
"name": "mindee",
"version": "4.5.0",
"version": "4.6.0",
"description": "Mindee Client Library for Node.js",

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

/// <reference types="node" />
import { Buffer } from "node:buffer";
import { BufferInput } from "../input/sources";
export interface ExtractedImage {
readonly pageId: number;
imageData: Buffer;
import { BufferInput } from "../input";
export declare abstract class ExtractedImage {
buffer: Buffer;
protected internalFileName: string;
constructor(buffer: Uint8Array, fileName: string);
/**
* Saves the document to a file.
*
* @param outputPath Path to save the file to.
*/
saveToFile(outputPath: string): void;
/**
* Return the file as a Mindee-compatible BufferInput source.
*
* @returns A BufferInput source.
*/
asSource(): BufferInput;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtractedImage = void 0;
const node_buffer_1 = require("node:buffer");
const errors_1 = require("../errors");
const node_fs_1 = require("node:fs");
const node_path_1 = __importDefault(require("node:path"));
const logger_1 = require("../logger");
const input_1 = require("../input");
class ExtractedImage {
constructor(buffer, fileName) {
this.buffer = node_buffer_1.Buffer.from(buffer);
this.internalFileName = fileName;
}
/**
* Saves the document to a file.
*
* @param outputPath Path to save the file to.
*/
saveToFile(outputPath) {
try {
(0, node_fs_1.writeFileSync)(node_path_1.default.resolve(outputPath), this.buffer);
logger_1.logger.info(`File saved successfully to ${node_path_1.default.resolve(outputPath)}.`);
}
catch (e) {
if (e instanceof TypeError) {
throw new errors_1.MindeeError("Invalid path/filename provided.");
}
else {
throw e;
}
}
}
/**
* Return the file as a Mindee-compatible BufferInput source.
*
* @returns A BufferInput source.
*/
asSource() {
return new input_1.BufferInput({
buffer: this.buffer,
filename: this.internalFileName,
});
}
}
exports.ExtractedImage = ExtractedImage;

@@ -1,10 +0,6 @@

/// <reference types="node" />
import { BufferInput } from "../input";
import { ExtractedImage } from "./extractedImage";
export declare class ExtractedMultiReceiptImage implements ExtractedImage {
export declare class ExtractedMultiReceiptImage extends ExtractedImage {
readonly receiptId: number;
readonly pageId: number;
imageData: Buffer;
constructor(imageData: Uint8Array, pageId: number, receiptId: number);
asSource(): BufferInput;
constructor(buffer: Uint8Array, pageId: number, receiptId: number);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtractedMultiReceiptImage = void 0;
const input_1 = require("../input");
class ExtractedMultiReceiptImage {
constructor(imageData, pageId, receiptId) {
const extractedImage_1 = require("./extractedImage");
class ExtractedMultiReceiptImage extends extractedImage_1.ExtractedImage {
constructor(buffer, pageId, receiptId) {
super(buffer, `receipt_p${pageId}_${receiptId}.pdf`);
this.pageId = pageId;
this.imageData = Buffer.from(imageData);
this.receiptId = receiptId;
}
asSource() {
return new input_1.BufferInput({
buffer: this.imageData,
filename: `receipt_p${this.pageId}_${this.receiptId}.pdf`,
});
}
}
exports.ExtractedMultiReceiptImage = ExtractedMultiReceiptImage;
export { extractReceipts } from "./multiReceiptsExtractor";
export { extractInvoices } from "./invoiceSplitterExtractor";
export { ExtractedMultiReceiptImage } from "./extractedMultiReceiptImage";
export { ExtractedInvoiceSplitterImage } from "./extractedInvoiceSplitterDocument";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtractedMultiReceiptImage = exports.extractReceipts = void 0;
exports.ExtractedInvoiceSplitterImage = exports.ExtractedMultiReceiptImage = exports.extractInvoices = exports.extractReceipts = void 0;
var multiReceiptsExtractor_1 = require("./multiReceiptsExtractor");
Object.defineProperty(exports, "extractReceipts", { enumerable: true, get: function () { return multiReceiptsExtractor_1.extractReceipts; } });
var invoiceSplitterExtractor_1 = require("./invoiceSplitterExtractor");
Object.defineProperty(exports, "extractInvoices", { enumerable: true, get: function () { return invoiceSplitterExtractor_1.extractInvoices; } });
var extractedMultiReceiptImage_1 = require("./extractedMultiReceiptImage");
Object.defineProperty(exports, "ExtractedMultiReceiptImage", { enumerable: true, get: function () { return extractedMultiReceiptImage_1.ExtractedMultiReceiptImage; } });
var extractedInvoiceSplitterDocument_1 = require("./extractedInvoiceSplitterDocument");
Object.defineProperty(exports, "ExtractedInvoiceSplitterImage", { enumerable: true, get: function () { return extractedInvoiceSplitterDocument_1.ExtractedInvoiceSplitterImage; } });
export { extractReceipts } from "./multiReceiptsExtractor";
export { extractInvoices } from "./invoiceSplitterExtractor";
export { ExtractedMultiReceiptImage } from "./extractedMultiReceiptImage";
export { ExtractedInvoiceSplitterImage } from "./extractedInvoiceSplitterDocument";
export { ExtractedImage } from "./extractedImage";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtractedMultiReceiptImage = exports.extractReceipts = void 0;
exports.ExtractedImage = exports.ExtractedInvoiceSplitterImage = exports.ExtractedMultiReceiptImage = exports.extractInvoices = exports.extractReceipts = void 0;
var multiReceiptsExtractor_1 = require("./multiReceiptsExtractor");
Object.defineProperty(exports, "extractReceipts", { enumerable: true, get: function () { return multiReceiptsExtractor_1.extractReceipts; } });
var invoiceSplitterExtractor_1 = require("./invoiceSplitterExtractor");
Object.defineProperty(exports, "extractInvoices", { enumerable: true, get: function () { return invoiceSplitterExtractor_1.extractInvoices; } });
var extractedMultiReceiptImage_1 = require("./extractedMultiReceiptImage");
Object.defineProperty(exports, "ExtractedMultiReceiptImage", { enumerable: true, get: function () { return extractedMultiReceiptImage_1.ExtractedMultiReceiptImage; } });
var extractedInvoiceSplitterDocument_1 = require("./extractedInvoiceSplitterDocument");
Object.defineProperty(exports, "ExtractedInvoiceSplitterImage", { enumerable: true, get: function () { return extractedInvoiceSplitterDocument_1.ExtractedInvoiceSplitterImage; } });
var extractedImage_1 = require("./extractedImage");
Object.defineProperty(exports, "ExtractedImage", { enumerable: true, get: function () { return extractedImage_1.ExtractedImage; } });
import { MultiReceiptsDetectorV1 } from "../product";
import { ExtractedMultiReceiptImage } from "./extractedMultiReceiptImage";
import { LocalInputSource } from "../input/base";
/**
* Extracts individual receipts from multi-receipts documents.
*
* @param inputFile File to extract sub-receipts from.
* @param inference Results of the inference.
* @returns Individual extracted receipts as an array of ExtractedMultiReceiptsImage.
*/
export declare function extractReceipts(inputFile: LocalInputSource, inference: MultiReceiptsDetectorV1): Promise<ExtractedMultiReceiptImage[]>;

@@ -13,3 +13,2 @@ "use strict";

const newHeight = height * ((0, geometry_1.getMinMaxY)(boundingBox).max - (0, geometry_1.getMinMaxY)(boundingBox).min);
//Note: PDF-lib seems to invert y coordinates, giving us the following horror:
const croppedReceipt = await receiptPdf.embedPage(pdfPage, {

@@ -52,2 +51,9 @@ left: (0, geometry_1.getMinMaxX)(boundingBox).min * width,

}
/**
* Extracts individual receipts from multi-receipts documents.
*
* @param inputFile File to extract sub-receipts from.
* @param inference Results of the inference.
* @returns Individual extracted receipts as an array of ExtractedMultiReceiptsImage.
*/
async function extractReceipts(inputFile, inference) {

@@ -54,0 +60,0 @@ const images = [];

@@ -32,3 +32,3 @@ /// <reference types="node" />

/**
* Merge PDF pages.
* Cut PDF pages.
* @param pageOptions

@@ -35,0 +35,0 @@ */

@@ -109,3 +109,3 @@ "use strict";

/**
* Merge PDF pages.
* Cut PDF pages.
* @param pageOptions

@@ -112,0 +112,0 @@ */

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