Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
- "macos-latest"
node-version:
- "20"
- "22"
- "26"
runs-on: ${{ matrix.os }}

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/_test-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ jobs:
strategy:
matrix:
node-version:
- "22"
- "24"
- "20"
- "26"

steps:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ name: Crontab

on:
schedule:
- cron: '23 0 * * *'
- cron: '23 3 * * *'
timezone: "Europe/Paris"

jobs:
test_regressions:
test_integrations:
uses: mindee/mindee-api-nodejs/.github/workflows/_test-integrations.yml@main
secrets: inherit
test_code_samples:
test_smoke:
uses: mindee/mindee-api-nodejs/.github/workflows/_test-smoke.yml@main
secrets: inherit
19 changes: 0 additions & 19 deletions src/pdf/pdfCompressor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export async function compressPdf(
forceSourceTextCompression: boolean = false,
disableSourceText: boolean = true
): Promise<Buffer> {
handleCompressionWarnings(forceSourceTextCompression, disableSourceText);
if (await hasSourceText(pdfData)) {
if (forceSourceTextCompression) {
if (!disableSourceText) {
Expand Down Expand Up @@ -72,24 +71,6 @@ export async function compressPdf(
return createNewPdfFromCompressedPages(compressedPages);
}

/**
* Handles compression warnings based on the provided parameters.
* @param forceSourceTextCompression If true, attempts to re-write detected text.
* @param disableSourceText If true, doesn't re-apply source text to the output PDF.
*/
function handleCompressionWarnings(
forceSourceTextCompression: boolean, disableSourceText: boolean
): void {
if (forceSourceTextCompression) {
if (!disableSourceText) {
logger.warn("Re-writing PDF source-text is an EXPERIMENTAL feature.");
} else {
logger.warn("Source file contains text, but the disable_source_text is set to false. "
+ "Resulting file will not contain any embedded text.");
}
}
}

/**
* Compresses PDF pages and returns an array of compressed page buffers.
* @param pdfData The input PDF as a Buffer.
Expand Down
1 change: 0 additions & 1 deletion src/v1/http/workflowEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class WorkflowEndpoint extends BaseEndpoint {
workflowId: string
) {
super(settings, `/v1/workflows/${workflowId}/executions`);

}

/**
Expand Down
10 changes: 3 additions & 7 deletions tests/input/compression.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,8 @@ describe("Input Sources - compression and resize #OptionalDepsRequired", { skip:
const pdfResizeInput = new PathInput(
{ inputPath: path.join(V1_PRODUCT_PATH, "invoice_splitter/default_sample.pdf") }
);
await pdfResizeInput.init();

const compressedPdf = await compressPdf(
pdfResizeInput.fileObject, 75, true
);
await fs.promises.writeFile(path.join(outputPath, "resize_indirect.pdf"), compressedPdf);
await pdfResizeInput.compress(75);
await fs.promises.writeFile(path.join(outputPath, "resize_indirect.pdf"), pdfResizeInput.fileObject);

const initialFileStats = await fs.promises.stat(
path.join(V1_PRODUCT_PATH, "invoice_splitter/default_sample.pdf")
Expand Down Expand Up @@ -166,7 +162,7 @@ describe("Input Sources - compression and resize #OptionalDepsRequired", { skip:

it("PDF Compress With Text Keeps Text", async () => {
const initialWithText = new PathInput(
{ inputPath: path.join(RESOURCE_PATH, "file_types/pdf/multipage.pdf") }
{ inputPath: path.join(RESOURCE_PATH, "file_types/pdf/multipage_cut-3.pdf") }
);
await initialWithText.init();

Expand Down
2 changes: 1 addition & 1 deletion tests/runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { dirname, join } from "node:path";

const testsDir = dirname(fileURLToPath(import.meta.url));

const suffix = process.argv[2] === "integration" ? ".integration.ts" : ".spec.ts";
const suffix = process.argv[2] + ".ts";
const subdir = process.argv[3];
const searchDir = subdir ? join(testsDir, subdir) : testsDir;

Expand Down
1 change: 1 addition & 0 deletions tests/v1/extraction/multiReceipts.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const hasOptionals = hasAllOptionalDependencies();
const apiKey = process.env.MINDEE_API_KEY;
let client: Client;
let sourceDoc: LocalInputSource;

describe("MindeeV1 - Integration - Multi-Receipt Extraction #OptionalDepsRequired",
{ timeout: 80000, skip: !hasOptionals }, () => {
describe("A Multi-Receipt PDF", () => {
Expand Down
18 changes: 4 additions & 14 deletions tests/v1/input/sources.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import assert from "node:assert";
import path from "path";
import { promises as fs } from "fs";
import { createReadStream } from "node:fs";
import * as mindee from "@/index.js";
import { Client } from "@/v1/index.js";
import { InvoiceV4 } from "@/v1/product/index.js";
import { V1_PRODUCT_PATH } from "../../index.js";
import { PathInput, Base64Input, BufferInput, BytesInput, UrlInput } from "@/index.js";
import { PathInput, Base64Input, BufferInput, BytesInput } from "@/index.js";

describe("MindeeV1 - Integration - File Input", { timeout: 80000 }, () => {
let client: mindee.v1.Client;
let client: Client;
let filePath: string;

beforeEach(() => {
client = new mindee.v1.Client();
client = new Client();
filePath = path.join(V1_PRODUCT_PATH, "invoices/default_sample.jpg");
});

Expand Down Expand Up @@ -44,7 +44,6 @@ describe("MindeeV1 - Integration - File Input", { timeout: 80000 }, () => {
assert.strictEqual(typeof result.document.id, "string");
});


it("should send a document from bytes", async () => {
const inputBytes = await fs.readFile(filePath);
const bytesInput = new BytesInput({ inputBytes: inputBytes, filename: "testFile.jpg" });
Expand All @@ -59,13 +58,4 @@ describe("MindeeV1 - Integration - File Input", { timeout: 80000 }, () => {
const result = await client.parse(InvoiceV4, bufferInput);
assert.strictEqual(typeof result.document.id, "string");
});

it("should send a document from a URL", async () => {
const url = "https://raw.githubusercontent.com/mindee/client-lib-test-data/" +
"refs/heads/main/v1/products/invoice_splitter/invoice_5p.pdf";
const urlInput = new UrlInput({ url: url });
await urlInput.init();
const result = await client.parse(InvoiceV4, urlInput);
assert.strictEqual(typeof result.document.id, "string");
});
});
20 changes: 17 additions & 3 deletions tests/v1/input/urlInputSource.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,33 @@ import assert from "node:assert";
import { UrlInput } from "@/index.js";
import { Client } from "@/v1/index.js";
import { InvoiceV4 } from "@/v1/product/index.js";
import { beforeEach } from "node:test";

describe("MindeeV1 - Integration - URL Input", { timeout: 80000 }, () => {
it("should retrieve and parse a remote file with redirection", async () => {
let client: Client;

beforeEach(() => {
const apiKey = process.env.MINDEE_API_KEY;
if (!apiKey) {
throw new Error("MINDEE_API_KEY environment variable is not set");
}
const client = new Client({ apiKey });
client = new Client({ apiKey });
});

it("should send a document from a URL", async () => {
const url = "https://raw.githubusercontent.com/mindee/client-lib-test-data/" +
"refs/heads/main/v1/products/invoice_splitter/invoice_5p.pdf";
const urlInput = new UrlInput({ url: url });
await urlInput.init();
const result = await client.parse(InvoiceV4, urlInput);
assert.strictEqual(typeof result.document.id, "string");
});

it("should retrieve and parse a remote file with redirection", async () => {
const remoteInput = new UrlInput({
url: "https://github.com/mindee/client-lib-test-data/blob/main/v1/" +
"products/invoice_splitter/invoice_5p.pdf?raw=true"
});
await remoteInput.init();
const localInput = await remoteInput.asLocalInputSource();

assert.strictEqual(localInput.filename, "invoice_5p.pdf");
Expand Down
10 changes: 7 additions & 3 deletions tests/v1/workflows/workflow.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ describe("MindeeV1 - Integration - Workflow calls", { timeout: 80000 }, () => {

beforeEach(async () => {
client = new mindee.v1.Client();
workflowId = process.env["WORKFLOW_ID"] ?? "";
if (!process.env["WORKFLOW_ID"]) {
throw new Error("WORKFLOW_ID environment variable is not set");
}
workflowId = process.env["WORKFLOW_ID"];

sample = new mindee.PathInput({
inputPath: path.join(V1_PRODUCT_PATH, "financial_document/default_sample.jpg")
});
await sample.init();
});

it("should retrieve a correct response from the API.", async () => {
Expand All @@ -31,7 +34,8 @@ describe("MindeeV1 - Integration - Workflow calls", { timeout: 80000 }, () => {
const response = await client.executeWorkflow(
sample,
workflowId,
{ alias: `node-${currentDateTime}`, priority: ExecutionPriority.low, rag: true });
{ alias: `node-${currentDateTime}`, priority: ExecutionPriority.low, rag: true }
);
assert.strictEqual(response.execution.priority, ExecutionPriority.low);
assert.strictEqual(response.execution.file.alias, `node-${currentDateTime}`);
});
Expand Down