webcrawlerapi-js 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { CrawlRequest, Job, JobId, ScrapeRequest, ScrapeResponse, ScrapeResponseError, ScrapeId, Action, JobMarkdownResponse, AgentRunRequest, AgentRun } from "./model";
1
+ import { CrawlRequest, Job, JobId, ScrapeRequest, ScrapeResponse, ScrapeResponseError, ScrapeId, JobMarkdownResponse, AgentRunRequest, AgentRun } from "./model";
2
2
  import { JobStatus, ErrorCode } from "./constants";
3
3
  import { WebcrawlerApiError } from "./errors";
4
4
  export { WebcrawlerApiError, JobStatus, ErrorCode };
@@ -15,8 +15,8 @@ export declare class WebcrawlerClient {
15
15
  runAgent(request: AgentRunRequest, maxPolls?: number): Promise<AgentRun>;
16
16
  getScrape(scrapeId: string): Promise<ScrapeResponse | ScrapeResponseError>;
17
17
  scrape(request: ScrapeRequest, maxPolls?: number): Promise<ScrapeResponse | ScrapeResponseError>;
18
- crawl(crawlRequest: CrawlRequest, actions?: Action | Action[]): Promise<Job>;
19
- crawlAsync(crawlRequest: CrawlRequest, actions?: Action | Action[]): Promise<JobId>;
18
+ crawl(crawlRequest: CrawlRequest, maxPolls?: number): Promise<Job>;
19
+ crawlAsync(crawlRequest: CrawlRequest): Promise<JobId>;
20
20
  getJob(jobID: string): Promise<Job>;
21
21
  getJobMarkdown(jobID: string): Promise<JobMarkdownResponse>;
22
22
  getJobMarkdownContent(jobID: string): Promise<string>;
@@ -53,7 +53,6 @@ export interface CrawlRequest {
53
53
  blacklist_regexp?: string;
54
54
  /** URL where the server will send a POST request once the job is completed. */
55
55
  webhook_url?: string;
56
- actions?: Action[];
57
56
  /** If true, the crawler will respect the website's robots.txt and skip disallowed pages. Default is false. */
58
57
  respect_robots_txt?: boolean;
59
58
  /** Extract only the main content of the page. Works best for articles, blog posts, news. */
@@ -62,6 +61,8 @@ export interface CrawlRequest {
62
61
  max_depth?: number;
63
62
  /** Maximum age of cached content in seconds. Set to 0 to always fetch fresh content. */
64
63
  max_age?: number;
64
+ /** If true, keeps query parameters in crawled URLs instead of stripping them. Default is false. */
65
+ keep_query_params?: boolean;
65
66
  }
66
67
  export interface Job {
67
68
  id: string;
@@ -95,7 +96,7 @@ export interface JobItem {
95
96
  updated_at: string;
96
97
  cost: number;
97
98
  referred_url: string;
98
- link?: string;
99
+ links?: string;
99
100
  depth?: number;
100
101
  raw_content_url?: string;
101
102
  cleaned_content_url?: string;
package/dist/api.js CHANGED
@@ -211,12 +211,11 @@ class WebcrawlerClient {
211
211
  // Return the last known state if maxPolls is reached
212
212
  return result;
213
213
  }
214
- async crawl(crawlRequest, actions) {
214
+ async crawl(crawlRequest, maxPolls = MaxPullRetries) {
215
215
  const url = `${this.basePath}/${this.apiVersion}/crawl`;
216
216
  const requestBody = {
217
217
  output_formats: ['markdown'],
218
- ...crawlRequest,
219
- actions: actions ? (Array.isArray(actions) ? actions : [actions]) : undefined
218
+ ...crawlRequest
220
219
  };
221
220
  const requestOptions = {
222
221
  'method': 'POST',
@@ -235,7 +234,7 @@ class WebcrawlerClient {
235
234
  throw new errors_1.WebcrawlerApiError('invalid_response', 'Failed to fetch job status', 0);
236
235
  }
237
236
  let delayIntervalMs = initialPullDelayMs;
238
- for (let i = 0; i < MaxPullRetries; i++) {
237
+ for (let i = 0; i < maxPolls; i++) {
239
238
  await new Promise(resolve => setTimeout(resolve, delayIntervalMs));
240
239
  const timestamp = new Date().getTime();
241
240
  const job = await this.getJob(`${jobIdResponse.id}?t=${timestamp}`);
@@ -248,12 +247,11 @@ class WebcrawlerClient {
248
247
  }
249
248
  throw new errors_1.WebcrawlerApiError('timeout', 'Crawling took too long, please retry or increase the number of polling retries', 0);
250
249
  }
251
- async crawlAsync(crawlRequest, actions) {
250
+ async crawlAsync(crawlRequest) {
252
251
  const url = `${this.basePath}/${this.apiVersion}/crawl`;
253
252
  const requestBody = {
254
253
  output_formats: ['markdown'],
255
- ...crawlRequest,
256
- actions: actions ? (Array.isArray(actions) ? actions : [actions]) : undefined
254
+ ...crawlRequest
257
255
  };
258
256
  const requestOptions = {
259
257
  'method': 'POST',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webcrawlerapi-js",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "JS client for WebcrawlerAPI",
5
5
  "main": "./dist/api.js",
6
6
  "types": "./dist/@types/api.d.ts",