@chat-ads/chatads-sdk 0.1.16 → 0.2.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 -10
- package/dist/client.js +0 -1
- package/dist/models.d.ts +20 -22
- package/dist/models.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,15 +41,7 @@ if (response.data?.offers?.length) {
|
|
|
41
41
|
```ts
|
|
42
42
|
const result = await client.analyzeMessage("Need scheduling ideas", {
|
|
43
43
|
country: "US",
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Image search
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
const result = await client.analyze({
|
|
51
|
-
message: "https://example.com/product-image.jpg",
|
|
52
|
-
input_type: "image_url",
|
|
44
|
+
max_offers: 2,
|
|
53
45
|
});
|
|
54
46
|
```
|
|
55
47
|
|
|
@@ -101,7 +93,8 @@ try {
|
|
|
101
93
|
"offers": [
|
|
102
94
|
{
|
|
103
95
|
"link_text": "CRM tools",
|
|
104
|
-
"url": "https://amazon.com/dp/example?tag=chatads-20"
|
|
96
|
+
"url": "https://www.amazon.com/dp/example?tag=chatads-20",
|
|
97
|
+
"is_branded": true
|
|
105
98
|
}
|
|
106
99
|
],
|
|
107
100
|
"requested": 1,
|
package/dist/client.js
CHANGED
|
@@ -180,7 +180,6 @@ async function parseResponse(response) {
|
|
|
180
180
|
extraction_source: data.extraction_source,
|
|
181
181
|
extraction_debug: data.extraction_debug,
|
|
182
182
|
resolution_debug: data.resolution_debug,
|
|
183
|
-
input_type: data.input_type,
|
|
184
183
|
},
|
|
185
184
|
error: raw.error,
|
|
186
185
|
meta: raw.meta ?? { request_id: "unknown" },
|
package/dist/models.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ExtractionMode = "none" | "
|
|
1
|
+
export type ExtractionMode = "none" | "standard";
|
|
2
2
|
export type ResolutionMode = "none" | "standard";
|
|
3
3
|
/** Top-level response status indicating the outcome of the request */
|
|
4
4
|
export type ResponseStatus = "filled" | "partial_fill" | "no_offer" | "no_brand_found" | "message_too_short" | "message_too_long" | "country_not_allowed" | "blocked_keyword" | "language_not_allowed" | "ip_country_not_allowed";
|
|
@@ -10,14 +10,14 @@ export type FunctionItemOptionalFields = {
|
|
|
10
10
|
ip?: string;
|
|
11
11
|
/** ISO 3166-1 alpha-2 country code for geo-targeting */
|
|
12
12
|
country?: string;
|
|
13
|
-
/**
|
|
14
|
-
input_type?: "text" | "image_url" | "image_file";
|
|
15
|
-
/** Extraction control: "none" (bring your own product), "fast" (NLP only), "standard" (default). Default: "standard" */
|
|
13
|
+
/** Extraction control: "none" (bring your own product), "standard" (default). Default: "standard" */
|
|
16
14
|
extraction_mode?: ExtractionMode;
|
|
17
15
|
/** Resolution control: "none" (extraction only), "standard" (default). Default: "standard" */
|
|
18
16
|
resolution_mode?: ResolutionMode;
|
|
19
|
-
/**
|
|
20
|
-
|
|
17
|
+
/** Max distinct keyterms with offers extracted (1-3). Default: 1. */
|
|
18
|
+
max_offers?: number;
|
|
19
|
+
/** Max resolved products per offer carousel (1-3). Default: 1. */
|
|
20
|
+
max_products_per_offer?: number;
|
|
21
21
|
/** Arbitrary JSON metadata passed through to the response (max 10KB, must be a JSON object) */
|
|
22
22
|
metadata?: Record<string, unknown>;
|
|
23
23
|
};
|
|
@@ -31,18 +31,22 @@ export type FunctionItemPayload = {
|
|
|
31
31
|
export interface Product {
|
|
32
32
|
/** Product title from search result */
|
|
33
33
|
title?: string;
|
|
34
|
-
/**
|
|
34
|
+
/** Raw product rating on the catalog's scale (e.g., 4.5 on a 5-star catalog) */
|
|
35
35
|
stars?: number;
|
|
36
36
|
/** Number of product reviews */
|
|
37
37
|
reviews?: number;
|
|
38
38
|
/** Product image URL */
|
|
39
39
|
image?: string;
|
|
40
|
-
/** Product price in USD
|
|
40
|
+
/** Product price in USD (canonical). Only present when available from search results. */
|
|
41
41
|
price?: number;
|
|
42
|
+
/** ISO 4217 currency code for `price`. Always "USD" today. */
|
|
43
|
+
currency?: string;
|
|
44
|
+
/** Raw catalog price in the source catalog's currency. Only populated for non-USD catalogs. */
|
|
45
|
+
price_local?: number;
|
|
46
|
+
/** ISO 4217 currency code for `price_local`. Only populated for non-USD catalogs. */
|
|
47
|
+
currency_local?: string;
|
|
42
48
|
/** Brand name (not always available) */
|
|
43
49
|
brand_name?: string;
|
|
44
|
-
/** Whether the product is Amazon Prime eligible */
|
|
45
|
-
is_prime?: boolean;
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* Single affiliate offer returned by the API.
|
|
@@ -53,18 +57,14 @@ export interface Offer {
|
|
|
53
57
|
link_text: string;
|
|
54
58
|
/** Product search term used (verbose mode only) */
|
|
55
59
|
search_term?: string;
|
|
56
|
-
/** Unified intent score (verbose mode only) */
|
|
57
|
-
confidence_score?: number | null;
|
|
58
|
-
/** Confidence level classification (verbose mode only) */
|
|
59
|
-
confidence_level?: string;
|
|
60
60
|
/** Affiliate URL — empty when resolution_mode=none */
|
|
61
61
|
url?: string;
|
|
62
|
-
/** Source of the URL resolution (e.g., vector
|
|
62
|
+
/** Source of the URL resolution (e.g., vector) (verbose mode only) */
|
|
63
63
|
resolution_source?: string;
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
|
|
64
|
+
/** Whether the winning extracted term was classified as brand-derived (true) or generic (false). Omitted when no classification is available (e.g. extraction_mode=none). */
|
|
65
|
+
is_branded?: boolean;
|
|
66
|
+
/** Resolved products carousel. products[0] is the ranking-best pick; additional entries are runner-ups deduped across offers. Up to max_products_per_offer entries (default 1). */
|
|
67
|
+
products?: Product[];
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* Response data containing affiliate offers.
|
|
@@ -80,14 +80,12 @@ export interface AnalyzeData {
|
|
|
80
80
|
returned: number;
|
|
81
81
|
/** Whether this request was billed */
|
|
82
82
|
billed: boolean;
|
|
83
|
-
/** Extraction source ("nlp"
|
|
83
|
+
/** Extraction source ("nlp") (verbose mode only) */
|
|
84
84
|
extraction_source?: string;
|
|
85
85
|
/** Extraction debug information (verbose mode only) */
|
|
86
86
|
extraction_debug?: unknown[];
|
|
87
87
|
/** Resolution debug information (verbose mode only) */
|
|
88
88
|
resolution_debug?: unknown[];
|
|
89
|
-
/** Request input type (verbose mode only) */
|
|
90
|
-
input_type?: string;
|
|
91
89
|
}
|
|
92
90
|
export interface ChatAdsError {
|
|
93
91
|
code: string;
|
package/dist/models.js
CHANGED