@webcrawl/client 1.3.7 → 1.3.8

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.
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ApiResponse, CrawlParams, ExtractParams, MapParams, ParseParams, ParseResponse, RerankParams, ScrapeParams, SearchParams, SearchResponse } from "./types.js";
1
+ import type { ApiResponse, CrawlParams, ExtractParams, MapParams, MonitorParams, MonitorResponse, MonitorUpdateParams, ParseParams, ParseResponse, RerankParams, ScrapeParams, SearchParams, SearchResponse } from "./types.js";
2
2
  export interface ClientOptions {
3
3
  apiKey?: string;
4
4
  baseUrl?: string;
@@ -18,7 +18,7 @@ export declare class WebcrawlClient {
18
18
  private readonly userAgent;
19
19
  private readonly timezone?;
20
20
  constructor(opts?: ClientOptions);
21
- request<T = ApiResponse>(method: "GET" | "POST", path: string, body?: unknown): Promise<T>;
21
+ request<T = ApiResponse>(method: "GET" | "POST" | "PATCH" | "DELETE", path: string, body?: unknown): Promise<T>;
22
22
  search(p: SearchParams): Promise<SearchResponse>;
23
23
  scrape(p: ScrapeParams): Promise<ApiResponse>;
24
24
  /** PDF, DOCX/XLSX/PPTX, image or audio/video to Markdown. Long files: pass `async: true` and poll `run()`. */
@@ -32,6 +32,18 @@ export declare class WebcrawlClient {
32
32
  categories(): Promise<ApiResponse>;
33
33
  targets(): Promise<ApiResponse>;
34
34
  usage(): Promise<ApiResponse>;
35
+ /** List all web monitors on the account. */
36
+ monitors(): Promise<MonitorResponse>;
37
+ /** Fetch a single web monitor by ID, including its latest snapshot and per-URL state. */
38
+ getMonitor(id: string): Promise<MonitorResponse>;
39
+ /** Create a new web monitor (single page, multi-URL list, or whole website section) and run its initial check. */
40
+ createMonitor(p: MonitorParams): Promise<MonitorResponse>;
41
+ /** Trigger an immediate live check on an existing web monitor, evaluating its condition and diffing against the prior snapshot. */
42
+ checkMonitor(id: string): Promise<MonitorResponse>;
43
+ /** Update a monitor's status (`active` | `paused`), interval, watch goal, trigger condition, or notification channels. */
44
+ updateMonitor(p: MonitorUpdateParams): Promise<MonitorResponse>;
45
+ /** Delete a web monitor by ID. */
46
+ deleteMonitor(id: string): Promise<MonitorResponse>;
35
47
  /** Send a 6-digit OTP verification code to an email address to sign up or log in (provisions 1,000 free monthly credits). */
36
48
  sendOtp(email: string): Promise<{
37
49
  success: boolean;
package/dist/client.js CHANGED
@@ -187,6 +187,45 @@ export class WebcrawlClient {
187
187
  usage() {
188
188
  return this.request("GET", "/v1/account/usage");
189
189
  }
190
+ /** List all web monitors on the account. */
191
+ monitors() {
192
+ return this.request("GET", "/v1/monitors");
193
+ }
194
+ /** Fetch a single web monitor by ID, including its latest snapshot and per-URL state. */
195
+ getMonitor(id) {
196
+ return this.request("GET", `/v1/monitors/${encodeURIComponent(id)}`);
197
+ }
198
+ /** Create a new web monitor (single page, multi-URL list, or whole website section) and run its initial check. */
199
+ createMonitor(p) {
200
+ const primaryUrl = p.url ?? p.urls?.[0];
201
+ if (!primaryUrl) {
202
+ throw new WebcrawlError("bad_request", "createMonitor requires `url` or non-empty `urls`");
203
+ }
204
+ return this.request("POST", "/v1/monitors", compact({
205
+ ...p,
206
+ url: primaryUrl,
207
+ maxPages: p.maxPages === undefined ? undefined : Math.min(25, Math.max(1, p.maxPages)),
208
+ }));
209
+ }
210
+ /** Trigger an immediate live check on an existing web monitor, evaluating its condition and diffing against the prior snapshot. */
211
+ checkMonitor(id) {
212
+ return this.request("POST", `/v1/monitors/${encodeURIComponent(id)}/check`, {});
213
+ }
214
+ /** Update a monitor's status (`active` | `paused`), interval, watch goal, trigger condition, or notification channels. */
215
+ updateMonitor(p) {
216
+ const { id, ...rest } = p;
217
+ if (!id) {
218
+ throw new WebcrawlError("bad_request", "updateMonitor requires `id`");
219
+ }
220
+ return this.request("PATCH", `/v1/monitors/${encodeURIComponent(id)}`, compact(rest));
221
+ }
222
+ /** Delete a web monitor by ID. */
223
+ deleteMonitor(id) {
224
+ if (!id) {
225
+ throw new WebcrawlError("bad_request", "deleteMonitor requires `id`");
226
+ }
227
+ return this.request("DELETE", `/v1/monitors/${encodeURIComponent(id)}`);
228
+ }
190
229
  /** Send a 6-digit OTP verification code to an email address to sign up or log in (provisions 1,000 free monthly credits). */
191
230
  sendOtp(email) {
192
231
  return this.request("POST", "/v1/auth/otp/send", { email: email.trim() });
package/dist/types.d.ts CHANGED
@@ -124,3 +124,72 @@ export interface RerankParams {
124
124
  documents: RerankDocument[];
125
125
  topK?: number;
126
126
  }
127
+ export type MonitorScopeMode = "page" | "urls" | "site";
128
+ export interface MonitorParams {
129
+ /** Primary URL to watch (or site root URL when `mode: "site"`). */
130
+ url?: string;
131
+ /** Multiple URLs to watch when `mode: "urls"`. */
132
+ urls?: string[];
133
+ /** Watch scope: single `"page"` (default), `"urls"` list, or whole `"site"`. */
134
+ mode?: MonitorScopeMode;
135
+ /** Max pages to sample in `"site"` mode (1..25, default 5). */
136
+ maxPages?: number;
137
+ /** Optional friendly name for the watch. */
138
+ name?: string;
139
+ /** Poll interval in minutes (5..10080, default 60). */
140
+ intervalMinutes?: number;
141
+ /** Natural-language focus describing what to watch for (e.g. "Pricing tiers and discounts"). */
142
+ watchFor?: string;
143
+ /** Trigger condition expression (e.g. `'price < 50'`, `'content contains "In Stock"'`) or condition AST object. */
144
+ condition?: string | Record<string, unknown>;
145
+ /** Email address to alert when triggered, or `true` to use the signed-in account email. */
146
+ notifyEmail?: string | boolean;
147
+ /** HTTPS webhook URL to POST when triggered. */
148
+ webhookUrl?: string;
149
+ }
150
+ export interface MonitorUpdateParams {
151
+ id: string;
152
+ name?: string | null;
153
+ status?: "active" | "paused";
154
+ intervalMinutes?: number;
155
+ watchFor?: string | null;
156
+ condition?: string | Record<string, unknown> | null;
157
+ notifyEmail?: string | boolean | null;
158
+ webhookUrl?: string | null;
159
+ urls?: string[];
160
+ maxPages?: number;
161
+ }
162
+ export interface MonitorRecord {
163
+ id: string;
164
+ name?: string | null;
165
+ mode?: MonitorScopeMode;
166
+ url: string;
167
+ urls?: string[];
168
+ maxPages?: number;
169
+ watchFor?: string | null;
170
+ condition?: Record<string, unknown> | null;
171
+ conditionJev?: string | null;
172
+ notifyEmail?: string | null;
173
+ webhookUrl?: string | null;
174
+ intervalMinutes: number;
175
+ status: "active" | "paused";
176
+ lastContentHash?: string | null;
177
+ lastTitle?: string | null;
178
+ lastSnapshot?: string | null;
179
+ lastDiffSummary?: string | null;
180
+ lastConditionMet?: boolean | null;
181
+ lastNotificationStatus?: string | null;
182
+ changeCount?: number;
183
+ lastCheckedAt?: string | null;
184
+ lastChangeDetectedAt?: string | null;
185
+ createdAt?: string;
186
+ [key: string]: unknown;
187
+ }
188
+ export interface MonitorResponse extends ApiResponse {
189
+ monitor?: MonitorRecord;
190
+ monitors?: MonitorRecord[];
191
+ initialCheck?: Record<string, unknown>;
192
+ check?: Record<string, unknown>;
193
+ notifications?: Record<string, unknown>;
194
+ deleted?: boolean;
195
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webcrawl/client",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "Zero-dependency TypeScript & Node.js SDK for Webcrawl Anything (search, scrape, parse, map, crawl, extract, rerank, targets)",
5
5
  "type": "module",
6
6
  "license": "MIT",