diff --git a/.github/workflows/_test-integrations.yml b/.github/workflows/_test-integrations.yml index 95a50efc..9d87e0ff 100644 --- a/.github/workflows/_test-integrations.yml +++ b/.github/workflows/_test-integrations.yml @@ -28,7 +28,6 @@ jobs: - "macos-latest" node-version: - "20" - - "22" - "26" runs-on: ${{ matrix.os }} diff --git a/.github/workflows/_test-smoke.yml b/.github/workflows/_test-smoke.yml index c559ea4d..175605d2 100644 --- a/.github/workflows/_test-smoke.yml +++ b/.github/workflows/_test-smoke.yml @@ -21,8 +21,7 @@ jobs: strategy: matrix: node-version: - - "22" - - "24" + - "20" - "26" steps: diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 00d3fe91..05984e29 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -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 diff --git a/src/pdf/pdfCompressor.ts b/src/pdf/pdfCompressor.ts index 68a1201a..37919dcd 100644 --- a/src/pdf/pdfCompressor.ts +++ b/src/pdf/pdfCompressor.ts @@ -35,7 +35,6 @@ export async function compressPdf( forceSourceTextCompression: boolean = false, disableSourceText: boolean = true ): Promise { - handleCompressionWarnings(forceSourceTextCompression, disableSourceText); if (await hasSourceText(pdfData)) { if (forceSourceTextCompression) { if (!disableSourceText) { @@ -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. diff --git a/src/v1/http/workflowEndpoint.ts b/src/v1/http/workflowEndpoint.ts index bd1fb33a..cba2840d 100644 --- a/src/v1/http/workflowEndpoint.ts +++ b/src/v1/http/workflowEndpoint.ts @@ -23,7 +23,6 @@ export class WorkflowEndpoint extends BaseEndpoint { workflowId: string ) { super(settings, `/v1/workflows/${workflowId}/executions`); - } /** diff --git a/tests/input/compression.spec.ts b/tests/input/compression.spec.ts index ee35e0d7..f30f4727 100644 --- a/tests/input/compression.spec.ts +++ b/tests/input/compression.spec.ts @@ -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") @@ -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(); diff --git a/tests/runner.mjs b/tests/runner.mjs index 3e202a83..dbe457e8 100644 --- a/tests/runner.mjs +++ b/tests/runner.mjs @@ -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; diff --git a/tests/v1/extraction/multiReceipts.integration.ts b/tests/v1/extraction/multiReceipts.integration.ts index c766cab6..c5d6663b 100644 --- a/tests/v1/extraction/multiReceipts.integration.ts +++ b/tests/v1/extraction/multiReceipts.integration.ts @@ -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", () => { diff --git a/tests/v1/input/sources.integration.ts b/tests/v1/input/sources.integration.ts index d62b08e5..1c527660 100644 --- a/tests/v1/input/sources.integration.ts +++ b/tests/v1/input/sources.integration.ts @@ -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"); }); @@ -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" }); @@ -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"); - }); }); diff --git a/tests/v1/input/urlInputSource.integration.ts b/tests/v1/input/urlInputSource.integration.ts index 92d4f3fd..5cef6373 100644 --- a/tests/v1/input/urlInputSource.integration.ts +++ b/tests/v1/input/urlInputSource.integration.ts @@ -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"); diff --git a/tests/v1/workflows/workflow.integration.ts b/tests/v1/workflows/workflow.integration.ts index dfb9e5ef..8b20a522 100644 --- a/tests/v1/workflows/workflow.integration.ts +++ b/tests/v1/workflows/workflow.integration.ts @@ -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 () => { @@ -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}`); });