@chat-ads/chatads-sdk 0.1.12 → 0.1.13
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 +9 -0
- package/dist/client.js +2 -1
- package/dist/models.d.ts +5 -2
- package/dist/models.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,6 +44,15 @@ const result = await client.analyzeMessage("Need scheduling ideas", {
|
|
|
44
44
|
});
|
|
45
45
|
```
|
|
46
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",
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
47
56
|
- Reserved payload keys (like `message`, `country`, etc.) cannot be overwritten inside `extraFields`; the client throws if it detects a collision.
|
|
48
57
|
- Pass `raiseOnFailure: true` to throw `ChatAdsAPIError` when the API returns an error with HTTP 200 responses.
|
|
49
58
|
- Retries honor `Retry-After` headers and exponential backoff (`maxRetries` + `retryBackoffFactorMs`).
|
package/dist/client.js
CHANGED
|
@@ -6,7 +6,7 @@ const DEFAULT_BACKOFF_FACTOR = 500; // ms
|
|
|
6
6
|
const DEFAULT_RETRYABLE_STATUSES = new Set([408, 429, 500, 502, 503, 504]);
|
|
7
7
|
/**
|
|
8
8
|
* Field aliases for normalizing optional field names.
|
|
9
|
-
*
|
|
9
|
+
* Field aliases for normalizing optional field names.
|
|
10
10
|
*/
|
|
11
11
|
const FIELD_ALIASES = {
|
|
12
12
|
fillpriority: "quality",
|
|
@@ -187,6 +187,7 @@ async function parseResponse(response) {
|
|
|
187
187
|
extraction_source: data.extraction_source,
|
|
188
188
|
extraction_debug: data.extraction_debug,
|
|
189
189
|
resolution_debug: data.resolution_debug,
|
|
190
|
+
input_type: data.input_type,
|
|
190
191
|
},
|
|
191
192
|
error: raw.error,
|
|
192
193
|
meta: raw.meta ?? { request_id: "unknown" },
|
package/dist/models.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export type Quality = "fast" | "standard" | "best";
|
|
|
3
3
|
export type ResponseStatus = "filled" | "partial_fill" | "no_offers_found" | "internal_error";
|
|
4
4
|
/**
|
|
5
5
|
* Optional fields for ChatAds API requests.
|
|
6
|
-
* Only these 3 optional fields are supported (plus required `message`).
|
|
7
6
|
*/
|
|
8
7
|
export type FunctionItemOptionalFields = {
|
|
9
8
|
/** Client IP address for geo-detection (max 45 characters) */
|
|
@@ -12,6 +11,8 @@ export type FunctionItemOptionalFields = {
|
|
|
12
11
|
country?: string;
|
|
13
12
|
/** Resolution quality level. Default: "standard" */
|
|
14
13
|
quality?: Quality;
|
|
14
|
+
/** Content type of the input message. Default: "text" */
|
|
15
|
+
input_type?: "text" | "image_url" | "image_file";
|
|
15
16
|
};
|
|
16
17
|
export type FunctionItemPayload = {
|
|
17
18
|
message: string;
|
|
@@ -68,6 +69,8 @@ export interface AnalyzeData {
|
|
|
68
69
|
extraction_debug?: unknown[];
|
|
69
70
|
/** Resolution debug information (verbose mode only) */
|
|
70
71
|
resolution_debug?: unknown[];
|
|
72
|
+
/** Request input type (verbose mode only) */
|
|
73
|
+
input_type?: string;
|
|
71
74
|
}
|
|
72
75
|
export interface ChatAdsError {
|
|
73
76
|
code: string;
|
|
@@ -99,6 +102,6 @@ export interface ChatAdsResponseEnvelope {
|
|
|
99
102
|
}
|
|
100
103
|
/**
|
|
101
104
|
* Reserved payload keys that cannot be used in extraFields.
|
|
102
|
-
* These are the
|
|
105
|
+
* These are the allowed request fields per the OpenAPI spec.
|
|
103
106
|
*/
|
|
104
107
|
export declare const RESERVED_PAYLOAD_KEYS: ReadonlySet<string>;
|
package/dist/models.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Reserved payload keys that cannot be used in extraFields.
|
|
3
|
-
* These are the
|
|
3
|
+
* These are the allowed request fields per the OpenAPI spec.
|
|
4
4
|
*/
|
|
5
5
|
export const RESERVED_PAYLOAD_KEYS = new Set([
|
|
6
6
|
"message",
|
|
7
7
|
"ip",
|
|
8
8
|
"country",
|
|
9
9
|
"quality",
|
|
10
|
+
"input_type",
|
|
10
11
|
]);
|