@xyz17711/url-extract 0.1.0 → 0.1.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.
- package/README.md +8 -5
- package/dist/index.d.ts +11 -2
- package/dist/index.js +10 -2
- package/dist/langchain.d.ts +1 -1
- package/dist/langchain.js +1 -1
- package/package.json +30 -2
- package/src/index.ts +0 -117
- package/src/langchain.ts +0 -36
- package/test/index.test.mjs +0 -41
- package/test/langchain.test.mjs +0 -24
- package/tsconfig.json +0 -16
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@xyz17711/url-extract)
|
|
5
5
|
[](https://github.com/17711-services/clients/blob/main/LICENSE)
|
|
6
6
|
|
|
7
|
-
Typed TypeScript client for
|
|
7
|
+
Typed TypeScript client for **url-extract-service**, part of the
|
|
8
8
|
[17711.xyz](https://api.17711.xyz) microservice fleet -- pay-per-call APIs settled in USDC via
|
|
9
9
|
[x402](https://x402.org), listed on [x402scan](https://www.x402scan.com/server/f1c7b972-3405-4b75-8b4f-d1bfbd6305ff).
|
|
10
10
|
|
|
@@ -26,10 +26,13 @@ npm install @xyz17711/url-extract
|
|
|
26
26
|
```typescript
|
|
27
27
|
import { Client } from "@xyz17711/url-extract";
|
|
28
28
|
|
|
29
|
-
const client = new Client(
|
|
29
|
+
const client = new Client(); // talks to https://api.17711.xyz/registry/url-extract-service by default
|
|
30
30
|
// see the Methods table above for every available call and its request/response type
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
Pass another base URL (self-hosted instance, test server) as the first argument:
|
|
34
|
+
`new Client("https://my-host.example/registry/url-extract-service")`.
|
|
35
|
+
|
|
33
36
|
## Paying past the free quota
|
|
34
37
|
|
|
35
38
|
Every gated tool allows a small number of free calls per day; beyond that it returns a 402
|
|
@@ -39,7 +42,7 @@ network, and payee address attached:
|
|
|
39
42
|
```typescript
|
|
40
43
|
import { Client, PaymentRequiredError } from "@xyz17711/url-extract";
|
|
41
44
|
|
|
42
|
-
const client = new Client(
|
|
45
|
+
const client = new Client();
|
|
43
46
|
try {
|
|
44
47
|
await client.getCompanyProfile(/* ... */);
|
|
45
48
|
} catch (e) {
|
|
@@ -55,7 +58,7 @@ own environment/secrets manager, never a literal string in source code:
|
|
|
55
58
|
```typescript
|
|
56
59
|
import { Client } from "@xyz17711/url-extract";
|
|
57
60
|
|
|
58
|
-
const client = new Client(
|
|
61
|
+
const client = new Client({
|
|
59
62
|
x402PrivateKey: process.env.X402_PRIVATE_KEY,
|
|
60
63
|
x402ExpectedNetwork: "eip155:8453", // Base mainnet; use eip155:84532 for Base Sepolia testnet
|
|
61
64
|
x402MaxPaymentUsdc: 0.01, // refuse any single call above this
|
|
@@ -74,7 +77,7 @@ with that same key in this process.
|
|
|
74
77
|
import { Client } from "@xyz17711/url-extract";
|
|
75
78
|
import { UrlExtractToolkit } from "@xyz17711/url-extract/langchain";
|
|
76
79
|
|
|
77
|
-
const client = new Client(
|
|
80
|
+
const client = new Client({ /* ...wallet options... */ });
|
|
78
81
|
const tools = new UrlExtractToolkit(client).getTools();
|
|
79
82
|
```
|
|
80
83
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Typed HTTP client and request/response interfaces for
|
|
2
|
+
* Typed HTTP client and request/response interfaces for url-extract-service.
|
|
3
3
|
*/
|
|
4
4
|
import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
|
|
5
5
|
export interface DomainInfo {
|
|
@@ -94,8 +94,17 @@ export interface GetStructuredDataRequest {
|
|
|
94
94
|
/** Address of the web page to read (`http` or `https`). */
|
|
95
95
|
url: string;
|
|
96
96
|
}
|
|
97
|
-
/**
|
|
97
|
+
/** Production base URL of this service; pass another to self-host or test. */
|
|
98
|
+
export declare const DEFAULT_BASE_URL = "https://api.17711.xyz/registry/url-extract-service";
|
|
99
|
+
/** Typed client for url-extract-service, e.g. `client.getCompanyProfile(...)`. */
|
|
98
100
|
export declare class Client extends BaseClient {
|
|
101
|
+
/**
|
|
102
|
+
* `new Client()` talks to the production service. Pass a base URL to target another
|
|
103
|
+
* instance, and/or wallet options (`new Client({ x402PrivateKey, ... })`) to pay past the
|
|
104
|
+
* free quota automatically.
|
|
105
|
+
*/
|
|
106
|
+
constructor(options?: ClientOptions);
|
|
107
|
+
constructor(baseUrl?: string, options?: ClientOptions);
|
|
99
108
|
/** [Deprecated - use company_profile_get_profile] Company profile from a domain or a name as valid JSON ($0.009, x402) */
|
|
100
109
|
getCompanyProfile(request: GetCompanyProfileRequest): Promise<GetCompanyProfileResponse>;
|
|
101
110
|
/** URL extract with a question: ask any web page a question and get structured data as JSON that matches your schema ($0.02, x402) */
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Typed HTTP client and request/response interfaces for
|
|
2
|
+
* Typed HTTP client and request/response interfaces for url-extract-service.
|
|
3
3
|
*/
|
|
4
4
|
import { Client as BaseClient } from "@xyz17711/core";
|
|
5
|
-
/**
|
|
5
|
+
/** Production base URL of this service; pass another to self-host or test. */
|
|
6
|
+
export const DEFAULT_BASE_URL = "https://api.17711.xyz/registry/url-extract-service";
|
|
7
|
+
/** Typed client for url-extract-service, e.g. `client.getCompanyProfile(...)`. */
|
|
6
8
|
export class Client extends BaseClient {
|
|
9
|
+
constructor(baseUrlOrOptions, options = {}) {
|
|
10
|
+
const [url, opts] = typeof baseUrlOrOptions === "object"
|
|
11
|
+
? [DEFAULT_BASE_URL, baseUrlOrOptions]
|
|
12
|
+
: [baseUrlOrOptions ?? DEFAULT_BASE_URL, options];
|
|
13
|
+
super(url, opts);
|
|
14
|
+
}
|
|
7
15
|
/** [Deprecated - use company_profile_get_profile] Company profile from a domain or a name as valid JSON ($0.009, x402) */
|
|
8
16
|
async getCompanyProfile(request) {
|
|
9
17
|
return this.post("/v1/url-extract/get_company_profile", request);
|
package/dist/langchain.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LangChain.js tools for
|
|
2
|
+
* LangChain.js tools for url-extract-service, 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 `url-extract/langchain`, never from the package root, so importing the base client never requires them installed.
|
|
3
3
|
*/
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Client } from "./index.js";
|
package/dist/langchain.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LangChain.js tools for
|
|
2
|
+
* LangChain.js tools for url-extract-service, 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 `url-extract/langchain`, never from the package root, so importing the base client never requires them installed.
|
|
3
3
|
*/
|
|
4
4
|
import { tool } from "@langchain/core/tools";
|
|
5
5
|
import { z } from "zod";
|
package/package.json
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyz17711/url-extract",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Typed TypeScript client for the 17711.xyz Url Extract 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/url-extract"
|
|
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
|
+
"url-extract"
|
|
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,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed HTTP client and request/response interfaces for 🧩 url-extract-service.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
|
|
6
|
-
|
|
7
|
-
export interface DomainInfo {
|
|
8
|
-
/** Years since registration, one decimal. */
|
|
9
|
-
domain_age_years?: number | null;
|
|
10
|
-
/** Mail platform deduced from the MX records (`google-workspace`, `microsoft-365`, ...). */
|
|
11
|
-
email_provider?: string | null;
|
|
12
|
-
/** Expiration date, `YYYY-MM-DD`. */
|
|
13
|
-
expires_at?: string | null;
|
|
14
|
-
/** Sending services declared in the SPF record (`sendgrid`, `mailchimp`, ...). */
|
|
15
|
-
mail_services: string[];
|
|
16
|
-
nameservers: string[];
|
|
17
|
-
/** Registration date, `YYYY-MM-DD`. */
|
|
18
|
-
registered_at?: string | null;
|
|
19
|
-
/** The registrable domain the lookups were made for. */
|
|
20
|
-
registrable_domain: string;
|
|
21
|
-
/** The registrant, only when it is an organization published in RDAP. */
|
|
22
|
-
registrant_org?: string | null;
|
|
23
|
-
registrar?: string | null;
|
|
24
|
-
/** RDAP status flags (e.g. `client transfer prohibited`), at most 4. */
|
|
25
|
-
statuses: string[];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface GetCompanyProfileResponse {
|
|
29
|
-
/** Every automatic correction applied to the model's answer. */
|
|
30
|
-
applied_fixes: unknown[];
|
|
31
|
-
/** The host that was profiled, lowercased, without scheme or path. */
|
|
32
|
-
domain: string;
|
|
33
|
-
/** Public registration and DNS facts about the domain: registrar, registration and expiry dates, age, name servers, public registrant organization, mail platform and sending services. Fields that could not be looked up are absent or empty. */
|
|
34
|
-
domain_info: DomainInfo;
|
|
35
|
-
/** Language of the profile's free-text values. */
|
|
36
|
-
output_language: string;
|
|
37
|
-
/** The pages that were actually read to build the profile. */
|
|
38
|
-
pages_read: string[];
|
|
39
|
-
/** Number of model passes used (2 only when the first answer was incomplete). */
|
|
40
|
-
passes: number;
|
|
41
|
-
/** The profile: `name`, `description`, `offering`, `target_customers`, `pricing_summary`, `headquarters`, `founded`, `contact` (`emails`, `phones`) and `social` (`linkedin`, `twitter`, `github`, `facebook`, `instagram`, `youtube`). A value the pages do not state is `null`. */
|
|
42
|
-
profile: unknown;
|
|
43
|
-
/** Every schema violation that could not be corrected. */
|
|
44
|
-
remaining_issues: unknown[];
|
|
45
|
-
/** `true` when the website was found from `company_name`. */
|
|
46
|
-
resolved_from_name: boolean;
|
|
47
|
-
/** Language of the website (ISO 639-1 code). */
|
|
48
|
-
source_language: string;
|
|
49
|
-
/** E-mail addresses and social links the model produced that do NOT appear in the pages read; they were removed from `profile` so nothing in it is invented. */
|
|
50
|
-
unverified_removed: string[];
|
|
51
|
-
/** Whether the profile satisfies the profile schema after automatic correction. */
|
|
52
|
-
valid?: boolean | null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface GetCompanyProfileRequest {
|
|
56
|
-
/** The company's name, when you do not know its website (e.g. `Mistral AI`): the official site is looked up first. `domain` wins when both are given. */
|
|
57
|
-
company_name?: string | null;
|
|
58
|
-
/** The company's website: a domain such as `stripe.com` or a full URL (`https://stripe.com/`). Give this or `company_name`. */
|
|
59
|
-
domain?: string | null;
|
|
60
|
-
/** Language of the free-text values of the answer (`en` by default; `fr`, `de`, `es`, `pt-BR`...). The pages may be in any language; the JSON keys are always English. */
|
|
61
|
-
language?: string | null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface GetStructuredDataResponse {
|
|
65
|
-
/** How old this answer is, in seconds (0 for a fresh read). */
|
|
66
|
-
age_seconds: number;
|
|
67
|
-
/** Every automatic correction applied to the model's answer, in order. */
|
|
68
|
-
applied_fixes: unknown[];
|
|
69
|
-
/** The structured answer (an object or an array), corrected against `schema` when one was given. */
|
|
70
|
-
data: unknown;
|
|
71
|
-
/** The URL actually read, after redirects. */
|
|
72
|
-
final_url: string;
|
|
73
|
-
/** `true` when this answer was served from a stored result rather than computed now. */
|
|
74
|
-
from_cache: boolean;
|
|
75
|
-
/** `true` when the page text came from a stored copy (fresh enough for `max_age_seconds`). */
|
|
76
|
-
page_from_cache: boolean;
|
|
77
|
-
/** `true` when the page was longer than the amount of text the answer is based on. */
|
|
78
|
-
page_truncated: boolean;
|
|
79
|
-
/** Every schema violation that could not be corrected. */
|
|
80
|
-
remaining_issues: unknown[];
|
|
81
|
-
/** When the page was read to build this answer (UTC). */
|
|
82
|
-
retrieved_at: string;
|
|
83
|
-
/** `true` when the page could not be refreshed and an older stored copy was used. */
|
|
84
|
-
stale_page: boolean;
|
|
85
|
-
/** The page title, when one could be extracted. */
|
|
86
|
-
title?: string | null;
|
|
87
|
-
/** The URL that was requested. */
|
|
88
|
-
url: string;
|
|
89
|
-
/** Whether `data` satisfies `schema` after correction; absent when no schema was given. */
|
|
90
|
-
valid?: boolean | null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface GetStructuredDataRequest {
|
|
94
|
-
/** The oldest answer you accept, in seconds. Omit it for the default (an identical question about the same page up to 1 hour old); `0` forces a fresh read of the page and a fresh answer. The response always says how old it is. */
|
|
95
|
-
max_age_seconds?: number | null;
|
|
96
|
-
/** What to extract or answer, in plain language, e.g. "list the pricing plans with their name and monthly price in USD". */
|
|
97
|
-
question: string;
|
|
98
|
-
/** Optional JSON Schema the answer must satisfy. When given, the answer is validated against it and automatically corrected where a safe fix exists (type coercion, missing defaults, out-of-range numbers, unknown properties); anything that cannot be fixed is reported in `remaining_issues`. Omitted = a free-form JSON answer, returned as-is. */
|
|
99
|
-
schema?: unknown;
|
|
100
|
-
/** Address of the web page to read (`http` or `https`). */
|
|
101
|
-
url: string;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** Typed client for 🧩 url-extract-service, e.g. `client.getCompanyProfile(...)`. */
|
|
105
|
-
export class Client extends BaseClient {
|
|
106
|
-
/** [Deprecated - use company_profile_get_profile] Company profile from a domain or a name as valid JSON ($0.009, x402) */
|
|
107
|
-
async getCompanyProfile(request: GetCompanyProfileRequest): Promise<GetCompanyProfileResponse> {
|
|
108
|
-
return this.post<GetCompanyProfileResponse>("/v1/url-extract/get_company_profile", request);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** URL extract with a question: ask any web page a question and get structured data as JSON that matches your schema ($0.02, x402) */
|
|
112
|
-
async getStructuredData(request: GetStructuredDataRequest): Promise<GetStructuredDataResponse> {
|
|
113
|
-
return this.post<GetStructuredDataResponse>("/v1/url-extract/get_structured_data", request);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export { ClientOptions };
|
package/src/langchain.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LangChain.js tools for 🧩 url-extract-service, 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 `url-extract/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 UrlExtractToolkit {
|
|
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.getCompanyProfile(input),
|
|
20
|
-
{
|
|
21
|
-
name: "getCompanyProfile",
|
|
22
|
-
description: "[Deprecated - use company_profile_get_profile] Company profile from a domain or a name as valid JSON ($0.009, x402)",
|
|
23
|
-
schema: z.object({ company_name: z.string().nullable().optional(), domain: z.string().nullable().optional(), language: z.string().nullable().optional() }),
|
|
24
|
-
},
|
|
25
|
-
),
|
|
26
|
-
tool(
|
|
27
|
-
async (input) => this.client.getStructuredData(input),
|
|
28
|
-
{
|
|
29
|
-
name: "getStructuredData",
|
|
30
|
-
description: "URL extract with a question: ask any web page a question and get structured data as JSON that matches your schema ($0.02, x402)",
|
|
31
|
-
schema: z.object({ max_age_seconds: z.number().nullable().optional(), question: z.string(), schema: z.unknown().optional(), url: z.string() }),
|
|
32
|
-
},
|
|
33
|
-
),
|
|
34
|
-
];
|
|
35
|
-
}
|
|
36
|
-
}
|
package/test/index.test.mjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies every url-extract 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("getCompanyProfile 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/url-extract/get_company_profile");
|
|
15
|
-
return new Response(JSON.stringify({ applied_fixes: [], domain: "test", domain_info: { domain_age_years: null, email_provider: null, expires_at: null, mail_services: [], nameservers: [], registered_at: null, registrable_domain: "test", registrant_org: null, registrar: null, statuses: [] }, output_language: "test", pages_read: [], passes: 0, profile: null, remaining_issues: [], resolved_from_name: false, source_language: "test", unverified_removed: [], valid: null }), { status: 200 });
|
|
16
|
-
};
|
|
17
|
-
try {
|
|
18
|
-
const client = new Client("https://example.test");
|
|
19
|
-
const result = await client.getCompanyProfile({ company_name: null, domain: null, language: null });
|
|
20
|
-
assert.ok(result !== undefined);
|
|
21
|
-
} finally {
|
|
22
|
-
globalThis.fetch = originalFetch;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("getStructuredData 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/url-extract/get_structured_data");
|
|
32
|
-
return new Response(JSON.stringify({ age_seconds: 0, applied_fixes: [], data: null, final_url: "test", from_cache: false, page_from_cache: false, page_truncated: false, remaining_issues: [], retrieved_at: "test", stale_page: false, title: null, url: "test", valid: null }), { status: 200 });
|
|
33
|
-
};
|
|
34
|
-
try {
|
|
35
|
-
const client = new Client("https://example.test");
|
|
36
|
-
const result = await client.getStructuredData({ max_age_seconds: null, question: "test", schema: null, url: "test" });
|
|
37
|
-
assert.ok(result !== undefined);
|
|
38
|
-
} finally {
|
|
39
|
-
globalThis.fetch = originalFetch;
|
|
40
|
-
}
|
|
41
|
-
});
|
package/test/langchain.test.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies every url-extract 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 { UrlExtractToolkit } from "../dist/langchain.js";
|
|
9
|
-
|
|
10
|
-
test("getCompanyProfile tool invoke", async () => {
|
|
11
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ applied_fixes: [], domain: "test", domain_info: { domain_age_years: null, email_provider: null, expires_at: null, mail_services: [], nameservers: [], registered_at: null, registrable_domain: "test", registrant_org: null, registrar: null, statuses: [] }, output_language: "test", pages_read: [], passes: 0, profile: null, remaining_issues: [], resolved_from_name: false, source_language: "test", unverified_removed: [], valid: null }), { status: 200 });
|
|
12
|
-
const toolkit = new UrlExtractToolkit(new Client("https://example.test"));
|
|
13
|
-
const t = toolkit.getTools().find((x) => x.name === "getCompanyProfile");
|
|
14
|
-
const result = await t.invoke({ company_name: "test", domain: "test", language: "test" });
|
|
15
|
-
assert.ok(result !== undefined);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("getStructuredData tool invoke", async () => {
|
|
19
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ age_seconds: 0, applied_fixes: [], data: null, final_url: "test", from_cache: false, page_from_cache: false, page_truncated: false, remaining_issues: [], retrieved_at: "test", stale_page: false, title: null, url: "test", valid: null }), { status: 200 });
|
|
20
|
-
const toolkit = new UrlExtractToolkit(new Client("https://example.test"));
|
|
21
|
-
const t = toolkit.getTools().find((x) => x.name === "getStructuredData");
|
|
22
|
-
const result = await t.invoke({ max_age_seconds: 0, question: "test", schema: null, url: "test" });
|
|
23
|
-
assert.ok(result !== undefined);
|
|
24
|
-
});
|
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
|
-
}
|