@xyz17711/company-profile 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 -84
- package/src/langchain.ts +0 -28
- package/test/index.test.mjs +0 -24
- package/test/langchain.test.mjs +0 -16
- package/tsconfig.json +0 -16
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@xyz17711/company-profile)
|
|
5
5
|
[](https://github.com/17711-services/clients/blob/main/LICENSE)
|
|
6
6
|
|
|
7
|
-
Typed TypeScript client for
|
|
7
|
+
Typed TypeScript client for **company-profile-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
|
|
|
@@ -25,10 +25,13 @@ npm install @xyz17711/company-profile
|
|
|
25
25
|
```typescript
|
|
26
26
|
import { Client } from "@xyz17711/company-profile";
|
|
27
27
|
|
|
28
|
-
const client = new Client(
|
|
28
|
+
const client = new Client(); // talks to https://api.17711.xyz/registry/company-profile-service by default
|
|
29
29
|
// see the Methods table above for every available call and its request/response type
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
Pass another base URL (self-hosted instance, test server) as the first argument:
|
|
33
|
+
`new Client("https://my-host.example/registry/company-profile-service")`.
|
|
34
|
+
|
|
32
35
|
## Paying past the free quota
|
|
33
36
|
|
|
34
37
|
Every gated tool allows a small number of free calls per day; beyond that it returns a 402
|
|
@@ -38,7 +41,7 @@ network, and payee address attached:
|
|
|
38
41
|
```typescript
|
|
39
42
|
import { Client, PaymentRequiredError } from "@xyz17711/company-profile";
|
|
40
43
|
|
|
41
|
-
const client = new Client(
|
|
44
|
+
const client = new Client();
|
|
42
45
|
try {
|
|
43
46
|
await client.getProfile(/* ... */);
|
|
44
47
|
} catch (e) {
|
|
@@ -54,7 +57,7 @@ own environment/secrets manager, never a literal string in source code:
|
|
|
54
57
|
```typescript
|
|
55
58
|
import { Client } from "@xyz17711/company-profile";
|
|
56
59
|
|
|
57
|
-
const client = new Client(
|
|
60
|
+
const client = new Client({
|
|
58
61
|
x402PrivateKey: process.env.X402_PRIVATE_KEY,
|
|
59
62
|
x402ExpectedNetwork: "eip155:8453", // Base mainnet; use eip155:84532 for Base Sepolia testnet
|
|
60
63
|
x402MaxPaymentUsdc: 0.01, // refuse any single call above this
|
|
@@ -73,7 +76,7 @@ with that same key in this process.
|
|
|
73
76
|
import { Client } from "@xyz17711/company-profile";
|
|
74
77
|
import { CompanyProfileToolkit } from "@xyz17711/company-profile/langchain";
|
|
75
78
|
|
|
76
|
-
const client = new Client(
|
|
79
|
+
const client = new Client({ /* ...wallet options... */ });
|
|
77
80
|
const tools = new CompanyProfileToolkit(client).getTools();
|
|
78
81
|
```
|
|
79
82
|
|
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 company-profile-service.
|
|
3
3
|
*/
|
|
4
4
|
import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
|
|
5
5
|
export interface DomainInfo {
|
|
@@ -68,8 +68,17 @@ export interface GetCompanyProfileRequest {
|
|
|
68
68
|
/** The oldest result you accept, in seconds. Omit it for the default (profiles up to 24 hours old); `0` forces a fresh read of the website. The response always says how old it is. */
|
|
69
69
|
max_age_seconds?: number | null;
|
|
70
70
|
}
|
|
71
|
-
/**
|
|
71
|
+
/** Production base URL of this service; pass another to self-host or test. */
|
|
72
|
+
export declare const DEFAULT_BASE_URL = "https://api.17711.xyz/registry/company-profile-service";
|
|
73
|
+
/** Typed client for company-profile-service, e.g. `client.getProfile(...)`. */
|
|
72
74
|
export declare class Client extends BaseClient {
|
|
75
|
+
/**
|
|
76
|
+
* `new Client()` talks to the production service. Pass a base URL to target another
|
|
77
|
+
* instance, and/or wallet options (`new Client({ x402PrivateKey, ... })`) to pay past the
|
|
78
|
+
* free quota automatically.
|
|
79
|
+
*/
|
|
80
|
+
constructor(options?: ClientOptions);
|
|
81
|
+
constructor(baseUrl?: string, options?: ClientOptions);
|
|
73
82
|
/** Company profile and enrichment from a domain or a name: offering, public contacts, social links and WHOIS domain data as valid JSON ($0.009, x402) */
|
|
74
83
|
getProfile(request: GetCompanyProfileRequest): Promise<GetCompanyProfileResponse>;
|
|
75
84
|
}
|
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 company-profile-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/company-profile-service";
|
|
7
|
+
/** Typed client for company-profile-service, e.g. `client.getProfile(...)`. */
|
|
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
|
/** Company profile and enrichment from a domain or a name: offering, public contacts, social links and WHOIS domain data as valid JSON ($0.009, x402) */
|
|
8
16
|
async getProfile(request) {
|
|
9
17
|
return this.post("/v1/company-profile/get_profile", request);
|
package/dist/langchain.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LangChain.js tools for
|
|
2
|
+
* LangChain.js tools for company-profile-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 `company-profile/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 company-profile-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 `company-profile/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/company-profile",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Typed TypeScript client for the 17711.xyz Company Profile 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/company-profile"
|
|
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
|
+
"company-profile"
|
|
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,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed HTTP client and request/response interfaces for 🏢 company-profile-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
|
-
/** How old this answer is, in seconds (0 for a fresh read). */
|
|
30
|
-
age_seconds: number;
|
|
31
|
-
/** Every automatic correction applied to the model's answer. */
|
|
32
|
-
applied_fixes: unknown[];
|
|
33
|
-
/** The host that was profiled, lowercased, without scheme or path. */
|
|
34
|
-
domain: string;
|
|
35
|
-
/** 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. */
|
|
36
|
-
domain_info: DomainInfo;
|
|
37
|
-
/** `true` when this answer was served from a stored result rather than a fresh read. */
|
|
38
|
-
from_cache: boolean;
|
|
39
|
-
/** Language of the profile's free-text values. */
|
|
40
|
-
output_language: string;
|
|
41
|
-
/** How many of the pages used came from a stored copy (fresh enough for `max_age_seconds`). */
|
|
42
|
-
pages_from_cache: number;
|
|
43
|
-
/** The pages that were actually read to build the profile. */
|
|
44
|
-
pages_read: string[];
|
|
45
|
-
/** Number of model passes used (2 only when the first answer was incomplete). */
|
|
46
|
-
passes: number;
|
|
47
|
-
/** 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`. */
|
|
48
|
-
profile: unknown;
|
|
49
|
-
/** Every schema violation that could not be corrected. */
|
|
50
|
-
remaining_issues: unknown[];
|
|
51
|
-
/** `true` when the website was found from `company_name`. */
|
|
52
|
-
resolved_from_name: boolean;
|
|
53
|
-
/** When the website was read to build this profile (UTC). */
|
|
54
|
-
retrieved_at: string;
|
|
55
|
-
/** Language of the website (ISO 639-1 code). */
|
|
56
|
-
source_language: string;
|
|
57
|
-
/** How many pages could not be refreshed and were answered from an older stored copy. */
|
|
58
|
-
stale_pages: number;
|
|
59
|
-
/** 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. */
|
|
60
|
-
unverified_removed: string[];
|
|
61
|
-
/** Whether the profile satisfies the profile schema after automatic correction. */
|
|
62
|
-
valid?: boolean | null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface GetCompanyProfileRequest {
|
|
66
|
-
/** 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. */
|
|
67
|
-
company_name?: string | null;
|
|
68
|
-
/** The company's website: a domain such as `stripe.com` or a full URL (`https://stripe.com/`). Give this or `company_name`. */
|
|
69
|
-
domain?: string | null;
|
|
70
|
-
/** 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. */
|
|
71
|
-
language?: string | null;
|
|
72
|
-
/** The oldest result you accept, in seconds. Omit it for the default (profiles up to 24 hours old); `0` forces a fresh read of the website. The response always says how old it is. */
|
|
73
|
-
max_age_seconds?: number | null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Typed client for 🏢 company-profile-service, e.g. `client.getProfile(...)`. */
|
|
77
|
-
export class Client extends BaseClient {
|
|
78
|
-
/** Company profile and enrichment from a domain or a name: offering, public contacts, social links and WHOIS domain data as valid JSON ($0.009, x402) */
|
|
79
|
-
async getProfile(request: GetCompanyProfileRequest): Promise<GetCompanyProfileResponse> {
|
|
80
|
-
return this.post<GetCompanyProfileResponse>("/v1/company-profile/get_profile", request);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export { ClientOptions };
|
package/src/langchain.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LangChain.js tools for 🏢 company-profile-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 `company-profile/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 CompanyProfileToolkit {
|
|
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.getProfile(input),
|
|
20
|
-
{
|
|
21
|
-
name: "getProfile",
|
|
22
|
-
description: "Company profile and enrichment from a domain or a name: offering, public contacts, social links and WHOIS domain data 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(), max_age_seconds: z.number().nullable().optional() }),
|
|
24
|
-
},
|
|
25
|
-
),
|
|
26
|
-
];
|
|
27
|
-
}
|
|
28
|
-
}
|
package/test/index.test.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies every company-profile 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("getProfile 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/company-profile/get_profile");
|
|
15
|
-
return new Response(JSON.stringify({ age_seconds: 0, 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: [] }, from_cache: false, output_language: "test", pages_from_cache: 0, pages_read: [], passes: 0, profile: null, remaining_issues: [], resolved_from_name: false, retrieved_at: "test", source_language: "test", stale_pages: 0, unverified_removed: [], valid: null }), { status: 200 });
|
|
16
|
-
};
|
|
17
|
-
try {
|
|
18
|
-
const client = new Client("https://example.test");
|
|
19
|
-
const result = await client.getProfile({ company_name: null, domain: null, language: null, max_age_seconds: null });
|
|
20
|
-
assert.ok(result !== undefined);
|
|
21
|
-
} finally {
|
|
22
|
-
globalThis.fetch = originalFetch;
|
|
23
|
-
}
|
|
24
|
-
});
|
package/test/langchain.test.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies every company-profile 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 { CompanyProfileToolkit } from "../dist/langchain.js";
|
|
9
|
-
|
|
10
|
-
test("getProfile tool invoke", async () => {
|
|
11
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ age_seconds: 0, 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: [] }, from_cache: false, output_language: "test", pages_from_cache: 0, pages_read: [], passes: 0, profile: null, remaining_issues: [], resolved_from_name: false, retrieved_at: "test", source_language: "test", stale_pages: 0, unverified_removed: [], valid: null }), { status: 200 });
|
|
12
|
-
const toolkit = new CompanyProfileToolkit(new Client("https://example.test"));
|
|
13
|
-
const t = toolkit.getTools().find((x) => x.name === "getProfile");
|
|
14
|
-
const result = await t.invoke({ company_name: "test", domain: "test", language: "test", max_age_seconds: 0 });
|
|
15
|
-
assert.ok(result !== undefined);
|
|
16
|
-
});
|
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
|
-
}
|