triqai 0.1.0 → 0.1.2

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/CHANGELOG.md CHANGED
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.2] - 2026-03-30
11
+
12
+ ### Changed
13
+
14
+ - Synced SDK types with the latest Triqai API schema from `openapi-public.yaml`.
15
+ - Removed `TransactionChannel` from exported SDK types after API removal of `data.transaction.channel`.
16
+ - Updated transaction test fixtures to reflect the current enrichment response structure.
17
+
18
+ ### Notes
19
+
20
+ - Confidence reason tags remain typed as `string[]` and support newly introduced reasons (for example `venue_or_attraction`, `merchant_location_crosscheck_corrected`, `merchant_location_crosscheck_recovered`, `merchant_location_mismatch`, and `geo_mismatch`).
21
+
22
+ ## [0.1.1] - 2026-03-22
23
+
24
+ ### Fixed
25
+
26
+ - Normalized request paths so methods now handle both `"/v1/..."` and `"v1/..."` input forms.
27
+ - Improved `Retry-After` parsing to support both integer seconds and HTTP-date formats.
28
+ - Avoided misclassifying non-network `TypeError`s as `ConnectionError` during request handling.
29
+
30
+ ### Tests
31
+
32
+ - Added coverage for path normalization behavior.
33
+ - Added coverage for `Retry-After` date parsing on both successful responses and 503 errors.
34
+ - Added coverage to ensure hook-thrown `TypeError`s propagate correctly.
35
+
8
36
  ## [0.1.0] - 2026-03-21
9
37
 
10
38
  ### Added
package/README.md CHANGED
@@ -92,6 +92,11 @@ const result = await triqai.transactions.enrich({
92
92
  },
93
93
  },
94
94
  });
95
+
96
+ // API v1.1.11+: `data.transaction.channel` is no longer returned.
97
+ // Confidence reasons are dynamic and may include tags like:
98
+ // `venue_or_attraction`, `merchant_location_crosscheck_corrected`,
99
+ // `merchant_location_crosscheck_recovered`, `merchant_location_mismatch`, `geo_mismatch`.
95
100
  ```
96
101
 
97
102
  #### Enrich with idempotency
@@ -341,7 +346,6 @@ import type {
341
346
  CategoryInfo,
342
347
  EntityResult,
343
348
  TransactionType,
344
- TransactionChannel,
345
349
  EnrichmentFieldPath,
346
350
  } from "triqai";
347
351
  ```
package/dist/index.cjs CHANGED
@@ -122,7 +122,7 @@ var DEFAULT_RETRY_DELAY = 500;
122
122
  var DEFAULT_MAX_RETRY_DELAY = 3e4;
123
123
  var DEFAULT_TIMEOUT = 6e4;
124
124
  var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 503, 504]);
