triqai 0.1.3 → 0.1.5
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 +7 -0
- package/README.md +1 -1
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -3
- package/dist/index.d.ts +59 -3
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/openapi-public.yaml +220 -12
- package/package.json +13 -7
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.4] - 2026-09-13
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Generate an idempotency key for each enrichment call and reuse it across automatic retries.
|
|
15
|
+
- Synchronize packaged API types with the current public API contract.
|
|
16
|
+
|
|
10
17
|
## [0.1.2] - 2026-03-30
|
|
11
18
|
|
|
12
19
|
### Changed
|
package/README.md
CHANGED
|
@@ -273,7 +273,7 @@ try {
|
|
|
273
273
|
The SDK automatically retries on transient errors (429, 500, 503, 504, and network errors) with exponential backoff:
|
|
274
274
|
|
|
275
275
|
- GET and DELETE requests are always retried
|
|
276
|
-
-
|
|
276
|
+
- Enrichment calls generate an idempotency key and reuse it across automatic retries. Supply your own `idempotencyKey` to safely retry across separate calls
|
|
277
277
|
- The `Retry-After` header is respected when present
|
|
278
278
|
- Default: 3 retries, 500ms base delay, 30s max delay
|
|
279
279
|
|
package/dist/index.cjs
CHANGED
|
@@ -669,6 +669,15 @@ var Merchants = class {
|
|
|
669
669
|
};
|
|
670
670
|
|
|
671
671
|
// src/resources/transactions.ts
|
|
672
|
+
async function createIdempotencyKey() {
|
|
673
|
+
if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();
|
|
674
|
+
const nodeCrypto = "node:crypto";
|
|
675
|
+
const { randomUUID } = await import(
|
|
676
|
+
/* webpackIgnore: true */
|
|
677
|
+
nodeCrypto
|
|
678
|
+
);
|
|
679
|
+
return randomUUID();
|
|
680
|
+
}
|
|
672
681
|
var Transactions = class {
|
|
673
682
|
constructor(http) {
|
|
674
683
|
this.http = http;
|
|
@@ -691,11 +700,10 @@ var Transactions = class {
|
|
|
691
700
|
* ```
|
|
692
701
|
*/
|
|
693
702
|
async enrich(request, options) {
|
|
694
|
-
const headers = {
|
|
703
|
+
const headers = {
|
|
704
|
+
"Idempotency-Key": options?.idempotencyKey ?? await createIdempotencyKey()
|
|
705
|
+
};
|
|
695
706
|
const query = {};
|
|
696
|
-
if (options?.idempotencyKey) {
|
|
697
|
-
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
698
|
-
}
|
|
699
707
|
if (options?.force) {
|
|
700
708
|
query.force = "true";
|
|
701
709
|
}
|
package/dist/index.cjs.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;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,SAA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AA;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.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\n ConfidenceWithReasons,\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;AA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AAA;AAAA;AAAA;AAAA,EAcA,MAAM,MAAA,GAAkC;AACtC,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,IAAoB,SAAS,CAAA;AAC1D,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,OAAA,GAAoC;AACxC,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,IAAqB,KAAK,CAAA;AACvD,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;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.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 // eslint-disable-next-line @typescript-eslint/no-this-alias -- Cursor advances to a different Page on each request.\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\nasync function createIdempotencyKey(): Promise<string> {\n if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();\n // Node 18 does not always expose Web Crypto globally. Keep its fallback lazy\n // and the module name dynamic so Worker bundlers need no Node compatibility.\n const nodeCrypto = \"node:crypto\";\n const { randomUUID } = await import(/* webpackIgnore: true */ nodeCrypto) as typeof import(\"node:crypto\");\n return randomUUID();\n}\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 \"Idempotency-Key\": options?.idempotencyKey ?? await createIdempotencyKey(),\n };\n const query: Record<string, unknown> = {};\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\n ConfidenceWithReasons,\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
|
@@ -23,6 +23,34 @@ type components = {
|
|
|
23
23
|
/** @enum {boolean} */
|
|
24
24
|
success: true;
|
|
25
25
|
};
|
|
26
|
+
/** @description Provide exactly one of `all`, `afterDate`, or `ids`. */
|
|
27
|
+
BatchDeleteRequest: {
|
|
28
|
+
/**
|
|
29
|
+
* @description When `true`, deletes all transactions for the organization.
|
|
30
|
+
* @enum {boolean}
|
|
31
|
+
*/
|
|
32
|
+
all: true;
|
|
33
|
+
} | {
|
|
34
|
+
/**
|
|
35
|
+
* Format: date-time
|
|
36
|
+
* @description Delete all transactions created on or after this date.
|
|
37
|
+
*/
|
|
38
|
+
afterDate: string;
|
|
39
|
+
} | {
|
|
40
|
+
/** @description Delete specific transactions by UUID (max 1000). */
|
|
41
|
+
ids: string[];
|
|
42
|
+
};
|
|
43
|
+
BatchDeleteResponse: {
|
|
44
|
+
data: {
|
|
45
|
+
/** @description Number of transactions deleted. */
|
|
46
|
+
count: number;
|
|
47
|
+
/** @enum {boolean} */
|
|
48
|
+
deleted: true;
|
|
49
|
+
};
|
|
50
|
+
meta: components["schemas"]["ResponseMeta"];
|
|
51
|
+
/** @enum {boolean} */
|
|
52
|
+
success: true;
|
|
53
|
+
};
|
|
26
54
|
Category: {
|
|
27
55
|
code: components["schemas"]["CategoryCode"];
|
|
28
56
|
name: string;
|
|
@@ -171,7 +199,7 @@ type components = {
|
|
|
171
199
|
};
|
|
172
200
|
EntityResult: {
|
|
173
201
|
confidence: components["schemas"]["ConfidenceWithReasons"];
|
|
174
|
-
data: components["schemas"]["
|
|
202
|
+
data: components["schemas"]["MerchantEntityData"] | components["schemas"]["LocationData"] | components["schemas"]["IntermediaryData"] | components["schemas"]["PersonData"];
|
|
175
203
|
role: string;
|
|
176
204
|
/** @enum {string} */
|
|
177
205
|
type: "merchant" | "location" | "intermediary" | "person";
|
|
@@ -287,6 +315,22 @@ type components = {
|
|
|
287
315
|
success: true;
|
|
288
316
|
};
|
|
289
317
|
MerchantData: {
|
|
318
|
+
alias: string[];
|
|
319
|
+
/** @description Merchant category classification. Present on `GET /v1/merchants/{id}` responses. */
|
|
320
|
+
category?: components["schemas"]["CategoryStructure"] | null;
|
|
321
|
+
color: string | null;
|
|
322
|
+
/** @description Brief description of the merchant. May be absent. */
|
|
323
|
+
description?: string;
|
|
324
|
+
domain: string | null;
|
|
325
|
+
icon: string | null;
|
|
326
|
+
/** Format: uuid */
|
|
327
|
+
id: string;
|
|
328
|
+
/** @description Search keywords associated with this merchant. May be absent. */
|
|
329
|
+
keywords?: string[];
|
|
330
|
+
name: string;
|
|
331
|
+
website: string | null;
|
|
332
|
+
};
|
|
333
|
+
MerchantEntityData: {
|
|
290
334
|
alias: string[];
|
|
291
335
|
color: string | null;
|
|
292
336
|
/** @description Brief description of the merchant. May be absent. */
|
|
@@ -375,8 +419,12 @@ type components = {
|
|
|
375
419
|
};
|
|
376
420
|
ReportIssueRequest: {
|
|
377
421
|
description: string;
|
|
422
|
+
/** @description Enrichment response field paths to report, such as `transaction.category.primary.name`. */
|
|
378
423
|
fields: components["schemas"]["EnrichmentFieldPath"][];
|
|
379
|
-
/**
|
|
424
|
+
/**
|
|
425
|
+
* Format: uuid
|
|
426
|
+
* @description Transaction identifier returned as `meta.transactionId` by the enrichment response. This is not `meta.requestId`, and the transaction must still exist in the organization's activity history.
|
|
427
|
+
*/
|
|
380
428
|
transaction_id: string;
|
|
381
429
|
};
|
|
382
430
|
ResponseMeta: {
|
|
@@ -397,6 +445,14 @@ type components = {
|
|
|
397
445
|
street: string;
|
|
398
446
|
timezone: string;
|
|
399
447
|
};
|
|
448
|
+
TransactionCountResponse: {
|
|
449
|
+
data: {
|
|
450
|
+
count: number;
|
|
451
|
+
};
|
|
452
|
+
meta: components["schemas"]["ResponseMeta"];
|
|
453
|
+
/** @enum {boolean} */
|
|
454
|
+
success: true;
|
|
455
|
+
};
|
|
400
456
|
TransactionData: {
|
|
401
457
|
category: components["schemas"]["CategoryStructure"];
|
|
402
458
|
confidence: components["schemas"]["ConfidenceWithReasons"];
|
|
@@ -753,7 +809,7 @@ interface RateLimitInfo {
|
|
|
753
809
|
interface EnrichOptions {
|
|
754
810
|
/** Bypass cached result. */
|
|
755
811
|
force?: boolean;
|
|
756
|
-
/**
|
|
812
|
+
/** Defaults to a UUID per enrich call, reused across automatic retries. Supply a stable key to retry across calls. Must match ^[a-zA-Z0-9_-]{1,64}$. */
|
|
757
813
|
idempotencyKey?: string;
|
|
758
814
|
}
|
|
759
815
|
interface ListTransactionsParams {
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,34 @@ type components = {
|
|
|
23
23
|
/** @enum {boolean} */
|
|
24
24
|
success: true;
|
|
25
25
|
};
|
|
26
|
+
/** @description Provide exactly one of `all`, `afterDate`, or `ids`. */
|
|
27
|
+
BatchDeleteRequest: {
|
|
28
|
+
/**
|
|
29
|
+
* @description When `true`, deletes all transactions for the organization.
|
|
30
|
+
* @enum {boolean}
|
|
31
|
+
*/
|
|
32
|
+
all: true;
|
|
33
|
+
} | {
|
|
34
|
+
/**
|
|
35
|
+
* Format: date-time
|
|
36
|
+
* @description Delete all transactions created on or after this date.
|
|
37
|
+
*/
|
|
38
|
+
afterDate: string;
|
|
39
|
+
} | {
|
|
40
|
+
/** @description Delete specific transactions by UUID (max 1000). */
|
|
41
|
+
ids: string[];
|
|
42
|
+
};
|
|
43
|
+
BatchDeleteResponse: {
|
|
44
|
+
data: {
|
|
45
|
+
/** @description Number of transactions deleted. */
|
|
46
|
+
count: number;
|
|
47
|
+
/** @enum {boolean} */
|
|
48
|
+
deleted: true;
|
|
49
|
+
};
|
|
50
|
+
meta: components["schemas"]["ResponseMeta"];
|
|
51
|
+
/** @enum {boolean} */
|
|
52
|
+
success: true;
|
|
53
|
+
};
|
|
26
54
|
Category: {
|
|
27
55
|
code: components["schemas"]["CategoryCode"];
|
|
28
56
|
name: string;
|
|
@@ -171,7 +199,7 @@ type components = {
|
|
|
171
199
|
};
|
|
172
200
|
EntityResult: {
|
|
173
201
|
confidence: components["schemas"]["ConfidenceWithReasons"];
|
|
174
|
-
data: components["schemas"]["
|
|
202
|
+
data: components["schemas"]["MerchantEntityData"] | components["schemas"]["LocationData"] | components["schemas"]["IntermediaryData"] | components["schemas"]["PersonData"];
|
|
175
203
|
role: string;
|
|
176
204
|
/** @enum {string} */
|
|
177
205
|
type: "merchant" | "location" | "intermediary" | "person";
|
|
@@ -287,6 +315,22 @@ type components = {
|
|
|
287
315
|
success: true;
|
|
288
316
|
};
|
|
289
317
|
MerchantData: {
|
|
318
|
+
alias: string[];
|
|
319
|
+
/** @description Merchant category classification. Present on `GET /v1/merchants/{id}` responses. */
|
|
320
|
+
category?: components["schemas"]["CategoryStructure"] | null;
|
|
321
|
+
color: string | null;
|
|
322
|
+
/** @description Brief description of the merchant. May be absent. */
|
|
323
|
+
description?: string;
|
|
324
|
+
domain: string | null;
|
|
325
|
+
icon: string | null;
|
|
326
|
+
/** Format: uuid */
|
|
327
|
+
id: string;
|
|
328
|
+
/** @description Search keywords associated with this merchant. May be absent. */
|
|
329
|
+
keywords?: string[];
|
|
330
|
+
name: string;
|
|
331
|
+
website: string | null;
|
|
332
|
+
};
|
|
333
|
+
MerchantEntityData: {
|
|
290
334
|
alias: string[];
|
|
291
335
|
color: string | null;
|
|
292
336
|
/** @description Brief description of the merchant. May be absent. */
|
|
@@ -375,8 +419,12 @@ type components = {
|
|
|
375
419
|
};
|
|
376
420
|
ReportIssueRequest: {
|
|
377
421
|
description: string;
|
|
422
|
+
/** @description Enrichment response field paths to report, such as `transaction.category.primary.name`. */
|
|
378
423
|
fields: components["schemas"]["EnrichmentFieldPath"][];
|
|
379
|
-
/**
|
|
424
|
+
/**
|
|
425
|
+
* Format: uuid
|
|
426
|
+
* @description Transaction identifier returned as `meta.transactionId` by the enrichment response. This is not `meta.requestId`, and the transaction must still exist in the organization's activity history.
|
|
427
|
+
*/
|
|
380
428
|
transaction_id: string;
|
|
381
429
|
};
|
|
382
430
|
ResponseMeta: {
|
|
@@ -397,6 +445,14 @@ type components = {
|
|
|
397
445
|
street: string;
|
|
398
446
|
timezone: string;
|
|
399
447
|
};
|
|
448
|
+
TransactionCountResponse: {
|
|
449
|
+
data: {
|
|
450
|
+
count: number;
|
|
451
|
+
};
|
|
452
|
+
meta: components["schemas"]["ResponseMeta"];
|
|
453
|
+
/** @enum {boolean} */
|
|
454
|
+
success: true;
|
|
455
|
+
};
|
|
400
456
|
TransactionData: {
|
|
401
457
|
category: components["schemas"]["CategoryStructure"];
|
|
402
458
|
confidence: components["schemas"]["ConfidenceWithReasons"];
|
|
@@ -753,7 +809,7 @@ interface RateLimitInfo {
|
|
|
753
809
|
interface EnrichOptions {
|
|
754
810
|
/** Bypass cached result. */
|
|
755
811
|
force?: boolean;
|
|
756
|
-
/**
|
|
812
|
+
/** Defaults to a UUID per enrich call, reused across automatic retries. Supply a stable key to retry across calls. Must match ^[a-zA-Z0-9_-]{1,64}$. */
|
|
757
813
|
idempotencyKey?: string;
|
|
758
814
|
}
|
|
759
815
|
interface ListTransactionsParams {
|
package/dist/index.js
CHANGED
|
@@ -665,6 +665,15 @@ var Merchants = class {
|
|
|
665
665
|
};
|
|
666
666
|
|
|
667
667
|
// src/resources/transactions.ts
|
|
668
|
+
async function createIdempotencyKey() {
|
|
669
|
+
if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();
|
|
670
|
+
const nodeCrypto = "node:crypto";
|
|
671
|
+
const { randomUUID } = await import(
|
|
672
|
+
/* webpackIgnore: true */
|
|
673
|
+
nodeCrypto
|
|
674
|
+
);
|
|
675
|
+
return randomUUID();
|
|
676
|
+
}
|
|
668
677
|
var Transactions = class {
|
|
669
678
|
constructor(http) {
|
|
670
679
|
this.http = http;
|
|
@@ -687,11 +696,10 @@ var Transactions = class {
|
|
|
687
696
|
* ```
|
|
688
697
|
*/
|
|
689
698
|
async enrich(request, options) {
|
|
690
|
-
const headers = {
|
|
699
|
+
const headers = {
|
|
700
|
+
"Idempotency-Key": options?.idempotencyKey ?? await createIdempotencyKey()
|
|
701
|
+
};
|
|
691
702
|
const query = {};
|
|
692
|
-
if (options?.idempotencyKey) {
|
|
693
|
-
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
694
|
-
}
|
|
695
703
|
if (options?.force) {
|
|
696
704
|
query.force = "true";
|
|
697
705
|
}
|
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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A,GAAO,MAAM,IAAA,CAAK,IAAA,CAAK,IAAqB,KAAK,CAAA;AACvD,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;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.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\n ConfidenceWithReasons,\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,IAAA,GAAO,qBAAA;AAAA,EACd;AACF;AAEO,IAAM,kBAAA,GAAN,cAAiC,WAAA,CAAY;AAAA,EAClD,WAAA,CAAY,SAAiB,IAAA,EAAqD;AAChF,IAAA,KAAA,CAAM,SAAS,GAAA,EAAK,EAAE,MAAM,qBAAA,EAAuB,GAAG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,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.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 // eslint-disable-next-line @typescript-eslint/no-this-alias -- Cursor advances to a different Page on each request.\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\nasync function createIdempotencyKey(): Promise<string> {\n if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();\n // Node 18 does not always expose Web Crypto globally. Keep its fallback lazy\n // and the module name dynamic so Worker bundlers need no Node compatibility.\n const nodeCrypto = \"node:crypto\";\n const { randomUUID } = await import(/* webpackIgnore: true */ nodeCrypto) as typeof import(\"node:crypto\");\n return randomUUID();\n}\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 \"Idempotency-Key\": options?.idempotencyKey ?? await createIdempotencyKey(),\n };\n const query: Record<string, unknown> = {};\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\n ConfidenceWithReasons,\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/openapi-public.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
openapi: 3.1.0
|
|
2
2
|
info:
|
|
3
3
|
title: Triqai Transaction Enrichment API
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.51
|
|
5
5
|
description: |
|
|
6
6
|
The Triqai API provides transaction enrichment capabilities for financial applications.
|
|
7
7
|
|
|
@@ -24,7 +24,7 @@ info:
|
|
|
24
24
|
|
|
25
25
|
## Idempotency
|
|
26
26
|
|
|
27
|
-
You
|
|
27
|
+
You must supply `Idempotency-Key` (or `X-Idempotency-Key`) for enrichment requests so retries preserve billing and persistence identity.
|
|
28
28
|
Keys must match `^[a-zA-Z0-9_-]{1,64}$`.
|
|
29
29
|
Reusing a key returns `409`:
|
|
30
30
|
- `state=completed`: request with this key already finished
|
|
@@ -109,17 +109,10 @@ paths:
|
|
|
109
109
|
description: Enriches a transaction and returns structured transaction + entity data.
|
|
110
110
|
operationId: enrichTransaction
|
|
111
111
|
parameters:
|
|
112
|
-
- name: force
|
|
113
|
-
in: query
|
|
114
|
-
required: false
|
|
115
|
-
description: Bypass cached result when true.
|
|
116
|
-
schema:
|
|
117
|
-
type: boolean
|
|
118
|
-
default: false
|
|
119
112
|
- name: Idempotency-Key
|
|
120
113
|
in: header
|
|
121
|
-
required:
|
|
122
|
-
description:
|
|
114
|
+
required: true
|
|
115
|
+
description: Required retry identity. `X-Idempotency-Key` is also accepted and must match when both are sent.
|
|
123
116
|
schema:
|
|
124
117
|
type: string
|
|
125
118
|
minLength: 1
|
|
@@ -311,6 +304,93 @@ paths:
|
|
|
311
304
|
'500':
|
|
312
305
|
$ref: '#/components/responses/InternalError'
|
|
313
306
|
|
|
307
|
+
/v1/transactions/count:
|
|
308
|
+
get:
|
|
309
|
+
tags:
|
|
310
|
+
- Transactions
|
|
311
|
+
summary: Count transactions
|
|
312
|
+
description: |
|
|
313
|
+
Returns the total number of transactions for the authenticated organization.
|
|
314
|
+
Optionally filter by `afterDate` to count only transactions created on or after a given date.
|
|
315
|
+
operationId: countTransactions
|
|
316
|
+
parameters:
|
|
317
|
+
- name: afterDate
|
|
318
|
+
in: query
|
|
319
|
+
required: false
|
|
320
|
+
description: Only count transactions created on or after this ISO 8601 timestamp.
|
|
321
|
+
schema:
|
|
322
|
+
type: string
|
|
323
|
+
format: date-time
|
|
324
|
+
responses:
|
|
325
|
+
'200':
|
|
326
|
+
description: Transaction count
|
|
327
|
+
content:
|
|
328
|
+
application/json:
|
|
329
|
+
schema:
|
|
330
|
+
$ref: '#/components/schemas/TransactionCountResponse'
|
|
331
|
+
'401':
|
|
332
|
+
$ref: '#/components/responses/Unauthorized'
|
|
333
|
+
'403':
|
|
334
|
+
$ref: '#/components/responses/Forbidden'
|
|
335
|
+
'422':
|
|
336
|
+
$ref: '#/components/responses/ValidationError'
|
|
337
|
+
'429':
|
|
338
|
+
$ref: '#/components/responses/RateLimited'
|
|
339
|
+
'500':
|
|
340
|
+
$ref: '#/components/responses/InternalError'
|
|
341
|
+
|
|
342
|
+
/v1/transactions/batch:
|
|
343
|
+
delete:
|
|
344
|
+
tags:
|
|
345
|
+
- Transactions
|
|
346
|
+
summary: Batch delete transactions
|
|
347
|
+
description: |
|
|
348
|
+
Delete multiple transactions in a single request. Provide exactly **one** of:
|
|
349
|
+
- `all: true` — delete every transaction for the organization
|
|
350
|
+
- `afterDate` — delete all transactions created on or after the given ISO 8601 date
|
|
351
|
+
- `ids` — delete specific transactions by UUID (max 1000)
|
|
352
|
+
|
|
353
|
+
Associated KV cache entries and DLQ entries are purged after deletion.
|
|
354
|
+
operationId: batchDeleteTransactions
|
|
355
|
+
requestBody:
|
|
356
|
+
required: true
|
|
357
|
+
content:
|
|
358
|
+
application/json:
|
|
359
|
+
schema:
|
|
360
|
+
$ref: '#/components/schemas/BatchDeleteRequest'
|
|
361
|
+
examples:
|
|
362
|
+
delete_all:
|
|
363
|
+
summary: Delete all transactions
|
|
364
|
+
value:
|
|
365
|
+
all: true
|
|
366
|
+
delete_by_date:
|
|
367
|
+
summary: Delete transactions after a date
|
|
368
|
+
value:
|
|
369
|
+
afterDate: '2026-01-01T00:00:00Z'
|
|
370
|
+
delete_by_ids:
|
|
371
|
+
summary: Delete specific transactions
|
|
372
|
+
value:
|
|
373
|
+
ids:
|
|
374
|
+
- 'f353ca91-4fc5-49f2-9b9e-304f83d11914'
|
|
375
|
+
- 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
|
|
376
|
+
responses:
|
|
377
|
+
'200':
|
|
378
|
+
description: Batch deletion completed
|
|
379
|
+
content:
|
|
380
|
+
application/json:
|
|
381
|
+
schema:
|
|
382
|
+
$ref: '#/components/schemas/BatchDeleteResponse'
|
|
383
|
+
'401':
|
|
384
|
+
$ref: '#/components/responses/Unauthorized'
|
|
385
|
+
'403':
|
|
386
|
+
$ref: '#/components/responses/Forbidden'
|
|
387
|
+
'422':
|
|
388
|
+
$ref: '#/components/responses/ValidationError'
|
|
389
|
+
'429':
|
|
390
|
+
$ref: '#/components/responses/RateLimited'
|
|
391
|
+
'500':
|
|
392
|
+
$ref: '#/components/responses/InternalError'
|
|
393
|
+
|
|
314
394
|
/v1/categories:
|
|
315
395
|
get:
|
|
316
396
|
tags:
|
|
@@ -1063,6 +1143,58 @@ components:
|
|
|
1063
1143
|
type: string
|
|
1064
1144
|
|
|
1065
1145
|
MerchantData:
|
|
1146
|
+
type: object
|
|
1147
|
+
required:
|
|
1148
|
+
- id
|
|
1149
|
+
- name
|
|
1150
|
+
- alias
|
|
1151
|
+
- icon
|
|
1152
|
+
- color
|
|
1153
|
+
- website
|
|
1154
|
+
- domain
|
|
1155
|
+
properties:
|
|
1156
|
+
id:
|
|
1157
|
+
type: string
|
|
1158
|
+
format: uuid
|
|
1159
|
+
name:
|
|
1160
|
+
type: string
|
|
1161
|
+
alias:
|
|
1162
|
+
type: array
|
|
1163
|
+
items:
|
|
1164
|
+
type: string
|
|
1165
|
+
keywords:
|
|
1166
|
+
type: array
|
|
1167
|
+
description: Search keywords associated with this merchant. May be absent.
|
|
1168
|
+
items:
|
|
1169
|
+
type: string
|
|
1170
|
+
icon:
|
|
1171
|
+
oneOf:
|
|
1172
|
+
- type: string
|
|
1173
|
+
format: uri
|
|
1174
|
+
- type: 'null'
|
|
1175
|
+
description:
|
|
1176
|
+
type: string
|
|
1177
|
+
description: Brief description of the merchant. May be absent.
|
|
1178
|
+
color:
|
|
1179
|
+
oneOf:
|
|
1180
|
+
- type: string
|
|
1181
|
+
- type: 'null'
|
|
1182
|
+
website:
|
|
1183
|
+
oneOf:
|
|
1184
|
+
- type: string
|
|
1185
|
+
format: uri
|
|
1186
|
+
- type: 'null'
|
|
1187
|
+
domain:
|
|
1188
|
+
oneOf:
|
|
1189
|
+
- type: string
|
|
1190
|
+
- type: 'null'
|
|
1191
|
+
category:
|
|
1192
|
+
oneOf:
|
|
1193
|
+
- $ref: '#/components/schemas/CategoryStructure'
|
|
1194
|
+
- type: 'null'
|
|
1195
|
+
description: Merchant category classification. Present on `GET /v1/merchants/{id}` responses.
|
|
1196
|
+
|
|
1197
|
+
MerchantEntityData:
|
|
1066
1198
|
type: object
|
|
1067
1199
|
required:
|
|
1068
1200
|
- id
|
|
@@ -1239,7 +1371,7 @@ components:
|
|
|
1239
1371
|
$ref: '#/components/schemas/ConfidenceWithReasons'
|
|
1240
1372
|
data:
|
|
1241
1373
|
oneOf:
|
|
1242
|
-
- $ref: '#/components/schemas/
|
|
1374
|
+
- $ref: '#/components/schemas/MerchantEntityData'
|
|
1243
1375
|
- $ref: '#/components/schemas/LocationData'
|
|
1244
1376
|
- $ref: '#/components/schemas/IntermediaryData'
|
|
1245
1377
|
- $ref: '#/components/schemas/PersonData'
|
|
@@ -1444,6 +1576,80 @@ components:
|
|
|
1444
1576
|
meta:
|
|
1445
1577
|
$ref: '#/components/schemas/ResponseMeta'
|
|
1446
1578
|
|
|
1579
|
+
TransactionCountResponse:
|
|
1580
|
+
type: object
|
|
1581
|
+
required:
|
|
1582
|
+
- success
|
|
1583
|
+
- data
|
|
1584
|
+
- meta
|
|
1585
|
+
properties:
|
|
1586
|
+
success:
|
|
1587
|
+
type: boolean
|
|
1588
|
+
enum: [true]
|
|
1589
|
+
data:
|
|
1590
|
+
type: object
|
|
1591
|
+
required:
|
|
1592
|
+
- count
|
|
1593
|
+
properties:
|
|
1594
|
+
count:
|
|
1595
|
+
type: integer
|
|
1596
|
+
minimum: 0
|
|
1597
|
+
meta:
|
|
1598
|
+
$ref: '#/components/schemas/ResponseMeta'
|
|
1599
|
+
|
|
1600
|
+
BatchDeleteRequest:
|
|
1601
|
+
type: object
|
|
1602
|
+
description: |
|
|
1603
|
+
Provide exactly one of `all`, `afterDate`, or `ids`.
|
|
1604
|
+
oneOf:
|
|
1605
|
+
- required: [all]
|
|
1606
|
+
properties:
|
|
1607
|
+
all:
|
|
1608
|
+
type: boolean
|
|
1609
|
+
enum: [true]
|
|
1610
|
+
description: When `true`, deletes all transactions for the organization.
|
|
1611
|
+
- required: [afterDate]
|
|
1612
|
+
properties:
|
|
1613
|
+
afterDate:
|
|
1614
|
+
type: string
|
|
1615
|
+
format: date-time
|
|
1616
|
+
description: Delete all transactions created on or after this date.
|
|
1617
|
+
- required: [ids]
|
|
1618
|
+
properties:
|
|
1619
|
+
ids:
|
|
1620
|
+
type: array
|
|
1621
|
+
description: Delete specific transactions by UUID (max 1000).
|
|
1622
|
+
maxItems: 1000
|
|
1623
|
+
items:
|
|
1624
|
+
type: string
|
|
1625
|
+
format: uuid
|
|
1626
|
+
|
|
1627
|
+
BatchDeleteResponse:
|
|
1628
|
+
type: object
|
|
1629
|
+
required:
|
|
1630
|
+
- success
|
|
1631
|
+
- data
|
|
1632
|
+
- meta
|
|
1633
|
+
properties:
|
|
1634
|
+
success:
|
|
1635
|
+
type: boolean
|
|
1636
|
+
enum: [true]
|
|
1637
|
+
data:
|
|
1638
|
+
type: object
|
|
1639
|
+
required:
|
|
1640
|
+
- deleted
|
|
1641
|
+
- count
|
|
1642
|
+
properties:
|
|
1643
|
+
deleted:
|
|
1644
|
+
type: boolean
|
|
1645
|
+
enum: [true]
|
|
1646
|
+
count:
|
|
1647
|
+
type: integer
|
|
1648
|
+
minimum: 0
|
|
1649
|
+
description: Number of transactions deleted.
|
|
1650
|
+
meta:
|
|
1651
|
+
$ref: '#/components/schemas/ResponseMeta'
|
|
1652
|
+
|
|
1447
1653
|
CategoryInfo:
|
|
1448
1654
|
type: object
|
|
1449
1655
|
required:
|
|
@@ -1630,6 +1836,7 @@ components:
|
|
|
1630
1836
|
transaction_id:
|
|
1631
1837
|
type: string
|
|
1632
1838
|
format: uuid
|
|
1839
|
+
description: Transaction identifier returned as `meta.transactionId` by the enrichment response. This is not `meta.requestId`, and the transaction must still exist in the organization's activity history.
|
|
1633
1840
|
description:
|
|
1634
1841
|
type: string
|
|
1635
1842
|
minLength: 1
|
|
@@ -1638,6 +1845,7 @@ components:
|
|
|
1638
1845
|
type: array
|
|
1639
1846
|
minItems: 1
|
|
1640
1847
|
maxItems: 50
|
|
1848
|
+
description: Enrichment response field paths to report, such as `transaction.category.primary.name`.
|
|
1641
1849
|
items:
|
|
1642
1850
|
$ref: '#/components/schemas/EnrichmentFieldPath'
|
|
1643
1851
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "triqai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
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/
|
|
7
|
+
"homepage": "https://github.com/triqai/triqai/tree/main/packages/sdk-node",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/triqai/
|
|
10
|
+
"url": "git+https://github.com/triqai/triqai.git",
|
|
11
|
+
"directory": "packages/sdk-node"
|
|
11
12
|
},
|
|
12
13
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/triqai/
|
|
14
|
+
"url": "https://github.com/triqai/triqai/issues"
|
|
14
15
|
},
|
|
15
16
|
"keywords": [
|
|
16
17
|
"triqai",
|
|
@@ -57,9 +58,11 @@
|
|
|
57
58
|
"test:watch": "vitest",
|
|
58
59
|
"typecheck": "tsc --noEmit",
|
|
59
60
|
"generate": "node scripts/generate-types.mjs",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
61
|
+
"prepublishOnly": "bun run typecheck && bun run test:ci && bun run build",
|
|
62
|
+
"lint": "eslint .",
|
|
63
|
+
"test:ci": "vitest run && bun run test:package",
|
|
64
|
+
"test:package": "bun run build && node scripts/check-package.mjs",
|
|
65
|
+
"generate:check": "node scripts/generate-types.mjs --check"
|
|
63
66
|
},
|
|
64
67
|
"devDependencies": {
|
|
65
68
|
"openapi-typescript": "^7.6.1",
|
|
@@ -67,5 +70,8 @@
|
|
|
67
70
|
"typescript": "^5.7.0",
|
|
68
71
|
"vitest": "^3.0.0",
|
|
69
72
|
"yaml": "^2.7.0"
|
|
73
|
+
},
|
|
74
|
+
"installConfig": {
|
|
75
|
+
"hoistingLimits": "workspaces"
|
|
70
76
|
}
|
|
71
77
|
}
|