From 2b763d848bf529c14097e2564e0295e6e3506b1e Mon Sep 17 00:00:00 2001 From: rafaelsideguide <150964962+rafaelsideguide@users.noreply.github.com> Date: Thu, 30 May 2024 08:44:38 -0300 Subject: [PATCH 1/2] improved js response and test for getting partial_data --- .../src/__tests__/e2e_withAuth/index.test.ts | 13 +++++++++++-- apps/js-sdk/firecrawl/src/index.ts | 8 +++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts b/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts index c9db6a9..7cb532c 100644 --- a/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts +++ b/apps/js-sdk/firecrawl/src/__tests__/e2e_withAuth/index.test.ts @@ -99,8 +99,17 @@ describe('FirecrawlApp E2E Tests', () => { expect(response).not.toBeNull(); expect(response.jobId).toBeDefined(); - await new Promise(resolve => setTimeout(resolve, 10000)); // wait for 10 seconds - const statusResponse = await app.checkCrawlStatus(response.jobId); + let statusResponse = await app.checkCrawlStatus(response.jobId); + const maxChecks = 15; + let checks = 0; + + while (statusResponse.status === 'active' && checks < maxChecks) { + await new Promise(resolve => setTimeout(resolve, 1000)); + expect(statusResponse.partial_data).not.toBeNull(); + statusResponse = await app.checkCrawlStatus(response.jobId); + checks++; + } + expect(statusResponse).not.toBeNull(); expect(statusResponse.status).toBe('completed'); expect(statusResponse.data.length).toBeGreaterThan(0); diff --git a/apps/js-sdk/firecrawl/src/index.ts b/apps/js-sdk/firecrawl/src/index.ts index 2a07f60..7329556 100644 --- a/apps/js-sdk/firecrawl/src/index.ts +++ b/apps/js-sdk/firecrawl/src/index.ts @@ -56,6 +56,7 @@ export interface JobStatusResponse { status: string; jobId?: string; data?: any; + partial_data?: any, error?: string; } @@ -226,7 +227,12 @@ export default class FirecrawlApp { headers ); if (response.status === 200) { - return response.data; + return { + success: true, + status: response.data.status, + data: response.data.data, + partial_data: !response.data.data ? response.data.partial_data : undefined, + }; } else { this.handleError(response, "check crawl status"); } From 1f4c6b7a87b98abc2e0845d792b5935417bf694a Mon Sep 17 00:00:00 2001 From: rafaelsideguide <150964962+rafaelsideguide@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:59:48 -0300 Subject: [PATCH 2/2] Update package.json --- apps/js-sdk/firecrawl/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/js-sdk/firecrawl/package.json b/apps/js-sdk/firecrawl/package.json index a1c42a0..d3581b3 100644 --- a/apps/js-sdk/firecrawl/package.json +++ b/apps/js-sdk/firecrawl/package.json @@ -1,6 +1,6 @@ { "name": "@mendable/firecrawl-js", - "version": "0.0.22", + "version": "0.0.23", "description": "JavaScript SDK for Firecrawl API", "main": "build/index.js", "types": "types/index.d.ts",