ucpregistry 0.1.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.
- package/README.md +132 -0
- package/dist/index.d.mts +216 -0
- package/dist/index.d.ts +216 -0
- package/dist/index.js +176 -0
- package/dist/index.mjs +150 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# ucpregistry
|
|
2
|
+
|
|
3
|
+
Official SDK for the [UCP Registry](https://ucpregistry.com) API. Discover UCP-enabled merchants, search products across stores, and manage registry entities.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install ucpregistry
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { UCPRegistry } from 'ucpregistry';
|
|
15
|
+
|
|
16
|
+
const registry = new UCPRegistry();
|
|
17
|
+
|
|
18
|
+
// Discover merchants
|
|
19
|
+
const merchants = await registry.discover({ category: 'Health & Beauty' });
|
|
20
|
+
|
|
21
|
+
// Get a specific merchant
|
|
22
|
+
const merchant = await registry.getMerchant('allbirds.com');
|
|
23
|
+
console.log(merchant.capabilities.checkout); // true
|
|
24
|
+
console.log(merchant.transports); // ['mcp', 'embedded']
|
|
25
|
+
|
|
26
|
+
// Search products across all merchants
|
|
27
|
+
const products = await registry.searchProducts({
|
|
28
|
+
query: 'running shoes',
|
|
29
|
+
sort: 'price_asc',
|
|
30
|
+
limit: 5,
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Authentication
|
|
35
|
+
|
|
36
|
+
Free tier endpoints (discover, search) work without authentication. For push API and entity management, pass your API token:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const registry = new UCPRegistry({
|
|
40
|
+
apiKey: 'ucpr_...',
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Get your token at [ucpregistry.com/tokens](https://ucpregistry.com/tokens).
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
### `discover(options?)`
|
|
49
|
+
|
|
50
|
+
Find UCP-enabled merchants.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const merchants = await registry.discover({
|
|
54
|
+
search: 'skincare', // keyword search
|
|
55
|
+
platform: 'shopify', // shopify, woocommerce, bigcommerce, etc.
|
|
56
|
+
category: 'Health & Beauty', // Google Product Taxonomy category
|
|
57
|
+
has_checkout: true, // only merchants with checkout
|
|
58
|
+
sort: 'ucp_score', // ucp_score | response_time | domain
|
|
59
|
+
limit: 20, // max results
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### `getMerchant(domain)`
|
|
64
|
+
|
|
65
|
+
Get full details for a merchant.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const m = await registry.getMerchant('imageskincare.com');
|
|
69
|
+
// m.capabilities, m.transports, m.sample_products, m.benchmark, etc.
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### `searchProducts(options?)`
|
|
73
|
+
|
|
74
|
+
Search products across all merchants.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
const products = await registry.searchProducts({
|
|
78
|
+
query: 'serum',
|
|
79
|
+
category: 'Health & Beauty',
|
|
80
|
+
min_price: 20,
|
|
81
|
+
max_price: 100,
|
|
82
|
+
sort: 'price_asc',
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### `push(type, slug, options)` (requires token)
|
|
87
|
+
|
|
88
|
+
Push a manifest version.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
const version = await registry.push('merchants', 'mystore.com', {
|
|
92
|
+
manifest: { version: '1.0', capabilities: ['checkout'] },
|
|
93
|
+
commit_message: 'Initial push',
|
|
94
|
+
});
|
|
95
|
+
// version.version → '1.0.0'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### `versions(type, slug)` (requires token)
|
|
99
|
+
|
|
100
|
+
List version history.
|
|
101
|
+
|
|
102
|
+
### `diff(type, slug, v1, v2)` (requires token)
|
|
103
|
+
|
|
104
|
+
Diff two versions.
|
|
105
|
+
|
|
106
|
+
## MCP Server
|
|
107
|
+
|
|
108
|
+
UCP Registry is also available as an MCP server. Add it to your agent:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"mcpServers": {
|
|
113
|
+
"ucpregistry": {
|
|
114
|
+
"url": "https://ucpregistry.com/mcp"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Tools: `discover-merchants`, `get-merchant`, `search-products`.
|
|
121
|
+
|
|
122
|
+
## Types
|
|
123
|
+
|
|
124
|
+
All types are exported:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import type { Merchant, ProductResult, MerchantCapabilities } from 'ucpregistry';
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/** UCP merchant status */
|
|
2
|
+
type MerchantStatus = 'verified' | 'pending' | 'not_detected' | 'invalid' | 'blocked' | 'unreachable';
|
|
3
|
+
/** Merchant capabilities */
|
|
4
|
+
interface MerchantCapabilities {
|
|
5
|
+
checkout: boolean;
|
|
6
|
+
identity_linking: boolean;
|
|
7
|
+
cart_management: boolean;
|
|
8
|
+
order: boolean;
|
|
9
|
+
payment_token: boolean;
|
|
10
|
+
count: number;
|
|
11
|
+
raw?: string[];
|
|
12
|
+
}
|
|
13
|
+
/** Benchmark grade and score */
|
|
14
|
+
interface MerchantBenchmark {
|
|
15
|
+
grade: string;
|
|
16
|
+
score: number;
|
|
17
|
+
}
|
|
18
|
+
/** Sample product from a merchant's catalog */
|
|
19
|
+
interface SampleProduct {
|
|
20
|
+
title: string;
|
|
21
|
+
price: number | null;
|
|
22
|
+
currency: string;
|
|
23
|
+
url: string | null;
|
|
24
|
+
image_url: string | null;
|
|
25
|
+
product_type: string | null;
|
|
26
|
+
}
|
|
27
|
+
/** Merchant entity from the registry */
|
|
28
|
+
interface Merchant {
|
|
29
|
+
domain: string;
|
|
30
|
+
status: MerchantStatus;
|
|
31
|
+
registry_id?: string;
|
|
32
|
+
ucp_score: number | null;
|
|
33
|
+
platform: string | null;
|
|
34
|
+
category: string | null;
|
|
35
|
+
description: string | null;
|
|
36
|
+
extended_description?: string | null;
|
|
37
|
+
capabilities: MerchantCapabilities;
|
|
38
|
+
transports: string[];
|
|
39
|
+
response_time_ms: number | null;
|
|
40
|
+
ucp_endpoint: string | null;
|
|
41
|
+
last_checked_at?: string | null;
|
|
42
|
+
benchmark?: MerchantBenchmark | null;
|
|
43
|
+
sample_products?: SampleProduct[];
|
|
44
|
+
plugins?: string[];
|
|
45
|
+
extensions?: string[];
|
|
46
|
+
registry_url: string;
|
|
47
|
+
}
|
|
48
|
+
/** Product search result */
|
|
49
|
+
interface ProductResult {
|
|
50
|
+
title: string;
|
|
51
|
+
price: number | null;
|
|
52
|
+
currency: string;
|
|
53
|
+
url: string | null;
|
|
54
|
+
image_url: string | null;
|
|
55
|
+
product_type: string | null;
|
|
56
|
+
merchant: string;
|
|
57
|
+
category: string | null;
|
|
58
|
+
platform: string | null;
|
|
59
|
+
}
|
|
60
|
+
/** Discovery query options */
|
|
61
|
+
interface DiscoverOptions {
|
|
62
|
+
search?: string;
|
|
63
|
+
platform?: string;
|
|
64
|
+
category?: string;
|
|
65
|
+
has_checkout?: boolean;
|
|
66
|
+
sort?: 'ucp_score' | 'response_time' | 'domain';
|
|
67
|
+
limit?: number;
|
|
68
|
+
}
|
|
69
|
+
/** Product search options */
|
|
70
|
+
interface SearchProductsOptions {
|
|
71
|
+
query?: string;
|
|
72
|
+
category?: string;
|
|
73
|
+
domain?: string;
|
|
74
|
+
min_price?: number;
|
|
75
|
+
max_price?: number;
|
|
76
|
+
sort?: 'relevance' | 'price_asc' | 'price_desc';
|
|
77
|
+
limit?: number;
|
|
78
|
+
}
|
|
79
|
+
/** Discovery response */
|
|
80
|
+
interface DiscoverResponse {
|
|
81
|
+
data: Merchant[];
|
|
82
|
+
meta: {
|
|
83
|
+
total: number;
|
|
84
|
+
returned: number;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Product search response */
|
|
88
|
+
interface ProductSearchResponse {
|
|
89
|
+
data: ProductResult[];
|
|
90
|
+
meta: {
|
|
91
|
+
total: number;
|
|
92
|
+
returned: number;
|
|
93
|
+
merchants: number;
|
|
94
|
+
query: string | null;
|
|
95
|
+
sort: string;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** Entity version (from push API) */
|
|
99
|
+
interface EntityVersion {
|
|
100
|
+
version: string;
|
|
101
|
+
commit_sha: string;
|
|
102
|
+
created_at: string;
|
|
103
|
+
diff_summary: string;
|
|
104
|
+
}
|
|
105
|
+
/** Push manifest options */
|
|
106
|
+
interface PushOptions {
|
|
107
|
+
manifest: Record<string, unknown>;
|
|
108
|
+
commit_message?: string;
|
|
109
|
+
}
|
|
110
|
+
/** SDK configuration */
|
|
111
|
+
interface UCPRegistryConfig {
|
|
112
|
+
baseUrl?: string;
|
|
113
|
+
apiKey?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* UCP Registry SDK
|
|
118
|
+
*
|
|
119
|
+
* Official client for the UCP Registry API. Discover UCP merchants,
|
|
120
|
+
* search products across stores, and manage registry entities.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* import { UCPRegistry } from 'ucpregistry';
|
|
125
|
+
*
|
|
126
|
+
* const registry = new UCPRegistry();
|
|
127
|
+
* const merchants = await registry.discover({ category: 'Health & Beauty' });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare class UCPRegistry {
|
|
131
|
+
private baseUrl;
|
|
132
|
+
private apiKey?;
|
|
133
|
+
constructor(config?: UCPRegistryConfig);
|
|
134
|
+
/**
|
|
135
|
+
* Discover UCP-enabled merchants.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* // All verified merchants
|
|
140
|
+
* const all = await registry.discover();
|
|
141
|
+
*
|
|
142
|
+
* // Shopify merchants with checkout
|
|
143
|
+
* const shopify = await registry.discover({
|
|
144
|
+
* platform: 'shopify',
|
|
145
|
+
* has_checkout: true,
|
|
146
|
+
* sort: 'ucp_score',
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* // Search by keyword
|
|
150
|
+
* const skincare = await registry.discover({ search: 'skincare' });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
discover(options?: DiscoverOptions): Promise<Merchant[]>;
|
|
154
|
+
/**
|
|
155
|
+
* Get detailed information about a specific merchant.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const merchant = await registry.getMerchant('allbirds.com');
|
|
160
|
+
* console.log(merchant.capabilities.checkout); // true
|
|
161
|
+
* console.log(merchant.transports); // ['mcp', 'embedded']
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
getMerchant(domain: string): Promise<Merchant>;
|
|
165
|
+
/**
|
|
166
|
+
* Search products across all UCP merchants.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const products = await registry.searchProducts({
|
|
171
|
+
* query: 'running shoes',
|
|
172
|
+
* sort: 'price_asc',
|
|
173
|
+
* limit: 5,
|
|
174
|
+
* });
|
|
175
|
+
*
|
|
176
|
+
* for (const product of products) {
|
|
177
|
+
* console.log(`${product.title} - $${product.price} at ${product.merchant}`);
|
|
178
|
+
* }
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
searchProducts(options?: SearchProductsOptions): Promise<ProductResult[]>;
|
|
182
|
+
/**
|
|
183
|
+
* Push a manifest version to an entity (requires API token).
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const registry = new UCPRegistry({ apiKey: 'ucpr_...' });
|
|
188
|
+
*
|
|
189
|
+
* const version = await registry.push('merchants', 'mystore.com', {
|
|
190
|
+
* manifest: { version: '1.0', capabilities: ['checkout'] },
|
|
191
|
+
* commit_message: 'Initial push',
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* console.log(version.version); // '1.0.0'
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
push(type: string, slug: string, options: PushOptions): Promise<EntityVersion>;
|
|
198
|
+
/**
|
|
199
|
+
* List version history for an entity (requires API token).
|
|
200
|
+
*/
|
|
201
|
+
versions(type: string, slug: string): Promise<{
|
|
202
|
+
data: EntityVersion[];
|
|
203
|
+
meta: {
|
|
204
|
+
total: number;
|
|
205
|
+
};
|
|
206
|
+
}>;
|
|
207
|
+
/**
|
|
208
|
+
* Diff two versions of an entity (requires API token).
|
|
209
|
+
*/
|
|
210
|
+
diff(type: string, slug: string, v1: string, v2: string): Promise<Record<string, unknown>>;
|
|
211
|
+
private fetch;
|
|
212
|
+
}
|
|
213
|
+
/** Create a new UCPRegistry client */
|
|
214
|
+
declare function createClient(config?: UCPRegistryConfig): UCPRegistry;
|
|
215
|
+
|
|
216
|
+
export { type DiscoverOptions, type DiscoverResponse, type EntityVersion, type Merchant, type MerchantBenchmark, type MerchantCapabilities, type MerchantStatus, type ProductResult, type ProductSearchResponse, type PushOptions, type SampleProduct, type SearchProductsOptions, UCPRegistry, type UCPRegistryConfig, createClient };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/** UCP merchant status */
|
|
2
|
+
type MerchantStatus = 'verified' | 'pending' | 'not_detected' | 'invalid' | 'blocked' | 'unreachable';
|
|
3
|
+
/** Merchant capabilities */
|
|
4
|
+
interface MerchantCapabilities {
|
|
5
|
+
checkout: boolean;
|
|
6
|
+
identity_linking: boolean;
|
|
7
|
+
cart_management: boolean;
|
|
8
|
+
order: boolean;
|
|
9
|
+
payment_token: boolean;
|
|
10
|
+
count: number;
|
|
11
|
+
raw?: string[];
|
|
12
|
+
}
|
|
13
|
+
/** Benchmark grade and score */
|
|
14
|
+
interface MerchantBenchmark {
|
|
15
|
+
grade: string;
|
|
16
|
+
score: number;
|
|
17
|
+
}
|
|
18
|
+
/** Sample product from a merchant's catalog */
|
|
19
|
+
interface SampleProduct {
|
|
20
|
+
title: string;
|
|
21
|
+
price: number | null;
|
|
22
|
+
currency: string;
|
|
23
|
+
url: string | null;
|
|
24
|
+
image_url: string | null;
|
|
25
|
+
product_type: string | null;
|
|
26
|
+
}
|
|
27
|
+
/** Merchant entity from the registry */
|
|
28
|
+
interface Merchant {
|
|
29
|
+
domain: string;
|
|
30
|
+
status: MerchantStatus;
|
|
31
|
+
registry_id?: string;
|
|
32
|
+
ucp_score: number | null;
|
|
33
|
+
platform: string | null;
|
|
34
|
+
category: string | null;
|
|
35
|
+
description: string | null;
|
|
36
|
+
extended_description?: string | null;
|
|
37
|
+
capabilities: MerchantCapabilities;
|
|
38
|
+
transports: string[];
|
|
39
|
+
response_time_ms: number | null;
|
|
40
|
+
ucp_endpoint: string | null;
|
|
41
|
+
last_checked_at?: string | null;
|
|
42
|
+
benchmark?: MerchantBenchmark | null;
|
|
43
|
+
sample_products?: SampleProduct[];
|
|
44
|
+
plugins?: string[];
|
|
45
|
+
extensions?: string[];
|
|
46
|
+
registry_url: string;
|
|
47
|
+
}
|
|
48
|
+
/** Product search result */
|
|
49
|
+
interface ProductResult {
|
|
50
|
+
title: string;
|
|
51
|
+
price: number | null;
|
|
52
|
+
currency: string;
|
|
53
|
+
url: string | null;
|
|
54
|
+
image_url: string | null;
|
|
55
|
+
product_type: string | null;
|
|
56
|
+
merchant: string;
|
|
57
|
+
category: string | null;
|
|
58
|
+
platform: string | null;
|
|
59
|
+
}
|
|
60
|
+
/** Discovery query options */
|
|
61
|
+
interface DiscoverOptions {
|
|
62
|
+
search?: string;
|
|
63
|
+
platform?: string;
|
|
64
|
+
category?: string;
|
|
65
|
+
has_checkout?: boolean;
|
|
66
|
+
sort?: 'ucp_score' | 'response_time' | 'domain';
|
|
67
|
+
limit?: number;
|
|
68
|
+
}
|
|
69
|
+
/** Product search options */
|
|
70
|
+
interface SearchProductsOptions {
|
|
71
|
+
query?: string;
|
|
72
|
+
category?: string;
|
|
73
|
+
domain?: string;
|
|
74
|
+
min_price?: number;
|
|
75
|
+
max_price?: number;
|
|
76
|
+
sort?: 'relevance' | 'price_asc' | 'price_desc';
|
|
77
|
+
limit?: number;
|
|
78
|
+
}
|
|
79
|
+
/** Discovery response */
|
|
80
|
+
interface DiscoverResponse {
|
|
81
|
+
data: Merchant[];
|
|
82
|
+
meta: {
|
|
83
|
+
total: number;
|
|
84
|
+
returned: number;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Product search response */
|
|
88
|
+
interface ProductSearchResponse {
|
|
89
|
+
data: ProductResult[];
|
|
90
|
+
meta: {
|
|
91
|
+
total: number;
|
|
92
|
+
returned: number;
|
|
93
|
+
merchants: number;
|
|
94
|
+
query: string | null;
|
|
95
|
+
sort: string;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** Entity version (from push API) */
|
|
99
|
+
interface EntityVersion {
|
|
100
|
+
version: string;
|
|
101
|
+
commit_sha: string;
|
|
102
|
+
created_at: string;
|
|
103
|
+
diff_summary: string;
|
|
104
|
+
}
|
|
105
|
+
/** Push manifest options */
|
|
106
|
+
interface PushOptions {
|
|
107
|
+
manifest: Record<string, unknown>;
|
|
108
|
+
commit_message?: string;
|
|
109
|
+
}
|
|
110
|
+
/** SDK configuration */
|
|
111
|
+
interface UCPRegistryConfig {
|
|
112
|
+
baseUrl?: string;
|
|
113
|
+
apiKey?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* UCP Registry SDK
|
|
118
|
+
*
|
|
119
|
+
* Official client for the UCP Registry API. Discover UCP merchants,
|
|
120
|
+
* search products across stores, and manage registry entities.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* import { UCPRegistry } from 'ucpregistry';
|
|
125
|
+
*
|
|
126
|
+
* const registry = new UCPRegistry();
|
|
127
|
+
* const merchants = await registry.discover({ category: 'Health & Beauty' });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare class UCPRegistry {
|
|
131
|
+
private baseUrl;
|
|
132
|
+
private apiKey?;
|
|
133
|
+
constructor(config?: UCPRegistryConfig);
|
|
134
|
+
/**
|
|
135
|
+
* Discover UCP-enabled merchants.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* // All verified merchants
|
|
140
|
+
* const all = await registry.discover();
|
|
141
|
+
*
|
|
142
|
+
* // Shopify merchants with checkout
|
|
143
|
+
* const shopify = await registry.discover({
|
|
144
|
+
* platform: 'shopify',
|
|
145
|
+
* has_checkout: true,
|
|
146
|
+
* sort: 'ucp_score',
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* // Search by keyword
|
|
150
|
+
* const skincare = await registry.discover({ search: 'skincare' });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
discover(options?: DiscoverOptions): Promise<Merchant[]>;
|
|
154
|
+
/**
|
|
155
|
+
* Get detailed information about a specific merchant.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const merchant = await registry.getMerchant('allbirds.com');
|
|
160
|
+
* console.log(merchant.capabilities.checkout); // true
|
|
161
|
+
* console.log(merchant.transports); // ['mcp', 'embedded']
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
getMerchant(domain: string): Promise<Merchant>;
|
|
165
|
+
/**
|
|
166
|
+
* Search products across all UCP merchants.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const products = await registry.searchProducts({
|
|
171
|
+
* query: 'running shoes',
|
|
172
|
+
* sort: 'price_asc',
|
|
173
|
+
* limit: 5,
|
|
174
|
+
* });
|
|
175
|
+
*
|
|
176
|
+
* for (const product of products) {
|
|
177
|
+
* console.log(`${product.title} - $${product.price} at ${product.merchant}`);
|
|
178
|
+
* }
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
searchProducts(options?: SearchProductsOptions): Promise<ProductResult[]>;
|
|
182
|
+
/**
|
|
183
|
+
* Push a manifest version to an entity (requires API token).
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const registry = new UCPRegistry({ apiKey: 'ucpr_...' });
|
|
188
|
+
*
|
|
189
|
+
* const version = await registry.push('merchants', 'mystore.com', {
|
|
190
|
+
* manifest: { version: '1.0', capabilities: ['checkout'] },
|
|
191
|
+
* commit_message: 'Initial push',
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* console.log(version.version); // '1.0.0'
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
push(type: string, slug: string, options: PushOptions): Promise<EntityVersion>;
|
|
198
|
+
/**
|
|
199
|
+
* List version history for an entity (requires API token).
|
|
200
|
+
*/
|
|
201
|
+
versions(type: string, slug: string): Promise<{
|
|
202
|
+
data: EntityVersion[];
|
|
203
|
+
meta: {
|
|
204
|
+
total: number;
|
|
205
|
+
};
|
|
206
|
+
}>;
|
|
207
|
+
/**
|
|
208
|
+
* Diff two versions of an entity (requires API token).
|
|
209
|
+
*/
|
|
210
|
+
diff(type: string, slug: string, v1: string, v2: string): Promise<Record<string, unknown>>;
|
|
211
|
+
private fetch;
|
|
212
|
+
}
|
|
213
|
+
/** Create a new UCPRegistry client */
|
|
214
|
+
declare function createClient(config?: UCPRegistryConfig): UCPRegistry;
|
|
215
|
+
|
|
216
|
+
export { type DiscoverOptions, type DiscoverResponse, type EntityVersion, type Merchant, type MerchantBenchmark, type MerchantCapabilities, type MerchantStatus, type ProductResult, type ProductSearchResponse, type PushOptions, type SampleProduct, type SearchProductsOptions, UCPRegistry, type UCPRegistryConfig, createClient };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
UCPRegistry: () => UCPRegistry,
|
|
24
|
+
createClient: () => createClient
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var DEFAULT_BASE_URL = "https://ucpregistry.com";
|
|
28
|
+
var UCPRegistry = class {
|
|
29
|
+
constructor(config = {}) {
|
|
30
|
+
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
31
|
+
this.apiKey = config.apiKey;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Discover UCP-enabled merchants.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // All verified merchants
|
|
39
|
+
* const all = await registry.discover();
|
|
40
|
+
*
|
|
41
|
+
* // Shopify merchants with checkout
|
|
42
|
+
* const shopify = await registry.discover({
|
|
43
|
+
* platform: 'shopify',
|
|
44
|
+
* has_checkout: true,
|
|
45
|
+
* sort: 'ucp_score',
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // Search by keyword
|
|
49
|
+
* const skincare = await registry.discover({ search: 'skincare' });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
async discover(options = {}) {
|
|
53
|
+
const params = new URLSearchParams();
|
|
54
|
+
if (options.search) params.set("search", options.search);
|
|
55
|
+
if (options.platform) params.set("platform", options.platform);
|
|
56
|
+
if (options.category) params.set("category", options.category);
|
|
57
|
+
if (options.sort) params.set("sort", options.sort);
|
|
58
|
+
if (options.limit) params.set("per_page", String(options.limit));
|
|
59
|
+
const url = `${this.baseUrl}/api/v1/merchants?${params}`;
|
|
60
|
+
const res = await this.fetch(url);
|
|
61
|
+
const data = await res.json();
|
|
62
|
+
return data.data;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get detailed information about a specific merchant.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const merchant = await registry.getMerchant('allbirds.com');
|
|
70
|
+
* console.log(merchant.capabilities.checkout); // true
|
|
71
|
+
* console.log(merchant.transports); // ['mcp', 'embedded']
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
async getMerchant(domain) {
|
|
75
|
+
const url = `${this.baseUrl}/api/v1/merchants/${encodeURIComponent(domain)}`;
|
|
76
|
+
const res = await this.fetch(url);
|
|
77
|
+
if (!res.ok) {
|
|
78
|
+
throw new Error(`Merchant '${domain}' not found (HTTP ${res.status})`);
|
|
79
|
+
}
|
|
80
|
+
const data = await res.json();
|
|
81
|
+
return data.data;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Search products across all UCP merchants.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const products = await registry.searchProducts({
|
|
89
|
+
* query: 'running shoes',
|
|
90
|
+
* sort: 'price_asc',
|
|
91
|
+
* limit: 5,
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* for (const product of products) {
|
|
95
|
+
* console.log(`${product.title} - $${product.price} at ${product.merchant}`);
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
async searchProducts(options = {}) {
|
|
100
|
+
const params = new URLSearchParams();
|
|
101
|
+
if (options.query) params.set("q", options.query);
|
|
102
|
+
if (options.category) params.set("category", options.category);
|
|
103
|
+
if (options.domain) params.set("domain", options.domain);
|
|
104
|
+
if (options.min_price) params.set("min_price", String(options.min_price));
|
|
105
|
+
if (options.max_price) params.set("max_price", String(options.max_price));
|
|
106
|
+
if (options.sort) params.set("sort", options.sort);
|
|
107
|
+
if (options.limit) params.set("limit", String(options.limit));
|
|
108
|
+
const url = `${this.baseUrl}/api/v1/products/search?${params}`;
|
|
109
|
+
const res = await this.fetch(url);
|
|
110
|
+
const data = await res.json();
|
|
111
|
+
return data.data;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Push a manifest version to an entity (requires API token).
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const registry = new UCPRegistry({ apiKey: 'ucpr_...' });
|
|
119
|
+
*
|
|
120
|
+
* const version = await registry.push('merchants', 'mystore.com', {
|
|
121
|
+
* manifest: { version: '1.0', capabilities: ['checkout'] },
|
|
122
|
+
* commit_message: 'Initial push',
|
|
123
|
+
* });
|
|
124
|
+
*
|
|
125
|
+
* console.log(version.version); // '1.0.0'
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
async push(type, slug, options) {
|
|
129
|
+
const url = `${this.baseUrl}/api/v1/entities/${type}/${slug}/push`;
|
|
130
|
+
const res = await this.fetch(url, {
|
|
131
|
+
method: "POST",
|
|
132
|
+
headers: { "Content-Type": "application/json" },
|
|
133
|
+
body: JSON.stringify(options)
|
|
134
|
+
});
|
|
135
|
+
if (!res.ok) {
|
|
136
|
+
const err = await res.json().catch(() => ({}));
|
|
137
|
+
throw new Error(err.error ?? `Push failed (HTTP ${res.status})`);
|
|
138
|
+
}
|
|
139
|
+
return await res.json();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* List version history for an entity (requires API token).
|
|
143
|
+
*/
|
|
144
|
+
async versions(type, slug) {
|
|
145
|
+
const url = `${this.baseUrl}/api/v1/entities/${type}/${slug}/versions`;
|
|
146
|
+
const res = await this.fetch(url);
|
|
147
|
+
return await res.json();
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Diff two versions of an entity (requires API token).
|
|
151
|
+
*/
|
|
152
|
+
async diff(type, slug, v1, v2) {
|
|
153
|
+
const url = `${this.baseUrl}/api/v1/entities/${type}/${slug}/diff/${v1}/${v2}`;
|
|
154
|
+
const res = await this.fetch(url);
|
|
155
|
+
return await res.json();
|
|
156
|
+
}
|
|
157
|
+
async fetch(url, init = {}) {
|
|
158
|
+
const headers = {
|
|
159
|
+
"Accept": "application/json",
|
|
160
|
+
"User-Agent": "ucpregistry-sdk/0.1.0",
|
|
161
|
+
...init.headers ?? {}
|
|
162
|
+
};
|
|
163
|
+
if (this.apiKey) {
|
|
164
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
165
|
+
}
|
|
166
|
+
return globalThis.fetch(url, { ...init, headers });
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
function createClient(config) {
|
|
170
|
+
return new UCPRegistry(config);
|
|
171
|
+
}
|
|
172
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
173
|
+
0 && (module.exports = {
|
|
174
|
+
UCPRegistry,
|
|
175
|
+
createClient
|
|
176
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var DEFAULT_BASE_URL = "https://ucpregistry.com";
|
|
3
|
+
var UCPRegistry = class {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
6
|
+
this.apiKey = config.apiKey;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Discover UCP-enabled merchants.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // All verified merchants
|
|
14
|
+
* const all = await registry.discover();
|
|
15
|
+
*
|
|
16
|
+
* // Shopify merchants with checkout
|
|
17
|
+
* const shopify = await registry.discover({
|
|
18
|
+
* platform: 'shopify',
|
|
19
|
+
* has_checkout: true,
|
|
20
|
+
* sort: 'ucp_score',
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Search by keyword
|
|
24
|
+
* const skincare = await registry.discover({ search: 'skincare' });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
async discover(options = {}) {
|
|
28
|
+
const params = new URLSearchParams();
|
|
29
|
+
if (options.search) params.set("search", options.search);
|
|
30
|
+
if (options.platform) params.set("platform", options.platform);
|
|
31
|
+
if (options.category) params.set("category", options.category);
|
|
32
|
+
if (options.sort) params.set("sort", options.sort);
|
|
33
|
+
if (options.limit) params.set("per_page", String(options.limit));
|
|
34
|
+
const url = `${this.baseUrl}/api/v1/merchants?${params}`;
|
|
35
|
+
const res = await this.fetch(url);
|
|
36
|
+
const data = await res.json();
|
|
37
|
+
return data.data;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get detailed information about a specific merchant.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const merchant = await registry.getMerchant('allbirds.com');
|
|
45
|
+
* console.log(merchant.capabilities.checkout); // true
|
|
46
|
+
* console.log(merchant.transports); // ['mcp', 'embedded']
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
async getMerchant(domain) {
|
|
50
|
+
const url = `${this.baseUrl}/api/v1/merchants/${encodeURIComponent(domain)}`;
|
|
51
|
+
const res = await this.fetch(url);
|
|
52
|
+
if (!res.ok) {
|
|
53
|
+
throw new Error(`Merchant '${domain}' not found (HTTP ${res.status})`);
|
|
54
|
+
}
|
|
55
|
+
const data = await res.json();
|
|
56
|
+
return data.data;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Search products across all UCP merchants.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const products = await registry.searchProducts({
|
|
64
|
+
* query: 'running shoes',
|
|
65
|
+
* sort: 'price_asc',
|
|
66
|
+
* limit: 5,
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* for (const product of products) {
|
|
70
|
+
* console.log(`${product.title} - $${product.price} at ${product.merchant}`);
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
async searchProducts(options = {}) {
|
|
75
|
+
const params = new URLSearchParams();
|
|
76
|
+
if (options.query) params.set("q", options.query);
|
|
77
|
+
if (options.category) params.set("category", options.category);
|
|
78
|
+
if (options.domain) params.set("domain", options.domain);
|
|
79
|
+
if (options.min_price) params.set("min_price", String(options.min_price));
|
|
80
|
+
if (options.max_price) params.set("max_price", String(options.max_price));
|
|
81
|
+
if (options.sort) params.set("sort", options.sort);
|
|
82
|
+
if (options.limit) params.set("limit", String(options.limit));
|
|
83
|
+
const url = `${this.baseUrl}/api/v1/products/search?${params}`;
|
|
84
|
+
const res = await this.fetch(url);
|
|
85
|
+
const data = await res.json();
|
|
86
|
+
return data.data;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Push a manifest version to an entity (requires API token).
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const registry = new UCPRegistry({ apiKey: 'ucpr_...' });
|
|
94
|
+
*
|
|
95
|
+
* const version = await registry.push('merchants', 'mystore.com', {
|
|
96
|
+
* manifest: { version: '1.0', capabilities: ['checkout'] },
|
|
97
|
+
* commit_message: 'Initial push',
|
|
98
|
+
* });
|
|
99
|
+
*
|
|
100
|
+
* console.log(version.version); // '1.0.0'
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
async push(type, slug, options) {
|
|
104
|
+
const url = `${this.baseUrl}/api/v1/entities/${type}/${slug}/push`;
|
|
105
|
+
const res = await this.fetch(url, {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers: { "Content-Type": "application/json" },
|
|
108
|
+
body: JSON.stringify(options)
|
|
109
|
+
});
|
|
110
|
+
if (!res.ok) {
|
|
111
|
+
const err = await res.json().catch(() => ({}));
|
|
112
|
+
throw new Error(err.error ?? `Push failed (HTTP ${res.status})`);
|
|
113
|
+
}
|
|
114
|
+
return await res.json();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* List version history for an entity (requires API token).
|
|
118
|
+
*/
|
|
119
|
+
async versions(type, slug) {
|
|
120
|
+
const url = `${this.baseUrl}/api/v1/entities/${type}/${slug}/versions`;
|
|
121
|
+
const res = await this.fetch(url);
|
|
122
|
+
return await res.json();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Diff two versions of an entity (requires API token).
|
|
126
|
+
*/
|
|
127
|
+
async diff(type, slug, v1, v2) {
|
|
128
|
+
const url = `${this.baseUrl}/api/v1/entities/${type}/${slug}/diff/${v1}/${v2}`;
|
|
129
|
+
const res = await this.fetch(url);
|
|
130
|
+
return await res.json();
|
|
131
|
+
}
|
|
132
|
+
async fetch(url, init = {}) {
|
|
133
|
+
const headers = {
|
|
134
|
+
"Accept": "application/json",
|
|
135
|
+
"User-Agent": "ucpregistry-sdk/0.1.0",
|
|
136
|
+
...init.headers ?? {}
|
|
137
|
+
};
|
|
138
|
+
if (this.apiKey) {
|
|
139
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
140
|
+
}
|
|
141
|
+
return globalThis.fetch(url, { ...init, headers });
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
function createClient(config) {
|
|
145
|
+
return new UCPRegistry(config);
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
UCPRegistry,
|
|
149
|
+
createClient
|
|
150
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ucpregistry",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official SDK for the UCP Registry API — discover UCP merchants, search products, and manage registry entities.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
21
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"ucp",
|
|
25
|
+
"registry",
|
|
26
|
+
"commerce",
|
|
27
|
+
"merchant",
|
|
28
|
+
"mcp",
|
|
29
|
+
"agent",
|
|
30
|
+
"ai",
|
|
31
|
+
"shopping"
|
|
32
|
+
],
|
|
33
|
+
"author": "UCP Registry",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"homepage": "https://ucpregistry.com",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/ucpregistry/sdk"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"tsup": "^8.0.0",
|
|
42
|
+
"typescript": "^5.0.0"
|
|
43
|
+
}
|
|
44
|
+
}
|