From 60b6e6b1d4bdfcec635e3a2c55f5386a13a4b05d Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 23 Oct 2024 15:59:40 -0300 Subject: [PATCH] Nick: fixes --- apps/js-sdk/firecrawl/package.json | 4 ++-- apps/js-sdk/firecrawl/src/index.ts | 32 +++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/apps/js-sdk/firecrawl/package.json b/apps/js-sdk/firecrawl/package.json index e50205d5..0dfb4d69 100644 --- a/apps/js-sdk/firecrawl/package.json +++ b/apps/js-sdk/firecrawl/package.json @@ -1,6 +1,6 @@ { - "name": "firecrawl", - "version": "1.6.1", + "name": "@mendable/firecrawl-js", + "version": "1.7.0-beta.2", "description": "JavaScript SDK for Firecrawl API", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/apps/js-sdk/firecrawl/src/index.ts b/apps/js-sdk/firecrawl/src/index.ts index e9985683..3e9c7bdf 100644 --- a/apps/js-sdk/firecrawl/src/index.ts +++ b/apps/js-sdk/firecrawl/src/index.ts @@ -154,6 +154,17 @@ export interface CrawlResponse { error?: string; } +/** + * Response interface for crawling operations. + * Defines the structure of the response received after initiating a crawl. + */ +export interface BatchScrapeResponse { + id?: string; + url?: string; + success: true; + error?: string; +} + /** * Response interface for job status checks. * Provides detailed status of a crawl job including progress and results. @@ -169,6 +180,21 @@ export interface CrawlStatusResponse { data: FirecrawlDocument[]; }; +/** + * Response interface for job status checks. + * Provides detailed status of a crawl job including progress and results. + */ +export interface BatchScrapeStatusResponse { + success: true; + status: "scraping" | "completed" | "failed" | "cancelled"; + completed: number; + total: number; + creditsUsed: number; + expiresAt: Date; + next?: string; + data: FirecrawlDocument[]; +}; + /** * Parameters for mapping operations. * Defines options for mapping URLs during a crawl. @@ -506,7 +532,7 @@ export default class FirecrawlApp { params?: ScrapeParams, pollInterval: number = 2, idempotencyKey?: string - ): Promise { + ): Promise { const headers = this.prepareHeaders(idempotencyKey); let jsonData: any = { urls, ...(params ?? {}) }; try { @@ -535,7 +561,7 @@ export default class FirecrawlApp { urls: string[], params?: ScrapeParams, idempotencyKey?: string - ): Promise { + ): Promise { const headers = this.prepareHeaders(idempotencyKey); let jsonData: any = { urls, ...(params ?? {}) }; try { @@ -587,7 +613,7 @@ export default class FirecrawlApp { * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`) * @returns The response containing the job status. */ - async checkBatchScrapeStatus(id?: string, getAllData = false): Promise { + async checkBatchScrapeStatus(id?: string, getAllData = false): Promise { if (!id) { throw new FirecrawlError("No batch scrape ID provided", 400); }