@xyz17711/web-scraper 0.1.0 → 0.1.1
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/README.md +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/langchain.js +3 -3
- package/package.json +30 -2
- package/src/index.ts +0 -97
- package/src/langchain.ts +0 -52
- package/test/index.test.mjs +0 -75
- package/test/langchain.test.mjs +0 -40
- package/tsconfig.json +0 -16
package/README.md
CHANGED
|
@@ -18,10 +18,10 @@ npm install @xyz17711/web-scraper
|
|
|
18
18
|
|
|
19
19
|
| Method | Description |
|
|
20
20
|
| --- | --- |
|
|
21
|
-
| `extractMarkdown` |
|
|
21
|
+
| `extractMarkdown` | URL to Markdown: read any web page and get its main article content as clean Markdown for agents ($0.003, x402) |
|
|
22
22
|
| `getTaskStatus` | Polls for the result of a task enqueued by a *_async tool |
|
|
23
|
-
| `scrapeUrl` |
|
|
24
|
-
| `scrapeUrlAsync` | Enqueues a web_scraper_scrape_url job and returns a task id immediately ($0.
|
|
23
|
+
| `scrapeUrl` | Scrape URL: fetch any web page through a proxy and get its status, content type and raw HTML ($0.002, x402) |
|
|
24
|
+
| `scrapeUrlAsync` | [Deprecated - use web_scraper_scrape_url] Enqueues a web_scraper_scrape_url job and returns a task id immediately ($0.002, x402) |
|
|
25
25
|
|
|
26
26
|
## Quickstart
|
|
27
27
|
|
package/dist/index.d.ts
CHANGED
|
@@ -62,13 +62,13 @@ export interface ScrapeUrlAsyncRequest {
|
|
|
62
62
|
}
|
|
63
63
|
/** Typed client for web-scraper, e.g. `client.extractMarkdown(...)`. */
|
|
64
64
|
export declare class Client extends BaseClient {
|
|
65
|
-
/**
|
|
65
|
+
/** URL to Markdown: read any web page and get its main article content as clean Markdown for agents ($0.003, x402) */
|
|
66
66
|
extractMarkdown(request: ExtractMarkdownRequest): Promise<ExtractMarkdownResponse>;
|
|
67
67
|
/** Polls for the result of a task enqueued by a *_async tool */
|
|
68
68
|
getTaskStatus(request: GetTaskStatusRequest): Promise<GetTaskStatusResponse>;
|
|
69
|
-
/**
|
|
69
|
+
/** Scrape URL: fetch any web page through a proxy and get its status, content type and raw HTML ($0.002, x402) */
|
|
70
70
|
scrapeUrl(request: ScrapeUrlRequest): Promise<ScrapeUrlResponse>;
|
|
71
|
-
/** Enqueues a web_scraper_scrape_url job and returns a task id immediately ($0.
|
|
71
|
+
/** [Deprecated - use web_scraper_scrape_url] Enqueues a web_scraper_scrape_url job and returns a task id immediately ($0.002, x402) */
|
|
72
72
|
scrapeUrlAsync(request: ScrapeUrlAsyncRequest): Promise<AsyncTaskResponse>;
|
|
73
73
|
}
|
|
74
74
|
export { ClientOptions };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Client as BaseClient } from "@xyz17711/core";
|
|
5
5
|
/** Typed client for web-scraper, e.g. `client.extractMarkdown(...)`. */
|
|
6
6
|
export class Client extends BaseClient {
|
|
7
|
-
/**
|
|
7
|
+
/** URL to Markdown: read any web page and get its main article content as clean Markdown for agents ($0.003, x402) */
|
|
8
8
|
async extractMarkdown(request) {
|
|
9
9
|
return this.post("/v1/web-scraper/extract_markdown", request);
|
|
10
10
|
}
|
|
@@ -12,11 +12,11 @@ export class Client extends BaseClient {
|
|
|
12
12
|
async getTaskStatus(request) {
|
|
13
13
|
return this.post("/v1/web-scraper/get_task_status", request);
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/** Scrape URL: fetch any web page through a proxy and get its status, content type and raw HTML ($0.002, x402) */
|
|
16
16
|
async scrapeUrl(request) {
|
|
17
17
|
return this.post("/v1/web-scraper/scrape_url", request);
|
|
18
18
|
}
|
|
19
|
-
/** Enqueues a web_scraper_scrape_url job and returns a task id immediately ($0.
|
|
19
|
+
/** [Deprecated - use web_scraper_scrape_url] Enqueues a web_scraper_scrape_url job and returns a task id immediately ($0.002, x402) */
|
|
20
20
|
async scrapeUrlAsync(request) {
|
|
21
21
|
return this.post("/v1/web-scraper/scrape_url_async", request);
|
|
22
22
|
}
|
package/dist/langchain.js
CHANGED
|
@@ -11,7 +11,7 @@ export class WebScraperToolkit {
|
|
|
11
11
|
return [
|
|
12
12
|
tool(async (input) => this.client.extractMarkdown(input), {
|
|
13
13
|
name: "extractMarkdown",
|
|
14
|
-
description: "
|
|
14
|
+
description: "URL to Markdown: read any web page and get its main article content as clean Markdown for agents ($0.003, x402)",
|
|
15
15
|
schema: z.object({ url: z.string() }),
|
|
16
16
|
}),
|
|
17
17
|
tool(async (input) => this.client.getTaskStatus(input), {
|
|
@@ -21,12 +21,12 @@ export class WebScraperToolkit {
|
|
|
21
21
|
}),
|
|
22
22
|
tool(async (input) => this.client.scrapeUrl(input), {
|
|
23
23
|
name: "scrapeUrl",
|
|
24
|
-
description: "
|
|
24
|
+
description: "Scrape URL: fetch any web page through a proxy and get its status, content type and raw HTML ($0.002, x402)",
|
|
25
25
|
schema: z.object({ url: z.string() }),
|
|
26
26
|
}),
|
|
27
27
|
tool(async (input) => this.client.scrapeUrlAsync(input), {
|
|
28
28
|
name: "scrapeUrlAsync",
|
|
29
|
-
description: "Enqueues a web_scraper_scrape_url job and returns a task id immediately ($0.
|
|
29
|
+
description: "[Deprecated - use web_scraper_scrape_url] Enqueues a web_scraper_scrape_url job and returns a task id immediately ($0.002, x402)",
|
|
30
30
|
schema: z.object({ callback_url: z.string().nullable().optional(), url: z.string() }),
|
|
31
31
|
}),
|
|
32
32
|
];
|
package/package.json
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyz17711/web-scraper",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Typed TypeScript client for the 17711.xyz Web Scraper API: pay-per-call, settled in USDC via x402.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "17711 Services",
|
|
7
|
+
"homepage": "https://api.17711.xyz",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/17711-services/clients.git",
|
|
11
|
+
"directory": "node/packages/web-scraper"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/17711-services/clients/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"x402",
|
|
18
|
+
"usdc",
|
|
19
|
+
"api-client",
|
|
20
|
+
"pay-per-call",
|
|
21
|
+
"ai-agents",
|
|
22
|
+
"mcp",
|
|
23
|
+
"langchain",
|
|
24
|
+
"web-scraper"
|
|
25
|
+
],
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
5
33
|
"type": "module",
|
|
6
34
|
"main": "dist/index.js",
|
|
7
35
|
"types": "dist/index.d.ts",
|
package/src/index.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed HTTP client and request/response interfaces for web-scraper.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
|
|
6
|
-
|
|
7
|
-
export interface ExtractMarkdownResponse {
|
|
8
|
-
content_type?: string | null;
|
|
9
|
-
/** The URL actually reached, after any redirects the target sent. */
|
|
10
|
-
final_url: string;
|
|
11
|
-
/** Boilerplate-stripped main article content, as Markdown -- navigation, ads, and sidebars removed, not the raw page HTML. */
|
|
12
|
-
markdown: string;
|
|
13
|
-
/** The REAL HTTP status the underlying fetch received. */
|
|
14
|
-
status: number;
|
|
15
|
-
/** Article title, if Readability found one. */
|
|
16
|
-
title?: string | null;
|
|
17
|
-
/** `true` if the underlying fetch's HTML was truncated by web-scraper's own fixed byte ceiling (see `web_scraper_scrape_url`'s own `truncated` field) -- `markdown` may then also be incomplete. */
|
|
18
|
-
truncated: boolean;
|
|
19
|
-
/** The URL as requested, verbatim. */
|
|
20
|
-
url: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface ExtractMarkdownRequest {
|
|
24
|
-
/** The target URL to fetch, e.g. `"https://example.com/article"`. Must be `http://` or `https://` -- same validation as `web_scraper_scrape_url`, since this tool fetches through the exact same internal scraper. */
|
|
25
|
-
url: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** `"pending"` (enqueued, no result yet), `"finished"` (a worker wrote a result -- see `ok`/ `result`), or `"unknown"` (this id was never valid, or both it and its result have expired -- see [`nimpoleon_tasks::TaskState`]'s own doc comment for why this is 3 states, not 2). */
|
|
29
|
-
export interface TaskStatusKind {
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface GetTaskStatusResponse {
|
|
33
|
-
ok?: boolean | null;
|
|
34
|
-
result?: unknown;
|
|
35
|
-
status: TaskStatusKind;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface GetTaskStatusRequest {
|
|
39
|
-
/** The `task_id` a `*_async` tool returned. */
|
|
40
|
-
task_id: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface ScrapeUrlResponse {
|
|
44
|
-
content_type?: string | null;
|
|
45
|
-
/** The URL actually reached, after any redirects the target sent. */
|
|
46
|
-
final_url: string;
|
|
47
|
-
/** Raw response body, decoded as UTF-8 (lossy -- see this tool's own description for why), truncated to this service's own fixed byte ceiling if needed. */
|
|
48
|
-
html: string;
|
|
49
|
-
/** The REAL HTTP status the target returned -- never masked, never itself a reason to retry. */
|
|
50
|
-
status: number;
|
|
51
|
-
/** `true` if `html` was cut short by this service's own fixed byte ceiling. */
|
|
52
|
-
truncated: boolean;
|
|
53
|
-
/** The URL as requested, verbatim. */
|
|
54
|
-
url: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface ScrapeUrlRequest {
|
|
58
|
-
/** The target URL to fetch, e.g. `"https://example.com/page"`. Must be `http://` or `https://` -- any other scheme is rejected before any fetch is attempted. */
|
|
59
|
-
url: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** The fixed response shape of every `*_async` tool -- deliberately NOT generic over the underlying sync tool's own response type, since no work has actually happened yet at this point. */
|
|
63
|
-
export interface AsyncTaskResponse {
|
|
64
|
-
task_id: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface ScrapeUrlAsyncRequest {
|
|
68
|
-
/** When set, the worker that processes this task POSTs the eventual result (a `TaskResult` JSON body) here, best-effort -- polling `web_scraper_get_task_status` always works too, regardless of whether this is set. */
|
|
69
|
-
callback_url?: string | null;
|
|
70
|
-
/** The target URL to fetch, e.g. `"https://example.com/page"`. Must be `http://` or `https://` -- any other scheme is rejected before any fetch is attempted. */
|
|
71
|
-
url: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Typed client for web-scraper, e.g. `client.extractMarkdown(...)`. */
|
|
75
|
-
export class Client extends BaseClient {
|
|
76
|
-
/** Fetches a URL and returns its main article content as clean Markdown ($0.007, x402) */
|
|
77
|
-
async extractMarkdown(request: ExtractMarkdownRequest): Promise<ExtractMarkdownResponse> {
|
|
78
|
-
return this.post<ExtractMarkdownResponse>("/v1/web-scraper/extract_markdown", request);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Polls for the result of a task enqueued by a *_async tool */
|
|
82
|
-
async getTaskStatus(request: GetTaskStatusRequest): Promise<GetTaskStatusResponse> {
|
|
83
|
-
return this.post<GetTaskStatusResponse>("/v1/web-scraper/get_task_status", request);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** Fetches an arbitrary URL through a proxy sourced from proxy-pool, never directly ($0.005, x402) */
|
|
87
|
-
async scrapeUrl(request: ScrapeUrlRequest): Promise<ScrapeUrlResponse> {
|
|
88
|
-
return this.post<ScrapeUrlResponse>("/v1/web-scraper/scrape_url", request);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Enqueues a web_scraper_scrape_url job and returns a task id immediately ($0.005, x402) */
|
|
92
|
-
async scrapeUrlAsync(request: ScrapeUrlAsyncRequest): Promise<AsyncTaskResponse> {
|
|
93
|
-
return this.post<AsyncTaskResponse>("/v1/web-scraper/scrape_url_async", request);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { ClientOptions };
|
package/src/langchain.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LangChain.js tools for web-scraper, grouped in one Toolkit -- one tool per operation, each just an async function (JS has no separate sync form to generate). Requires the `@langchain/core`+`zod` peer dependencies declared in this package's own package.json -- imported from `web-scraper/langchain`, never from the package root, so importing the base client never requires them installed.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { tool } from "@langchain/core/tools";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { Client } from "./index.js";
|
|
8
|
-
|
|
9
|
-
export class WebScraperToolkit {
|
|
10
|
-
private client: Client;
|
|
11
|
-
|
|
12
|
-
constructor(client: Client) {
|
|
13
|
-
this.client = client;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getTools() {
|
|
17
|
-
return [
|
|
18
|
-
tool(
|
|
19
|
-
async (input) => this.client.extractMarkdown(input),
|
|
20
|
-
{
|
|
21
|
-
name: "extractMarkdown",
|
|
22
|
-
description: "Fetches a URL and returns its main article content as clean Markdown ($0.007, x402)",
|
|
23
|
-
schema: z.object({ url: z.string() }),
|
|
24
|
-
},
|
|
25
|
-
),
|
|
26
|
-
tool(
|
|
27
|
-
async (input) => this.client.getTaskStatus(input),
|
|
28
|
-
{
|
|
29
|
-
name: "getTaskStatus",
|
|
30
|
-
description: "Polls for the result of a task enqueued by a *_async tool",
|
|
31
|
-
schema: z.object({ task_id: z.string() }),
|
|
32
|
-
},
|
|
33
|
-
),
|
|
34
|
-
tool(
|
|
35
|
-
async (input) => this.client.scrapeUrl(input),
|
|
36
|
-
{
|
|
37
|
-
name: "scrapeUrl",
|
|
38
|
-
description: "Fetches an arbitrary URL through a proxy sourced from proxy-pool, never directly ($0.005, x402)",
|
|
39
|
-
schema: z.object({ url: z.string() }),
|
|
40
|
-
},
|
|
41
|
-
),
|
|
42
|
-
tool(
|
|
43
|
-
async (input) => this.client.scrapeUrlAsync(input),
|
|
44
|
-
{
|
|
45
|
-
name: "scrapeUrlAsync",
|
|
46
|
-
description: "Enqueues a web_scraper_scrape_url job and returns a task id immediately ($0.005, x402)",
|
|
47
|
-
schema: z.object({ callback_url: z.string().nullable().optional(), url: z.string() }),
|
|
48
|
-
},
|
|
49
|
-
),
|
|
50
|
-
];
|
|
51
|
-
}
|
|
52
|
-
}
|
package/test/index.test.mjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies every web-scraper client method sends a request to the expected path/HTTP verb and parses a well-formed response -- one test per operation, real fetch mocked via a plain reassignment of `globalThis.fetch` (no extra test/mocking dependency). Runs against the COMPILED package (`../dist/index.js`) -- build before testing.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { test } from "node:test";
|
|
6
|
-
import assert from "node:assert/strict";
|
|
7
|
-
import { Client } from "../dist/index.js";
|
|
8
|
-
|
|
9
|
-
test("extractMarkdown calls the expected path", async () => {
|
|
10
|
-
const originalFetch = globalThis.fetch;
|
|
11
|
-
globalThis.fetch = async (url, init = {}) => {
|
|
12
|
-
const parsed = new URL(url);
|
|
13
|
-
assert.equal((init.method ?? "GET").toUpperCase(), "POST");
|
|
14
|
-
assert.equal(parsed.pathname, "/v1/web-scraper/extract_markdown");
|
|
15
|
-
return new Response(JSON.stringify({ content_type: null, final_url: "test", markdown: "test", status: 0, title: null, truncated: false, url: "test" }), { status: 200 });
|
|
16
|
-
};
|
|
17
|
-
try {
|
|
18
|
-
const client = new Client("https://example.test");
|
|
19
|
-
const result = await client.extractMarkdown({ url: "test" });
|
|
20
|
-
assert.ok(result !== undefined);
|
|
21
|
-
} finally {
|
|
22
|
-
globalThis.fetch = originalFetch;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("getTaskStatus calls the expected path", async () => {
|
|
27
|
-
const originalFetch = globalThis.fetch;
|
|
28
|
-
globalThis.fetch = async (url, init = {}) => {
|
|
29
|
-
const parsed = new URL(url);
|
|
30
|
-
assert.equal((init.method ?? "GET").toUpperCase(), "POST");
|
|
31
|
-
assert.equal(parsed.pathname, "/v1/web-scraper/get_task_status");
|
|
32
|
-
return new Response(JSON.stringify({ ok: null, result: null, status: { } }), { status: 200 });
|
|
33
|
-
};
|
|
34
|
-
try {
|
|
35
|
-
const client = new Client("https://example.test");
|
|
36
|
-
const result = await client.getTaskStatus({ task_id: "test" });
|
|
37
|
-
assert.ok(result !== undefined);
|
|
38
|
-
} finally {
|
|
39
|
-
globalThis.fetch = originalFetch;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("scrapeUrl calls the expected path", async () => {
|
|
44
|
-
const originalFetch = globalThis.fetch;
|
|
45
|
-
globalThis.fetch = async (url, init = {}) => {
|
|
46
|
-
const parsed = new URL(url);
|
|
47
|
-
assert.equal((init.method ?? "GET").toUpperCase(), "POST");
|
|
48
|
-
assert.equal(parsed.pathname, "/v1/web-scraper/scrape_url");
|
|
49
|
-
return new Response(JSON.stringify({ content_type: null, final_url: "test", html: "test", status: 0, truncated: false, url: "test" }), { status: 200 });
|
|
50
|
-
};
|
|
51
|
-
try {
|
|
52
|
-
const client = new Client("https://example.test");
|
|
53
|
-
const result = await client.scrapeUrl({ url: "test" });
|
|
54
|
-
assert.ok(result !== undefined);
|
|
55
|
-
} finally {
|
|
56
|
-
globalThis.fetch = originalFetch;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("scrapeUrlAsync calls the expected path", async () => {
|
|
61
|
-
const originalFetch = globalThis.fetch;
|
|
62
|
-
globalThis.fetch = async (url, init = {}) => {
|
|
63
|
-
const parsed = new URL(url);
|
|
64
|
-
assert.equal((init.method ?? "GET").toUpperCase(), "POST");
|
|
65
|
-
assert.equal(parsed.pathname, "/v1/web-scraper/scrape_url_async");
|
|
66
|
-
return new Response(JSON.stringify({ task_id: "test" }), { status: 200 });
|
|
67
|
-
};
|
|
68
|
-
try {
|
|
69
|
-
const client = new Client("https://example.test");
|
|
70
|
-
const result = await client.scrapeUrlAsync({ callback_url: null, url: "test" });
|
|
71
|
-
assert.ok(result !== undefined);
|
|
72
|
-
} finally {
|
|
73
|
-
globalThis.fetch = originalFetch;
|
|
74
|
-
}
|
|
75
|
-
});
|
package/test/langchain.test.mjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies every web-scraper LangChain tool through the real StructuredTool (`.invoke()`), not just the underlying client method -- catches schema-shape bugs a plain client-method test would miss. Requires the `langchain`/`zod` dev dependencies.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { test } from "node:test";
|
|
6
|
-
import assert from "node:assert/strict";
|
|
7
|
-
import { Client } from "../dist/index.js";
|
|
8
|
-
import { WebScraperToolkit } from "../dist/langchain.js";
|
|
9
|
-
|
|
10
|
-
test("extractMarkdown tool invoke", async () => {
|
|
11
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ content_type: null, final_url: "test", markdown: "test", status: 0, title: null, truncated: false, url: "test" }), { status: 200 });
|
|
12
|
-
const toolkit = new WebScraperToolkit(new Client("https://example.test"));
|
|
13
|
-
const t = toolkit.getTools().find((x) => x.name === "extractMarkdown");
|
|
14
|
-
const result = await t.invoke({ url: "test" });
|
|
15
|
-
assert.ok(result !== undefined);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("getTaskStatus tool invoke", async () => {
|
|
19
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ ok: null, result: null, status: { } }), { status: 200 });
|
|
20
|
-
const toolkit = new WebScraperToolkit(new Client("https://example.test"));
|
|
21
|
-
const t = toolkit.getTools().find((x) => x.name === "getTaskStatus");
|
|
22
|
-
const result = await t.invoke({ task_id: "test" });
|
|
23
|
-
assert.ok(result !== undefined);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("scrapeUrl tool invoke", async () => {
|
|
27
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ content_type: null, final_url: "test", html: "test", status: 0, truncated: false, url: "test" }), { status: 200 });
|
|
28
|
-
const toolkit = new WebScraperToolkit(new Client("https://example.test"));
|
|
29
|
-
const t = toolkit.getTools().find((x) => x.name === "scrapeUrl");
|
|
30
|
-
const result = await t.invoke({ url: "test" });
|
|
31
|
-
assert.ok(result !== undefined);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("scrapeUrlAsync tool invoke", async () => {
|
|
35
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ task_id: "test" }), { status: 200 });
|
|
36
|
-
const toolkit = new WebScraperToolkit(new Client("https://example.test"));
|
|
37
|
-
const t = toolkit.getTools().find((x) => x.name === "scrapeUrlAsync");
|
|
38
|
-
const result = await t.invoke({ callback_url: "test", url: "test" });
|
|
39
|
-
assert.ok(result !== undefined);
|
|
40
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "ES2020",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"outDir": "dist",
|
|
8
|
-
"rootDir": "src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"src"
|
|
15
|
-
]
|
|
16
|
-
}
|