Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

added type declarations

rafaelsideguide890bde686f5b
diff --git a/apps/js-sdk/firecrawl/package.json b/apps/js-sdk/firecrawl/package.json
index 58aa5aca7..811f87fea 100644
--- a/apps/js-sdk/firecrawl/package.json
+++ b/apps/js-sdk/firecrawl/package.json
@@ -1,8 +1,9 @@
{
"name": "@mendable/firecrawl-js",
- "version": "0.0.10",
+ "version": "0.0.11",
"description": "JavaScript SDK for Firecrawl API",
"main": "build/index.js",
+ "types": "types/index.d.ts",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
diff --git a/apps/js-sdk/firecrawl/tsconfig.json b/apps/js-sdk/firecrawl/tsconfig.json
index 5bca86d59..d7764a46d 100644
--- a/apps/js-sdk/firecrawl/tsconfig.json
+++ b/apps/js-sdk/firecrawl/tsconfig.json
@@ -49,7 +49,7 @@
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
@@ -70,7 +70,7 @@
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
+ "declarationDir": "./types", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
@@ -105,5 +105,7 @@
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
- }
+ },
+ "include": ["src/**/*"],
+ "exclude": ["node_modules", "dist", "**/__tests__/*"]
}
diff --git a/apps/js-sdk/firecrawl/types/index.d.ts b/apps/js-sdk/firecrawl/types/index.d.ts
new file mode 100644
index 000000000..a9d04ba99
--- /dev/null
+++ b/apps/js-sdk/firecrawl/types/index.d.ts
@@ -0,0 +1,107 @@
+import { AxiosResponse, AxiosRequestHeaders } from 'axios';
+/**
+ * Configuration interface for FirecrawlApp.
+ */
+export interface FirecrawlAppConfig {
+ apiKey?: string | null;
+}
+/**
+ * Generic parameter interface.
+ */
+export interface Params {
+ [key: string]: any;
+}
+/**
+ * Response interface for scraping operations.
+ */
+export interface ScrapeResponse {
+ success: boolean;
+ data?: any;
+ error?: string;
+}
+/**
+ * Response interface for crawling operations.
+ */
+export interface CrawlResponse {
+ success: boolean;
+ jobId?: string;
+ data?: any;
+ error?: string;
+}
+/**
+ * Response interface for job status checks.
+ */
+export interface JobStatusResponse {
+ success: boolean;
+ status: string;
+ jobId?: string;
+ data?: any;
+ error?: string;
+}
+/**
+ * Main class for interacting with the Firecrawl API.
+ */
+export default class FirecrawlApp {
+ private apiKey;
+ /**
+ * Initializes a new instance of the FirecrawlApp class.
+ * @param {FirecrawlAppConfig} config - Configuration options for the FirecrawlApp instance.
+ */
+ constructor({ apiKey }: FirecrawlAppConfig);
+ /**
+ * Scrapes a URL using the Firecrawl API.
+ * @param {string} url - The URL to scrape.
+ * @param {Params | null} params - Additional parameters for the scrape request.
+ * @returns {Promise<ScrapeResponse>} The response from the scrape operation.
+ */
+ scrapeUrl(url: string, params?: Params | null): Promise<ScrapeResponse>;
+ /**
+ * Initiates a crawl job for a URL using the Firecrawl API.
+ * @param {string} url - The URL to crawl.
+ * @param {Params | null} params - Additional parameters for the crawl request.
+ * @param {boolean} waitUntilDone - Whether to wait for the crawl job to complete.
+ * @param {number} timeout - Timeout in seconds for job status checks.
+ * @returns {Promise<CrawlResponse>} The response from the crawl operation.
+ */
+ crawlUrl(url: string, params?: Params | null, waitUntilDone?: boolean, timeout?: number): Promise<CrawlResponse>;
+ /**
+ * Checks the status of a crawl job using the Firecrawl API.
+ * @param {string} jobId - The job ID of the crawl operation.
+ * @returns {Promise<JobStatusResponse>} The response containing the job status.
+ */
+ checkCrawlStatus(jobId: string): Promise<JobStatusResponse>;
+ /**
+ * Prepares the headers for an API request.
+ * @returns {AxiosRequestHeaders} The prepared headers.
+ */
+ prepareHeaders(): AxiosRequestHeaders;
+ /**
+ * Sends a POST request to the specified URL.
+ * @param {string} url - The URL to send the request to.
+ * @param {Params} data - The data to send in the request.
+ * @param {AxiosRequestHeaders} headers - The headers for the request.
+ * @returns {Promise<AxiosResponse>} The response from the POST request.
+ */
+ postRequest(url: string, data: Params, headers: AxiosRequestHeaders): Promise<AxiosResponse>;
+ /**
+ * Sends a GET request to the specified URL.
+ * @param {string} url - The URL to send the request to.
+ * @param {AxiosRequestHeaders} headers - The headers for the request.
+ * @returns {Promise<AxiosResponse>} The response from the GET request.
+ */
+ getRequest(url: string, headers: AxiosRequestHeaders): Promise<AxiosResponse>;
+ /**
+ * Monitors the status of a crawl job until completion or failure.
+ * @param {string} jobId - The job ID of the crawl operation.
+ * @param {AxiosRequestHeaders} headers - The headers for the request.
+ * @param {number} timeout - Timeout in seconds for job status checks.
+ * @returns {Promise<any>} The final job status or data.
+ */
+ monitorJobStatus(jobId: string, headers: AxiosRequestHeaders, timeout: number): Promise<any>;
+ /**
+ * Handles errors from API responses.
+ * @param {AxiosResponse} response - The response from the API.
+ * @param {string} action - The action being performed when the error occurred.
+ */
+ handleError(response: AxiosResponse, action: string): void;
+}