@chat-ads/chatads-sdk 0.1.13 → 0.1.15

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/dist/client.js CHANGED
@@ -4,14 +4,6 @@ const DEFAULT_ENDPOINT = "/v1/chatads/messages";
4
4
  const DEFAULT_TIMEOUT_MS = 10000;
5
5
  const DEFAULT_BACKOFF_FACTOR = 500; // ms
6
6
  const DEFAULT_RETRYABLE_STATUSES = new Set([408, 429, 500, 502, 503, 504]);
7
- /**
8
- * Field aliases for normalizing optional field names.
9
- * Field aliases for normalizing optional field names.
10
- */
11
- const FIELD_ALIASES = {
12
- fillpriority: "quality",
13
- quality: "quality",
14
- };
15
7
  export class ChatAdsClient {
16
8
  constructor(options) {
17
9
  if (!options?.apiKey) {
@@ -167,8 +159,7 @@ function normalizeOptionalFields(data) {
167
159
  if (key === "extraFields") {
168
160
  continue;
169
161
  }
170
- const aliasKey = FIELD_ALIASES[key.toLowerCase()] ?? key;
171
- normalized[aliasKey] = value;
162
+ normalized[key] = value;
172
163
  }
173
164
  return normalized;
174
165
  }
@@ -179,11 +170,13 @@ async function parseResponse(response) {
179
170
  // Normalize null/undefined to empty defaults so devs don't need null checks
180
171
  const data = raw.data ?? { offers: [], requested: 0, returned: 0 };
181
172
  return {
173
+ ...raw,
182
174
  data: {
183
175
  status: data.status,
184
176
  offers: data.offers ?? [],
185
177
  requested: data.requested ?? 0,
186
178
  returned: data.returned ?? 0,
179
+ billed: data.billed ?? false,
187
180
  extraction_source: data.extraction_source,
188
181
  extraction_debug: data.extraction_debug,
189
182
  resolution_debug: data.resolution_debug,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { ChatAdsClient } from "./client.js";
2
2
  export { ChatAdsAPIError, ChatAdsSDKError } from "./errors.js";
3
3
  export type { ChatAdsClientOptions, AnalyzeOptions, AnalyzeMessageOptions, } from "./client.js";
4
- export type { ChatAdsResponseEnvelope, Offer, Product, AnalyzeData, ChatAdsError, ChatAdsMeta, UsageInfo, FunctionItemPayload, FunctionItemOptionalFields, Quality, ResponseStatus, } from "./models.js";
4
+ export type { ChatAdsResponseEnvelope, Offer, Product, AnalyzeData, ChatAdsError, ChatAdsMeta, UsageInfo, FunctionItemPayload, FunctionItemOptionalFields, ResponseStatus, } from "./models.js";
package/dist/models.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- export type Quality = "fast" | "standard" | "best";
1
+ export type ExtractionMode = "none" | "fast" | "standard";
2
+ export type ResolutionMode = "none" | "fast" | "standard";
2
3
  /** Top-level response status indicating the outcome of the request */
3
- export type ResponseStatus = "filled" | "partial_fill" | "no_offers_found" | "internal_error";
4
+ export type ResponseStatus = "filled" | "partial_fill" | "no_offer" | "message_too_short" | "message_too_long" | "country_not_allowed" | "blocked_keyword" | "language_not_allowed" | "ip_country_not_allowed";
4
5
  /**
5
6
  * Optional fields for ChatAds API requests.
6
7
  */
@@ -9,10 +10,14 @@ export type FunctionItemOptionalFields = {
9
10
  ip?: string;
10
11
  /** ISO 3166-1 alpha-2 country code for geo-targeting */
11
12
  country?: string;
12
- /** Resolution quality level. Default: "standard" */
13
- quality?: Quality;
14
13
  /** Content type of the input message. Default: "text" */
15
14
  input_type?: "text" | "image_url" | "image_file";
15
+ /** Extraction control: "none" (bring your own product), "fast" (NLP only), "standard" (default). Default: "standard" */
16
+ extraction_mode?: ExtractionMode;
17
+ /** Resolution control: "none" (extraction only), "fast" (vector only), "standard" (default). Default: "standard" */
18
+ resolution_mode?: ResolutionMode;
19
+ /** Filter image search results by title keyword (image input_type only) */
20
+ image_title_filter?: string;
16
21
  };
17
22
  export type FunctionItemPayload = {
18
23
  message: string;
@@ -30,10 +35,12 @@ export interface Product {
30
35
  stars?: number;
31
36
  /** Number of product reviews */
32
37
  reviews?: number;
38
+ /** Product image URL (image input_type only) */
39
+ image?: string;
33
40
  }
34
41
  /**
35
42
  * Single affiliate offer returned by the API.
36
- * If an offer is in the array, it is guaranteed to have a URL.
43
+ * URL is populated for resolved offers but may be empty in extraction-only mode (resolution_mode=none).
37
44
  */
38
45
  export interface Offer {
39
46
  /** Text to use for the affiliate link */
@@ -44,12 +51,14 @@ export interface Offer {
44
51
  confidence_score?: number | null;
45
52
  /** Confidence level classification (verbose mode only) */
46
53
  confidence_level?: string;
47
- /** Affiliate URL (always populated) */
48
- url: string;
54
+ /** Affiliate URL empty when resolution_mode=none */
55
+ url?: string;
49
56
  /** Source of the URL resolution (e.g., amazon, serper, vector) (verbose mode only) */
50
57
  resolution_source?: string;
51
58
  /** Product metadata from resolution */
52
59
  product?: Product;
60
+ /** Source retailer name (image input_type only) */
61
+ offer_source?: string;
53
62
  }
54
63
  /**
55
64
  * Response data containing affiliate offers.
@@ -57,12 +66,14 @@ export interface Offer {
57
66
  export interface AnalyzeData {
58
67
  /** Status of the request - single source of truth for outcome */
59
68
  status: ResponseStatus;
60
- /** Array of affiliate offers (only contains filled offers with URLs, never null) */
69
+ /** Array of affiliate offers (URL may be absent in extraction-only mode, never null) */
61
70
  offers: Offer[];
62
71
  /** Number of offers requested */
63
72
  requested: number;
64
73
  /** Number of offers returned (equals len(Offers)) */
65
74
  returned: number;
75
+ /** Whether this request was billed */
76
+ billed: boolean;
66
77
  /** Extraction source ("nlp", "groq_vector", "groq_resolved") (verbose mode only) */
67
78
  extraction_source?: string;
68
79
  /** Extraction debug information (verbose mode only) */
package/dist/models.js CHANGED
@@ -6,6 +6,8 @@ export const RESERVED_PAYLOAD_KEYS = new Set([
6
6
  "message",
7
7
  "ip",
8
8
  "country",
9
- "quality",
10
9
  "input_type",
10
+ "extraction_mode",
11
+ "resolution_mode",
12
+ "image_title_filter",
11
13
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chat-ads/chatads-sdk",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "TypeScript/JavaScript client for the ChatAds prospect scoring API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,14 +32,7 @@
32
32
  "ads"
33
33
  ],
34
34
  "author": "ChatAds",
35
- "repository": {
36
- "type": "git",
37
- "url": "https://github.com/Chat-Ads/chatads-typescript-sdk"
38
- },
39
- "bugs": {
40
- "url": "https://github.com/Chat-Ads/chatads-typescript-sdk/issues"
41
- },
42
- "homepage": "https://github.com/Chat-Ads/chatads-typescript-sdk",
35
+ "homepage": "https://docs.getchatads.com",
43
36
  "devDependencies": {
44
37
  "@types/node": "22.5.0",
45
38
  "@typescript-eslint/eslint-plugin": "^7.17.0",