125
- var SDK_VERSION = "0.1.0";
125
+ var SDK_VERSION = "0.1.1";
126
126
  var HttpClient = class {
127
127
  apiKey;
128
128
  baseUrl;
@@ -264,7 +264,9 @@ var HttpClient = class {
264
264
  return this.request("POST", path, body, query, headers);
265
265
  }
266
266
  buildUrl(path, query) {
267
- const base = `${this.baseUrl}${path}`;
267
+ const isAbsoluteUrl = /^https?:\/\//i.test(path);
268
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
269
+ const base = isAbsoluteUrl ? path : `${this.baseUrl}${normalizedPath}`;
268
270
  if (!query) return base;
269
271
  const params = new URLSearchParams();
270
272
  for (const [k, v] of Object.entries(query)) {
@@ -332,7 +334,7 @@ var HttpClient = class {
332
334
  opts
333
335
  );
334
336
  case 503: {
335
- const retryAfter = headers["retry-after"] ? parseInt(headers["retry-after"], 10) : void 0;
337
+ const retryAfter = parseRetryAfterHeader(headers["retry-after"]);
336
338
  return new ServiceUnavailableError(parsed.message, retryAfter, opts);
337
339
  }
338
340
  case 504:
@@ -360,7 +362,7 @@ function parseRateLimitHeaders(headers) {
360
362
  scope: headers["x-ratelimit-scope"],
361
363
  concurrencyLimit: maybeInt(headers["x-ratelimit-concurrency-limit"]),
362
364
  concurrencyRemaining: maybeInt(headers["x-ratelimit-concurrency-remaining"]),
363
- retryAfter: maybeInt(headers["retry-after"])
365
+ retryAfter: parseRetryAfterHeader(headers["retry-after"])
364
366
  };
365
367
  }
366
368
  function maybeInt(val) {
@@ -368,6 +370,19 @@ function maybeInt(val) {
368
370
  const n = parseInt(val, 10);
369
371
  return Number.isNaN(n) ? void 0 : n;
370
372
  }
373
+ function parseRetryAfterHeader(val) {
374
+ if (val === void 0) return void 0;
375
+ const seconds = maybeInt(val);
376
+ if (seconds !== void 0 && seconds >= 0) {
377
+ return seconds;
378
+ }
379
+ const timestamp = Date.parse(val);
380
+ if (Number.isNaN(timestamp)) {
381
+ return void 0;
382
+ }
383
+ const secondsUntil = Math.ceil((timestamp - Date.now()) / 1e3);
384
+ return Math.max(secondsUntil, 0);
385
+ }
371
386
  function parseErrorBody(body) {
372
387
  if (!body || typeof body !== "object") {
373
388
  return {
@@ -401,8 +416,19 @@ function normalizeHeaderKeyMap(headers) {
401
416
  return new Set(Object.keys(headers).map((key) => key.toLowerCase()));
402
417
  }
403
418
  function isNetworkError(err) {
404
- if (err instanceof TypeError) return true;
405
- if (err instanceof Error && err.message.includes("fetch")) return true;
419
+ if (!(err instanceof Error)) return false;
420
+ const message = err.message.toLowerCase();
421
+ const hasNetworkSignal = message.includes("fetch") || message.includes("network") || message.includes("econnreset") || message.includes("enotfound") || message.includes("econnrefused") || message.includes("etimedout");
422
+ if (err instanceof TypeError) {
423
+ return hasNetworkSignal;
424
+ }
425
+ if (err.name === "NetworkError") {
426
+ return true;
427
+ }
428
+ if (err.cause instanceof Error) {
429
+ const causeMessage = err.cause.message.toLowerCase();
430
+ return causeMessage.includes("fetch") || causeMessage.includes("network") || causeMessage.includes("econnreset") || causeMessage.includes("enotfound") || causeMessage.includes("econnrefused") || causeMessage.includes("etimedout");
431
+ }
406
432
  return false;
407
433
  }
408
434
  function sleep(ms) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/http-client.ts","../src/resources/categories.ts","../src/resources/intermediaries.ts","../src/pagination.ts","../src/resources/issue-reports.ts","../src/resources/locations.ts","../src/resources/merchants.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;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,MAAA,CACJ,IAAA,EACA,KAAA,EAC0B;AAC1B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAO,IAAA,EAAM,KAAK,CAAA;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,OAAA,CACJ,IAAA,EACA,IAAA,EAC0B;AAC1B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAQ,IAAA,EAAM,IAAI,CAAA;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,UAAuB,IAAA,EAAwC;AACnE,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,MAAA,CAAU,IAAI,CAAA;AAAA,EACjC;AACF;;;ACrIA,IAAO,aAAA,GAAQ","file":"index.cjs","sourcesContent":["import type { RateLimitInfo } from \"./types/index.js\";\n\nexport interface RawErrorObject {\n code: string;\n message: string;\n details?: Record<string, unknown>;\n}\n\nexport interface RawResponseMeta {\n generatedAt: string;\n requestId: string;\n version: string;\n [key: string]: unknown;\n}\n\nexport class TriqaiError extends Error {\n /** HTTP status code from the API response. */\n readonly statusCode: number;\n /** Machine-readable error code from the API (e.g. \"validation_error\"). */\n readonly code: string;\n /** Correlation ID for support inquiries. */\n readonly requestId: string | undefined;\n /** The raw error body returned by the API. */\n readonly rawError: RawErrorObject | undefined;\n /** Response metadata. */\n readonly meta: RawResponseMeta | undefined;\n\n constructor(\n message: string,\n statusCode: number,\n opts?: {\n code?: string;\n requestId?: string;\n rawError?: RawErrorObject;\n meta?: RawResponseMeta;\n },\n ) {\n super(message);\n this.name = \"TriqaiError\";\n this.statusCode = statusCode;\n this.code = opts?.code ?? \"unknown_error\";\n this.requestId = opts?.requestId;\n this.rawError = opts?.rawError;\n this.meta = opts?.meta;\n }\n}\n\nexport class AuthenticationError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 401, { code: \"authentication_error\", ...opts });\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class AuthorizationError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 403, { code: \"authorization_error\", ...opts });\n this.name = \"AuthorizationError\";\n }\n}\n\nexport class InsufficientCreditsError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 402, { code: \"insufficient_credits\", ...opts });\n this.name = \"InsufficientCreditsError\";\n }\n}\n\nexport class NotFoundError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 404, { code: \"not_found\", ...opts });\n this.name = \"NotFoundError\";\n }\n}\n\nexport class ValidationError extends TriqaiError {\n readonly fieldErrors: Record<string, string[]>;\n\n constructor(\n message: string,\n fieldErrors?: Record<string, string[]>,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 422, { code: \"validation_error\", ...opts });\n this.name = \"ValidationError\";\n this.fieldErrors = fieldErrors ?? {};\n }\n}\n\nexport class ClientDisconnectedError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 499, { code: \"client_disconnected\", ...opts });\n this.name = \"ClientDisconnectedError\";\n }\n}\n\nexport class DuplicateRequestError extends TriqaiError {\n readonly state: \"in_progress\" | \"completed\" | undefined;\n readonly duplicateRequestId: string | undefined;\n readonly retryAfter: number | undefined;\n\n constructor(\n message: string,\n opts?: ConstructorParameters<typeof TriqaiError>[2] & {\n state?: \"in_progress\" | \"completed\";\n duplicateRequestId?: string;\n retryAfter?: number;\n },\n ) {\n super(message, 409, { code: \"DUPLICATE_REQUEST\", ...opts });\n this.name = \"DuplicateRequestError\";\n this.state = opts?.state;\n this.duplicateRequestId = opts?.duplicateRequestId;\n this.retryAfter = opts?.retryAfter;\n }\n}\n\nexport class RateLimitError extends TriqaiError {\n readonly rateLimitInfo: RateLimitInfo;\n\n constructor(\n message: string,\n rateLimitInfo: RateLimitInfo,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 429, { code: \"rate_limited\", ...opts });\n this.name = \"RateLimitError\";\n this.rateLimitInfo = rateLimitInfo;\n }\n}\n\nexport class InternalServerError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 500, { code: \"internal_error\", ...opts });\n this.name = \"InternalServerError\";\n }\n}\n\nexport class ServiceUnavailableError extends TriqaiError {\n readonly retryAfter: number | undefined;\n\n constructor(\n message: string,\n retryAfter?: number,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 503, { code: \"service_unavailable\", ...opts });\n this.name = \"ServiceUnavailableError\";\n this.retryAfter = retryAfter;\n }\n}\n\nexport class GatewayTimeoutError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 504, { code: \"gateway_timeout\", ...opts });\n this.name = \"GatewayTimeoutError\";\n }\n}\n\nexport class ConnectionError extends TriqaiError {\n constructor(message: string) {\n super(message, 0, { code: \"connection_error\" });\n this.name = \"ConnectionError\";\n }\n}\n\nexport class TimeoutError extends TriqaiError {\n constructor(message: string) {\n super(message, 0, { code: \"timeout\" });\n this.name = \"TimeoutError\";\n }\n}\n","import {\n AuthenticationError,\n AuthorizationError,\n ClientDisconnectedError,\n ConnectionError,\n DuplicateRequestError,\n GatewayTimeoutError,\n InsufficientCreditsError,\n InternalServerError,\n NotFoundError,\n RateLimitError,\n ServiceUnavailableError,\n TimeoutError,\n TriqaiError,\n ValidationError,\n} from \"./errors.js\";\nimport type { RawErrorObject, RawResponseMeta } from \"./errors.js\";\nimport type {\n RateLimitInfo,\n RequestInfo,\n ResponseInfo,\n TriqaiConfig,\n} from \"./types/index.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.triqai.com\";\nconst DEFAULT_MAX_RETRIES = 3;\nconst DEFAULT_RETRY_DELAY = 500;\nconst DEFAULT_MAX_RETRY_DELAY = 30_000;\nconst DEFAULT_TIMEOUT = 60_000;\nconst RETRYABLE_STATUS_CODES = new Set([429, 500, 503, 504]);\nconst SDK_VERSION = \"0.1.0\";\n\nexport interface HttpResponse<T> {\n data: T;\n status: number;\n headers: Record<string, string>;\n rateLimitInfo: RateLimitInfo;\n}\n\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly maxRetries: number;\n private readonly retryDelay: number;\n private readonly maxRetryDelay: number;\n private readonly timeout: number;\n private readonly defaultHeaders: Record<string, string>;\n private readonly onRequest?: (info: RequestInfo) => void;\n private readonly onResponse?: (info: ResponseInfo) => void;\n\n constructor(apiKey: string, config: TriqaiConfig = {}) {\n if (!apiKey) {\n throw new Error(\n \"API key is required. Get yours at https://triqai.com/dashboard\",\n );\n }\n this.apiKey = apiKey;\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;\n this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY;\n this.maxRetryDelay = config.maxRetryDelay ?? DEFAULT_MAX_RETRY_DELAY;\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT;\n this.defaultHeaders = config.defaultHeaders ?? {};\n this.onRequest = config.onRequest;\n this.onResponse = config.onResponse;\n }\n\n async get<T>(path: string, query?: Record<string, unknown>): Promise<HttpResponse<T>> {\n return this.request<T>(\"GET\", path, undefined, query);\n }\n\n async post<T>(path: string, body?: unknown): Promise<HttpResponse<T>> {\n return this.request<T>(\"POST\", path, body);\n }\n\n async delete<T>(path: string): Promise<HttpResponse<T>> {\n return this.request<T>(\"DELETE\", path);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n query?: Record<string, unknown>,\n extraHeaders?: Record<string, string>,\n ): Promise<HttpResponse<T>> {\n const url = this.buildUrl(path, query);\n const headers: Record<string, string> = {\n \"X-API-Key\": this.apiKey,\n \"User-Agent\": `triqai-node/${SDK_VERSION}`,\n Accept: \"application/json\",\n ...this.defaultHeaders,\n ...extraHeaders,\n };\n\n if (body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const delay = this.calculateDelay(attempt, lastError);\n await sleep(delay);\n }\n\n const startMs = Date.now();\n\n this.onRequest?.({ method, url, headers: { ...headers }, body });\n\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n let response: Response;\n try {\n response = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n } finally {\n clearTimeout(timeoutId);\n }\n\n const responseHeaders = parseHeaders(response.headers);\n const responseBody = await response.json().catch(() => null);\n const durationMs = Date.now() - startMs;\n\n this.onResponse?.({\n status: response.status,\n headers: responseHeaders,\n body: responseBody,\n durationMs,\n retryCount: attempt,\n });\n\n if (response.ok) {\n return {\n data: responseBody as T,\n status: response.status,\n headers: responseHeaders,\n rateLimitInfo: parseRateLimitHeaders(responseHeaders),\n };\n }\n\n const shouldRetry = this.canRetry(\n attempt,\n method,\n headers,\n RETRYABLE_STATUS_CODES.has(response.status),\n );\n\n lastError = this.mapError(response.status, responseBody, responseHeaders);\n\n if (!shouldRetry) {\n throw lastError;\n }\n } catch (err) {\n if (err instanceof TriqaiError) {\n const canRetry = this.canRetry(\n attempt,\n method,\n headers,\n RETRYABLE_STATUS_CODES.has(err.statusCode),\n );\n if (!canRetry) {\n throw err;\n }\n lastError = err;\n continue;\n }\n\n if (err instanceof DOMException && err.name === \"AbortError\") {\n lastError = new TimeoutError(\n `Request timed out after ${this.timeout}ms: ${method} ${path}`,\n );\n if (!this.canRetry(attempt, method, headers, true)) {\n throw lastError;\n }\n continue;\n }\n\n if (isNetworkError(err)) {\n lastError = new ConnectionError(\n `Network error: ${err instanceof Error ? err.message : String(err)}`,\n );\n if (!this.canRetry(attempt, method, headers, true)) {\n throw lastError;\n }\n continue;\n }\n\n throw err;\n }\n }\n\n throw lastError ?? new TriqaiError(\"Request failed after retries\", 0);\n }\n\n /**\n * Variant that injects custom headers (used by resources for Idempotency-Key etc.).\n */\n async postWithHeaders<T>(\n path: string,\n body: unknown,\n headers: Record<string, string>,\n query?: Record<string, unknown>,\n ): Promise<HttpResponse<T>> {\n return this.request<T>(\"POST\", path, body, query, headers);\n }\n\n private buildUrl(path: string, query?: Record<string, unknown>): string {\n const base = `${this.baseUrl}${path}`;\n if (!query) return base;\n\n const params = new URLSearchParams();\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined && v !== null) {\n if (v instanceof Date) {\n params.set(k, v.toISOString());\n } else {\n params.set(k, String(v));\n }\n }\n }\n const qs = params.toString();\n return qs ? `${base}?${qs}` : base;\n }\n\n private calculateDelay(attempt: number, lastError?: Error): number {\n if (lastError instanceof RateLimitError && lastError.rateLimitInfo.retryAfter) {\n return lastError.rateLimitInfo.retryAfter * 1000;\n }\n if (lastError instanceof ServiceUnavailableError && lastError.retryAfter) {\n return lastError.retryAfter * 1000;\n }\n const exponential = this.retryDelay * Math.pow(2, attempt - 1);\n const jitter = exponential * 0.2 * Math.random();\n return Math.min(exponential + jitter, this.maxRetryDelay);\n }\n\n private canRetry(\n attempt: number,\n method: string,\n headers: Record<string, string>,\n retryableSignal: boolean,\n ): boolean {\n return (\n retryableSignal &&\n attempt < this.maxRetries &&\n isIdempotent(method, headers)\n );\n }\n\n private mapError(\n status: number,\n body: unknown,\n headers: Record<string, string>,\n ): TriqaiError {\n const parsed = parseErrorBody(body);\n const opts = {\n code: parsed.code,\n requestId: parsed.requestId,\n rawError: parsed.error,\n meta: parsed.meta,\n };\n\n switch (status) {\n case 401:\n return new AuthenticationError(parsed.message, opts);\n case 402:\n return new InsufficientCreditsError(parsed.message, opts);\n case 403:\n return new AuthorizationError(parsed.message, opts);\n case 404:\n return new NotFoundError(parsed.message, opts);\n case 499:\n return new ClientDisconnectedError(parsed.message, opts);\n case 409: {\n const details = (parsed.error?.details ?? {}) as\n { state?: \"in_progress\" | \"completed\"; requestId?: string; retryAfterSeconds?: number };\n return new DuplicateRequestError(parsed.message, {\n ...opts,\n state: details?.state,\n duplicateRequestId: details?.requestId,\n retryAfter: details?.retryAfterSeconds,\n });\n }\n case 422: {\n const fieldErrors = (parsed.error?.details as { fieldErrors?: Record<string, string[]> } | undefined)\n ?.fieldErrors;\n return new ValidationError(parsed.message, fieldErrors, opts);\n }\n case 429:\n return new RateLimitError(\n parsed.message,\n parseRateLimitHeaders(headers),\n opts,\n );\n case 503: {\n const retryAfter = headers[\"retry-after\"]\n ? parseInt(headers[\"retry-after\"], 10)\n : undefined;\n return new ServiceUnavailableError(parsed.message, retryAfter, opts);\n }\n case 504:\n return new GatewayTimeoutError(parsed.message, opts);\n default:\n if (status >= 500) {\n return new InternalServerError(parsed.message, opts);\n }\n return new TriqaiError(parsed.message, status, opts);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction parseHeaders(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n out[key.toLowerCase()] = value;\n });\n return out;\n}\n\nfunction parseRateLimitHeaders(headers: Record<string, string>): RateLimitInfo {\n return {\n limit: maybeInt(headers[\"x-ratelimit-limit\"]),\n remaining: maybeInt(headers[\"x-ratelimit-remaining\"]),\n reset: headers[\"x-ratelimit-reset\"] ?? undefined,\n scope: headers[\"x-ratelimit-scope\"] as RateLimitInfo[\"scope\"],\n concurrencyLimit: maybeInt(headers[\"x-ratelimit-concurrency-limit\"]),\n concurrencyRemaining: maybeInt(headers[\"x-ratelimit-concurrency-remaining\"]),\n retryAfter: maybeInt(headers[\"retry-after\"]),\n };\n}\n\nfunction maybeInt(val: string | undefined): number | undefined {\n if (val === undefined) return undefined;\n const n = parseInt(val, 10);\n return Number.isNaN(n) ? undefined : n;\n}\n\ninterface ParsedError {\n message: string;\n code: string;\n requestId: string | undefined;\n error: RawErrorObject | undefined;\n meta: RawResponseMeta | undefined;\n}\n\nfunction parseErrorBody(body: unknown): ParsedError {\n if (!body || typeof body !== \"object\") {\n return {\n message: \"Unknown error\",\n code: \"unknown_error\",\n requestId: undefined,\n error: undefined,\n meta: undefined,\n };\n }\n\n const b = body as Record<string, unknown>;\n const error = b.error as { code?: string; message?: string; details?: Record<string, unknown> } | undefined;\n const meta = b.meta as Record<string, unknown> | undefined;\n\n return {\n message: error?.message ?? \"Unknown error\",\n code: error?.code ?? \"unknown_error\",\n requestId: meta?.requestId as string | undefined,\n error: error?.code\n ? { code: error.code, message: error.message ?? \"Unknown error\", details: error.details }\n : undefined,\n meta: meta?.generatedAt\n ? (meta as RawResponseMeta)\n : undefined,\n };\n}\n\nfunction isIdempotent(method: string, headers: Record<string, string>): boolean {\n if (method === \"GET\" || method === \"DELETE\") return true;\n const normalized = normalizeHeaderKeyMap(headers);\n if (normalized.has(\"idempotency-key\") || normalized.has(\"x-idempotency-key\")) {\n return true;\n }\n return false;\n}\n\nfunction normalizeHeaderKeyMap(headers: Record<string, string>): Set<string> {\n return new Set(Object.keys(headers).map((key) => key.toLowerCase()));\n}\n\nfunction isNetworkError(err: unknown): boolean {\n if (err instanceof TypeError) return true;\n if (err instanceof Error && err.message.includes(\"fetch\")) return true;\n return false;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { CategoryInfo, CategoryListResponse } from \"../types/index.js\";\n\nexport class Categories {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * List all available transaction categories.\n *\n * Returns the full category tree used for transaction classification,\n * including MCC, SIC, and NAICS codes.\n *\n * @returns Array of category info objects and the total count.\n *\n * @example\n * ```ts\n * const { categories, total } = await triqai.categories.list();\n * console.log(`${total} categories available`);\n * ```\n */\n async list(): Promise<{ categories: CategoryInfo[]; total: number; categoryVersion: string }> {\n const resp = await this.http.get<CategoryListResponse>(\"/v1/categories\");\n return {\n categories: resp.data.data.categories,\n total: resp.data.data.total,\n categoryVersion: resp.data.meta.categoryVersion,\n };\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { IntermediaryData, IntermediaryResponse } from \"../types/index.js\";\n\nexport class Intermediaries {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get an intermediary (payment processor / platform) by ID.\n *\n * @param id - Intermediary UUID.\n * @returns The intermediary data (name, icon, description, website, domain, etc.).\n *\n * @example\n * ```ts\n * const intermediary = await triqai.intermediaries.get(\"550e8400-...\");\n * console.log(intermediary.name); // \"PayPal\", \"Square\", etc.\n * ```\n */\n async get(id: string): Promise<IntermediaryData> {\n const resp = await this.http.get<IntermediaryResponse>(\n `/v1/intermediaries/${encodeURIComponent(id)}`,\n );\n return resp.data.data.intermediary;\n }\n}\n","/**\n * Pagination helpers for list endpoints.\n *\n * Provides a `Page<T>` type with metadata and an `autoPaginate()` method\n * that returns an async iterator walking through all pages automatically.\n */\n\nexport interface PageInfo {\n page: number;\n size: number;\n total: number;\n totalPages: number;\n}\n\nexport class Page<T> {\n readonly data: T[];\n readonly pageInfo: PageInfo;\n\n private readonly _fetchPage: (page: number, size: number) => Promise<Page<T>>;\n\n constructor(\n data: T[],\n pageInfo: PageInfo,\n fetchPage: (page: number, size: number) => Promise<Page<T>>,\n ) {\n this.data = data;\n this.pageInfo = pageInfo;\n this._fetchPage = fetchPage;\n }\n\n get hasNextPage(): boolean {\n return this.pageInfo.page < this.pageInfo.totalPages;\n }\n\n get hasPreviousPage(): boolean {\n return this.pageInfo.page > 1;\n }\n\n async nextPage(): Promise<Page<T>> {\n if (!this.hasNextPage) {\n return new Page<T>([], this.pageInfo, this._fetchPage);\n }\n return this._fetchPage(this.pageInfo.page + 1, this.pageInfo.size);\n }\n\n async previousPage(): Promise<Page<T>> {\n if (!this.hasPreviousPage) {\n return new Page<T>([], this.pageInfo, this._fetchPage);\n }\n return this._fetchPage(this.pageInfo.page - 1, this.pageInfo.size);\n }\n\n /**\n * Returns an async iterator that yields every item across all pages,\n * starting from the current page.\n *\n * ```ts\n * for await (const item of page.autoPaginate()) {\n * console.log(item);\n * }\n * ```\n */\n async *autoPaginate(): AsyncGenerator<T, void, unknown> {\n let current: Page<T> = this;\n while (true) {\n for (const item of current.data) {\n yield item;\n }\n if (!current.hasNextPage) break;\n current = await current.nextPage();\n }\n }\n\n /**\n * Symbol.asyncIterator so `Page` itself can be used in `for await...of`.\n */\n [Symbol.asyncIterator](): AsyncIterableIterator<T> {\n return this.autoPaginate();\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport { Page } from \"../pagination.js\";\nimport type {\n EnrichmentFieldPath,\n IssueReport,\n IssueReportListResponse,\n IssueReportResponse,\n ListIssueReportsParams,\n} from \"../types/index.js\";\n\nexport interface CreateIssueReportParams {\n /** The transaction ID to report an issue for. */\n transactionId: string;\n /** A description of what is wrong with the enrichment result. */\n description: string;\n /** Which enrichment fields are incorrect. */\n fields: EnrichmentFieldPath[];\n}\n\nexport class IssueReports {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Report an issue with an enrichment result.\n *\n * @param params - The issue report details.\n * @returns The created issue report.\n *\n * @example\n * ```ts\n * const report = await triqai.issueReports.create({\n * transactionId: \"tx-uuid\",\n * description: \"Merchant was identified incorrectly\",\n * fields: [\"entities.merchant.data.name\"],\n * });\n * console.log(report.id, report.status);\n * ```\n */\n async create(params: CreateIssueReportParams): Promise<IssueReport> {\n const resp = await this.http.post<IssueReportResponse>(\"/v1/report-issue\", {\n transaction_id: params.transactionId,\n description: params.description,\n fields: params.fields,\n });\n return resp.data.data.issueReport;\n }\n\n /**\n * List issue reports with pagination.\n *\n * @returns A `Page` of issue reports. Use `.autoPaginate()` or\n * `for await...of` to iterate through all pages automatically.\n *\n * @example\n * ```ts\n * const page = await triqai.issueReports.list({ status: \"pending\" });\n * for (const report of page.data) {\n * console.log(report.id, report.status);\n * }\n * ```\n */\n async list(params?: ListIssueReportsParams): Promise<Page<IssueReport>> {\n const fetchPage = async (page: number, size: number): Promise<Page<IssueReport>> => {\n const query: Record<string, unknown> = { page, size };\n if (params?.status) query.status = params.status;\n if (params?.transactionId) query.transaction_id = params.transactionId;\n\n const resp = await this.http.get<IssueReportListResponse>(\"/v1/report-issue\", query);\n const pageInfo = {\n page: resp.data.meta.page,\n size: resp.data.meta.size,\n total: resp.data.meta.total,\n totalPages: resp.data.meta.totalPages,\n };\n return new Page(resp.data.data, pageInfo, fetchPage);\n };\n\n return fetchPage(params?.page ?? 1, params?.size ?? 25);\n }\n\n /**\n * Get a single issue report by ID.\n *\n * @param id - Issue report UUID.\n * @returns The issue report details.\n */\n async get(id: string): Promise<IssueReport> {\n const resp = await this.http.get<IssueReportResponse>(\n `/v1/report-issue/${encodeURIComponent(id)}`,\n );\n return resp.data.data.issueReport;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { LocationData, LocationResponse } from \"../types/index.js\";\n\nexport class Locations {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get a location by ID.\n *\n * @param id - Location UUID.\n * @returns The location data (name, formatted address, coordinates, phone, rating, etc.).\n *\n * @example\n * ```ts\n * const location = await triqai.locations.get(\"550e8400-e29b-41d4-a716-446655440000\");\n * console.log(location.formatted, location.structured.city);\n * ```\n */\n async get(id: string): Promise<LocationData> {\n const resp = await this.http.get<LocationResponse>(\n `/v1/locations/${encodeURIComponent(id)}`,\n );\n return resp.data.data.location;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { MerchantData, MerchantResponse } from \"../types/index.js\";\n\nexport class Merchants {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get a merchant by ID.\n *\n * @param id - Merchant UUID.\n * @returns The merchant data (name, icon, website, domain, aliases, etc.).\n *\n * @example\n * ```ts\n * const merchant = await triqai.merchants.get(\"550e8400-e29b-41d4-a716-446655440000\");\n * console.log(merchant.name, merchant.website);\n * ```\n */\n async get(id: string): Promise<MerchantData> {\n const resp = await this.http.get<MerchantResponse>(\n `/v1/merchants/${encodeURIComponent(id)}`,\n );\n return resp.data.data.merchant;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport { Page } from \"../pagination.js\";\nimport type {\n DeleteTransactionResponse,\n EnrichedTransaction,\n EnrichOptions,\n EnrichRequest,\n EnrichSuccessResponse,\n ListTransactionsParams,\n TransactionDetailResponse,\n TransactionListResponse,\n} from \"../types/index.js\";\n\nexport class Transactions {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Enrich a transaction with merchant, category, location, and entity data.\n *\n * @param request - The transaction to enrich (title, country, type, and optional options).\n * @param options - Optional enrichment controls (force bypass cache, idempotency key).\n * @returns The enriched transaction data.\n *\n * @example\n * ```ts\n * const result = await triqai.transactions.enrich({\n * title: \"STARBUCKS SEATTLE WA\",\n * country: \"US\",\n * type: \"expense\",\n * });\n * console.log(result.data.entities);\n * ```\n */\n async enrich(\n request: EnrichRequest,\n options?: EnrichOptions,\n ): Promise<EnrichSuccessResponse> {\n const headers: Record<string, string> = {};\n const query: Record<string, unknown> = {};\n\n if (options?.idempotencyKey) {\n headers[\"Idempotency-Key\"] = options.idempotencyKey;\n }\n if (options?.force) {\n query.force = \"true\";\n }\n\n const resp = await this.http.postWithHeaders<EnrichSuccessResponse>(\n \"/v1/transactions/enrich\",\n request,\n headers,\n Object.keys(query).length > 0 ? query : undefined,\n );\n return resp.data;\n }\n\n /**\n * List enriched transactions with pagination.\n *\n * @returns A `Page` of enriched transactions. Use `.autoPaginate()` or\n * `for await...of` to iterate through all pages automatically.\n *\n * @example\n * ```ts\n * const page = await triqai.transactions.list({ size: 10 });\n * console.log(page.data); // first 10 transactions\n *\n * // Auto-paginate through all:\n * for await (const tx of page) {\n * console.log(tx.id, tx.raw);\n * }\n * ```\n */\n async list(params?: ListTransactionsParams): Promise<Page<EnrichedTransaction>> {\n const fetchPage = async (page: number, size: number): Promise<Page<EnrichedTransaction>> => {\n const query: Record<string, unknown> = {\n page,\n size,\n };\n if (params?.startDate) {\n query.startDate =\n params.startDate instanceof Date\n ? params.startDate.toISOString()\n : params.startDate;\n }\n if (params?.endDate) {\n query.endDate =\n params.endDate instanceof Date\n ? params.endDate.toISOString()\n : params.endDate;\n }\n\n const resp = await this.http.get<TransactionListResponse>(\"/v1/transactions\", query);\n const { transactions, pagination } = resp.data.data;\n return new Page(transactions, pagination, fetchPage);\n };\n\n return fetchPage(params?.page ?? 1, params?.size ?? 25);\n }\n\n /**\n * Get a single transaction by ID.\n *\n * @param id - Transaction UUID.\n * @returns The enriched transaction record.\n */\n async get(id: string): Promise<EnrichedTransaction> {\n const resp = await this.http.get<TransactionDetailResponse>(\n `/v1/transactions/${encodeURIComponent(id)}`,\n );\n return resp.data.data.transaction;\n }\n\n /**\n * Delete a transaction by ID.\n *\n * @param id - Transaction UUID.\n * @returns Confirmation with the deleted transaction ID.\n */\n async delete(id: string): Promise<{ deleted: true; transactionId: string }> {\n const resp = await this.http.delete<DeleteTransactionResponse>(\n `/v1/transactions/${encodeURIComponent(id)}`,\n );\n return resp.data.data;\n }\n}\n","import type { HttpResponse } from \"./http-client.js\";\nimport { HttpClient } from \"./http-client.js\";\nimport { Categories } from \"./resources/categories.js\";\nimport { Intermediaries } from \"./resources/intermediaries.js\";\nimport { IssueReports } from \"./resources/issue-reports.js\";\nimport { Locations } from \"./resources/locations.js\";\nimport { Merchants } from \"./resources/merchants.js\";\nimport { Transactions } from \"./resources/transactions.js\";\nimport type {\n ApiInfoResponse,\n HealthResponse,\n TriqaiConfig,\n} from \"./types/index.js\";\n\n/**\n * The Triqai SDK client.\n *\n * @example\n * ```ts\n * import Triqai from \"triqai\";\n *\n * const triqai = new Triqai(\"triq_your_api_key\");\n *\n * const result = await triqai.transactions.enrich({\n * title: \"STARBUCKS SEATTLE WA\",\n * country: \"US\",\n * type: \"expense\",\n * });\n * ```\n */\nexport class Triqai {\n /** Enrich, list, get, and delete transactions. */\n readonly transactions: Transactions;\n /** List the full category taxonomy. */\n readonly categories: Categories;\n /** Look up merchant details by ID. */\n readonly merchants: Merchants;\n /** Look up location details by ID. */\n readonly locations: Locations;\n /** Look up intermediary (payment processor) details by ID. */\n readonly intermediaries: Intermediaries;\n /** Create and manage enrichment issue reports. */\n readonly issueReports: IssueReports;\n\n private readonly http: HttpClient;\n\n /**\n * Create a new Triqai SDK client.\n *\n * @param apiKey - Your Triqai API key (starts with `triq_`). Get one at https://triqai.com/dashboard\n * @param config - Optional configuration (base URL, retry settings, hooks).\n */\n constructor(apiKey: string, config?: TriqaiConfig) {\n this.http = new HttpClient(apiKey, config);\n this.transactions = new Transactions(this.http);\n this.categories = new Categories(this.http);\n this.merchants = new Merchants(this.http);\n this.locations = new Locations(this.http);\n this.intermediaries = new Intermediaries(this.http);\n this.issueReports = new IssueReports(this.http);\n }\n\n /**\n * Check the API health status.\n *\n * @returns Health status including service name and version.\n *\n * @example\n * ```ts\n * const health = await triqai.health();\n * console.log(health.data.status); // \"healthy\"\n * console.log(health.data.version); // \"1.1.9\"\n * ```\n */\n async health(): Promise<HealthResponse> {\n const resp = await this.http.get<HealthResponse>(\"/health\");\n return resp.data;\n }\n\n /**\n * Get API version and endpoint directory.\n *\n * @returns API version info and available endpoint paths.\n *\n * @example\n * ```ts\n * const info = await triqai.apiInfo();\n * console.log(info.data.version); // \"v1\"\n * console.log(info.data.endpoints);\n * ```\n */\n async apiInfo(): Promise<ApiInfoResponse> {\n const resp = await this.http.get<ApiInfoResponse>(\"/v1\");\n return resp.data;\n }\n\n /**\n * Make a raw GET request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-endpoint\").\n * @param query - Optional query parameters.\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawGet<T = unknown>(\n path: string,\n query?: Record<string, unknown>,\n ): Promise<HttpResponse<T>> {\n return this.http.get<T>(path, query);\n }\n\n /**\n * Make a raw POST request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-endpoint\").\n * @param body - Request body.\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawPost<T = unknown>(\n path: string,\n body?: unknown,\n ): Promise<HttpResponse<T>> {\n return this.http.post<T>(path, body);\n }\n\n /**\n * Make a raw DELETE request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-resource/uuid\").\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawDelete<T = unknown>(path: string): Promise<HttpResponse<T>> {\n return this.http.delete<T>(path);\n }\n}\n","import { Triqai } from \"./client.js\";\n\nexport { Triqai };\nexport default Triqai;\n\nexport {\n TriqaiError,\n AuthenticationError,\n AuthorizationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n ClientDisconnectedError,\n DuplicateRequestError,\n RateLimitError,\n InternalServerError,\n ServiceUnavailableError,\n GatewayTimeoutError,\n ConnectionError,\n TimeoutError,\n} from \"./errors.js\";\nexport type { RawErrorObject, RawResponseMeta } from \"./errors.js\";\n\nexport type { HttpResponse } from \"./http-client.js\";\n\nexport { Page } from \"./pagination.js\";\nexport type { PageInfo } from \"./pagination.js\";\n\nexport type { CreateIssueReportParams } from \"./resources/issue-reports.js\";\n\nexport type {\n // SDK config types\n TriqaiConfig,\n RequestInfo,\n ResponseInfo,\n RateLimitInfo,\n EnrichOptions,\n ListTransactionsParams,\n ListIssueReportsParams,\n // Enrichment request types\n EnrichRequest,\n EnrichRequestOptions,\n EnrichmentFilterOptions,\n PrefilledMerchant,\n PrefilledLocation,\n PrefilledIntermediary,\n // Enrichment response types\n EnrichSuccessResponse,\n EnrichmentData,\n EnrichMeta,\n EnrichmentErrorCode,\n // Transaction types\n TransactionData,\n TransactionType,\n TransactionChannel,\n TransactionRecord,\n EnrichedTransaction,\n TransactionPagination,\n TransactionListResponse,\n TransactionDetailResponse,\n DeleteTransactionResponse,\n // Category types\n CategoryStructure,\n Category,\n CategoryCode,\n CategoryInfo,\n CategoryListResponse,\n // Confidence / subscription\n ConfidenceWithReasons,\n Subscription,\n SubscriptionType,\n // Entity types\n EntityResult,\n MerchantData,\n LocationData,\n IntermediaryData,\n IntermediaryRecord,\n PersonData,\n Coordinates,\n StructuredAddress,\n LocationRating,\n // Entity response types\n MerchantResponse,\n LocationResponse,\n IntermediaryResponse,\n // Issue report types\n IssueReport,\n IssueReportStatus,\n IssueReportResponse,\n IssueReportListResponse,\n ReportIssueRequest,\n EnrichmentFieldPath,\n // Error response types\n ErrorResponse,\n ErrorObject,\n DuplicateRequestErrorResponse,\n ClientDisconnectedErrorResponse,\n // Meta types\n ResponseMeta,\n PaginationMeta,\n // Utility response types\n HealthResponse,\n ApiInfoResponse,\n} from \"./types/index.js\";\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/http-client.ts","../src/resources/categories.ts","../src/resources/intermediaries.ts","../src/pagination.ts","../src/resources/issue-reports.ts","../src/resources/locations.ts","../src/resources/merchants.ts","../src/resources/transactions.ts","../src/client.ts","../src/index.ts"],"names":[],"mappings":";;;;;AAeO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA;AAAA,EAE5B,UAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,IAAA;AAAA,EAET,WAAA,CACE,OAAA,EACA,UAAA,EACA,IAAA,EAMA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,IAAA,GAAO,MAAM,IAAA,IAAQ,eAAA;AAC1B,IAAA,IAAA,CAAK,YAAY,IAAA,EAAM,SAAA;AACvB,IAAA,IAAA,CAAK,WAAW,IAAA,EAAM,QAAA;AACtB,IAAA,IAAA,CAAK,OAAO,IAAA,EAAM,IAAA;A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,IAAA,CAAK,IAAA,CAAQ,IAAA,EAAM,IAAI,CAAA;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,UAAuB,IAAA,EAAwC;AACnE,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,MAAA,CAAU,IAAI,CAAA;AAAA,EACjC;AACF;;;ACrIA,IAAO,aAAA,GAAQ","file":"index.cjs","sourcesContent":["import type { RateLimitInfo } from \"./types/index.js\";\n\nexport interface RawErrorObject {\n code: string;\n message: string;\n details?: Record<string, unknown>;\n}\n\nexport interface RawResponseMeta {\n generatedAt: string;\n requestId: string;\n version: string;\n [key: string]: unknown;\n}\n\nexport class TriqaiError extends Error {\n /** HTTP status code from the API response. */\n readonly statusCode: number;\n /** Machine-readable error code from the API (e.g. \"validation_error\"). */\n readonly code: string;\n /** Correlation ID for support inquiries. */\n readonly requestId: string | undefined;\n /** The raw error body returned by the API. */\n readonly rawError: RawErrorObject | undefined;\n /** Response metadata. */\n readonly meta: RawResponseMeta | undefined;\n\n constructor(\n message: string,\n statusCode: number,\n opts?: {\n code?: string;\n requestId?: string;\n rawError?: RawErrorObject;\n meta?: RawResponseMeta;\n },\n ) {\n super(message);\n this.name = \"TriqaiError\";\n this.statusCode = statusCode;\n this.code = opts?.code ?? \"unknown_error\";\n this.requestId = opts?.requestId;\n this.rawError = opts?.rawError;\n this.meta = opts?.meta;\n }\n}\n\nexport class AuthenticationError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 401, { code: \"authentication_error\", ...opts });\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class AuthorizationError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 403, { code: \"authorization_error\", ...opts });\n this.name = \"AuthorizationError\";\n }\n}\n\nexport class InsufficientCreditsError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 402, { code: \"insufficient_credits\", ...opts });\n this.name = \"InsufficientCreditsError\";\n }\n}\n\nexport class NotFoundError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 404, { code: \"not_found\", ...opts });\n this.name = \"NotFoundError\";\n }\n}\n\nexport class ValidationError extends TriqaiError {\n readonly fieldErrors: Record<string, string[]>;\n\n constructor(\n message: string,\n fieldErrors?: Record<string, string[]>,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 422, { code: \"validation_error\", ...opts });\n this.name = \"ValidationError\";\n this.fieldErrors = fieldErrors ?? {};\n }\n}\n\nexport class ClientDisconnectedError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 499, { code: \"client_disconnected\", ...opts });\n this.name = \"ClientDisconnectedError\";\n }\n}\n\nexport class DuplicateRequestError extends TriqaiError {\n readonly state: \"in_progress\" | \"completed\" | undefined;\n readonly duplicateRequestId: string | undefined;\n readonly retryAfter: number | undefined;\n\n constructor(\n message: string,\n opts?: ConstructorParameters<typeof TriqaiError>[2] & {\n state?: \"in_progress\" | \"completed\";\n duplicateRequestId?: string;\n retryAfter?: number;\n },\n ) {\n super(message, 409, { code: \"DUPLICATE_REQUEST\", ...opts });\n this.name = \"DuplicateRequestError\";\n this.state = opts?.state;\n this.duplicateRequestId = opts?.duplicateRequestId;\n this.retryAfter = opts?.retryAfter;\n }\n}\n\nexport class RateLimitError extends TriqaiError {\n readonly rateLimitInfo: RateLimitInfo;\n\n constructor(\n message: string,\n rateLimitInfo: RateLimitInfo,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 429, { code: \"rate_limited\", ...opts });\n this.name = \"RateLimitError\";\n this.rateLimitInfo = rateLimitInfo;\n }\n}\n\nexport class InternalServerError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 500, { code: \"internal_error\", ...opts });\n this.name = \"InternalServerError\";\n }\n}\n\nexport class ServiceUnavailableError extends TriqaiError {\n readonly retryAfter: number | undefined;\n\n constructor(\n message: string,\n retryAfter?: number,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 503, { code: \"service_unavailable\", ...opts });\n this.name = \"ServiceUnavailableError\";\n this.retryAfter = retryAfter;\n }\n}\n\nexport class GatewayTimeoutError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 504, { code: \"gateway_timeout\", ...opts });\n this.name = \"GatewayTimeoutError\";\n }\n}\n\nexport class ConnectionError extends TriqaiError {\n constructor(message: string) {\n super(message, 0, { code: \"connection_error\" });\n this.name = \"ConnectionError\";\n }\n}\n\nexport class TimeoutError extends TriqaiError {\n constructor(message: string) {\n super(message, 0, { code: \"timeout\" });\n this.name = \"TimeoutError\";\n }\n}\n","import {\n AuthenticationError,\n AuthorizationError,\n ClientDisconnectedError,\n ConnectionError,\n DuplicateRequestError,\n GatewayTimeoutError,\n InsufficientCreditsError,\n InternalServerError,\n NotFoundError,\n RateLimitError,\n ServiceUnavailableError,\n TimeoutError,\n TriqaiError,\n ValidationError,\n} from \"./errors.js\";\nimport type { RawErrorObject, RawResponseMeta } from \"./errors.js\";\nimport type {\n RateLimitInfo,\n RequestInfo,\n ResponseInfo,\n TriqaiConfig,\n} from \"./types/index.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.triqai.com\";\nconst DEFAULT_MAX_RETRIES = 3;\nconst DEFAULT_RETRY_DELAY = 500;\nconst DEFAULT_MAX_RETRY_DELAY = 30_000;\nconst DEFAULT_TIMEOUT = 60_000;\nconst RETRYABLE_STATUS_CODES = new Set([429, 500, 503, 504]);\nconst SDK_VERSION = \"0.1.1\";\n\nexport interface HttpResponse<T> {\n data: T;\n status: number;\n headers: Record<string, string>;\n rateLimitInfo: RateLimitInfo;\n}\n\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly maxRetries: number;\n private readonly retryDelay: number;\n private readonly maxRetryDelay: number;\n private readonly timeout: number;\n private readonly defaultHeaders: Record<string, string>;\n private readonly onRequest?: (info: RequestInfo) => void;\n private readonly onResponse?: (info: ResponseInfo) => void;\n\n constructor(apiKey: string, config: TriqaiConfig = {}) {\n if (!apiKey) {\n throw new Error(\n \"API key is required. Get yours at https://triqai.com/dashboard\",\n );\n }\n this.apiKey = apiKey;\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;\n this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY;\n this.maxRetryDelay = config.maxRetryDelay ?? DEFAULT_MAX_RETRY_DELAY;\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT;\n this.defaultHeaders = config.defaultHeaders ?? {};\n this.onRequest = config.onRequest;\n this.onResponse = config.onResponse;\n }\n\n async get<T>(path: string, query?: Record<string, unknown>): Promise<HttpResponse<T>> {\n return this.request<T>(\"GET\", path, undefined, query);\n }\n\n async post<T>(path: string, body?: unknown): Promise<HttpResponse<T>> {\n return this.request<T>(\"POST\", path, body);\n }\n\n async delete<T>(path: string): Promise<HttpResponse<T>> {\n return this.request<T>(\"DELETE\", path);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n query?: Record<string, unknown>,\n extraHeaders?: Record<string, string>,\n ): Promise<HttpResponse<T>> {\n const url = this.buildUrl(path, query);\n const headers: Record<string, string> = {\n \"X-API-Key\": this.apiKey,\n \"User-Agent\": `triqai-node/${SDK_VERSION}`,\n Accept: \"application/json\",\n ...this.defaultHeaders,\n ...extraHeaders,\n };\n\n if (body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const delay = this.calculateDelay(attempt, lastError);\n await sleep(delay);\n }\n\n const startMs = Date.now();\n\n this.onRequest?.({ method, url, headers: { ...headers }, body });\n\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n let response: Response;\n try {\n response = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n } finally {\n clearTimeout(timeoutId);\n }\n\n const responseHeaders = parseHeaders(response.headers);\n const responseBody = await response.json().catch(() => null);\n const durationMs = Date.now() - startMs;\n\n this.onResponse?.({\n status: response.status,\n headers: responseHeaders,\n body: responseBody,\n durationMs,\n retryCount: attempt,\n });\n\n if (response.ok) {\n return {\n data: responseBody as T,\n status: response.status,\n headers: responseHeaders,\n rateLimitInfo: parseRateLimitHeaders(responseHeaders),\n };\n }\n\n const shouldRetry = this.canRetry(\n attempt,\n method,\n headers,\n RETRYABLE_STATUS_CODES.has(response.status),\n );\n\n lastError = this.mapError(response.status, responseBody, responseHeaders);\n\n if (!shouldRetry) {\n throw lastError;\n }\n } catch (err) {\n if (err instanceof TriqaiError) {\n const canRetry = this.canRetry(\n attempt,\n method,\n headers,\n RETRYABLE_STATUS_CODES.has(err.statusCode),\n );\n if (!canRetry) {\n throw err;\n }\n lastError = err;\n continue;\n }\n\n if (err instanceof DOMException && err.name === \"AbortError\") {\n lastError = new TimeoutError(\n `Request timed out after ${this.timeout}ms: ${method} ${path}`,\n );\n if (!this.canRetry(attempt, method, headers, true)) {\n throw lastError;\n }\n continue;\n }\n\n if (isNetworkError(err)) {\n lastError = new ConnectionError(\n `Network error: ${err instanceof Error ? err.message : String(err)}`,\n );\n if (!this.canRetry(attempt, method, headers, true)) {\n throw lastError;\n }\n continue;\n }\n\n throw err;\n }\n }\n\n throw lastError ?? new TriqaiError(\"Request failed after retries\", 0);\n }\n\n /**\n * Variant that injects custom headers (used by resources for Idempotency-Key etc.).\n */\n async postWithHeaders<T>(\n path: string,\n body: unknown,\n headers: Record<string, string>,\n query?: Record<string, unknown>,\n ): Promise<HttpResponse<T>> {\n return this.request<T>(\"POST\", path, body, query, headers);\n }\n\n private buildUrl(path: string, query?: Record<string, unknown>): string {\n const isAbsoluteUrl = /^https?:\\/\\//i.test(path);\n const normalizedPath = path.startsWith(\"/\") ? path : `/${path}`;\n const base = isAbsoluteUrl ? path : `${this.baseUrl}${normalizedPath}`;\n if (!query) return base;\n\n const params = new URLSearchParams();\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined && v !== null) {\n if (v instanceof Date) {\n params.set(k, v.toISOString());\n } else {\n params.set(k, String(v));\n }\n }\n }\n const qs = params.toString();\n return qs ? `${base}?${qs}` : base;\n }\n\n private calculateDelay(attempt: number, lastError?: Error): number {\n if (lastError instanceof RateLimitError && lastError.rateLimitInfo.retryAfter) {\n return lastError.rateLimitInfo.retryAfter * 1000;\n }\n if (lastError instanceof ServiceUnavailableError && lastError.retryAfter) {\n return lastError.retryAfter * 1000;\n }\n const exponential = this.retryDelay * Math.pow(2, attempt - 1);\n const jitter = exponential * 0.2 * Math.random();\n return Math.min(exponential + jitter, this.maxRetryDelay);\n }\n\n private canRetry(\n attempt: number,\n method: string,\n headers: Record<string, string>,\n retryableSignal: boolean,\n ): boolean {\n return (\n retryableSignal &&\n attempt < this.maxRetries &&\n isIdempotent(method, headers)\n );\n }\n\n private mapError(\n status: number,\n body: unknown,\n headers: Record<string, string>,\n ): TriqaiError {\n const parsed = parseErrorBody(body);\n const opts = {\n code: parsed.code,\n requestId: parsed.requestId,\n rawError: parsed.error,\n meta: parsed.meta,\n };\n\n switch (status) {\n case 401:\n return new AuthenticationError(parsed.message, opts);\n case 402:\n return new InsufficientCreditsError(parsed.message, opts);\n case 403:\n return new AuthorizationError(parsed.message, opts);\n case 404:\n return new NotFoundError(parsed.message, opts);\n case 499:\n return new ClientDisconnectedError(parsed.message, opts);\n case 409: {\n const details = (parsed.error?.details ?? {}) as\n { state?: \"in_progress\" | \"completed\"; requestId?: string; retryAfterSeconds?: number };\n return new DuplicateRequestError(parsed.message, {\n ...opts,\n state: details?.state,\n duplicateRequestId: details?.requestId,\n retryAfter: details?.retryAfterSeconds,\n });\n }\n case 422: {\n const fieldErrors = (parsed.error?.details as { fieldErrors?: Record<string, string[]> } | undefined)\n ?.fieldErrors;\n return new ValidationError(parsed.message, fieldErrors, opts);\n }\n case 429:\n return new RateLimitError(\n parsed.message,\n parseRateLimitHeaders(headers),\n opts,\n );\n case 503: {\n const retryAfter = parseRetryAfterHeader(headers[\"retry-after\"]);\n return new ServiceUnavailableError(parsed.message, retryAfter, opts);\n }\n case 504:\n return new GatewayTimeoutError(parsed.message, opts);\n default:\n if (status >= 500) {\n return new InternalServerError(parsed.message, opts);\n }\n return new TriqaiError(parsed.message, status, opts);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction parseHeaders(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n out[key.toLowerCase()] = value;\n });\n return out;\n}\n\nfunction parseRateLimitHeaders(headers: Record<string, string>): RateLimitInfo {\n return {\n limit: maybeInt(headers[\"x-ratelimit-limit\"]),\n remaining: maybeInt(headers[\"x-ratelimit-remaining\"]),\n reset: headers[\"x-ratelimit-reset\"] ?? undefined,\n scope: headers[\"x-ratelimit-scope\"] as RateLimitInfo[\"scope\"],\n concurrencyLimit: maybeInt(headers[\"x-ratelimit-concurrency-limit\"]),\n concurrencyRemaining: maybeInt(headers[\"x-ratelimit-concurrency-remaining\"]),\n retryAfter: parseRetryAfterHeader(headers[\"retry-after\"]),\n };\n}\n\nfunction maybeInt(val: string | undefined): number | undefined {\n if (val === undefined) return undefined;\n const n = parseInt(val, 10);\n return Number.isNaN(n) ? undefined : n;\n}\n\nfunction parseRetryAfterHeader(val: string | undefined): number | undefined {\n if (val === undefined) return undefined;\n\n const seconds = maybeInt(val);\n if (seconds !== undefined && seconds >= 0) {\n return seconds;\n }\n\n const timestamp = Date.parse(val);\n if (Number.isNaN(timestamp)) {\n return undefined;\n }\n\n const secondsUntil = Math.ceil((timestamp - Date.now()) / 1000);\n return Math.max(secondsUntil, 0);\n}\n\ninterface ParsedError {\n message: string;\n code: string;\n requestId: string | undefined;\n error: RawErrorObject | undefined;\n meta: RawResponseMeta | undefined;\n}\n\nfunction parseErrorBody(body: unknown): ParsedError {\n if (!body || typeof body !== \"object\") {\n return {\n message: \"Unknown error\",\n code: \"unknown_error\",\n requestId: undefined,\n error: undefined,\n meta: undefined,\n };\n }\n\n const b = body as Record<string, unknown>;\n const error = b.error as { code?: string; message?: string; details?: Record<string, unknown> } | undefined;\n const meta = b.meta as Record<string, unknown> | undefined;\n\n return {\n message: error?.message ?? \"Unknown error\",\n code: error?.code ?? \"unknown_error\",\n requestId: meta?.requestId as string | undefined,\n error: error?.code\n ? { code: error.code, message: error.message ?? \"Unknown error\", details: error.details }\n : undefined,\n meta: meta?.generatedAt\n ? (meta as RawResponseMeta)\n : undefined,\n };\n}\n\nfunction isIdempotent(method: string, headers: Record<string, string>): boolean {\n if (method === \"GET\" || method === \"DELETE\") return true;\n const normalized = normalizeHeaderKeyMap(headers);\n if (normalized.has(\"idempotency-key\") || normalized.has(\"x-idempotency-key\")) {\n return true;\n }\n return false;\n}\n\nfunction normalizeHeaderKeyMap(headers: Record<string, string>): Set<string> {\n return new Set(Object.keys(headers).map((key) => key.toLowerCase()));\n}\n\nfunction isNetworkError(err: unknown): boolean {\n if (!(err instanceof Error)) return false;\n\n const message = err.message.toLowerCase();\n const hasNetworkSignal =\n message.includes(\"fetch\") ||\n message.includes(\"network\") ||\n message.includes(\"econnreset\") ||\n message.includes(\"enotfound\") ||\n message.includes(\"econnrefused\") ||\n message.includes(\"etimedout\");\n\n if (err instanceof TypeError) {\n return hasNetworkSignal;\n }\n\n if (err.name === \"NetworkError\") {\n return true;\n }\n\n if (err.cause instanceof Error) {\n const causeMessage = err.cause.message.toLowerCase();\n return (\n causeMessage.includes(\"fetch\") ||\n causeMessage.includes(\"network\") ||\n causeMessage.includes(\"econnreset\") ||\n causeMessage.includes(\"enotfound\") ||\n causeMessage.includes(\"econnrefused\") ||\n causeMessage.includes(\"etimedout\")\n );\n }\n\n return false;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { CategoryInfo, CategoryListResponse } from \"../types/index.js\";\n\nexport class Categories {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * List all available transaction categories.\n *\n * Returns the full category tree used for transaction classification,\n * including MCC, SIC, and NAICS codes.\n *\n * @returns Array of category info objects and the total count.\n *\n * @example\n * ```ts\n * const { categories, total } = await triqai.categories.list();\n * console.log(`${total} categories available`);\n * ```\n */\n async list(): Promise<{ categories: CategoryInfo[]; total: number; categoryVersion: string }> {\n const resp = await this.http.get<CategoryListResponse>(\"/v1/categories\");\n return {\n categories: resp.data.data.categories,\n total: resp.data.data.total,\n categoryVersion: resp.data.meta.categoryVersion,\n };\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { IntermediaryData, IntermediaryResponse } from \"../types/index.js\";\n\nexport class Intermediaries {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get an intermediary (payment processor / platform) by ID.\n *\n * @param id - Intermediary UUID.\n * @returns The intermediary data (name, icon, description, website, domain, etc.).\n *\n * @example\n * ```ts\n * const intermediary = await triqai.intermediaries.get(\"550e8400-...\");\n * console.log(intermediary.name); // \"PayPal\", \"Square\", etc.\n * ```\n */\n async get(id: string): Promise<IntermediaryData> {\n const resp = await this.http.get<IntermediaryResponse>(\n `/v1/intermediaries/${encodeURIComponent(id)}`,\n );\n return resp.data.data.intermediary;\n }\n}\n","/**\n * Pagination helpers for list endpoints.\n *\n * Provides a `Page<T>` type with metadata and an `autoPaginate()` method\n * that returns an async iterator walking through all pages automatically.\n */\n\nexport interface PageInfo {\n page: number;\n size: number;\n total: number;\n totalPages: number;\n}\n\nexport class Page<T> {\n readonly data: T[];\n readonly pageInfo: PageInfo;\n\n private readonly _fetchPage: (page: number, size: number) => Promise<Page<T>>;\n\n constructor(\n data: T[],\n pageInfo: PageInfo,\n fetchPage: (page: number, size: number) => Promise<Page<T>>,\n ) {\n this.data = data;\n this.pageInfo = pageInfo;\n this._fetchPage = fetchPage;\n }\n\n get hasNextPage(): boolean {\n return this.pageInfo.page < this.pageInfo.totalPages;\n }\n\n get hasPreviousPage(): boolean {\n return this.pageInfo.page > 1;\n }\n\n async nextPage(): Promise<Page<T>> {\n if (!this.hasNextPage) {\n return new Page<T>([], this.pageInfo, this._fetchPage);\n }\n return this._fetchPage(this.pageInfo.page + 1, this.pageInfo.size);\n }\n\n async previousPage(): Promise<Page<T>> {\n if (!this.hasPreviousPage) {\n return new Page<T>([], this.pageInfo, this._fetchPage);\n }\n return this._fetchPage(this.pageInfo.page - 1, this.pageInfo.size);\n }\n\n /**\n * Returns an async iterator that yields every item across all pages,\n * starting from the current page.\n *\n * ```ts\n * for await (const item of page.autoPaginate()) {\n * console.log(item);\n * }\n * ```\n */\n async *autoPaginate(): AsyncGenerator<T, void, unknown> {\n let current: Page<T> = this;\n while (true) {\n for (const item of current.data) {\n yield item;\n }\n if (!current.hasNextPage) break;\n current = await current.nextPage();\n }\n }\n\n /**\n * Symbol.asyncIterator so `Page` itself can be used in `for await...of`.\n */\n [Symbol.asyncIterator](): AsyncIterableIterator<T> {\n return this.autoPaginate();\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport { Page } from \"../pagination.js\";\nimport type {\n EnrichmentFieldPath,\n IssueReport,\n IssueReportListResponse,\n IssueReportResponse,\n ListIssueReportsParams,\n} from \"../types/index.js\";\n\nexport interface CreateIssueReportParams {\n /** The transaction ID to report an issue for. */\n transactionId: string;\n /** A description of what is wrong with the enrichment result. */\n description: string;\n /** Which enrichment fields are incorrect. */\n fields: EnrichmentFieldPath[];\n}\n\nexport class IssueReports {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Report an issue with an enrichment result.\n *\n * @param params - The issue report details.\n * @returns The created issue report.\n *\n * @example\n * ```ts\n * const report = await triqai.issueReports.create({\n * transactionId: \"tx-uuid\",\n * description: \"Merchant was identified incorrectly\",\n * fields: [\"entities.merchant.data.name\"],\n * });\n * console.log(report.id, report.status);\n * ```\n */\n async create(params: CreateIssueReportParams): Promise<IssueReport> {\n const resp = await this.http.post<IssueReportResponse>(\"/v1/report-issue\", {\n transaction_id: params.transactionId,\n description: params.description,\n fields: params.fields,\n });\n return resp.data.data.issueReport;\n }\n\n /**\n * List issue reports with pagination.\n *\n * @returns A `Page` of issue reports. Use `.autoPaginate()` or\n * `for await...of` to iterate through all pages automatically.\n *\n * @example\n * ```ts\n * const page = await triqai.issueReports.list({ status: \"pending\" });\n * for (const report of page.data) {\n * console.log(report.id, report.status);\n * }\n * ```\n */\n async list(params?: ListIssueReportsParams): Promise<Page<IssueReport>> {\n const fetchPage = async (page: number, size: number): Promise<Page<IssueReport>> => {\n const query: Record<string, unknown> = { page, size };\n if (params?.status) query.status = params.status;\n if (params?.transactionId) query.transaction_id = params.transactionId;\n\n const resp = await this.http.get<IssueReportListResponse>(\"/v1/report-issue\", query);\n const pageInfo = {\n page: resp.data.meta.page,\n size: resp.data.meta.size,\n total: resp.data.meta.total,\n totalPages: resp.data.meta.totalPages,\n };\n return new Page(resp.data.data, pageInfo, fetchPage);\n };\n\n return fetchPage(params?.page ?? 1, params?.size ?? 25);\n }\n\n /**\n * Get a single issue report by ID.\n *\n * @param id - Issue report UUID.\n * @returns The issue report details.\n */\n async get(id: string): Promise<IssueReport> {\n const resp = await this.http.get<IssueReportResponse>(\n `/v1/report-issue/${encodeURIComponent(id)}`,\n );\n return resp.data.data.issueReport;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { LocationData, LocationResponse } from \"../types/index.js\";\n\nexport class Locations {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get a location by ID.\n *\n * @param id - Location UUID.\n * @returns The location data (name, formatted address, coordinates, phone, rating, etc.).\n *\n * @example\n * ```ts\n * const location = await triqai.locations.get(\"550e8400-e29b-41d4-a716-446655440000\");\n * console.log(location.formatted, location.structured.city);\n * ```\n */\n async get(id: string): Promise<LocationData> {\n const resp = await this.http.get<LocationResponse>(\n `/v1/locations/${encodeURIComponent(id)}`,\n );\n return resp.data.data.location;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { MerchantData, MerchantResponse } from \"../types/index.js\";\n\nexport class Merchants {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get a merchant by ID.\n *\n * @param id - Merchant UUID.\n * @returns The merchant data (name, icon, website, domain, aliases, etc.).\n *\n * @example\n * ```ts\n * const merchant = await triqai.merchants.get(\"550e8400-e29b-41d4-a716-446655440000\");\n * console.log(merchant.name, merchant.website);\n * ```\n */\n async get(id: string): Promise<MerchantData> {\n const resp = await this.http.get<MerchantResponse>(\n `/v1/merchants/${encodeURIComponent(id)}`,\n );\n return resp.data.data.merchant;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport { Page } from \"../pagination.js\";\nimport type {\n DeleteTransactionResponse,\n EnrichedTransaction,\n EnrichOptions,\n EnrichRequest,\n EnrichSuccessResponse,\n ListTransactionsParams,\n TransactionDetailResponse,\n TransactionListResponse,\n} from \"../types/index.js\";\n\nexport class Transactions {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Enrich a transaction with merchant, category, location, and entity data.\n *\n * @param request - The transaction to enrich (title, country, type, and optional options).\n * @param options - Optional enrichment controls (force bypass cache, idempotency key).\n * @returns The enriched transaction data.\n *\n * @example\n * ```ts\n * const result = await triqai.transactions.enrich({\n * title: \"STARBUCKS SEATTLE WA\",\n * country: \"US\",\n * type: \"expense\",\n * });\n * console.log(result.data.entities);\n * ```\n */\n async enrich(\n request: EnrichRequest,\n options?: EnrichOptions,\n ): Promise<EnrichSuccessResponse> {\n const headers: Record<string, string> = {};\n const query: Record<string, unknown> = {};\n\n if (options?.idempotencyKey) {\n headers[\"Idempotency-Key\"] = options.idempotencyKey;\n }\n if (options?.force) {\n query.force = \"true\";\n }\n\n const resp = await this.http.postWithHeaders<EnrichSuccessResponse>(\n \"/v1/transactions/enrich\",\n request,\n headers,\n Object.keys(query).length > 0 ? query : undefined,\n );\n return resp.data;\n }\n\n /**\n * List enriched transactions with pagination.\n *\n * @returns A `Page` of enriched transactions. Use `.autoPaginate()` or\n * `for await...of` to iterate through all pages automatically.\n *\n * @example\n * ```ts\n * const page = await triqai.transactions.list({ size: 10 });\n * console.log(page.data); // first 10 transactions\n *\n * // Auto-paginate through all:\n * for await (const tx of page) {\n * console.log(tx.id, tx.raw);\n * }\n * ```\n */\n async list(params?: ListTransactionsParams): Promise<Page<EnrichedTransaction>> {\n const fetchPage = async (page: number, size: number): Promise<Page<EnrichedTransaction>> => {\n const query: Record<string, unknown> = {\n page,\n size,\n };\n if (params?.startDate) {\n query.startDate =\n params.startDate instanceof Date\n ? params.startDate.toISOString()\n : params.startDate;\n }\n if (params?.endDate) {\n query.endDate =\n params.endDate instanceof Date\n ? params.endDate.toISOString()\n : params.endDate;\n }\n\n const resp = await this.http.get<TransactionListResponse>(\"/v1/transactions\", query);\n const { transactions, pagination } = resp.data.data;\n return new Page(transactions, pagination, fetchPage);\n };\n\n return fetchPage(params?.page ?? 1, params?.size ?? 25);\n }\n\n /**\n * Get a single transaction by ID.\n *\n * @param id - Transaction UUID.\n * @returns The enriched transaction record.\n */\n async get(id: string): Promise<EnrichedTransaction> {\n const resp = await this.http.get<TransactionDetailResponse>(\n `/v1/transactions/${encodeURIComponent(id)}`,\n );\n return resp.data.data.transaction;\n }\n\n /**\n * Delete a transaction by ID.\n *\n * @param id - Transaction UUID.\n * @returns Confirmation with the deleted transaction ID.\n */\n async delete(id: string): Promise<{ deleted: true; transactionId: string }> {\n const resp = await this.http.delete<DeleteTransactionResponse>(\n `/v1/transactions/${encodeURIComponent(id)}`,\n );\n return resp.data.data;\n }\n}\n","import type { HttpResponse } from \"./http-client.js\";\nimport { HttpClient } from \"./http-client.js\";\nimport { Categories } from \"./resources/categories.js\";\nimport { Intermediaries } from \"./resources/intermediaries.js\";\nimport { IssueReports } from \"./resources/issue-reports.js\";\nimport { Locations } from \"./resources/locations.js\";\nimport { Merchants } from \"./resources/merchants.js\";\nimport { Transactions } from \"./resources/transactions.js\";\nimport type {\n ApiInfoResponse,\n HealthResponse,\n TriqaiConfig,\n} from \"./types/index.js\";\n\n/**\n * The Triqai SDK client.\n *\n * @example\n * ```ts\n * import Triqai from \"triqai\";\n *\n * const triqai = new Triqai(\"triq_your_api_key\");\n *\n * const result = await triqai.transactions.enrich({\n * title: \"STARBUCKS SEATTLE WA\",\n * country: \"US\",\n * type: \"expense\",\n * });\n * ```\n */\nexport class Triqai {\n /** Enrich, list, get, and delete transactions. */\n readonly transactions: Transactions;\n /** List the full category taxonomy. */\n readonly categories: Categories;\n /** Look up merchant details by ID. */\n readonly merchants: Merchants;\n /** Look up location details by ID. */\n readonly locations: Locations;\n /** Look up intermediary (payment processor) details by ID. */\n readonly intermediaries: Intermediaries;\n /** Create and manage enrichment issue reports. */\n readonly issueReports: IssueReports;\n\n private readonly http: HttpClient;\n\n /**\n * Create a new Triqai SDK client.\n *\n * @param apiKey - Your Triqai API key (starts with `triq_`). Get one at https://triqai.com/dashboard\n * @param config - Optional configuration (base URL, retry settings, hooks).\n */\n constructor(apiKey: string, config?: TriqaiConfig) {\n this.http = new HttpClient(apiKey, config);\n this.transactions = new Transactions(this.http);\n this.categories = new Categories(this.http);\n this.merchants = new Merchants(this.http);\n this.locations = new Locations(this.http);\n this.intermediaries = new Intermediaries(this.http);\n this.issueReports = new IssueReports(this.http);\n }\n\n /**\n * Check the API health status.\n *\n * @returns Health status including service name and version.\n *\n * @example\n * ```ts\n * const health = await triqai.health();\n * console.log(health.data.status); // \"healthy\"\n * console.log(health.data.version); // \"1.1.9\"\n * ```\n */\n async health(): Promise<HealthResponse> {\n const resp = await this.http.get<HealthResponse>(\"/health\");\n return resp.data;\n }\n\n /**\n * Get API version and endpoint directory.\n *\n * @returns API version info and available endpoint paths.\n *\n * @example\n * ```ts\n * const info = await triqai.apiInfo();\n * console.log(info.data.version); // \"v1\"\n * console.log(info.data.endpoints);\n * ```\n */\n async apiInfo(): Promise<ApiInfoResponse> {\n const resp = await this.http.get<ApiInfoResponse>(\"/v1\");\n return resp.data;\n }\n\n /**\n * Make a raw GET request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-endpoint\").\n * @param query - Optional query parameters.\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawGet<T = unknown>(\n path: string,\n query?: Record<string, unknown>,\n ): Promise<HttpResponse<T>> {\n return this.http.get<T>(path, query);\n }\n\n /**\n * Make a raw POST request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-endpoint\").\n * @param body - Request body.\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawPost<T = unknown>(\n path: string,\n body?: unknown,\n ): Promise<HttpResponse<T>> {\n return this.http.post<T>(path, body);\n }\n\n /**\n * Make a raw DELETE request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-resource/uuid\").\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawDelete<T = unknown>(path: string): Promise<HttpResponse<T>> {\n return this.http.delete<T>(path);\n }\n}\n","import { Triqai } from \"./client.js\";\n\nexport { Triqai };\nexport default Triqai;\n\nexport {\n TriqaiError,\n AuthenticationError,\n AuthorizationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n ClientDisconnectedError,\n DuplicateRequestError,\n RateLimitError,\n InternalServerError,\n ServiceUnavailableError,\n GatewayTimeoutError,\n ConnectionError,\n TimeoutError,\n} from \"./errors.js\";\nexport type { RawErrorObject, RawResponseMeta } from \"./errors.js\";\n\nexport type { HttpResponse } from \"./http-client.js\";\n\nexport { Page } from \"./pagination.js\";\nexport type { PageInfo } from \"./pagination.js\";\n\nexport type { CreateIssueReportParams } from \"./resources/issue-reports.js\";\n\nexport type {\n // SDK config types\n TriqaiConfig,\n RequestInfo,\n ResponseInfo,\n RateLimitInfo,\n EnrichOptions,\n ListTransactionsParams,\n ListIssueReportsParams,\n // Enrichment request types\n EnrichRequest,\n EnrichRequestOptions,\n EnrichmentFilterOptions,\n PrefilledMerchant,\n PrefilledLocation,\n PrefilledIntermediary,\n // Enrichment response types\n EnrichSuccessResponse,\n EnrichmentData,\n EnrichMeta,\n EnrichmentErrorCode,\n // Transaction types\n TransactionData,\n TransactionType,\n TransactionRecord,\n EnrichedTransaction,\n TransactionPagination,\n TransactionListResponse,\n TransactionDetailResponse,\n DeleteTransactionResponse,\n // Category types\n CategoryStructure,\n Category,\n CategoryCode,\n CategoryInfo,\n CategoryListResponse,\n // Confidence / subscription\n ConfidenceWithReasons,\n Subscription,\n SubscriptionType,\n // Entity types\n EntityResult,\n MerchantData,\n LocationData,\n IntermediaryData,\n IntermediaryRecord,\n PersonData,\n Coordinates,\n StructuredAddress,\n LocationRating,\n // Entity response types\n MerchantResponse,\n LocationResponse,\n IntermediaryResponse,\n // Issue report types\n IssueReport,\n IssueReportStatus,\n IssueReportResponse,\n IssueReportListResponse,\n ReportIssueRequest,\n EnrichmentFieldPath,\n // Error response types\n ErrorResponse,\n ErrorObject,\n DuplicateRequestErrorResponse,\n ClientDisconnectedErrorResponse,\n // Meta types\n ResponseMeta,\n PaginationMeta,\n // Utility response types\n HealthResponse,\n ApiInfoResponse,\n} from \"./types/index.js\";\n"]}
package/dist/index.d.cts CHANGED
@@ -72,6 +72,7 @@ type components = {
72
72
  success: false;
73
73
  };
74
74
  ConfidenceWithReasons: {
75
+ /** @description Confidence explanation tags. This list is dynamic and may evolve over time. */
75
76
  reasons: string[];
76
77
  value: number;
77
78
  };
@@ -118,7 +119,7 @@ type components = {
118
119
  /** @enum {string} */
119
120
  EnrichmentErrorCode: "location_timeout" | "merchant_scrape_failed" | "processor_lookup_failed" | "rate_limited" | "internal_error" | "title_dissection_failed";
120
121
  /** @enum {string} */
121
- EnrichmentFieldPath: "transaction" | "transaction.category" | "transaction.category.primary" | "transaction.category.primary.name" | "transaction.category.primary.code" | "transaction.category.primary.code.mcc" | "transaction.category.primary.code.sic" | "transaction.category.primary.code.naics" | "transaction.category.secondary" | "transaction.category.secondary.name" | "transaction.category.secondary.code" | "transaction.category.secondary.code.mcc" | "transaction.category.secondary.code.sic" | "transaction.category.secondary.code.naics" | "transaction.category.tertiary" | "transaction.category.tertiary.name" | "transaction.category.tertiary.code" | "transaction.category.tertiary.code.mcc" | "transaction.category.tertiary.code.sic" | "transaction.category.tertiary.code.naics" | "transaction.category.confidence" | "transaction.subscription" | "transaction.subscription.recurring" | "transaction.subscription.type" | "transaction.channel" | "transaction.confidence" | "entities" | "entities.merchant" | "entities.merchant.data" | "entities.merchant.data.name" | "entities.merchant.data.icon" | "entities.merchant.data.website" | "entities.merchant.data.description" | "entities.location" | "entities.location.data" | "entities.location.data.name" | "entities.location.data.formatted" | "entities.location.data.structured" | "entities.location.data.structured.city" | "entities.location.data.structured.country" | "entities.intermediary" | "entities.intermediary.data" | "entities.intermediary.data.name" | "entities.intermediary.data.icon" | "entities.person" | "entities.person.data" | "entities.person.data.displayName";
122
+ EnrichmentFieldPath: "transaction" | "transaction.category" | "transaction.category.primary" | "transaction.category.primary.name" | "transaction.category.primary.code" | "transaction.category.primary.code.mcc" | "transaction.category.primary.code.sic" | "transaction.category.primary.code.naics" | "transaction.category.secondary" | "transaction.category.secondary.name" | "transaction.category.secondary.code" | "transaction.category.secondary.code.mcc" | "transaction.category.secondary.code.sic" | "transaction.category.secondary.code.naics" | "transaction.category.tertiary" | "transaction.category.tertiary.name" | "transaction.category.tertiary.code" | "transaction.category.tertiary.code.mcc" | "transaction.category.tertiary.code.sic" | "transaction.category.tertiary.code.naics" | "transaction.category.confidence" | "transaction.subscription" | "transaction.subscription.recurring" | "transaction.subscription.type" | "transaction.confidence" | "entities" | "entities.merchant" | "entities.merchant.data" | "entities.merchant.data.name" | "entities.merchant.data.icon" | "entities.merchant.data.website" | "entities.merchant.data.description" | "entities.location" | "entities.location.data" | "entities.location.data.name" | "entities.location.data.formatted" | "entities.location.data.structured" | "entities.location.data.structured.city" | "entities.location.data.structured.country" | "entities.intermediary" | "entities.intermediary.data" | "entities.intermediary.data.name" | "entities.intermediary.data.icon" | "entities.person" | "entities.person.data" | "entities.person.data.displayName";
122
123
  /** @description Disable extraction of specific entity types from the transaction title. */
123
124
  EnrichmentFilterOptions: {
124
125
  /** @description When `true`, intermediary (payment processor) extraction is skipped. */
@@ -395,11 +396,8 @@ type components = {
395
396
  };
396
397
  /** @enum {string} */
397
398
  SubscriptionType: "streaming" | "software" | "news" | "fitness" | "mobile" | "gaming" | "utilities" | "other";
398
- /** @enum {string} */
399
- TransactionChannel: "in_store" | "online" | "mobile_app" | "atm" | "bank_transfer" | "unknown";
400
399
  TransactionData: {
401
400
  category: components["schemas"]["CategoryStructure"];
402
- channel: components["schemas"]["TransactionChannel"];
403
401
  confidence: components["schemas"]["ConfidenceWithReasons"];
404
402
  subscription: components["schemas"]["Subscription"];
405
403
  };
@@ -673,7 +671,6 @@ type EnrichmentData = components["schemas"]["EnrichmentData"];
673
671
  type EnrichMeta = components["schemas"]["EnrichMeta"];
674
672
  type TransactionData = components["schemas"]["TransactionData"];
675
673
  type TransactionType = components["schemas"]["TransactionType"];
676
- type TransactionChannel = components["schemas"]["TransactionChannel"];
677
674
  type TransactionRecord = components["schemas"]["TransactionRecord"];
678
675
  type EnrichedTransaction = components["schemas"]["EnrichedTransaction"];
679
676
  type TransactionPagination = components["schemas"]["TransactionPagination"];
@@ -1203,4 +1200,4 @@ declare class TimeoutError extends TriqaiError {
1203
1200
  constructor(message: string);
1204
1201
  }
1205
1202
 
1206
- export { type ApiInfoResponse, AuthenticationError, AuthorizationError, type Category, type CategoryCode, type CategoryInfo, type CategoryListResponse, type CategoryStructure, ClientDisconnectedError, type ClientDisconnectedErrorResponse, type ConfidenceWithReasons, ConnectionError, type Coordinates, type CreateIssueReportParams, type DeleteTransactionResponse, DuplicateRequestError, type DuplicateRequestErrorResponse, type EnrichMeta, type EnrichOptions, type EnrichRequest, type EnrichRequestOptions, type EnrichSuccessResponse, type EnrichedTransaction, type EnrichmentData, type EnrichmentErrorCode, type EnrichmentFieldPath, type EnrichmentFilterOptions, type EntityResult, type ErrorObject, type ErrorResponse, GatewayTimeoutError, type HealthResponse, type HttpResponse, InsufficientCreditsError, type IntermediaryData, type IntermediaryRecord, type IntermediaryResponse, InternalServerError, type IssueReport, type IssueReportListResponse, type IssueReportResponse, type IssueReportStatus, type ListIssueReportsParams, type ListTransactionsParams, type LocationData, type LocationRating, type LocationResponse, type MerchantData, type MerchantResponse, NotFoundError, Page, type PageInfo, type PaginationMeta, type PersonData, type PrefilledIntermediary, type PrefilledLocation, type PrefilledMerchant, RateLimitError, type RateLimitInfo, type RawErrorObject, type RawResponseMeta, type ReportIssueRequest, type RequestInfo, type ResponseInfo, type ResponseMeta, ServiceUnavailableError, type StructuredAddress, type Subscription, type SubscriptionType, TimeoutError, type TransactionChannel, type TransactionData, type TransactionDetailResponse, type TransactionListResponse, type TransactionPagination, type TransactionRecord, type TransactionType, Triqai, type TriqaiConfig, TriqaiError, ValidationError, Triqai as default };
1203
+ export { type ApiInfoResponse, AuthenticationError, AuthorizationError, type Category, type CategoryCode, type CategoryInfo, type CategoryListResponse, type CategoryStructure, ClientDisconnectedError, type ClientDisconnectedErrorResponse, type ConfidenceWithReasons, ConnectionError, type Coordinates, type CreateIssueReportParams, type DeleteTransactionResponse, DuplicateRequestError, type DuplicateRequestErrorResponse, type EnrichMeta, type EnrichOptions, type EnrichRequest, type EnrichRequestOptions, type EnrichSuccessResponse, type EnrichedTransaction, type EnrichmentData, type EnrichmentErrorCode, type EnrichmentFieldPath, type EnrichmentFilterOptions, type EntityResult, type ErrorObject, type ErrorResponse, GatewayTimeoutError, type HealthResponse, type HttpResponse, InsufficientCreditsError, type IntermediaryData, type IntermediaryRecord, type IntermediaryResponse, InternalServerError, type IssueReport, type IssueReportListResponse, type IssueReportResponse, type IssueReportStatus, type ListIssueReportsParams, type ListTransactionsParams, type LocationData, type LocationRating, type LocationResponse, type MerchantData, type MerchantResponse, NotFoundError, Page, type PageInfo, type PaginationMeta, type PersonData, type PrefilledIntermediary, type PrefilledLocation, type PrefilledMerchant, RateLimitError, type RateLimitInfo, type RawErrorObject, type RawResponseMeta, type ReportIssueRequest, type RequestInfo, type ResponseInfo, type ResponseMeta, ServiceUnavailableError, type StructuredAddress, type Subscription, type SubscriptionType, TimeoutError, type TransactionData, type TransactionDetailResponse, type TransactionListResponse, type TransactionPagination, type TransactionRecord, type TransactionType, Triqai, type TriqaiConfig, TriqaiError, ValidationError, Triqai as default };
package/dist/index.d.ts CHANGED
@@ -72,6 +72,7 @@ type components = {
72
72
  success: false;
73
73
  };
74
74
  ConfidenceWithReasons: {
75
+ /** @description Confidence explanation tags. This list is dynamic and may evolve over time. */
75
76
  reasons: string[];
76
77
  value: number;
77
78
  };
@@ -118,7 +119,7 @@ type components = {
118
119
  /** @enum {string} */
119
120
  EnrichmentErrorCode: "location_timeout" | "merchant_scrape_failed" | "processor_lookup_failed" | "rate_limited" | "internal_error" | "title_dissection_failed";
120
121
  /** @enum {string} */
121
- EnrichmentFieldPath: "transaction" | "transaction.category" | "transaction.category.primary" | "transaction.category.primary.name" | "transaction.category.primary.code" | "transaction.category.primary.code.mcc" | "transaction.category.primary.code.sic" | "transaction.category.primary.code.naics" | "transaction.category.secondary" | "transaction.category.secondary.name" | "transaction.category.secondary.code" | "transaction.category.secondary.code.mcc" | "transaction.category.secondary.code.sic" | "transaction.category.secondary.code.naics" | "transaction.category.tertiary" | "transaction.category.tertiary.name" | "transaction.category.tertiary.code" | "transaction.category.tertiary.code.mcc" | "transaction.category.tertiary.code.sic" | "transaction.category.tertiary.code.naics" | "transaction.category.confidence" | "transaction.subscription" | "transaction.subscription.recurring" | "transaction.subscription.type" | "transaction.channel" | "transaction.confidence" | "entities" | "entities.merchant" | "entities.merchant.data" | "entities.merchant.data.name" | "entities.merchant.data.icon" | "entities.merchant.data.website" | "entities.merchant.data.description" | "entities.location" | "entities.location.data" | "entities.location.data.name" | "entities.location.data.formatted" | "entities.location.data.structured" | "entities.location.data.structured.city" | "entities.location.data.structured.country" | "entities.intermediary" | "entities.intermediary.data" | "entities.intermediary.data.name" | "entities.intermediary.data.icon" | "entities.person" | "entities.person.data" | "entities.person.data.displayName";
122
+ EnrichmentFieldPath: "transaction" | "transaction.category" | "transaction.category.primary" | "transaction.category.primary.name" | "transaction.category.primary.code" | "transaction.category.primary.code.mcc" | "transaction.category.primary.code.sic" | "transaction.category.primary.code.naics" | "transaction.category.secondary" | "transaction.category.secondary.name" | "transaction.category.secondary.code" | "transaction.category.secondary.code.mcc" | "transaction.category.secondary.code.sic" | "transaction.category.secondary.code.naics" | "transaction.category.tertiary" | "transaction.category.tertiary.name" | "transaction.category.tertiary.code" | "transaction.category.tertiary.code.mcc" | "transaction.category.tertiary.code.sic" | "transaction.category.tertiary.code.naics" | "transaction.category.confidence" | "transaction.subscription" | "transaction.subscription.recurring" | "transaction.subscription.type" | "transaction.confidence" | "entities" | "entities.merchant" | "entities.merchant.data" | "entities.merchant.data.name" | "entities.merchant.data.icon" | "entities.merchant.data.website" | "entities.merchant.data.description" | "entities.location" | "entities.location.data" | "entities.location.data.name" | "entities.location.data.formatted" | "entities.location.data.structured" | "entities.location.data.structured.city" | "entities.location.data.structured.country" | "entities.intermediary" | "entities.intermediary.data" | "entities.intermediary.data.name" | "entities.intermediary.data.icon" | "entities.person" | "entities.person.data" | "entities.person.data.displayName";
122
123
  /** @description Disable extraction of specific entity types from the transaction title. */
123
124
  EnrichmentFilterOptions: {
124
125
  /** @description When `true`, intermediary (payment processor) extraction is skipped. */
@@ -395,11 +396,8 @@ type components = {
395
396
  };
396
397
  /** @enum {string} */
397
398
  SubscriptionType: "streaming" | "software" | "news" | "fitness" | "mobile" | "gaming" | "utilities" | "other";
398
- /** @enum {string} */
399
- TransactionChannel: "in_store" | "online" | "mobile_app" | "atm" | "bank_transfer" | "unknown";
400
399
  TransactionData: {
401
400
  category: components["schemas"]["CategoryStructure"];
402
- channel: components["schemas"]["TransactionChannel"];
403
401
  confidence: components["schemas"]["ConfidenceWithReasons"];
404
402
  subscription: components["schemas"]["Subscription"];
405
403
  };
@@ -673,7 +671,6 @@ type EnrichmentData = components["schemas"]["EnrichmentData"];
673
671
  type EnrichMeta = components["schemas"]["EnrichMeta"];
674
672
  type TransactionData = components["schemas"]["TransactionData"];
675
673
  type TransactionType = components["schemas"]["TransactionType"];
676
- type TransactionChannel = components["schemas"]["TransactionChannel"];
677
674
  type TransactionRecord = components["schemas"]["TransactionRecord"];
678
675
  type EnrichedTransaction = components["schemas"]["EnrichedTransaction"];
679
676
  type TransactionPagination = components["schemas"]["TransactionPagination"];
@@ -1203,4 +1200,4 @@ declare class TimeoutError extends TriqaiError {
1203
1200
  constructor(message: string);
1204
1201
  }
1205
1202
 
1206
- export { type ApiInfoResponse, AuthenticationError, AuthorizationError, type Category, type CategoryCode, type CategoryInfo, type CategoryListResponse, type CategoryStructure, ClientDisconnectedError, type ClientDisconnectedErrorResponse, type ConfidenceWithReasons, ConnectionError, type Coordinates, type CreateIssueReportParams, type DeleteTransactionResponse, DuplicateRequestError, type DuplicateRequestErrorResponse, type EnrichMeta, type EnrichOptions, type EnrichRequest, type EnrichRequestOptions, type EnrichSuccessResponse, type EnrichedTransaction, type EnrichmentData, type EnrichmentErrorCode, type EnrichmentFieldPath, type EnrichmentFilterOptions, type EntityResult, type ErrorObject, type ErrorResponse, GatewayTimeoutError, type HealthResponse, type HttpResponse, InsufficientCreditsError, type IntermediaryData, type IntermediaryRecord, type IntermediaryResponse, InternalServerError, type IssueReport, type IssueReportListResponse, type IssueReportResponse, type IssueReportStatus, type ListIssueReportsParams, type ListTransactionsParams, type LocationData, type LocationRating, type LocationResponse, type MerchantData, type MerchantResponse, NotFoundError, Page, type PageInfo, type PaginationMeta, type PersonData, type PrefilledIntermediary, type PrefilledLocation, type PrefilledMerchant, RateLimitError, type RateLimitInfo, type RawErrorObject, type RawResponseMeta, type ReportIssueRequest, type RequestInfo, type ResponseInfo, type ResponseMeta, ServiceUnavailableError, type StructuredAddress, type Subscription, type SubscriptionType, TimeoutError, type TransactionChannel, type TransactionData, type TransactionDetailResponse, type TransactionListResponse, type TransactionPagination, type TransactionRecord, type TransactionType, Triqai, type TriqaiConfig, TriqaiError, ValidationError, Triqai as default };
1203
+ export { type ApiInfoResponse, AuthenticationError, AuthorizationError, type Category, type CategoryCode, type CategoryInfo, type CategoryListResponse, type CategoryStructure, ClientDisconnectedError, type ClientDisconnectedErrorResponse, type ConfidenceWithReasons, ConnectionError, type Coordinates, type CreateIssueReportParams, type DeleteTransactionResponse, DuplicateRequestError, type DuplicateRequestErrorResponse, type EnrichMeta, type EnrichOptions, type EnrichRequest, type EnrichRequestOptions, type EnrichSuccessResponse, type EnrichedTransaction, type EnrichmentData, type EnrichmentErrorCode, type EnrichmentFieldPath, type EnrichmentFilterOptions, type EntityResult, type ErrorObject, type ErrorResponse, GatewayTimeoutError, type HealthResponse, type HttpResponse, InsufficientCreditsError, type IntermediaryData, type IntermediaryRecord, type IntermediaryResponse, InternalServerError, type IssueReport, type IssueReportListResponse, type IssueReportResponse, type IssueReportStatus, type ListIssueReportsParams, type ListTransactionsParams, type LocationData, type LocationRating, type LocationResponse, type MerchantData, type MerchantResponse, NotFoundError, Page, type PageInfo, type PaginationMeta, type PersonData, type PrefilledIntermediary, type PrefilledLocation, type PrefilledMerchant, RateLimitError, type RateLimitInfo, type RawErrorObject, type RawResponseMeta, type ReportIssueRequest, type RequestInfo, type ResponseInfo, type ResponseMeta, ServiceUnavailableError, type StructuredAddress, type Subscription, type SubscriptionType, TimeoutError, type TransactionData, type TransactionDetailResponse, type TransactionListResponse, type TransactionPagination, type TransactionRecord, type TransactionType, Triqai, type TriqaiConfig, TriqaiError, ValidationError, Triqai as default };
package/dist/index.js CHANGED
@@ -118,7 +118,7 @@ var DEFAULT_RETRY_DELAY = 500;
118
118
  var DEFAULT_MAX_RETRY_DELAY = 3e4;
119
119
  var DEFAULT_TIMEOUT = 6e4;
120
120
  var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 503, 504]);
121
- var SDK_VERSION = "0.1.0";
121
+ var SDK_VERSION = "0.1.1";
122
122
  var HttpClient = class {
123
123
  apiKey;
124
124
  baseUrl;
@@ -260,7 +260,9 @@ var HttpClient = class {
260
260
  return this.request("POST", path, body, query, headers);
261
261
  }
262
262
  buildUrl(path, query) {
263
- const base = `${this.baseUrl}${path}`;
263
+ const isAbsoluteUrl = /^https?:\/\//i.test(path);
264
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
265
+ const base = isAbsoluteUrl ? path : `${this.baseUrl}${normalizedPath}`;
264
266
  if (!query) return base;
265
267
  const params = new URLSearchParams();
266
268
  for (const [k, v] of Object.entries(query)) {
@@ -328,7 +330,7 @@ var HttpClient = class {
328
330
  opts
329
331
  );
330
332
  case 503: {
331
- const retryAfter = headers["retry-after"] ? parseInt(headers["retry-after"], 10) : void 0;
333
+ const retryAfter = parseRetryAfterHeader(headers["retry-after"]);
332
334
  return new ServiceUnavailableError(parsed.message, retryAfter, opts);
333
335
  }
334
336
  case 504:
@@ -356,7 +358,7 @@ function parseRateLimitHeaders(headers) {
356
358
  scope: headers["x-ratelimit-scope"],
357
359
  concurrencyLimit: maybeInt(headers["x-ratelimit-concurrency-limit"]),
358
360
  concurrencyRemaining: maybeInt(headers["x-ratelimit-concurrency-remaining"]),
359
- retryAfter: maybeInt(headers["retry-after"])
361
+ retryAfter: parseRetryAfterHeader(headers["retry-after"])
360
362
  };
361
363
  }
362
364
  function maybeInt(val) {
@@ -364,6 +366,19 @@ function maybeInt(val) {
364
366
  const n = parseInt(val, 10);
365
367
  return Number.isNaN(n) ? void 0 : n;
366
368
  }
369
+ function parseRetryAfterHeader(val) {
370
+ if (val === void 0) return void 0;
371
+ const seconds = maybeInt(val);
372
+ if (seconds !== void 0 && seconds >= 0) {
373
+ return seconds;
374
+ }
375
+ const timestamp = Date.parse(val);
376
+ if (Number.isNaN(timestamp)) {
377
+ return void 0;
378
+ }
379
+ const secondsUntil = Math.ceil((timestamp - Date.now()) / 1e3);
380
+ return Math.max(secondsUntil, 0);
381
+ }
367
382
  function parseErrorBody(body) {
368
383
  if (!body || typeof body !== "object") {
369
384
  return {
@@ -397,8 +412,19 @@ function normalizeHeaderKeyMap(headers) {
397
412
  return new Set(Object.keys(headers).map((key) => key.toLowerCase()));
398
413
  }
399
414
  function isNetworkError(err) {
400
- if (err instanceof TypeError) return true;
401
- if (err instanceof Error && err.message.includes("fetch")) return true;
415
+ if (!(err instanceof Error)) return false;
416
+ const message = err.message.toLowerCase();
417
+ const hasNetworkSignal = message.includes("fetch") || message.includes("network") || message.includes("econnreset") || message.includes("enotfound") || message.includes("econnrefused") || message.includes("etimedout");
418
+ if (err instanceof TypeError) {
419
+ return hasNetworkSignal;
420
+ }
421
+ if (err.name === "NetworkError") {
422
+ return true;
423
+ }
424
+ if (err.cause instanceof Error) {
425
+ const causeMessage = err.cause.message.toLowerCase();
426
+ return causeMessage.includes("fetch") || causeMessage.includes("network") || causeMessage.includes("econnreset") || causeMessage.includes("enotfound") || causeMessage.includes("econnrefused") || causeMessage.includes("etimedout");
427
+ }
402
428
  return false;
403
429
  }
404
430
  function sleep(ms) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/http-client.ts","../src/resources/categories.ts","../src/resources/intermediaries.ts","../src/pagination.ts","../src/resources/issue-reports.ts","../src/resources/locations.ts","../src/resources/merchants.ts","../src/resources/transactions.ts","../src/client.ts","../src/index.ts"],"names":[],"mappings":";AAeO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA;AAAA,EAE5B,UAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAA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AAA;AAAA;AAAA,EAUA,MAAM,OAAA,CACJ,IAAA,EACA,IAAA,EAC0B;AAC1B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAQ,IAAA,EAAM,IAAI,CAAA;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,UAAuB,IAAA,EAAwC;AACnE,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,MAAA,CAAU,IAAI,CAAA;AAAA,EACjC;AACF;;;ACrIA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["import type { RateLimitInfo } from \"./types/index.js\";\n\nexport interface RawErrorObject {\n code: string;\n message: string;\n details?: Record<string, unknown>;\n}\n\nexport interface RawResponseMeta {\n generatedAt: string;\n requestId: string;\n version: string;\n [key: string]: unknown;\n}\n\nexport class TriqaiError extends Error {\n /** HTTP status code from the API response. */\n readonly statusCode: number;\n /** Machine-readable error code from the API (e.g. \"validation_error\"). */\n readonly code: string;\n /** Correlation ID for support inquiries. */\n readonly requestId: string | undefined;\n /** The raw error body returned by the API. */\n readonly rawError: RawErrorObject | undefined;\n /** Response metadata. */\n readonly meta: RawResponseMeta | undefined;\n\n constructor(\n message: string,\n statusCode: number,\n opts?: {\n code?: string;\n requestId?: string;\n rawError?: RawErrorObject;\n meta?: RawResponseMeta;\n },\n ) {\n super(message);\n this.name = \"TriqaiError\";\n this.statusCode = statusCode;\n this.code = opts?.code ?? \"unknown_error\";\n this.requestId = opts?.requestId;\n this.rawError = opts?.rawError;\n this.meta = opts?.meta;\n }\n}\n\nexport class AuthenticationError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 401, { code: \"authentication_error\", ...opts });\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class AuthorizationError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 403, { code: \"authorization_error\", ...opts });\n this.name = \"AuthorizationError\";\n }\n}\n\nexport class InsufficientCreditsError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 402, { code: \"insufficient_credits\", ...opts });\n this.name = \"InsufficientCreditsError\";\n }\n}\n\nexport class NotFoundError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 404, { code: \"not_found\", ...opts });\n this.name = \"NotFoundError\";\n }\n}\n\nexport class ValidationError extends TriqaiError {\n readonly fieldErrors: Record<string, string[]>;\n\n constructor(\n message: string,\n fieldErrors?: Record<string, string[]>,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 422, { code: \"validation_error\", ...opts });\n this.name = \"ValidationError\";\n this.fieldErrors = fieldErrors ?? {};\n }\n}\n\nexport class ClientDisconnectedError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 499, { code: \"client_disconnected\", ...opts });\n this.name = \"ClientDisconnectedError\";\n }\n}\n\nexport class DuplicateRequestError extends TriqaiError {\n readonly state: \"in_progress\" | \"completed\" | undefined;\n readonly duplicateRequestId: string | undefined;\n readonly retryAfter: number | undefined;\n\n constructor(\n message: string,\n opts?: ConstructorParameters<typeof TriqaiError>[2] & {\n state?: \"in_progress\" | \"completed\";\n duplicateRequestId?: string;\n retryAfter?: number;\n },\n ) {\n super(message, 409, { code: \"DUPLICATE_REQUEST\", ...opts });\n this.name = \"DuplicateRequestError\";\n this.state = opts?.state;\n this.duplicateRequestId = opts?.duplicateRequestId;\n this.retryAfter = opts?.retryAfter;\n }\n}\n\nexport class RateLimitError extends TriqaiError {\n readonly rateLimitInfo: RateLimitInfo;\n\n constructor(\n message: string,\n rateLimitInfo: RateLimitInfo,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 429, { code: \"rate_limited\", ...opts });\n this.name = \"RateLimitError\";\n this.rateLimitInfo = rateLimitInfo;\n }\n}\n\nexport class InternalServerError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 500, { code: \"internal_error\", ...opts });\n this.name = \"InternalServerError\";\n }\n}\n\nexport class ServiceUnavailableError extends TriqaiError {\n readonly retryAfter: number | undefined;\n\n constructor(\n message: string,\n retryAfter?: number,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 503, { code: \"service_unavailable\", ...opts });\n this.name = \"ServiceUnavailableError\";\n this.retryAfter = retryAfter;\n }\n}\n\nexport class GatewayTimeoutError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 504, { code: \"gateway_timeout\", ...opts });\n this.name = \"GatewayTimeoutError\";\n }\n}\n\nexport class ConnectionError extends TriqaiError {\n constructor(message: string) {\n super(message, 0, { code: \"connection_error\" });\n this.name = \"ConnectionError\";\n }\n}\n\nexport class TimeoutError extends TriqaiError {\n constructor(message: string) {\n super(message, 0, { code: \"timeout\" });\n this.name = \"TimeoutError\";\n }\n}\n","import {\n AuthenticationError,\n AuthorizationError,\n ClientDisconnectedError,\n ConnectionError,\n DuplicateRequestError,\n GatewayTimeoutError,\n InsufficientCreditsError,\n InternalServerError,\n NotFoundError,\n RateLimitError,\n ServiceUnavailableError,\n TimeoutError,\n TriqaiError,\n ValidationError,\n} from \"./errors.js\";\nimport type { RawErrorObject, RawResponseMeta } from \"./errors.js\";\nimport type {\n RateLimitInfo,\n RequestInfo,\n ResponseInfo,\n TriqaiConfig,\n} from \"./types/index.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.triqai.com\";\nconst DEFAULT_MAX_RETRIES = 3;\nconst DEFAULT_RETRY_DELAY = 500;\nconst DEFAULT_MAX_RETRY_DELAY = 30_000;\nconst DEFAULT_TIMEOUT = 60_000;\nconst RETRYABLE_STATUS_CODES = new Set([429, 500, 503, 504]);\nconst SDK_VERSION = \"0.1.0\";\n\nexport interface HttpResponse<T> {\n data: T;\n status: number;\n headers: Record<string, string>;\n rateLimitInfo: RateLimitInfo;\n}\n\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly maxRetries: number;\n private readonly retryDelay: number;\n private readonly maxRetryDelay: number;\n private readonly timeout: number;\n private readonly defaultHeaders: Record<string, string>;\n private readonly onRequest?: (info: RequestInfo) => void;\n private readonly onResponse?: (info: ResponseInfo) => void;\n\n constructor(apiKey: string, config: TriqaiConfig = {}) {\n if (!apiKey) {\n throw new Error(\n \"API key is required. Get yours at https://triqai.com/dashboard\",\n );\n }\n this.apiKey = apiKey;\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;\n this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY;\n this.maxRetryDelay = config.maxRetryDelay ?? DEFAULT_MAX_RETRY_DELAY;\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT;\n this.defaultHeaders = config.defaultHeaders ?? {};\n this.onRequest = config.onRequest;\n this.onResponse = config.onResponse;\n }\n\n async get<T>(path: string, query?: Record<string, unknown>): Promise<HttpResponse<T>> {\n return this.request<T>(\"GET\", path, undefined, query);\n }\n\n async post<T>(path: string, body?: unknown): Promise<HttpResponse<T>> {\n return this.request<T>(\"POST\", path, body);\n }\n\n async delete<T>(path: string): Promise<HttpResponse<T>> {\n return this.request<T>(\"DELETE\", path);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n query?: Record<string, unknown>,\n extraHeaders?: Record<string, string>,\n ): Promise<HttpResponse<T>> {\n const url = this.buildUrl(path, query);\n const headers: Record<string, string> = {\n \"X-API-Key\": this.apiKey,\n \"User-Agent\": `triqai-node/${SDK_VERSION}`,\n Accept: \"application/json\",\n ...this.defaultHeaders,\n ...extraHeaders,\n };\n\n if (body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const delay = this.calculateDelay(attempt, lastError);\n await sleep(delay);\n }\n\n const startMs = Date.now();\n\n this.onRequest?.({ method, url, headers: { ...headers }, body });\n\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n let response: Response;\n try {\n response = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n } finally {\n clearTimeout(timeoutId);\n }\n\n const responseHeaders = parseHeaders(response.headers);\n const responseBody = await response.json().catch(() => null);\n const durationMs = Date.now() - startMs;\n\n this.onResponse?.({\n status: response.status,\n headers: responseHeaders,\n body: responseBody,\n durationMs,\n retryCount: attempt,\n });\n\n if (response.ok) {\n return {\n data: responseBody as T,\n status: response.status,\n headers: responseHeaders,\n rateLimitInfo: parseRateLimitHeaders(responseHeaders),\n };\n }\n\n const shouldRetry = this.canRetry(\n attempt,\n method,\n headers,\n RETRYABLE_STATUS_CODES.has(response.status),\n );\n\n lastError = this.mapError(response.status, responseBody, responseHeaders);\n\n if (!shouldRetry) {\n throw lastError;\n }\n } catch (err) {\n if (err instanceof TriqaiError) {\n const canRetry = this.canRetry(\n attempt,\n method,\n headers,\n RETRYABLE_STATUS_CODES.has(err.statusCode),\n );\n if (!canRetry) {\n throw err;\n }\n lastError = err;\n continue;\n }\n\n if (err instanceof DOMException && err.name === \"AbortError\") {\n lastError = new TimeoutError(\n `Request timed out after ${this.timeout}ms: ${method} ${path}`,\n );\n if (!this.canRetry(attempt, method, headers, true)) {\n throw lastError;\n }\n continue;\n }\n\n if (isNetworkError(err)) {\n lastError = new ConnectionError(\n `Network error: ${err instanceof Error ? err.message : String(err)}`,\n );\n if (!this.canRetry(attempt, method, headers, true)) {\n throw lastError;\n }\n continue;\n }\n\n throw err;\n }\n }\n\n throw lastError ?? new TriqaiError(\"Request failed after retries\", 0);\n }\n\n /**\n * Variant that injects custom headers (used by resources for Idempotency-Key etc.).\n */\n async postWithHeaders<T>(\n path: string,\n body: unknown,\n headers: Record<string, string>,\n query?: Record<string, unknown>,\n ): Promise<HttpResponse<T>> {\n return this.request<T>(\"POST\", path, body, query, headers);\n }\n\n private buildUrl(path: string, query?: Record<string, unknown>): string {\n const base = `${this.baseUrl}${path}`;\n if (!query) return base;\n\n const params = new URLSearchParams();\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined && v !== null) {\n if (v instanceof Date) {\n params.set(k, v.toISOString());\n } else {\n params.set(k, String(v));\n }\n }\n }\n const qs = params.toString();\n return qs ? `${base}?${qs}` : base;\n }\n\n private calculateDelay(attempt: number, lastError?: Error): number {\n if (lastError instanceof RateLimitError && lastError.rateLimitInfo.retryAfter) {\n return lastError.rateLimitInfo.retryAfter * 1000;\n }\n if (lastError instanceof ServiceUnavailableError && lastError.retryAfter) {\n return lastError.retryAfter * 1000;\n }\n const exponential = this.retryDelay * Math.pow(2, attempt - 1);\n const jitter = exponential * 0.2 * Math.random();\n return Math.min(exponential + jitter, this.maxRetryDelay);\n }\n\n private canRetry(\n attempt: number,\n method: string,\n headers: Record<string, string>,\n retryableSignal: boolean,\n ): boolean {\n return (\n retryableSignal &&\n attempt < this.maxRetries &&\n isIdempotent(method, headers)\n );\n }\n\n private mapError(\n status: number,\n body: unknown,\n headers: Record<string, string>,\n ): TriqaiError {\n const parsed = parseErrorBody(body);\n const opts = {\n code: parsed.code,\n requestId: parsed.requestId,\n rawError: parsed.error,\n meta: parsed.meta,\n };\n\n switch (status) {\n case 401:\n return new AuthenticationError(parsed.message, opts);\n case 402:\n return new InsufficientCreditsError(parsed.message, opts);\n case 403:\n return new AuthorizationError(parsed.message, opts);\n case 404:\n return new NotFoundError(parsed.message, opts);\n case 499:\n return new ClientDisconnectedError(parsed.message, opts);\n case 409: {\n const details = (parsed.error?.details ?? {}) as\n { state?: \"in_progress\" | \"completed\"; requestId?: string; retryAfterSeconds?: number };\n return new DuplicateRequestError(parsed.message, {\n ...opts,\n state: details?.state,\n duplicateRequestId: details?.requestId,\n retryAfter: details?.retryAfterSeconds,\n });\n }\n case 422: {\n const fieldErrors = (parsed.error?.details as { fieldErrors?: Record<string, string[]> } | undefined)\n ?.fieldErrors;\n return new ValidationError(parsed.message, fieldErrors, opts);\n }\n case 429:\n return new RateLimitError(\n parsed.message,\n parseRateLimitHeaders(headers),\n opts,\n );\n case 503: {\n const retryAfter = headers[\"retry-after\"]\n ? parseInt(headers[\"retry-after\"], 10)\n : undefined;\n return new ServiceUnavailableError(parsed.message, retryAfter, opts);\n }\n case 504:\n return new GatewayTimeoutError(parsed.message, opts);\n default:\n if (status >= 500) {\n return new InternalServerError(parsed.message, opts);\n }\n return new TriqaiError(parsed.message, status, opts);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction parseHeaders(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n out[key.toLowerCase()] = value;\n });\n return out;\n}\n\nfunction parseRateLimitHeaders(headers: Record<string, string>): RateLimitInfo {\n return {\n limit: maybeInt(headers[\"x-ratelimit-limit\"]),\n remaining: maybeInt(headers[\"x-ratelimit-remaining\"]),\n reset: headers[\"x-ratelimit-reset\"] ?? undefined,\n scope: headers[\"x-ratelimit-scope\"] as RateLimitInfo[\"scope\"],\n concurrencyLimit: maybeInt(headers[\"x-ratelimit-concurrency-limit\"]),\n concurrencyRemaining: maybeInt(headers[\"x-ratelimit-concurrency-remaining\"]),\n retryAfter: maybeInt(headers[\"retry-after\"]),\n };\n}\n\nfunction maybeInt(val: string | undefined): number | undefined {\n if (val === undefined) return undefined;\n const n = parseInt(val, 10);\n return Number.isNaN(n) ? undefined : n;\n}\n\ninterface ParsedError {\n message: string;\n code: string;\n requestId: string | undefined;\n error: RawErrorObject | undefined;\n meta: RawResponseMeta | undefined;\n}\n\nfunction parseErrorBody(body: unknown): ParsedError {\n if (!body || typeof body !== \"object\") {\n return {\n message: \"Unknown error\",\n code: \"unknown_error\",\n requestId: undefined,\n error: undefined,\n meta: undefined,\n };\n }\n\n const b = body as Record<string, unknown>;\n const error = b.error as { code?: string; message?: string; details?: Record<string, unknown> } | undefined;\n const meta = b.meta as Record<string, unknown> | undefined;\n\n return {\n message: error?.message ?? \"Unknown error\",\n code: error?.code ?? \"unknown_error\",\n requestId: meta?.requestId as string | undefined,\n error: error?.code\n ? { code: error.code, message: error.message ?? \"Unknown error\", details: error.details }\n : undefined,\n meta: meta?.generatedAt\n ? (meta as RawResponseMeta)\n : undefined,\n };\n}\n\nfunction isIdempotent(method: string, headers: Record<string, string>): boolean {\n if (method === \"GET\" || method === \"DELETE\") return true;\n const normalized = normalizeHeaderKeyMap(headers);\n if (normalized.has(\"idempotency-key\") || normalized.has(\"x-idempotency-key\")) {\n return true;\n }\n return false;\n}\n\nfunction normalizeHeaderKeyMap(headers: Record<string, string>): Set<string> {\n return new Set(Object.keys(headers).map((key) => key.toLowerCase()));\n}\n\nfunction isNetworkError(err: unknown): boolean {\n if (err instanceof TypeError) return true;\n if (err instanceof Error && err.message.includes(\"fetch\")) return true;\n return false;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { CategoryInfo, CategoryListResponse } from \"../types/index.js\";\n\nexport class Categories {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * List all available transaction categories.\n *\n * Returns the full category tree used for transaction classification,\n * including MCC, SIC, and NAICS codes.\n *\n * @returns Array of category info objects and the total count.\n *\n * @example\n * ```ts\n * const { categories, total } = await triqai.categories.list();\n * console.log(`${total} categories available`);\n * ```\n */\n async list(): Promise<{ categories: CategoryInfo[]; total: number; categoryVersion: string }> {\n const resp = await this.http.get<CategoryListResponse>(\"/v1/categories\");\n return {\n categories: resp.data.data.categories,\n total: resp.data.data.total,\n categoryVersion: resp.data.meta.categoryVersion,\n };\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { IntermediaryData, IntermediaryResponse } from \"../types/index.js\";\n\nexport class Intermediaries {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get an intermediary (payment processor / platform) by ID.\n *\n * @param id - Intermediary UUID.\n * @returns The intermediary data (name, icon, description, website, domain, etc.).\n *\n * @example\n * ```ts\n * const intermediary = await triqai.intermediaries.get(\"550e8400-...\");\n * console.log(intermediary.name); // \"PayPal\", \"Square\", etc.\n * ```\n */\n async get(id: string): Promise<IntermediaryData> {\n const resp = await this.http.get<IntermediaryResponse>(\n `/v1/intermediaries/${encodeURIComponent(id)}`,\n );\n return resp.data.data.intermediary;\n }\n}\n","/**\n * Pagination helpers for list endpoints.\n *\n * Provides a `Page<T>` type with metadata and an `autoPaginate()` method\n * that returns an async iterator walking through all pages automatically.\n */\n\nexport interface PageInfo {\n page: number;\n size: number;\n total: number;\n totalPages: number;\n}\n\nexport class Page<T> {\n readonly data: T[];\n readonly pageInfo: PageInfo;\n\n private readonly _fetchPage: (page: number, size: number) => Promise<Page<T>>;\n\n constructor(\n data: T[],\n pageInfo: PageInfo,\n fetchPage: (page: number, size: number) => Promise<Page<T>>,\n ) {\n this.data = data;\n this.pageInfo = pageInfo;\n this._fetchPage = fetchPage;\n }\n\n get hasNextPage(): boolean {\n return this.pageInfo.page < this.pageInfo.totalPages;\n }\n\n get hasPreviousPage(): boolean {\n return this.pageInfo.page > 1;\n }\n\n async nextPage(): Promise<Page<T>> {\n if (!this.hasNextPage) {\n return new Page<T>([], this.pageInfo, this._fetchPage);\n }\n return this._fetchPage(this.pageInfo.page + 1, this.pageInfo.size);\n }\n\n async previousPage(): Promise<Page<T>> {\n if (!this.hasPreviousPage) {\n return new Page<T>([], this.pageInfo, this._fetchPage);\n }\n return this._fetchPage(this.pageInfo.page - 1, this.pageInfo.size);\n }\n\n /**\n * Returns an async iterator that yields every item across all pages,\n * starting from the current page.\n *\n * ```ts\n * for await (const item of page.autoPaginate()) {\n * console.log(item);\n * }\n * ```\n */\n async *autoPaginate(): AsyncGenerator<T, void, unknown> {\n let current: Page<T> = this;\n while (true) {\n for (const item of current.data) {\n yield item;\n }\n if (!current.hasNextPage) break;\n current = await current.nextPage();\n }\n }\n\n /**\n * Symbol.asyncIterator so `Page` itself can be used in `for await...of`.\n */\n [Symbol.asyncIterator](): AsyncIterableIterator<T> {\n return this.autoPaginate();\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport { Page } from \"../pagination.js\";\nimport type {\n EnrichmentFieldPath,\n IssueReport,\n IssueReportListResponse,\n IssueReportResponse,\n ListIssueReportsParams,\n} from \"../types/index.js\";\n\nexport interface CreateIssueReportParams {\n /** The transaction ID to report an issue for. */\n transactionId: string;\n /** A description of what is wrong with the enrichment result. */\n description: string;\n /** Which enrichment fields are incorrect. */\n fields: EnrichmentFieldPath[];\n}\n\nexport class IssueReports {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Report an issue with an enrichment result.\n *\n * @param params - The issue report details.\n * @returns The created issue report.\n *\n * @example\n * ```ts\n * const report = await triqai.issueReports.create({\n * transactionId: \"tx-uuid\",\n * description: \"Merchant was identified incorrectly\",\n * fields: [\"entities.merchant.data.name\"],\n * });\n * console.log(report.id, report.status);\n * ```\n */\n async create(params: CreateIssueReportParams): Promise<IssueReport> {\n const resp = await this.http.post<IssueReportResponse>(\"/v1/report-issue\", {\n transaction_id: params.transactionId,\n description: params.description,\n fields: params.fields,\n });\n return resp.data.data.issueReport;\n }\n\n /**\n * List issue reports with pagination.\n *\n * @returns A `Page` of issue reports. Use `.autoPaginate()` or\n * `for await...of` to iterate through all pages automatically.\n *\n * @example\n * ```ts\n * const page = await triqai.issueReports.list({ status: \"pending\" });\n * for (const report of page.data) {\n * console.log(report.id, report.status);\n * }\n * ```\n */\n async list(params?: ListIssueReportsParams): Promise<Page<IssueReport>> {\n const fetchPage = async (page: number, size: number): Promise<Page<IssueReport>> => {\n const query: Record<string, unknown> = { page, size };\n if (params?.status) query.status = params.status;\n if (params?.transactionId) query.transaction_id = params.transactionId;\n\n const resp = await this.http.get<IssueReportListResponse>(\"/v1/report-issue\", query);\n const pageInfo = {\n page: resp.data.meta.page,\n size: resp.data.meta.size,\n total: resp.data.meta.total,\n totalPages: resp.data.meta.totalPages,\n };\n return new Page(resp.data.data, pageInfo, fetchPage);\n };\n\n return fetchPage(params?.page ?? 1, params?.size ?? 25);\n }\n\n /**\n * Get a single issue report by ID.\n *\n * @param id - Issue report UUID.\n * @returns The issue report details.\n */\n async get(id: string): Promise<IssueReport> {\n const resp = await this.http.get<IssueReportResponse>(\n `/v1/report-issue/${encodeURIComponent(id)}`,\n );\n return resp.data.data.issueReport;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { LocationData, LocationResponse } from \"../types/index.js\";\n\nexport class Locations {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get a location by ID.\n *\n * @param id - Location UUID.\n * @returns The location data (name, formatted address, coordinates, phone, rating, etc.).\n *\n * @example\n * ```ts\n * const location = await triqai.locations.get(\"550e8400-e29b-41d4-a716-446655440000\");\n * console.log(location.formatted, location.structured.city);\n * ```\n */\n async get(id: string): Promise<LocationData> {\n const resp = await this.http.get<LocationResponse>(\n `/v1/locations/${encodeURIComponent(id)}`,\n );\n return resp.data.data.location;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { MerchantData, MerchantResponse } from \"../types/index.js\";\n\nexport class Merchants {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get a merchant by ID.\n *\n * @param id - Merchant UUID.\n * @returns The merchant data (name, icon, website, domain, aliases, etc.).\n *\n * @example\n * ```ts\n * const merchant = await triqai.merchants.get(\"550e8400-e29b-41d4-a716-446655440000\");\n * console.log(merchant.name, merchant.website);\n * ```\n */\n async get(id: string): Promise<MerchantData> {\n const resp = await this.http.get<MerchantResponse>(\n `/v1/merchants/${encodeURIComponent(id)}`,\n );\n return resp.data.data.merchant;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport { Page } from \"../pagination.js\";\nimport type {\n DeleteTransactionResponse,\n EnrichedTransaction,\n EnrichOptions,\n EnrichRequest,\n EnrichSuccessResponse,\n ListTransactionsParams,\n TransactionDetailResponse,\n TransactionListResponse,\n} from \"../types/index.js\";\n\nexport class Transactions {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Enrich a transaction with merchant, category, location, and entity data.\n *\n * @param request - The transaction to enrich (title, country, type, and optional options).\n * @param options - Optional enrichment controls (force bypass cache, idempotency key).\n * @returns The enriched transaction data.\n *\n * @example\n * ```ts\n * const result = await triqai.transactions.enrich({\n * title: \"STARBUCKS SEATTLE WA\",\n * country: \"US\",\n * type: \"expense\",\n * });\n * console.log(result.data.entities);\n * ```\n */\n async enrich(\n request: EnrichRequest,\n options?: EnrichOptions,\n ): Promise<EnrichSuccessResponse> {\n const headers: Record<string, string> = {};\n const query: Record<string, unknown> = {};\n\n if (options?.idempotencyKey) {\n headers[\"Idempotency-Key\"] = options.idempotencyKey;\n }\n if (options?.force) {\n query.force = \"true\";\n }\n\n const resp = await this.http.postWithHeaders<EnrichSuccessResponse>(\n \"/v1/transactions/enrich\",\n request,\n headers,\n Object.keys(query).length > 0 ? query : undefined,\n );\n return resp.data;\n }\n\n /**\n * List enriched transactions with pagination.\n *\n * @returns A `Page` of enriched transactions. Use `.autoPaginate()` or\n * `for await...of` to iterate through all pages automatically.\n *\n * @example\n * ```ts\n * const page = await triqai.transactions.list({ size: 10 });\n * console.log(page.data); // first 10 transactions\n *\n * // Auto-paginate through all:\n * for await (const tx of page) {\n * console.log(tx.id, tx.raw);\n * }\n * ```\n */\n async list(params?: ListTransactionsParams): Promise<Page<EnrichedTransaction>> {\n const fetchPage = async (page: number, size: number): Promise<Page<EnrichedTransaction>> => {\n const query: Record<string, unknown> = {\n page,\n size,\n };\n if (params?.startDate) {\n query.startDate =\n params.startDate instanceof Date\n ? params.startDate.toISOString()\n : params.startDate;\n }\n if (params?.endDate) {\n query.endDate =\n params.endDate instanceof Date\n ? params.endDate.toISOString()\n : params.endDate;\n }\n\n const resp = await this.http.get<TransactionListResponse>(\"/v1/transactions\", query);\n const { transactions, pagination } = resp.data.data;\n return new Page(transactions, pagination, fetchPage);\n };\n\n return fetchPage(params?.page ?? 1, params?.size ?? 25);\n }\n\n /**\n * Get a single transaction by ID.\n *\n * @param id - Transaction UUID.\n * @returns The enriched transaction record.\n */\n async get(id: string): Promise<EnrichedTransaction> {\n const resp = await this.http.get<TransactionDetailResponse>(\n `/v1/transactions/${encodeURIComponent(id)}`,\n );\n return resp.data.data.transaction;\n }\n\n /**\n * Delete a transaction by ID.\n *\n * @param id - Transaction UUID.\n * @returns Confirmation with the deleted transaction ID.\n */\n async delete(id: string): Promise<{ deleted: true; transactionId: string }> {\n const resp = await this.http.delete<DeleteTransactionResponse>(\n `/v1/transactions/${encodeURIComponent(id)}`,\n );\n return resp.data.data;\n }\n}\n","import type { HttpResponse } from \"./http-client.js\";\nimport { HttpClient } from \"./http-client.js\";\nimport { Categories } from \"./resources/categories.js\";\nimport { Intermediaries } from \"./resources/intermediaries.js\";\nimport { IssueReports } from \"./resources/issue-reports.js\";\nimport { Locations } from \"./resources/locations.js\";\nimport { Merchants } from \"./resources/merchants.js\";\nimport { Transactions } from \"./resources/transactions.js\";\nimport type {\n ApiInfoResponse,\n HealthResponse,\n TriqaiConfig,\n} from \"./types/index.js\";\n\n/**\n * The Triqai SDK client.\n *\n * @example\n * ```ts\n * import Triqai from \"triqai\";\n *\n * const triqai = new Triqai(\"triq_your_api_key\");\n *\n * const result = await triqai.transactions.enrich({\n * title: \"STARBUCKS SEATTLE WA\",\n * country: \"US\",\n * type: \"expense\",\n * });\n * ```\n */\nexport class Triqai {\n /** Enrich, list, get, and delete transactions. */\n readonly transactions: Transactions;\n /** List the full category taxonomy. */\n readonly categories: Categories;\n /** Look up merchant details by ID. */\n readonly merchants: Merchants;\n /** Look up location details by ID. */\n readonly locations: Locations;\n /** Look up intermediary (payment processor) details by ID. */\n readonly intermediaries: Intermediaries;\n /** Create and manage enrichment issue reports. */\n readonly issueReports: IssueReports;\n\n private readonly http: HttpClient;\n\n /**\n * Create a new Triqai SDK client.\n *\n * @param apiKey - Your Triqai API key (starts with `triq_`). Get one at https://triqai.com/dashboard\n * @param config - Optional configuration (base URL, retry settings, hooks).\n */\n constructor(apiKey: string, config?: TriqaiConfig) {\n this.http = new HttpClient(apiKey, config);\n this.transactions = new Transactions(this.http);\n this.categories = new Categories(this.http);\n this.merchants = new Merchants(this.http);\n this.locations = new Locations(this.http);\n this.intermediaries = new Intermediaries(this.http);\n this.issueReports = new IssueReports(this.http);\n }\n\n /**\n * Check the API health status.\n *\n * @returns Health status including service name and version.\n *\n * @example\n * ```ts\n * const health = await triqai.health();\n * console.log(health.data.status); // \"healthy\"\n * console.log(health.data.version); // \"1.1.9\"\n * ```\n */\n async health(): Promise<HealthResponse> {\n const resp = await this.http.get<HealthResponse>(\"/health\");\n return resp.data;\n }\n\n /**\n * Get API version and endpoint directory.\n *\n * @returns API version info and available endpoint paths.\n *\n * @example\n * ```ts\n * const info = await triqai.apiInfo();\n * console.log(info.data.version); // \"v1\"\n * console.log(info.data.endpoints);\n * ```\n */\n async apiInfo(): Promise<ApiInfoResponse> {\n const resp = await this.http.get<ApiInfoResponse>(\"/v1\");\n return resp.data;\n }\n\n /**\n * Make a raw GET request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-endpoint\").\n * @param query - Optional query parameters.\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawGet<T = unknown>(\n path: string,\n query?: Record<string, unknown>,\n ): Promise<HttpResponse<T>> {\n return this.http.get<T>(path, query);\n }\n\n /**\n * Make a raw POST request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-endpoint\").\n * @param body - Request body.\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawPost<T = unknown>(\n path: string,\n body?: unknown,\n ): Promise<HttpResponse<T>> {\n return this.http.post<T>(path, body);\n }\n\n /**\n * Make a raw DELETE request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-resource/uuid\").\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawDelete<T = unknown>(path: string): Promise<HttpResponse<T>> {\n return this.http.delete<T>(path);\n }\n}\n","import { Triqai } from \"./client.js\";\n\nexport { Triqai };\nexport default Triqai;\n\nexport {\n TriqaiError,\n AuthenticationError,\n AuthorizationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n ClientDisconnectedError,\n DuplicateRequestError,\n RateLimitError,\n InternalServerError,\n ServiceUnavailableError,\n GatewayTimeoutError,\n ConnectionError,\n TimeoutError,\n} from \"./errors.js\";\nexport type { RawErrorObject, RawResponseMeta } from \"./errors.js\";\n\nexport type { HttpResponse } from \"./http-client.js\";\n\nexport { Page } from \"./pagination.js\";\nexport type { PageInfo } from \"./pagination.js\";\n\nexport type { CreateIssueReportParams } from \"./resources/issue-reports.js\";\n\nexport type {\n // SDK config types\n TriqaiConfig,\n RequestInfo,\n ResponseInfo,\n RateLimitInfo,\n EnrichOptions,\n ListTransactionsParams,\n ListIssueReportsParams,\n // Enrichment request types\n EnrichRequest,\n EnrichRequestOptions,\n EnrichmentFilterOptions,\n PrefilledMerchant,\n PrefilledLocation,\n PrefilledIntermediary,\n // Enrichment response types\n EnrichSuccessResponse,\n EnrichmentData,\n EnrichMeta,\n EnrichmentErrorCode,\n // Transaction types\n TransactionData,\n TransactionType,\n TransactionChannel,\n TransactionRecord,\n EnrichedTransaction,\n TransactionPagination,\n TransactionListResponse,\n TransactionDetailResponse,\n DeleteTransactionResponse,\n // Category types\n CategoryStructure,\n Category,\n CategoryCode,\n CategoryInfo,\n CategoryListResponse,\n // Confidence / subscription\n ConfidenceWithReasons,\n Subscription,\n SubscriptionType,\n // Entity types\n EntityResult,\n MerchantData,\n LocationData,\n IntermediaryData,\n IntermediaryRecord,\n PersonData,\n Coordinates,\n StructuredAddress,\n LocationRating,\n // Entity response types\n MerchantResponse,\n LocationResponse,\n IntermediaryResponse,\n // Issue report types\n IssueReport,\n IssueReportStatus,\n IssueReportResponse,\n IssueReportListResponse,\n ReportIssueRequest,\n EnrichmentFieldPath,\n // Error response types\n ErrorResponse,\n ErrorObject,\n DuplicateRequestErrorResponse,\n ClientDisconnectedErrorResponse,\n // Meta types\n ResponseMeta,\n PaginationMeta,\n // Utility response types\n HealthResponse,\n ApiInfoResponse,\n} from \"./types/index.js\";\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/http-client.ts","../src/resources/categories.ts","../src/resources/intermediaries.ts","../src/pagination.ts","../src/resources/issue-reports.ts","../src/resources/locations.ts","../src/resources/merchants.ts","../src/resources/transactions.ts","../src/client.ts","../src/index.ts"],"names":[],"mappings":";AAeO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA;AAAA,EAE5B,UAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,IAAA;AAAA,EAET,WAAA,CACE,OAAA,EACA,UAAA,EACA,IAAA,EAMA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,IAAA,GAAO,MAAM,IAAA,IAAQ,eAAA;AAC1B,IAAA,IAAA,CAAK,YAAY,IAAA,EAAM,SAAA;AACvB,IAAA,IAAA,CAAK,WAAW,IAAA,EAAM,QAAA;AACtB,IAAA,IAAA,CAAK,OAAO,IAAA,EAAM,IAAA;AAAA,EACpB;AACF;AAEO,IAAM,mBAAA,GAAN,cAAkC,WAAA,CAAY;AAAA,EACnD,WAAA,CAAY,SAAiB,IAAA,EAAqD;AAChF,IAAA,KAAA,CAAM,SAAS,GAAA,EAAK,EAAE,MAAM,sBAAA,EAAwB,GAAG,MAAM,CAAA;AAC7D,IAAA,IAAA,CAAK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ACjC;AACF;;;ACrIA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["import type { RateLimitInfo } from \"./types/index.js\";\n\nexport interface RawErrorObject {\n code: string;\n message: string;\n details?: Record<string, unknown>;\n}\n\nexport interface RawResponseMeta {\n generatedAt: string;\n requestId: string;\n version: string;\n [key: string]: unknown;\n}\n\nexport class TriqaiError extends Error {\n /** HTTP status code from the API response. */\n readonly statusCode: number;\n /** Machine-readable error code from the API (e.g. \"validation_error\"). */\n readonly code: string;\n /** Correlation ID for support inquiries. */\n readonly requestId: string | undefined;\n /** The raw error body returned by the API. */\n readonly rawError: RawErrorObject | undefined;\n /** Response metadata. */\n readonly meta: RawResponseMeta | undefined;\n\n constructor(\n message: string,\n statusCode: number,\n opts?: {\n code?: string;\n requestId?: string;\n rawError?: RawErrorObject;\n meta?: RawResponseMeta;\n },\n ) {\n super(message);\n this.name = \"TriqaiError\";\n this.statusCode = statusCode;\n this.code = opts?.code ?? \"unknown_error\";\n this.requestId = opts?.requestId;\n this.rawError = opts?.rawError;\n this.meta = opts?.meta;\n }\n}\n\nexport class AuthenticationError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 401, { code: \"authentication_error\", ...opts });\n this.name = \"AuthenticationError\";\n }\n}\n\nexport class AuthorizationError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 403, { code: \"authorization_error\", ...opts });\n this.name = \"AuthorizationError\";\n }\n}\n\nexport class InsufficientCreditsError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 402, { code: \"insufficient_credits\", ...opts });\n this.name = \"InsufficientCreditsError\";\n }\n}\n\nexport class NotFoundError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 404, { code: \"not_found\", ...opts });\n this.name = \"NotFoundError\";\n }\n}\n\nexport class ValidationError extends TriqaiError {\n readonly fieldErrors: Record<string, string[]>;\n\n constructor(\n message: string,\n fieldErrors?: Record<string, string[]>,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 422, { code: \"validation_error\", ...opts });\n this.name = \"ValidationError\";\n this.fieldErrors = fieldErrors ?? {};\n }\n}\n\nexport class ClientDisconnectedError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 499, { code: \"client_disconnected\", ...opts });\n this.name = \"ClientDisconnectedError\";\n }\n}\n\nexport class DuplicateRequestError extends TriqaiError {\n readonly state: \"in_progress\" | \"completed\" | undefined;\n readonly duplicateRequestId: string | undefined;\n readonly retryAfter: number | undefined;\n\n constructor(\n message: string,\n opts?: ConstructorParameters<typeof TriqaiError>[2] & {\n state?: \"in_progress\" | \"completed\";\n duplicateRequestId?: string;\n retryAfter?: number;\n },\n ) {\n super(message, 409, { code: \"DUPLICATE_REQUEST\", ...opts });\n this.name = \"DuplicateRequestError\";\n this.state = opts?.state;\n this.duplicateRequestId = opts?.duplicateRequestId;\n this.retryAfter = opts?.retryAfter;\n }\n}\n\nexport class RateLimitError extends TriqaiError {\n readonly rateLimitInfo: RateLimitInfo;\n\n constructor(\n message: string,\n rateLimitInfo: RateLimitInfo,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 429, { code: \"rate_limited\", ...opts });\n this.name = \"RateLimitError\";\n this.rateLimitInfo = rateLimitInfo;\n }\n}\n\nexport class InternalServerError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 500, { code: \"internal_error\", ...opts });\n this.name = \"InternalServerError\";\n }\n}\n\nexport class ServiceUnavailableError extends TriqaiError {\n readonly retryAfter: number | undefined;\n\n constructor(\n message: string,\n retryAfter?: number,\n opts?: ConstructorParameters<typeof TriqaiError>[2],\n ) {\n super(message, 503, { code: \"service_unavailable\", ...opts });\n this.name = \"ServiceUnavailableError\";\n this.retryAfter = retryAfter;\n }\n}\n\nexport class GatewayTimeoutError extends TriqaiError {\n constructor(message: string, opts?: ConstructorParameters<typeof TriqaiError>[2]) {\n super(message, 504, { code: \"gateway_timeout\", ...opts });\n this.name = \"GatewayTimeoutError\";\n }\n}\n\nexport class ConnectionError extends TriqaiError {\n constructor(message: string) {\n super(message, 0, { code: \"connection_error\" });\n this.name = \"ConnectionError\";\n }\n}\n\nexport class TimeoutError extends TriqaiError {\n constructor(message: string) {\n super(message, 0, { code: \"timeout\" });\n this.name = \"TimeoutError\";\n }\n}\n","import {\n AuthenticationError,\n AuthorizationError,\n ClientDisconnectedError,\n ConnectionError,\n DuplicateRequestError,\n GatewayTimeoutError,\n InsufficientCreditsError,\n InternalServerError,\n NotFoundError,\n RateLimitError,\n ServiceUnavailableError,\n TimeoutError,\n TriqaiError,\n ValidationError,\n} from \"./errors.js\";\nimport type { RawErrorObject, RawResponseMeta } from \"./errors.js\";\nimport type {\n RateLimitInfo,\n RequestInfo,\n ResponseInfo,\n TriqaiConfig,\n} from \"./types/index.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.triqai.com\";\nconst DEFAULT_MAX_RETRIES = 3;\nconst DEFAULT_RETRY_DELAY = 500;\nconst DEFAULT_MAX_RETRY_DELAY = 30_000;\nconst DEFAULT_TIMEOUT = 60_000;\nconst RETRYABLE_STATUS_CODES = new Set([429, 500, 503, 504]);\nconst SDK_VERSION = \"0.1.1\";\n\nexport interface HttpResponse<T> {\n data: T;\n status: number;\n headers: Record<string, string>;\n rateLimitInfo: RateLimitInfo;\n}\n\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly maxRetries: number;\n private readonly retryDelay: number;\n private readonly maxRetryDelay: number;\n private readonly timeout: number;\n private readonly defaultHeaders: Record<string, string>;\n private readonly onRequest?: (info: RequestInfo) => void;\n private readonly onResponse?: (info: ResponseInfo) => void;\n\n constructor(apiKey: string, config: TriqaiConfig = {}) {\n if (!apiKey) {\n throw new Error(\n \"API key is required. Get yours at https://triqai.com/dashboard\",\n );\n }\n this.apiKey = apiKey;\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;\n this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY;\n this.maxRetryDelay = config.maxRetryDelay ?? DEFAULT_MAX_RETRY_DELAY;\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT;\n this.defaultHeaders = config.defaultHeaders ?? {};\n this.onRequest = config.onRequest;\n this.onResponse = config.onResponse;\n }\n\n async get<T>(path: string, query?: Record<string, unknown>): Promise<HttpResponse<T>> {\n return this.request<T>(\"GET\", path, undefined, query);\n }\n\n async post<T>(path: string, body?: unknown): Promise<HttpResponse<T>> {\n return this.request<T>(\"POST\", path, body);\n }\n\n async delete<T>(path: string): Promise<HttpResponse<T>> {\n return this.request<T>(\"DELETE\", path);\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n query?: Record<string, unknown>,\n extraHeaders?: Record<string, string>,\n ): Promise<HttpResponse<T>> {\n const url = this.buildUrl(path, query);\n const headers: Record<string, string> = {\n \"X-API-Key\": this.apiKey,\n \"User-Agent\": `triqai-node/${SDK_VERSION}`,\n Accept: \"application/json\",\n ...this.defaultHeaders,\n ...extraHeaders,\n };\n\n if (body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const delay = this.calculateDelay(attempt, lastError);\n await sleep(delay);\n }\n\n const startMs = Date.now();\n\n this.onRequest?.({ method, url, headers: { ...headers }, body });\n\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n let response: Response;\n try {\n response = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n } finally {\n clearTimeout(timeoutId);\n }\n\n const responseHeaders = parseHeaders(response.headers);\n const responseBody = await response.json().catch(() => null);\n const durationMs = Date.now() - startMs;\n\n this.onResponse?.({\n status: response.status,\n headers: responseHeaders,\n body: responseBody,\n durationMs,\n retryCount: attempt,\n });\n\n if (response.ok) {\n return {\n data: responseBody as T,\n status: response.status,\n headers: responseHeaders,\n rateLimitInfo: parseRateLimitHeaders(responseHeaders),\n };\n }\n\n const shouldRetry = this.canRetry(\n attempt,\n method,\n headers,\n RETRYABLE_STATUS_CODES.has(response.status),\n );\n\n lastError = this.mapError(response.status, responseBody, responseHeaders);\n\n if (!shouldRetry) {\n throw lastError;\n }\n } catch (err) {\n if (err instanceof TriqaiError) {\n const canRetry = this.canRetry(\n attempt,\n method,\n headers,\n RETRYABLE_STATUS_CODES.has(err.statusCode),\n );\n if (!canRetry) {\n throw err;\n }\n lastError = err;\n continue;\n }\n\n if (err instanceof DOMException && err.name === \"AbortError\") {\n lastError = new TimeoutError(\n `Request timed out after ${this.timeout}ms: ${method} ${path}`,\n );\n if (!this.canRetry(attempt, method, headers, true)) {\n throw lastError;\n }\n continue;\n }\n\n if (isNetworkError(err)) {\n lastError = new ConnectionError(\n `Network error: ${err instanceof Error ? err.message : String(err)}`,\n );\n if (!this.canRetry(attempt, method, headers, true)) {\n throw lastError;\n }\n continue;\n }\n\n throw err;\n }\n }\n\n throw lastError ?? new TriqaiError(\"Request failed after retries\", 0);\n }\n\n /**\n * Variant that injects custom headers (used by resources for Idempotency-Key etc.).\n */\n async postWithHeaders<T>(\n path: string,\n body: unknown,\n headers: Record<string, string>,\n query?: Record<string, unknown>,\n ): Promise<HttpResponse<T>> {\n return this.request<T>(\"POST\", path, body, query, headers);\n }\n\n private buildUrl(path: string, query?: Record<string, unknown>): string {\n const isAbsoluteUrl = /^https?:\\/\\//i.test(path);\n const normalizedPath = path.startsWith(\"/\") ? path : `/${path}`;\n const base = isAbsoluteUrl ? path : `${this.baseUrl}${normalizedPath}`;\n if (!query) return base;\n\n const params = new URLSearchParams();\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined && v !== null) {\n if (v instanceof Date) {\n params.set(k, v.toISOString());\n } else {\n params.set(k, String(v));\n }\n }\n }\n const qs = params.toString();\n return qs ? `${base}?${qs}` : base;\n }\n\n private calculateDelay(attempt: number, lastError?: Error): number {\n if (lastError instanceof RateLimitError && lastError.rateLimitInfo.retryAfter) {\n return lastError.rateLimitInfo.retryAfter * 1000;\n }\n if (lastError instanceof ServiceUnavailableError && lastError.retryAfter) {\n return lastError.retryAfter * 1000;\n }\n const exponential = this.retryDelay * Math.pow(2, attempt - 1);\n const jitter = exponential * 0.2 * Math.random();\n return Math.min(exponential + jitter, this.maxRetryDelay);\n }\n\n private canRetry(\n attempt: number,\n method: string,\n headers: Record<string, string>,\n retryableSignal: boolean,\n ): boolean {\n return (\n retryableSignal &&\n attempt < this.maxRetries &&\n isIdempotent(method, headers)\n );\n }\n\n private mapError(\n status: number,\n body: unknown,\n headers: Record<string, string>,\n ): TriqaiError {\n const parsed = parseErrorBody(body);\n const opts = {\n code: parsed.code,\n requestId: parsed.requestId,\n rawError: parsed.error,\n meta: parsed.meta,\n };\n\n switch (status) {\n case 401:\n return new AuthenticationError(parsed.message, opts);\n case 402:\n return new InsufficientCreditsError(parsed.message, opts);\n case 403:\n return new AuthorizationError(parsed.message, opts);\n case 404:\n return new NotFoundError(parsed.message, opts);\n case 499:\n return new ClientDisconnectedError(parsed.message, opts);\n case 409: {\n const details = (parsed.error?.details ?? {}) as\n { state?: \"in_progress\" | \"completed\"; requestId?: string; retryAfterSeconds?: number };\n return new DuplicateRequestError(parsed.message, {\n ...opts,\n state: details?.state,\n duplicateRequestId: details?.requestId,\n retryAfter: details?.retryAfterSeconds,\n });\n }\n case 422: {\n const fieldErrors = (parsed.error?.details as { fieldErrors?: Record<string, string[]> } | undefined)\n ?.fieldErrors;\n return new ValidationError(parsed.message, fieldErrors, opts);\n }\n case 429:\n return new RateLimitError(\n parsed.message,\n parseRateLimitHeaders(headers),\n opts,\n );\n case 503: {\n const retryAfter = parseRetryAfterHeader(headers[\"retry-after\"]);\n return new ServiceUnavailableError(parsed.message, retryAfter, opts);\n }\n case 504:\n return new GatewayTimeoutError(parsed.message, opts);\n default:\n if (status >= 500) {\n return new InternalServerError(parsed.message, opts);\n }\n return new TriqaiError(parsed.message, status, opts);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction parseHeaders(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n out[key.toLowerCase()] = value;\n });\n return out;\n}\n\nfunction parseRateLimitHeaders(headers: Record<string, string>): RateLimitInfo {\n return {\n limit: maybeInt(headers[\"x-ratelimit-limit\"]),\n remaining: maybeInt(headers[\"x-ratelimit-remaining\"]),\n reset: headers[\"x-ratelimit-reset\"] ?? undefined,\n scope: headers[\"x-ratelimit-scope\"] as RateLimitInfo[\"scope\"],\n concurrencyLimit: maybeInt(headers[\"x-ratelimit-concurrency-limit\"]),\n concurrencyRemaining: maybeInt(headers[\"x-ratelimit-concurrency-remaining\"]),\n retryAfter: parseRetryAfterHeader(headers[\"retry-after\"]),\n };\n}\n\nfunction maybeInt(val: string | undefined): number | undefined {\n if (val === undefined) return undefined;\n const n = parseInt(val, 10);\n return Number.isNaN(n) ? undefined : n;\n}\n\nfunction parseRetryAfterHeader(val: string | undefined): number | undefined {\n if (val === undefined) return undefined;\n\n const seconds = maybeInt(val);\n if (seconds !== undefined && seconds >= 0) {\n return seconds;\n }\n\n const timestamp = Date.parse(val);\n if (Number.isNaN(timestamp)) {\n return undefined;\n }\n\n const secondsUntil = Math.ceil((timestamp - Date.now()) / 1000);\n return Math.max(secondsUntil, 0);\n}\n\ninterface ParsedError {\n message: string;\n code: string;\n requestId: string | undefined;\n error: RawErrorObject | undefined;\n meta: RawResponseMeta | undefined;\n}\n\nfunction parseErrorBody(body: unknown): ParsedError {\n if (!body || typeof body !== \"object\") {\n return {\n message: \"Unknown error\",\n code: \"unknown_error\",\n requestId: undefined,\n error: undefined,\n meta: undefined,\n };\n }\n\n const b = body as Record<string, unknown>;\n const error = b.error as { code?: string; message?: string; details?: Record<string, unknown> } | undefined;\n const meta = b.meta as Record<string, unknown> | undefined;\n\n return {\n message: error?.message ?? \"Unknown error\",\n code: error?.code ?? \"unknown_error\",\n requestId: meta?.requestId as string | undefined,\n error: error?.code\n ? { code: error.code, message: error.message ?? \"Unknown error\", details: error.details }\n : undefined,\n meta: meta?.generatedAt\n ? (meta as RawResponseMeta)\n : undefined,\n };\n}\n\nfunction isIdempotent(method: string, headers: Record<string, string>): boolean {\n if (method === \"GET\" || method === \"DELETE\") return true;\n const normalized = normalizeHeaderKeyMap(headers);\n if (normalized.has(\"idempotency-key\") || normalized.has(\"x-idempotency-key\")) {\n return true;\n }\n return false;\n}\n\nfunction normalizeHeaderKeyMap(headers: Record<string, string>): Set<string> {\n return new Set(Object.keys(headers).map((key) => key.toLowerCase()));\n}\n\nfunction isNetworkError(err: unknown): boolean {\n if (!(err instanceof Error)) return false;\n\n const message = err.message.toLowerCase();\n const hasNetworkSignal =\n message.includes(\"fetch\") ||\n message.includes(\"network\") ||\n message.includes(\"econnreset\") ||\n message.includes(\"enotfound\") ||\n message.includes(\"econnrefused\") ||\n message.includes(\"etimedout\");\n\n if (err instanceof TypeError) {\n return hasNetworkSignal;\n }\n\n if (err.name === \"NetworkError\") {\n return true;\n }\n\n if (err.cause instanceof Error) {\n const causeMessage = err.cause.message.toLowerCase();\n return (\n causeMessage.includes(\"fetch\") ||\n causeMessage.includes(\"network\") ||\n causeMessage.includes(\"econnreset\") ||\n causeMessage.includes(\"enotfound\") ||\n causeMessage.includes(\"econnrefused\") ||\n causeMessage.includes(\"etimedout\")\n );\n }\n\n return false;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { CategoryInfo, CategoryListResponse } from \"../types/index.js\";\n\nexport class Categories {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * List all available transaction categories.\n *\n * Returns the full category tree used for transaction classification,\n * including MCC, SIC, and NAICS codes.\n *\n * @returns Array of category info objects and the total count.\n *\n * @example\n * ```ts\n * const { categories, total } = await triqai.categories.list();\n * console.log(`${total} categories available`);\n * ```\n */\n async list(): Promise<{ categories: CategoryInfo[]; total: number; categoryVersion: string }> {\n const resp = await this.http.get<CategoryListResponse>(\"/v1/categories\");\n return {\n categories: resp.data.data.categories,\n total: resp.data.data.total,\n categoryVersion: resp.data.meta.categoryVersion,\n };\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { IntermediaryData, IntermediaryResponse } from \"../types/index.js\";\n\nexport class Intermediaries {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get an intermediary (payment processor / platform) by ID.\n *\n * @param id - Intermediary UUID.\n * @returns The intermediary data (name, icon, description, website, domain, etc.).\n *\n * @example\n * ```ts\n * const intermediary = await triqai.intermediaries.get(\"550e8400-...\");\n * console.log(intermediary.name); // \"PayPal\", \"Square\", etc.\n * ```\n */\n async get(id: string): Promise<IntermediaryData> {\n const resp = await this.http.get<IntermediaryResponse>(\n `/v1/intermediaries/${encodeURIComponent(id)}`,\n );\n return resp.data.data.intermediary;\n }\n}\n","/**\n * Pagination helpers for list endpoints.\n *\n * Provides a `Page<T>` type with metadata and an `autoPaginate()` method\n * that returns an async iterator walking through all pages automatically.\n */\n\nexport interface PageInfo {\n page: number;\n size: number;\n total: number;\n totalPages: number;\n}\n\nexport class Page<T> {\n readonly data: T[];\n readonly pageInfo: PageInfo;\n\n private readonly _fetchPage: (page: number, size: number) => Promise<Page<T>>;\n\n constructor(\n data: T[],\n pageInfo: PageInfo,\n fetchPage: (page: number, size: number) => Promise<Page<T>>,\n ) {\n this.data = data;\n this.pageInfo = pageInfo;\n this._fetchPage = fetchPage;\n }\n\n get hasNextPage(): boolean {\n return this.pageInfo.page < this.pageInfo.totalPages;\n }\n\n get hasPreviousPage(): boolean {\n return this.pageInfo.page > 1;\n }\n\n async nextPage(): Promise<Page<T>> {\n if (!this.hasNextPage) {\n return new Page<T>([], this.pageInfo, this._fetchPage);\n }\n return this._fetchPage(this.pageInfo.page + 1, this.pageInfo.size);\n }\n\n async previousPage(): Promise<Page<T>> {\n if (!this.hasPreviousPage) {\n return new Page<T>([], this.pageInfo, this._fetchPage);\n }\n return this._fetchPage(this.pageInfo.page - 1, this.pageInfo.size);\n }\n\n /**\n * Returns an async iterator that yields every item across all pages,\n * starting from the current page.\n *\n * ```ts\n * for await (const item of page.autoPaginate()) {\n * console.log(item);\n * }\n * ```\n */\n async *autoPaginate(): AsyncGenerator<T, void, unknown> {\n let current: Page<T> = this;\n while (true) {\n for (const item of current.data) {\n yield item;\n }\n if (!current.hasNextPage) break;\n current = await current.nextPage();\n }\n }\n\n /**\n * Symbol.asyncIterator so `Page` itself can be used in `for await...of`.\n */\n [Symbol.asyncIterator](): AsyncIterableIterator<T> {\n return this.autoPaginate();\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport { Page } from \"../pagination.js\";\nimport type {\n EnrichmentFieldPath,\n IssueReport,\n IssueReportListResponse,\n IssueReportResponse,\n ListIssueReportsParams,\n} from \"../types/index.js\";\n\nexport interface CreateIssueReportParams {\n /** The transaction ID to report an issue for. */\n transactionId: string;\n /** A description of what is wrong with the enrichment result. */\n description: string;\n /** Which enrichment fields are incorrect. */\n fields: EnrichmentFieldPath[];\n}\n\nexport class IssueReports {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Report an issue with an enrichment result.\n *\n * @param params - The issue report details.\n * @returns The created issue report.\n *\n * @example\n * ```ts\n * const report = await triqai.issueReports.create({\n * transactionId: \"tx-uuid\",\n * description: \"Merchant was identified incorrectly\",\n * fields: [\"entities.merchant.data.name\"],\n * });\n * console.log(report.id, report.status);\n * ```\n */\n async create(params: CreateIssueReportParams): Promise<IssueReport> {\n const resp = await this.http.post<IssueReportResponse>(\"/v1/report-issue\", {\n transaction_id: params.transactionId,\n description: params.description,\n fields: params.fields,\n });\n return resp.data.data.issueReport;\n }\n\n /**\n * List issue reports with pagination.\n *\n * @returns A `Page` of issue reports. Use `.autoPaginate()` or\n * `for await...of` to iterate through all pages automatically.\n *\n * @example\n * ```ts\n * const page = await triqai.issueReports.list({ status: \"pending\" });\n * for (const report of page.data) {\n * console.log(report.id, report.status);\n * }\n * ```\n */\n async list(params?: ListIssueReportsParams): Promise<Page<IssueReport>> {\n const fetchPage = async (page: number, size: number): Promise<Page<IssueReport>> => {\n const query: Record<string, unknown> = { page, size };\n if (params?.status) query.status = params.status;\n if (params?.transactionId) query.transaction_id = params.transactionId;\n\n const resp = await this.http.get<IssueReportListResponse>(\"/v1/report-issue\", query);\n const pageInfo = {\n page: resp.data.meta.page,\n size: resp.data.meta.size,\n total: resp.data.meta.total,\n totalPages: resp.data.meta.totalPages,\n };\n return new Page(resp.data.data, pageInfo, fetchPage);\n };\n\n return fetchPage(params?.page ?? 1, params?.size ?? 25);\n }\n\n /**\n * Get a single issue report by ID.\n *\n * @param id - Issue report UUID.\n * @returns The issue report details.\n */\n async get(id: string): Promise<IssueReport> {\n const resp = await this.http.get<IssueReportResponse>(\n `/v1/report-issue/${encodeURIComponent(id)}`,\n );\n return resp.data.data.issueReport;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { LocationData, LocationResponse } from \"../types/index.js\";\n\nexport class Locations {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get a location by ID.\n *\n * @param id - Location UUID.\n * @returns The location data (name, formatted address, coordinates, phone, rating, etc.).\n *\n * @example\n * ```ts\n * const location = await triqai.locations.get(\"550e8400-e29b-41d4-a716-446655440000\");\n * console.log(location.formatted, location.structured.city);\n * ```\n */\n async get(id: string): Promise<LocationData> {\n const resp = await this.http.get<LocationResponse>(\n `/v1/locations/${encodeURIComponent(id)}`,\n );\n return resp.data.data.location;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport type { MerchantData, MerchantResponse } from \"../types/index.js\";\n\nexport class Merchants {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get a merchant by ID.\n *\n * @param id - Merchant UUID.\n * @returns The merchant data (name, icon, website, domain, aliases, etc.).\n *\n * @example\n * ```ts\n * const merchant = await triqai.merchants.get(\"550e8400-e29b-41d4-a716-446655440000\");\n * console.log(merchant.name, merchant.website);\n * ```\n */\n async get(id: string): Promise<MerchantData> {\n const resp = await this.http.get<MerchantResponse>(\n `/v1/merchants/${encodeURIComponent(id)}`,\n );\n return resp.data.data.merchant;\n }\n}\n","import type { HttpClient } from \"../http-client.js\";\nimport { Page } from \"../pagination.js\";\nimport type {\n DeleteTransactionResponse,\n EnrichedTransaction,\n EnrichOptions,\n EnrichRequest,\n EnrichSuccessResponse,\n ListTransactionsParams,\n TransactionDetailResponse,\n TransactionListResponse,\n} from \"../types/index.js\";\n\nexport class Transactions {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Enrich a transaction with merchant, category, location, and entity data.\n *\n * @param request - The transaction to enrich (title, country, type, and optional options).\n * @param options - Optional enrichment controls (force bypass cache, idempotency key).\n * @returns The enriched transaction data.\n *\n * @example\n * ```ts\n * const result = await triqai.transactions.enrich({\n * title: \"STARBUCKS SEATTLE WA\",\n * country: \"US\",\n * type: \"expense\",\n * });\n * console.log(result.data.entities);\n * ```\n */\n async enrich(\n request: EnrichRequest,\n options?: EnrichOptions,\n ): Promise<EnrichSuccessResponse> {\n const headers: Record<string, string> = {};\n const query: Record<string, unknown> = {};\n\n if (options?.idempotencyKey) {\n headers[\"Idempotency-Key\"] = options.idempotencyKey;\n }\n if (options?.force) {\n query.force = \"true\";\n }\n\n const resp = await this.http.postWithHeaders<EnrichSuccessResponse>(\n \"/v1/transactions/enrich\",\n request,\n headers,\n Object.keys(query).length > 0 ? query : undefined,\n );\n return resp.data;\n }\n\n /**\n * List enriched transactions with pagination.\n *\n * @returns A `Page` of enriched transactions. Use `.autoPaginate()` or\n * `for await...of` to iterate through all pages automatically.\n *\n * @example\n * ```ts\n * const page = await triqai.transactions.list({ size: 10 });\n * console.log(page.data); // first 10 transactions\n *\n * // Auto-paginate through all:\n * for await (const tx of page) {\n * console.log(tx.id, tx.raw);\n * }\n * ```\n */\n async list(params?: ListTransactionsParams): Promise<Page<EnrichedTransaction>> {\n const fetchPage = async (page: number, size: number): Promise<Page<EnrichedTransaction>> => {\n const query: Record<string, unknown> = {\n page,\n size,\n };\n if (params?.startDate) {\n query.startDate =\n params.startDate instanceof Date\n ? params.startDate.toISOString()\n : params.startDate;\n }\n if (params?.endDate) {\n query.endDate =\n params.endDate instanceof Date\n ? params.endDate.toISOString()\n : params.endDate;\n }\n\n const resp = await this.http.get<TransactionListResponse>(\"/v1/transactions\", query);\n const { transactions, pagination } = resp.data.data;\n return new Page(transactions, pagination, fetchPage);\n };\n\n return fetchPage(params?.page ?? 1, params?.size ?? 25);\n }\n\n /**\n * Get a single transaction by ID.\n *\n * @param id - Transaction UUID.\n * @returns The enriched transaction record.\n */\n async get(id: string): Promise<EnrichedTransaction> {\n const resp = await this.http.get<TransactionDetailResponse>(\n `/v1/transactions/${encodeURIComponent(id)}`,\n );\n return resp.data.data.transaction;\n }\n\n /**\n * Delete a transaction by ID.\n *\n * @param id - Transaction UUID.\n * @returns Confirmation with the deleted transaction ID.\n */\n async delete(id: string): Promise<{ deleted: true; transactionId: string }> {\n const resp = await this.http.delete<DeleteTransactionResponse>(\n `/v1/transactions/${encodeURIComponent(id)}`,\n );\n return resp.data.data;\n }\n}\n","import type { HttpResponse } from \"./http-client.js\";\nimport { HttpClient } from \"./http-client.js\";\nimport { Categories } from \"./resources/categories.js\";\nimport { Intermediaries } from \"./resources/intermediaries.js\";\nimport { IssueReports } from \"./resources/issue-reports.js\";\nimport { Locations } from \"./resources/locations.js\";\nimport { Merchants } from \"./resources/merchants.js\";\nimport { Transactions } from \"./resources/transactions.js\";\nimport type {\n ApiInfoResponse,\n HealthResponse,\n TriqaiConfig,\n} from \"./types/index.js\";\n\n/**\n * The Triqai SDK client.\n *\n * @example\n * ```ts\n * import Triqai from \"triqai\";\n *\n * const triqai = new Triqai(\"triq_your_api_key\");\n *\n * const result = await triqai.transactions.enrich({\n * title: \"STARBUCKS SEATTLE WA\",\n * country: \"US\",\n * type: \"expense\",\n * });\n * ```\n */\nexport class Triqai {\n /** Enrich, list, get, and delete transactions. */\n readonly transactions: Transactions;\n /** List the full category taxonomy. */\n readonly categories: Categories;\n /** Look up merchant details by ID. */\n readonly merchants: Merchants;\n /** Look up location details by ID. */\n readonly locations: Locations;\n /** Look up intermediary (payment processor) details by ID. */\n readonly intermediaries: Intermediaries;\n /** Create and manage enrichment issue reports. */\n readonly issueReports: IssueReports;\n\n private readonly http: HttpClient;\n\n /**\n * Create a new Triqai SDK client.\n *\n * @param apiKey - Your Triqai API key (starts with `triq_`). Get one at https://triqai.com/dashboard\n * @param config - Optional configuration (base URL, retry settings, hooks).\n */\n constructor(apiKey: string, config?: TriqaiConfig) {\n this.http = new HttpClient(apiKey, config);\n this.transactions = new Transactions(this.http);\n this.categories = new Categories(this.http);\n this.merchants = new Merchants(this.http);\n this.locations = new Locations(this.http);\n this.intermediaries = new Intermediaries(this.http);\n this.issueReports = new IssueReports(this.http);\n }\n\n /**\n * Check the API health status.\n *\n * @returns Health status including service name and version.\n *\n * @example\n * ```ts\n * const health = await triqai.health();\n * console.log(health.data.status); // \"healthy\"\n * console.log(health.data.version); // \"1.1.9\"\n * ```\n */\n async health(): Promise<HealthResponse> {\n const resp = await this.http.get<HealthResponse>(\"/health\");\n return resp.data;\n }\n\n /**\n * Get API version and endpoint directory.\n *\n * @returns API version info and available endpoint paths.\n *\n * @example\n * ```ts\n * const info = await triqai.apiInfo();\n * console.log(info.data.version); // \"v1\"\n * console.log(info.data.endpoints);\n * ```\n */\n async apiInfo(): Promise<ApiInfoResponse> {\n const resp = await this.http.get<ApiInfoResponse>(\"/v1\");\n return resp.data;\n }\n\n /**\n * Make a raw GET request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-endpoint\").\n * @param query - Optional query parameters.\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawGet<T = unknown>(\n path: string,\n query?: Record<string, unknown>,\n ): Promise<HttpResponse<T>> {\n return this.http.get<T>(path, query);\n }\n\n /**\n * Make a raw POST request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-endpoint\").\n * @param body - Request body.\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawPost<T = unknown>(\n path: string,\n body?: unknown,\n ): Promise<HttpResponse<T>> {\n return this.http.post<T>(path, body);\n }\n\n /**\n * Make a raw DELETE request to any API path.\n * Useful for accessing endpoints not yet covered by a resource class.\n *\n * @param path - API path (e.g. \"/v1/some-resource/uuid\").\n * @returns The full HTTP response including headers and rate limit info.\n */\n async rawDelete<T = unknown>(path: string): Promise<HttpResponse<T>> {\n return this.http.delete<T>(path);\n }\n}\n","import { Triqai } from \"./client.js\";\n\nexport { Triqai };\nexport default Triqai;\n\nexport {\n TriqaiError,\n AuthenticationError,\n AuthorizationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n ClientDisconnectedError,\n DuplicateRequestError,\n RateLimitError,\n InternalServerError,\n ServiceUnavailableError,\n GatewayTimeoutError,\n ConnectionError,\n TimeoutError,\n} from \"./errors.js\";\nexport type { RawErrorObject, RawResponseMeta } from \"./errors.js\";\n\nexport type { HttpResponse } from \"./http-client.js\";\n\nexport { Page } from \"./pagination.js\";\nexport type { PageInfo } from \"./pagination.js\";\n\nexport type { CreateIssueReportParams } from \"./resources/issue-reports.js\";\n\nexport type {\n // SDK config types\n TriqaiConfig,\n RequestInfo,\n ResponseInfo,\n RateLimitInfo,\n EnrichOptions,\n ListTransactionsParams,\n ListIssueReportsParams,\n // Enrichment request types\n EnrichRequest,\n EnrichRequestOptions,\n EnrichmentFilterOptions,\n PrefilledMerchant,\n PrefilledLocation,\n PrefilledIntermediary,\n // Enrichment response types\n EnrichSuccessResponse,\n EnrichmentData,\n EnrichMeta,\n EnrichmentErrorCode,\n // Transaction types\n TransactionData,\n TransactionType,\n TransactionRecord,\n EnrichedTransaction,\n TransactionPagination,\n TransactionListResponse,\n TransactionDetailResponse,\n DeleteTransactionResponse,\n // Category types\n CategoryStructure,\n Category,\n CategoryCode,\n CategoryInfo,\n CategoryListResponse,\n // Confidence / subscription\n ConfidenceWithReasons,\n Subscription,\n SubscriptionType,\n // Entity types\n EntityResult,\n MerchantData,\n LocationData,\n IntermediaryData,\n IntermediaryRecord,\n PersonData,\n Coordinates,\n StructuredAddress,\n LocationRating,\n // Entity response types\n MerchantResponse,\n LocationResponse,\n IntermediaryResponse,\n // Issue report types\n IssueReport,\n IssueReportStatus,\n IssueReportResponse,\n IssueReportListResponse,\n ReportIssueRequest,\n EnrichmentFieldPath,\n // Error response types\n ErrorResponse,\n ErrorObject,\n DuplicateRequestErrorResponse,\n ClientDisconnectedErrorResponse,\n // Meta types\n ResponseMeta,\n PaginationMeta,\n // Utility response types\n HealthResponse,\n ApiInfoResponse,\n} from \"./types/index.js\";\n"]}
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: Triqai Transaction Enrichment API
4
- version: 1.1.9
4
+ version: 1.1.10
5
5
  description: |
6
6
  The Triqai API provides transaction enrichment capabilities for financial applications.
7
7
 
@@ -965,8 +965,22 @@ components:
965
965
  maximum: 100
966
966
  reasons:
967
967
  type: array
968
+ description: |
969
+ Confidence explanation tags. This list is dynamic and may evolve over time.
968
970
  items:
969
971
  type: string
972
+ description: |
973
+ Non-exhaustive confidence reason tag.
974
+ examples:
975
+ - known_processor_match
976
+ - results_contradict
977
+ - ambiguous_entity
978
+ - broad_merchant_name
979
+ - venue_or_attraction
980
+ - merchant_location_crosscheck_corrected
981
+ - merchant_location_crosscheck_recovered
982
+ - merchant_location_mismatch
983
+ - geo_mismatch
970
984
 
971
985
  CategoryCode:
972
986
  type: object
@@ -1039,16 +1053,6 @@ components:
1039
1053
  - $ref: '#/components/schemas/SubscriptionType'
1040
1054
  - type: 'null'
1041
1055
 
1042
- TransactionChannel:
1043
- type: string
1044
- enum:
1045
- - in_store
1046
- - online
1047
- - mobile_app
1048
- - atm
1049
- - bank_transfer
1050
- - unknown
1051
-
1052
1056
  Coordinates:
1053
1057
  type: object
1054
1058
  required:
@@ -1278,15 +1282,12 @@ components:
1278
1282
  required:
1279
1283
  - category
1280
1284
  - subscription
1281
- - channel
1282
1285
  - confidence
1283
1286
  properties:
1284
1287
  category:
1285
1288
  $ref: '#/components/schemas/CategoryStructure'
1286
1289
  subscription:
1287
1290
  $ref: '#/components/schemas/Subscription'
1288
- channel:
1289
- $ref: '#/components/schemas/TransactionChannel'
1290
1291
  confidence:
1291
1292
  $ref: '#/components/schemas/ConfidenceWithReasons'
1292
1293
 
@@ -1631,7 +1632,6 @@ components:
1631
1632
  - transaction.subscription
1632
1633
  - transaction.subscription.recurring
1633
1634
  - transaction.subscription.type
1634
- - transaction.channel
1635
1635
  - transaction.confidence
1636
1636
  - entities
1637
1637
  - entities.merchant
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "triqai",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Official TypeScript SDK for the Triqai Transaction Enrichment API",
5
5
  "author": "Triqai <hello@triqai.com>",
6
6
  "license": "MIT",
7
- "homepage": "https://github.com/triqai/triqai-node",
7
+ "homepage": "https://github.com/triqai/typescript-sdk",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/triqai/triqai-node.git"
10
+ "url": "git+https://github.com/triqai/typescript-sdk.git"
11
11
  },
12
12
  "bugs": {
13
- "url": "https://github.com/triqai/triqai-node/issues"
13
+ "url": "https://github.com/triqai/typescript-sdk/issues"
14
14
  },
15
15
  "keywords": [
16
16
  "triqai",