@trustrails/sdk 0.4.6 → 0.4.8

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 CHANGED
@@ -67,7 +67,7 @@ Search for products. Returns summary data (title, price, availability, category)
67
67
  - `options.category?: string` - Filter by product category (e.g., 'Laptops', 'Headphones')
68
68
  - `options.minPrice?: number` - Minimum price filter in GBP
69
69
  - `options.maxPrice?: number` - Maximum price filter in GBP
70
- - `options.lite?: boolean` - Return trimmed product objects with only essential fields (reduces payload by ~80%)
70
+ - `options.lite?: boolean` - Return trimmed product objects with only essential fields including `offer_count` (reduces payload by ~80%)
71
71
  - `options.limit?: number` - Maximum number of results (default: 50, max: 100)
72
72
  - `options.sort?: string` - Sort order: `'relevance'` (default), `'price_asc'` (cheapest first), `'price_desc'` (most expensive first)
73
73
 
@@ -96,7 +96,7 @@ const results = await trustrails.search({
96
96
 
97
97
  ##### `product(id: string): Promise<Product>`
98
98
 
99
- Get full details for a single product. Returns complete technical specifications, full description, stock level, delivery time, and retailer source. Use this after `search()` to get detailed specs for comparison or recommendations.
99
+ Get full details for a single product. Returns complete technical specifications including `specs.description` (full prose spec text with processor, RAM, storage, display, etc.), stock level, delivery time, and all retailer offers with per-retailer pricing. Accepts canonical product IDs or original retailer offer IDs. Use this after `search()` to get detailed specs for comparison or recommendations.
100
100
 
101
101
  **Parameters:**
102
102
  - `id: string` - The product ID
@@ -115,8 +115,8 @@ const product = await trustrails.product('prod_123');
115
115
  ```typescript
116
116
  interface Product {
117
117
  id: string;
118
+ ean?: string;
118
119
  title: string;
119
- description?: string;
120
120
  brand?: string;
121
121
  price: number;
122
122
  currency: string;
@@ -127,13 +127,31 @@ interface Product {
127
127
  category: string;
128
128
  product_type: "product" | "accessory";
129
129
  specs: {
130
- [key: string]: any;
130
+ description?: string; // Full prose spec text — always check this for technical details
131
+ model_number?: string;
132
+ dimensions?: string;
131
133
  };
132
134
  provenance: {
133
135
  source: string;
134
136
  last_updated: string;
135
137
  };
136
138
  purchase_url: string;
139
+ offer_count?: number; // number of retailer offers (when >1, call product() to compare prices)
140
+ offers?: Offer[]; // per-retailer offers sorted by price (returned by product())
141
+ }
142
+
143
+ interface Offer {
144
+ id: string;
145
+ source: string;
146
+ title: string;
147
+ price: number;
148
+ currency: string;
149
+ availability: "in_stock" | "low_stock" | "out_of_stock";
150
+ stock: number;
151
+ delivery_time: string;
152
+ purchase_url: string;
153
+ image_url?: string;
154
+ last_updated: string;
137
155
  }
138
156
  ```
139
157
 
package/dist/index.d.mts CHANGED
@@ -2,13 +2,29 @@
2
2
  * Product availability status
3
3
  */
4
4
  type Availability = "in_stock" | "low_stock" | "out_of_stock";
5
+ /**
6
+ * Per-retailer offer for a product
7
+ */
8
+ interface Offer {
9
+ id: string;
10
+ source: string;
11
+ title: string;
12
+ price: number;
13
+ currency: string;
14
+ availability: Availability;
15
+ stock: number;
16
+ delivery_time: string;
17
+ purchase_url: string;
18
+ image_url?: string;
19
+ last_updated: string;
20
+ }
5
21
  /**
6
22
  * Product information returned by TrustRails API
7
23
  */
8
24
  interface Product {
9
25
  id: string;
26
+ ean?: string;
10
27
  title: string;
11
- description?: string;
12
28
  brand?: string;
13
29
  price: number;
14
30
  currency: string;
@@ -19,16 +35,19 @@ interface Product {
19
35
  category: string;
20
36
  product_type: 'product' | 'accessory';
21
37
  specs: {
22
- raw_category?: string;
38
+ description?: string;
23
39
  model_number?: string;
24
40
  dimensions?: string;
25
- [key: string]: any;
26
41
  };
27
42
  provenance: {
28
43
  source: string;
29
44
  last_updated: string;
30
45
  };
31
46
  purchase_url: string;
47
+ /** Number of retailer offers available for this product */
48
+ offer_count?: number;
49
+ /** Per-retailer offers sorted by price (full mode / getProduct only) */
50
+ offers?: Offer[];
32
51
  }
33
52
  /**
34
53
  * Options for searching products
package/dist/index.d.ts CHANGED
@@ -2,13 +2,29 @@
2
2
  * Product availability status
3
3
  */
4
4
  type Availability = "in_stock" | "low_stock" | "out_of_stock";
5
+ /**
6
+ * Per-retailer offer for a product
7
+ */
8
+ interface Offer {
9
+ id: string;
10
+ source: string;
11
+ title: string;
12
+ price: number;
13
+ currency: string;
14
+ availability: Availability;
15
+ stock: number;
16
+ delivery_time: string;
17
+ purchase_url: string;
18
+ image_url?: string;
19
+ last_updated: string;
20
+ }
5
21
  /**
6
22
  * Product information returned by TrustRails API
7
23
  */
8
24
  interface Product {
9
25
  id: string;
26
+ ean?: string;
10
27
  title: string;
11
- description?: string;
12
28
  brand?: string;
13
29
  price: number;
14
30
  currency: string;
@@ -19,16 +35,19 @@ interface Product {
19
35
  category: string;
20
36
  product_type: 'product' | 'accessory';
21
37
  specs: {
22
- raw_category?: string;
38
+ description?: string;
23
39
  model_number?: string;
24
40
  dimensions?: string;
25
- [key: string]: any;
26
41
  };
27
42
  provenance: {
28
43
  source: string;
29
44
  last_updated: string;
30
45
  };
31
46
  purchase_url: string;
47
+ /** Number of retailer offers available for this product */
48
+ offer_count?: number;
49
+ /** Per-retailer offers sorted by price (full mode / getProduct only) */
50
+ offers?: Offer[];
32
51
  }
33
52
  /**
34
53
  * Options for searching products
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustrails/sdk",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "description": "Official TypeScript SDK for TrustRails API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",