@acedatacloud/sdk 2026.430.0 → 2026.504.0

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.
@@ -0,0 +1,61 @@
1
+ /** WebExtrator web render & extract resources. */
2
+
3
+ import { Transport } from '../runtime/transport';
4
+
5
+ export class WebExtrator {
6
+ constructor(private transport: Transport) {}
7
+
8
+ async extract(opts: {
9
+ url: string;
10
+ expectedType?: 'product' | 'article' | 'general';
11
+ enableLlm?: boolean;
12
+ waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
13
+ timeout?: number;
14
+ delay?: number;
15
+ waitForSelector?: string;
16
+ blockResources?: string[];
17
+ headers?: Record<string, string>;
18
+ userAgent?: string;
19
+ callbackUrl?: string;
20
+ [key: string]: unknown;
21
+ }): Promise<Record<string, unknown>> {
22
+ const { url, expectedType, enableLlm, waitUntil, timeout, delay, waitForSelector, blockResources, headers, userAgent, callbackUrl, ...rest } = opts;
23
+ const body: Record<string, unknown> = { url, ...rest };
24
+ if (expectedType !== undefined) body.expected_type = expectedType;
25
+ if (enableLlm !== undefined) body.enable_llm = enableLlm;
26
+ if (waitUntil !== undefined) body.wait_until = waitUntil;
27
+ if (timeout !== undefined) body.timeout = timeout;
28
+ if (delay !== undefined) body.delay = delay;
29
+ if (waitForSelector !== undefined) body.wait_for_selector = waitForSelector;
30
+ if (blockResources !== undefined) body.block_resources = blockResources;
31
+ if (headers !== undefined) body.headers = headers;
32
+ if (userAgent !== undefined) body.user_agent = userAgent;
33
+ if (callbackUrl !== undefined) body.callback_url = callbackUrl;
34
+ return this.transport.request('POST', '/webextrator/extract', { json: body });
35
+ }
36
+
37
+ async render(opts: {
38
+ url: string;
39
+ waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
40
+ timeout?: number;
41
+ delay?: number;
42
+ waitForSelector?: string;
43
+ blockResources?: string[];
44
+ headers?: Record<string, string>;
45
+ userAgent?: string;
46
+ callbackUrl?: string;
47
+ [key: string]: unknown;
48
+ }): Promise<Record<string, unknown>> {
49
+ const { url, waitUntil, timeout, delay, waitForSelector, blockResources, headers, userAgent, callbackUrl, ...rest } = opts;
50
+ const body: Record<string, unknown> = { url, ...rest };
51
+ if (waitUntil !== undefined) body.wait_until = waitUntil;
52
+ if (timeout !== undefined) body.timeout = timeout;
53
+ if (delay !== undefined) body.delay = delay;
54
+ if (waitForSelector !== undefined) body.wait_for_selector = waitForSelector;
55
+ if (blockResources !== undefined) body.block_resources = blockResources;
56
+ if (headers !== undefined) body.headers = headers;
57
+ if (userAgent !== undefined) body.user_agent = userAgent;
58
+ if (callbackUrl !== undefined) body.callback_url = callbackUrl;
59
+ return this.transport.request('POST', '/webextrator/render', { json: body });
60
+ }
61
+ }