triqai 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.8] - 2026-11-15
11
+
12
+ ### Added
13
+
14
+ - `options.p2p` on transaction enrichment: `true` for a known person-to-person transfer, `false` for a known payment to a business.
15
+
16
+ ## [0.2.7] - 2026-10-23
17
+
18
+ ### Changed
19
+
20
+ - Updated transaction deletion response types to include temporary cleanup failures.
21
+ - Included terminal `410` enrichment responses for erased transaction data or inactive organizations.
22
+
10
23
  ## [0.2.6] - 2026-10-21
11
24
 
12
25
  ### Changed
package/README.md CHANGED
@@ -96,6 +96,15 @@ const result = await triqai.transactions.enrich({
96
96
  },
97
97
  });
98
98
 
99
+ // When your payment rail already tells you who was paid, pass `p2p`:
100
+ // `true` for a person-to-person transfer, `false` for a payment to a business.
101
+ await triqai.transactions.enrich({
102
+ title: "BILL PAYMENT TO J D MORGAN REF RENT",
103
+ country: "GB",
104
+ type: "expense",
105
+ options: { p2p: true },
106
+ });
107
+
99
108
  // API v1.1.11+: `data.transaction.channel` is no longer returned.
100
109
  // Confidence reasons are dynamic and may include tags like:
101
110
  // `venue_or_attraction`, `merchant_location_crosscheck_corrected`,
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  // package.json
6
- var version = "0.2.6";
6
+ var version = "0.2.8";
7
7
 
8
8
  // src/errors.ts
9
9
  var TriqaiError = class extends Error {
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/errors.ts","../src/http-client.ts","../src/resources/banks.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/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B,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;;;ACzIA,IAAO,aAAA,GAAQ","file":"index.cjs","sourcesContent":["{\n\t\"name\": \"triqai\",\n\t\"version\": \"0.2.6\",\n\t\"description\": \"Official TypeScript SDK for the Triqai Transaction Enrichment API\",\n\t\"author\": \"Triqai <hello@triqai.com>\",\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://github.com/triqai/triqai/tree/main/packages/sdk-node\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/triqai/triqai.git\",\n\t\t\"directory\": \"packages/sdk-node\"\n\t},\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/triqai/triqai/issues\"\n\t},\n\t\"keywords\": [\n\t\t\"triqai\",\n\t\t\"transaction\",\n\t\t\"enrichment\",\n\t\t\"fintech\",\n\t\t\"banking\",\n\t\t\"categorization\",\n\t\t\"merchant\",\n\t\t\"sdk\",\n\t\t\"api\"\n\t],\n\t\"sideEffects\": false,\n\t\"type\": \"module\",\n\t\"main\": \"./dist/index.cjs\",\n\t\"module\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\t\"default\": \"./dist/index.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/index.d.cts\",\n\t\t\t\t\"default\": \"./dist/index.cjs\"\n\t\t\t}\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"openapi-public.yaml\",\n\t\t\"README.md\",\n\t\t\"LICENSE\",\n\t\t\"CHANGELOG.md\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=18.0.0\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"tsup\",\n\t\t\"dev\": \"tsup --watch\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"typecheck\": \"tsc --noEmit\",\n\t\t\"generate\": \"node scripts/generate-types.mjs\",\n\t\t\"prepublishOnly\": \"bun run typecheck && bun run test:ci && bun run build\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"test:ci\": \"vitest run && bun run test:package\",\n\t\t\"test:package\": \"bun run build && node scripts/check-package.mjs\",\n\t\t\"generate:check\": \"node scripts/generate-types.mjs --check\"\n\t},\n\t\"devDependencies\": {\n\t\t\"openapi-typescript\": \"^7.6.1\",\n\t\t\"tsup\": \"^8.4.0\",\n\t\t\"typescript\": \"^5.7.0\",\n\t\t\"vitest\": \"4.1.11\",\n\t\t\"yaml\": \"^2.7.0\"\n\t},\n\t\"installConfig\": {\n\t\t\"hoistingLimits\": \"workspaces\"\n\t}\n}\n","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 { version as SDK_VERSION } from \"../package.json\";\nimport {\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 DEFAULT_MAX_RETRY_TIME = 300_000;\nconst MAX_TIMER_DELAY = 2_147_483_647;\nconst RETRYABLE_STATUS_CODES = new Set([429, 500, 503, 504]);\n\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 maxRetryTime: 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.maxRetryTime = config.maxRetryTime ?? DEFAULT_MAX_RETRY_TIME;\n if (!Number.isFinite(this.maxRetryTime) || this.maxRetryTime <= 0 || this.maxRetryTime > MAX_TIMER_DELAY) {\n throw new Error(`maxRetryTime must be greater than 0 and at most ${MAX_TIMER_DELAY}ms`);\n }\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 const deadline = performance.now() + this.maxRetryTime;\n const serializedBody = body !== undefined ? JSON.stringify(body) : undefined;\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 // Never shorten Retry-After to fit the budget: return the last server\n // error so callers can schedule a later retry with the same key.\n if (delay >= deadline - performance.now()) {\n throw lastError ?? new TimeoutError(\"Request retry budget exhausted\");\n }\n await sleep(delay);\n }\n\n const remainingMs = deadline - performance.now();\n if (remainingMs <= 0) {\n throw new TimeoutError(`Request exceeded ${this.maxRetryTime}ms total retry budget`);\n }\n const attemptTimeout = Math.min(this.timeout, remainingMs);\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(), attemptTimeout);\n\n let response: Response;\n let responseBody: unknown;\n try {\n response = await fetch(url, {\n method,\n headers,\n body: serializedBody,\n signal: controller.signal,\n });\n responseBody = await response.json().catch((err: unknown) => {\n // A known HTTP failure remains authoritative even if its body\n // aborts or disconnects. Keep its status and Retry-After headers.\n if (err instanceof SyntaxError || !response.ok) return null;\n throw err;\n });\n if (controller.signal.aborted && response.ok) {\n throw new DOMException(\"The operation was aborted.\", \"AbortError\");\n }\n } finally {\n clearTimeout(timeoutId);\n }\n\n const responseHeaders = parseHeaders(response.headers);\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 ${attemptTimeout}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 const retryAfter = lastError instanceof RateLimitError\n ? lastError.rateLimitInfo.retryAfter\n : lastError instanceof ServiceUnavailableError ? lastError.retryAfter : undefined;\n if (retryAfter) {\n const minimumDelay = retryAfter * 1000;\n // Retry-After is a minimum. Spread recovery traffic without retrying early.\n return minimumDelay + Math.min(minimumDelay * 0.2, 1000) * Math.random();\n }\n // Leave room for jitter at the cap; clamping after jitter would make\n // every concurrent caller retry at exactly maxRetryDelay.\n const exponential = Math.min(this.retryDelay * Math.pow(2, attempt - 1), this.maxRetryDelay / 1.2);\n return exponential * (1 + 0.2 * Math.random());\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 return Object.entries(headers).some(([key, value]) =>\n (key.toLowerCase() === \"idempotency-key\" || key.toLowerCase() === \"x-idempotency-key\") &&\n /^[a-zA-Z0-9_-]{1,64}$/.test(value.trim()),\n );\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 { BankData, BankResponse, BankSearchParams, BankSearchResponse } from \"../types/index.js\";\n\nexport class Banks {\n constructor(private readonly http: HttpClient) {}\n\n /** Exact, case-insensitive name lookup with an optional country of origin. Costs zero credits. */\n async search(params: BankSearchParams): Promise<BankSearchResponse[\"data\"]> {\n const resp = await this.http.get<BankSearchResponse>(\"/v1/banks\", { ...params });\n return resp.data.data;\n }\n\n /** Retrieve stored bank details by UUID. */\n async get(id: string): Promise<BankData> {\n const resp = await this.http.get<BankResponse>(`/v1/banks/${encodeURIComponent(id)}`);\n return resp.data.data.bank;\n }\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 { Banks } from \"./resources/banks.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 /** Search stored bank profiles or retrieve them by ID. */\n readonly banks: Banks;\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.banks = new Banks(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 BankData,\n BankResponse,\n BankSearchResponse,\n BankSearchParams,\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":["../package.json","../src/errors.ts","../src/http-client.ts","../src/resources/banks.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":";;;;;AAEC,IAAA,OAAA,GAAW,OAAA;;;ACaL,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,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IAAI,CAAA;AAAA,EACjC;AACF;;;ACzIA,IAAO,aAAA,GAAQ","file":"index.cjs","sourcesContent":["{\n\t\"name\": \"triqai\",\n\t\"version\": \"0.2.8\",\n\t\"description\": \"Official TypeScript SDK for the Triqai Transaction Enrichment API\",\n\t\"author\": \"Triqai <hello@triqai.com>\",\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://github.com/triqai/triqai/tree/main/packages/sdk-node\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/triqai/triqai.git\",\n\t\t\"directory\": \"packages/sdk-node\"\n\t},\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/triqai/triqai/issues\"\n\t},\n\t\"keywords\": [\n\t\t\"triqai\",\n\t\t\"transaction\",\n\t\t\"enrichment\",\n\t\t\"fintech\",\n\t\t\"banking\",\n\t\t\"categorization\",\n\t\t\"merchant\",\n\t\t\"sdk\",\n\t\t\"api\"\n\t],\n\t\"sideEffects\": false,\n\t\"type\": \"module\",\n\t\"main\": \"./dist/index.cjs\",\n\t\"module\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\t\"default\": \"./dist/index.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/index.d.cts\",\n\t\t\t\t\"default\": \"./dist/index.cjs\"\n\t\t\t}\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"openapi-public.yaml\",\n\t\t\"README.md\",\n\t\t\"LICENSE\",\n\t\t\"CHANGELOG.md\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=18.0.0\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"tsup\",\n\t\t\"dev\": \"tsup --watch\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"typecheck\": \"tsc --noEmit\",\n\t\t\"generate\": \"node scripts/generate-types.mjs\",\n\t\t\"prepublishOnly\": \"bun run typecheck && bun run test:ci && bun run build\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"test:ci\": \"vitest run && bun run test:package\",\n\t\t\"test:package\": \"bun run build && node scripts/check-package.mjs\",\n\t\t\"generate:check\": \"node scripts/generate-types.mjs --check\"\n\t},\n\t\"devDependencies\": {\n\t\t\"openapi-typescript\": \"^7.6.1\",\n\t\t\"tsup\": \"^8.4.0\",\n\t\t\"typescript\": \"^5.7.0\",\n\t\t\"vitest\": \"4.1.11\",\n\t\t\"yaml\": \"^2.7.0\"\n\t},\n\t\"installConfig\": {\n\t\t\"hoistingLimits\": \"workspaces\"\n\t}\n}\n","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 { version as SDK_VERSION } from \"../package.json\";\nimport {\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 DEFAULT_MAX_RETRY_TIME = 300_000;\nconst MAX_TIMER_DELAY = 2_147_483_647;\nconst RETRYABLE_STATUS_CODES = new Set([429, 500, 503, 504]);\n\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 maxRetryTime: 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.maxRetryTime = config.maxRetryTime ?? DEFAULT_MAX_RETRY_TIME;\n if (!Number.isFinite(this.maxRetryTime) || this.maxRetryTime <= 0 || this.maxRetryTime > MAX_TIMER_DELAY) {\n throw new Error(`maxRetryTime must be greater than 0 and at most ${MAX_TIMER_DELAY}ms`);\n }\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 const deadline = performance.now() + this.maxRetryTime;\n const serializedBody = body !== undefined ? JSON.stringify(body) : undefined;\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 // Never shorten Retry-After to fit the budget: return the last server\n // error so callers can schedule a later retry with the same key.\n if (delay >= deadline - performance.now()) {\n throw lastError ?? new TimeoutError(\"Request retry budget exhausted\");\n }\n await sleep(delay);\n }\n\n const remainingMs = deadline - performance.now();\n if (remainingMs <= 0) {\n throw new TimeoutError(`Request exceeded ${this.maxRetryTime}ms total retry budget`);\n }\n const attemptTimeout = Math.min(this.timeout, remainingMs);\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(), attemptTimeout);\n\n let response: Response;\n let responseBody: unknown;\n try {\n response = await fetch(url, {\n method,\n headers,\n body: serializedBody,\n signal: controller.signal,\n });\n responseBody = await response.json().catch((err: unknown) => {\n // A known HTTP failure remains authoritative even if its body\n // aborts or disconnects. Keep its status and Retry-After headers.\n if (err instanceof SyntaxError || !response.ok) return null;\n throw err;\n });\n if (controller.signal.aborted && response.ok) {\n throw new DOMException(\"The operation was aborted.\", \"AbortError\");\n }\n } finally {\n clearTimeout(timeoutId);\n }\n\n const responseHeaders = parseHeaders(response.headers);\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 ${attemptTimeout}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 const retryAfter = lastError instanceof RateLimitError\n ? lastError.rateLimitInfo.retryAfter\n : lastError instanceof ServiceUnavailableError ? lastError.retryAfter : undefined;\n if (retryAfter) {\n const minimumDelay = retryAfter * 1000;\n // Retry-After is a minimum. Spread recovery traffic without retrying early.\n return minimumDelay + Math.min(minimumDelay * 0.2, 1000) * Math.random();\n }\n // Leave room for jitter at the cap; clamping after jitter would make\n // every concurrent caller retry at exactly maxRetryDelay.\n const exponential = Math.min(this.retryDelay * Math.pow(2, attempt - 1), this.maxRetryDelay / 1.2);\n return exponential * (1 + 0.2 * Math.random());\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 return Object.entries(headers).some(([key, value]) =>\n (key.toLowerCase() === \"idempotency-key\" || key.toLowerCase() === \"x-idempotency-key\") &&\n /^[a-zA-Z0-9_-]{1,64}$/.test(value.trim()),\n );\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 { BankData, BankResponse, BankSearchParams, BankSearchResponse } from \"../types/index.js\";\n\nexport class Banks {\n constructor(private readonly http: HttpClient) {}\n\n /** Exact, case-insensitive name lookup with an optional country of origin. Costs zero credits. */\n async search(params: BankSearchParams): Promise<BankSearchResponse[\"data\"]> {\n const resp = await this.http.get<BankSearchResponse>(\"/v1/banks\", { ...params });\n return resp.data.data;\n }\n\n /** Retrieve stored bank details by UUID. */\n async get(id: string): Promise<BankData> {\n const resp = await this.http.get<BankResponse>(`/v1/banks/${encodeURIComponent(id)}`);\n return resp.data.data.bank;\n }\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 { Banks } from \"./resources/banks.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 /** Search stored bank profiles or retrieve them by ID. */\n readonly banks: Banks;\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.banks = new Banks(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 BankData,\n BankResponse,\n BankSearchResponse,\n BankSearchParams,\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
@@ -229,10 +229,12 @@ type components = {
229
229
  };
230
230
  /**
231
231
  * @description Optional enrichment controls. Use `filters` to skip specific entity types,
232
- * or pre-fill known entity data to improve accuracy and reduce latency.
232
+ * pre-fill known entity data to improve accuracy and reduce latency, or set
233
+ * `p2p` when you already know whether the payment went to a person.
233
234
  *
234
235
  * **Mutual exclusivity:** a filter flag (e.g. `noMerchant`) cannot be combined with
235
- * pre-filled data for the same entity type.
236
+ * pre-filled data for the same entity type, and `p2p: true` cannot be combined with
237
+ * pre-filled `merchant` data.
236
238
  */
237
239
  EnrichRequestOptions: {
238
240
  filters?: components["schemas"]["EnrichmentFilterOptions"];
@@ -240,7 +242,21 @@ type components = {
240
242
  intermediaries?: components["schemas"]["PrefilledIntermediary"][];
241
243
  location?: components["schemas"]["PrefilledLocation"];
242
244
  merchant?: components["schemas"]["PrefilledMerchant"];
243
- } & (unknown & unknown & unknown);
245
+ /**
246
+ * @description Whether the transaction is a person-to-person transfer, when you know it from the
247
+ * payment rail (for example an account transfer to a payee, or a card payment).
248
+ *
249
+ * - `true`: the counterparty is a private person. No merchant is returned; the
250
+ * response has a `person` entity when the title names the person, and the
251
+ * `Peer to Peer` category.
252
+ * - `false`: the counterparty is a business or organization. No `person` entity
253
+ * and never the `Peer to Peer` category.
254
+ * - Omitted: Triqai decides from the title and web evidence.
255
+ *
256
+ * Requests with different `p2p` values are cached separately.
257
+ */
258
+ p2p?: boolean;
259
+ } & (unknown & unknown & unknown & unknown);
244
260
  EnrichSuccessResponse: {
245
261
  data: components["schemas"]["EnrichmentData"];
246
262
  meta: components["schemas"]["EnrichMeta"];
@@ -1162,6 +1178,7 @@ interface operations {
1162
1178
  422: components["responses"]["ValidationError"];
1163
1179
  429: components["responses"]["RateLimited"];
1164
1180
  500: components["responses"]["InternalError"];
1181
+ 503: components["responses"]["ServiceUnavailable"];
1165
1182
  };
1166
1183
  };
1167
1184
  batchDeleteTransactions: {
@@ -1191,6 +1208,7 @@ interface operations {
1191
1208
  422: components["responses"]["ValidationError"];
1192
1209
  429: components["responses"]["RateLimited"];
1193
1210
  500: components["responses"]["InternalError"];
1211
+ 503: components["responses"]["ServiceUnavailable"];
1194
1212
  };
1195
1213
  };
1196
1214
  countTransactions: {
@@ -1250,6 +1268,15 @@ interface operations {
1250
1268
  402: components["responses"]["InsufficientCredits"];
1251
1269
  403: components["responses"]["Forbidden"];
1252
1270
  409: components["responses"]["DuplicateRequest"];
1271
+ /** @description Transaction persistence refused because the transaction was erased or the organization is inactive. This response is terminal and must not be retried automatically. */
1272
+ 410: {
1273
+ headers: {
1274
+ [name: string]: unknown;
1275
+ };
1276
+ content: {
1277
+ "application/json": components["schemas"]["ErrorResponse"];
1278
+ };
1279
+ };
1253
1280
  422: components["responses"]["ValidationError"];
1254
1281
  429: components["responses"]["RateLimited"];
1255
1282
  499: components["responses"]["ClientDisconnected"];
package/dist/index.d.ts CHANGED
@@ -229,10 +229,12 @@ type components = {
229
229
  };
230
230
  /**
231
231
  * @description Optional enrichment controls. Use `filters` to skip specific entity types,
232
- * or pre-fill known entity data to improve accuracy and reduce latency.
232
+ * pre-fill known entity data to improve accuracy and reduce latency, or set
233
+ * `p2p` when you already know whether the payment went to a person.
233
234
  *
234
235
  * **Mutual exclusivity:** a filter flag (e.g. `noMerchant`) cannot be combined with
235
- * pre-filled data for the same entity type.
236
+ * pre-filled data for the same entity type, and `p2p: true` cannot be combined with
237
+ * pre-filled `merchant` data.
236
238
  */
237
239
  EnrichRequestOptions: {
238
240
  filters?: components["schemas"]["EnrichmentFilterOptions"];
@@ -240,7 +242,21 @@ type components = {
240
242
  intermediaries?: components["schemas"]["PrefilledIntermediary"][];
241
243
  location?: components["schemas"]["PrefilledLocation"];
242
244
  merchant?: components["schemas"]["PrefilledMerchant"];
243
- } & (unknown & unknown & unknown);
245
+ /**
246
+ * @description Whether the transaction is a person-to-person transfer, when you know it from the
247
+ * payment rail (for example an account transfer to a payee, or a card payment).
248
+ *
249
+ * - `true`: the counterparty is a private person. No merchant is returned; the
250
+ * response has a `person` entity when the title names the person, and the
251
+ * `Peer to Peer` category.
252
+ * - `false`: the counterparty is a business or organization. No `person` entity
253
+ * and never the `Peer to Peer` category.
254
+ * - Omitted: Triqai decides from the title and web evidence.
255
+ *
256
+ * Requests with different `p2p` values are cached separately.
257
+ */
258
+ p2p?: boolean;
259
+ } & (unknown & unknown & unknown & unknown);
244
260
  EnrichSuccessResponse: {
245
261
  data: components["schemas"]["EnrichmentData"];
246
262
  meta: components["schemas"]["EnrichMeta"];
@@ -1162,6 +1178,7 @@ interface operations {
1162
1178
  422: components["responses"]["ValidationError"];
1163
1179
  429: components["responses"]["RateLimited"];
1164
1180
  500: components["responses"]["InternalError"];
1181
+ 503: components["responses"]["ServiceUnavailable"];
1165
1182
  };
1166
1183
  };
1167
1184
  batchDeleteTransactions: {
@@ -1191,6 +1208,7 @@ interface operations {
1191
1208
  422: components["responses"]["ValidationError"];
1192
1209
  429: components["responses"]["RateLimited"];
1193
1210
  500: components["responses"]["InternalError"];
1211
+ 503: components["responses"]["ServiceUnavailable"];
1194
1212
  };
1195
1213
  };
1196
1214
  countTransactions: {
@@ -1250,6 +1268,15 @@ interface operations {
1250
1268
  402: components["responses"]["InsufficientCredits"];
1251
1269
  403: components["responses"]["Forbidden"];
1252
1270
  409: components["responses"]["DuplicateRequest"];
1271
+ /** @description Transaction persistence refused because the transaction was erased or the organization is inactive. This response is terminal and must not be retried automatically. */
1272
+ 410: {
1273
+ headers: {
1274
+ [name: string]: unknown;
1275
+ };
1276
+ content: {
1277
+ "application/json": components["schemas"]["ErrorResponse"];
1278
+ };
1279
+ };
1253
1280
  422: components["responses"]["ValidationError"];
1254
1281
  429: components["responses"]["RateLimited"];
1255
1282
  499: components["responses"]["ClientDisconnected"];
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.2.6";
2
+ var version = "0.2.8";
3
3
 
4
4
  // src/errors.ts
5
5
  var TriqaiError = class extends Error {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/errors.ts","../src/http-client.ts","../src/resources/banks.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":";AAEC,IAAA,OAAA,GAAW,OAAA;;;ACaL,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,EAA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AAM,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;;;ACzIA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["{\n\t\"name\": \"triqai\",\n\t\"version\": \"0.2.6\",\n\t\"description\": \"Official TypeScript SDK for the Triqai Transaction Enrichment API\",\n\t\"author\": \"Triqai <hello@triqai.com>\",\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://github.com/triqai/triqai/tree/main/packages/sdk-node\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/triqai/triqai.git\",\n\t\t\"directory\": \"packages/sdk-node\"\n\t},\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/triqai/triqai/issues\"\n\t},\n\t\"keywords\": [\n\t\t\"triqai\",\n\t\t\"transaction\",\n\t\t\"enrichment\",\n\t\t\"fintech\",\n\t\t\"banking\",\n\t\t\"categorization\",\n\t\t\"merchant\",\n\t\t\"sdk\",\n\t\t\"api\"\n\t],\n\t\"sideEffects\": false,\n\t\"type\": \"module\",\n\t\"main\": \"./dist/index.cjs\",\n\t\"module\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\t\"default\": \"./dist/index.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/index.d.cts\",\n\t\t\t\t\"default\": \"./dist/index.cjs\"\n\t\t\t}\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"openapi-public.yaml\",\n\t\t\"README.md\",\n\t\t\"LICENSE\",\n\t\t\"CHANGELOG.md\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=18.0.0\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"tsup\",\n\t\t\"dev\": \"tsup --watch\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"typecheck\": \"tsc --noEmit\",\n\t\t\"generate\": \"node scripts/generate-types.mjs\",\n\t\t\"prepublishOnly\": \"bun run typecheck && bun run test:ci && bun run build\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"test:ci\": \"vitest run && bun run test:package\",\n\t\t\"test:package\": \"bun run build && node scripts/check-package.mjs\",\n\t\t\"generate:check\": \"node scripts/generate-types.mjs --check\"\n\t},\n\t\"devDependencies\": {\n\t\t\"openapi-typescript\": \"^7.6.1\",\n\t\t\"tsup\": \"^8.4.0\",\n\t\t\"typescript\": \"^5.7.0\",\n\t\t\"vitest\": \"4.1.11\",\n\t\t\"yaml\": \"^2.7.0\"\n\t},\n\t\"installConfig\": {\n\t\t\"hoistingLimits\": \"workspaces\"\n\t}\n}\n","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 { version as SDK_VERSION } from \"../package.json\";\nimport {\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 DEFAULT_MAX_RETRY_TIME = 300_000;\nconst MAX_TIMER_DELAY = 2_147_483_647;\nconst RETRYABLE_STATUS_CODES = new Set([429, 500, 503, 504]);\n\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 maxRetryTime: 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.maxRetryTime = config.maxRetryTime ?? DEFAULT_MAX_RETRY_TIME;\n if (!Number.isFinite(this.maxRetryTime) || this.maxRetryTime <= 0 || this.maxRetryTime > MAX_TIMER_DELAY) {\n throw new Error(`maxRetryTime must be greater than 0 and at most ${MAX_TIMER_DELAY}ms`);\n }\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 const deadline = performance.now() + this.maxRetryTime;\n const serializedBody = body !== undefined ? JSON.stringify(body) : undefined;\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 // Never shorten Retry-After to fit the budget: return the last server\n // error so callers can schedule a later retry with the same key.\n if (delay >= deadline - performance.now()) {\n throw lastError ?? new TimeoutError(\"Request retry budget exhausted\");\n }\n await sleep(delay);\n }\n\n const remainingMs = deadline - performance.now();\n if (remainingMs <= 0) {\n throw new TimeoutError(`Request exceeded ${this.maxRetryTime}ms total retry budget`);\n }\n const attemptTimeout = Math.min(this.timeout, remainingMs);\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(), attemptTimeout);\n\n let response: Response;\n let responseBody: unknown;\n try {\n response = await fetch(url, {\n method,\n headers,\n body: serializedBody,\n signal: controller.signal,\n });\n responseBody = await response.json().catch((err: unknown) => {\n // A known HTTP failure remains authoritative even if its body\n // aborts or disconnects. Keep its status and Retry-After headers.\n if (err instanceof SyntaxError || !response.ok) return null;\n throw err;\n });\n if (controller.signal.aborted && response.ok) {\n throw new DOMException(\"The operation was aborted.\", \"AbortError\");\n }\n } finally {\n clearTimeout(timeoutId);\n }\n\n const responseHeaders = parseHeaders(response.headers);\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 ${attemptTimeout}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 const retryAfter = lastError instanceof RateLimitError\n ? lastError.rateLimitInfo.retryAfter\n : lastError instanceof ServiceUnavailableError ? lastError.retryAfter : undefined;\n if (retryAfter) {\n const minimumDelay = retryAfter * 1000;\n // Retry-After is a minimum. Spread recovery traffic without retrying early.\n return minimumDelay + Math.min(minimumDelay * 0.2, 1000) * Math.random();\n }\n // Leave room for jitter at the cap; clamping after jitter would make\n // every concurrent caller retry at exactly maxRetryDelay.\n const exponential = Math.min(this.retryDelay * Math.pow(2, attempt - 1), this.maxRetryDelay / 1.2);\n return exponential * (1 + 0.2 * Math.random());\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 return Object.entries(headers).some(([key, value]) =>\n (key.toLowerCase() === \"idempotency-key\" || key.toLowerCase() === \"x-idempotency-key\") &&\n /^[a-zA-Z0-9_-]{1,64}$/.test(value.trim()),\n );\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 { BankData, BankResponse, BankSearchParams, BankSearchResponse } from \"../types/index.js\";\n\nexport class Banks {\n constructor(private readonly http: HttpClient) {}\n\n /** Exact, case-insensitive name lookup with an optional country of origin. Costs zero credits. */\n async search(params: BankSearchParams): Promise<BankSearchResponse[\"data\"]> {\n const resp = await this.http.get<BankSearchResponse>(\"/v1/banks\", { ...params });\n return resp.data.data;\n }\n\n /** Retrieve stored bank details by UUID. */\n async get(id: string): Promise<BankData> {\n const resp = await this.http.get<BankResponse>(`/v1/banks/${encodeURIComponent(id)}`);\n return resp.data.data.bank;\n }\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 { Banks } from \"./resources/banks.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 /** Search stored bank profiles or retrieve them by ID. */\n readonly banks: Banks;\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.banks = new Banks(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 BankData,\n BankResponse,\n BankSearchResponse,\n BankSearchParams,\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":["../package.json","../src/errors.ts","../src/http-client.ts","../src/resources/banks.ts","../src/resources/categories.ts","../src/resources/intermediaries.ts","../src/pagination.ts","../src/resources/issue-reports.ts","../src/resources/locations.ts","../src/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AC0B;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;;;ACzIA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["{\n\t\"name\": \"triqai\",\n\t\"version\": \"0.2.8\",\n\t\"description\": \"Official TypeScript SDK for the Triqai Transaction Enrichment API\",\n\t\"author\": \"Triqai <hello@triqai.com>\",\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://github.com/triqai/triqai/tree/main/packages/sdk-node\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/triqai/triqai.git\",\n\t\t\"directory\": \"packages/sdk-node\"\n\t},\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/triqai/triqai/issues\"\n\t},\n\t\"keywords\": [\n\t\t\"triqai\",\n\t\t\"transaction\",\n\t\t\"enrichment\",\n\t\t\"fintech\",\n\t\t\"banking\",\n\t\t\"categorization\",\n\t\t\"merchant\",\n\t\t\"sdk\",\n\t\t\"api\"\n\t],\n\t\"sideEffects\": false,\n\t\"type\": \"module\",\n\t\"main\": \"./dist/index.cjs\",\n\t\"module\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.ts\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\t\"default\": \"./dist/index.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/index.d.cts\",\n\t\t\t\t\"default\": \"./dist/index.cjs\"\n\t\t\t}\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"openapi-public.yaml\",\n\t\t\"README.md\",\n\t\t\"LICENSE\",\n\t\t\"CHANGELOG.md\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=18.0.0\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"tsup\",\n\t\t\"dev\": \"tsup --watch\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"typecheck\": \"tsc --noEmit\",\n\t\t\"generate\": \"node scripts/generate-types.mjs\",\n\t\t\"prepublishOnly\": \"bun run typecheck && bun run test:ci && bun run build\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"test:ci\": \"vitest run && bun run test:package\",\n\t\t\"test:package\": \"bun run build && node scripts/check-package.mjs\",\n\t\t\"generate:check\": \"node scripts/generate-types.mjs --check\"\n\t},\n\t\"devDependencies\": {\n\t\t\"openapi-typescript\": \"^7.6.1\",\n\t\t\"tsup\": \"^8.4.0\",\n\t\t\"typescript\": \"^5.7.0\",\n\t\t\"vitest\": \"4.1.11\",\n\t\t\"yaml\": \"^2.7.0\"\n\t},\n\t\"installConfig\": {\n\t\t\"hoistingLimits\": \"workspaces\"\n\t}\n}\n","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 { version as SDK_VERSION } from \"../package.json\";\nimport {\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 DEFAULT_MAX_RETRY_TIME = 300_000;\nconst MAX_TIMER_DELAY = 2_147_483_647;\nconst RETRYABLE_STATUS_CODES = new Set([429, 500, 503, 504]);\n\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 maxRetryTime: 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.maxRetryTime = config.maxRetryTime ?? DEFAULT_MAX_RETRY_TIME;\n if (!Number.isFinite(this.maxRetryTime) || this.maxRetryTime <= 0 || this.maxRetryTime > MAX_TIMER_DELAY) {\n throw new Error(`maxRetryTime must be greater than 0 and at most ${MAX_TIMER_DELAY}ms`);\n }\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 const deadline = performance.now() + this.maxRetryTime;\n const serializedBody = body !== undefined ? JSON.stringify(body) : undefined;\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 // Never shorten Retry-After to fit the budget: return the last server\n // error so callers can schedule a later retry with the same key.\n if (delay >= deadline - performance.now()) {\n throw lastError ?? new TimeoutError(\"Request retry budget exhausted\");\n }\n await sleep(delay);\n }\n\n const remainingMs = deadline - performance.now();\n if (remainingMs <= 0) {\n throw new TimeoutError(`Request exceeded ${this.maxRetryTime}ms total retry budget`);\n }\n const attemptTimeout = Math.min(this.timeout, remainingMs);\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(), attemptTimeout);\n\n let response: Response;\n let responseBody: unknown;\n try {\n response = await fetch(url, {\n method,\n headers,\n body: serializedBody,\n signal: controller.signal,\n });\n responseBody = await response.json().catch((err: unknown) => {\n // A known HTTP failure remains authoritative even if its body\n // aborts or disconnects. Keep its status and Retry-After headers.\n if (err instanceof SyntaxError || !response.ok) return null;\n throw err;\n });\n if (controller.signal.aborted && response.ok) {\n throw new DOMException(\"The operation was aborted.\", \"AbortError\");\n }\n } finally {\n clearTimeout(timeoutId);\n }\n\n const responseHeaders = parseHeaders(response.headers);\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 ${attemptTimeout}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 const retryAfter = lastError instanceof RateLimitError\n ? lastError.rateLimitInfo.retryAfter\n : lastError instanceof ServiceUnavailableError ? lastError.retryAfter : undefined;\n if (retryAfter) {\n const minimumDelay = retryAfter * 1000;\n // Retry-After is a minimum. Spread recovery traffic without retrying early.\n return minimumDelay + Math.min(minimumDelay * 0.2, 1000) * Math.random();\n }\n // Leave room for jitter at the cap; clamping after jitter would make\n // every concurrent caller retry at exactly maxRetryDelay.\n const exponential = Math.min(this.retryDelay * Math.pow(2, attempt - 1), this.maxRetryDelay / 1.2);\n return exponential * (1 + 0.2 * Math.random());\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 return Object.entries(headers).some(([key, value]) =>\n (key.toLowerCase() === \"idempotency-key\" || key.toLowerCase() === \"x-idempotency-key\") &&\n /^[a-zA-Z0-9_-]{1,64}$/.test(value.trim()),\n );\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 { BankData, BankResponse, BankSearchParams, BankSearchResponse } from \"../types/index.js\";\n\nexport class Banks {\n constructor(private readonly http: HttpClient) {}\n\n /** Exact, case-insensitive name lookup with an optional country of origin. Costs zero credits. */\n async search(params: BankSearchParams): Promise<BankSearchResponse[\"data\"]> {\n const resp = await this.http.get<BankSearchResponse>(\"/v1/banks\", { ...params });\n return resp.data.data;\n }\n\n /** Retrieve stored bank details by UUID. */\n async get(id: string): Promise<BankData> {\n const resp = await this.http.get<BankResponse>(`/v1/banks/${encodeURIComponent(id)}`);\n return resp.data.data.bank;\n }\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 { Banks } from \"./resources/banks.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 /** Search stored bank profiles or retrieve them by ID. */\n readonly banks: Banks;\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.banks = new Banks(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 BankData,\n BankResponse,\n BankSearchResponse,\n BankSearchParams,\n MerchantData,\n LocationData,\n IntermediaryData,\n IntermediaryRecord,\n PersonData,\n Coordinates,\n StructuredAddress,\n LocationRating,\n // Entity response types\n MerchantResponse,\n LocationResponse,\n IntermediaryResponse,\n // Issue report types\n IssueReport,\n IssueReportStatus,\n IssueReportResponse,\n IssueReportListResponse,\n ReportIssueRequest,\n EnrichmentFieldPath,\n // Error response types\n ErrorResponse,\n ErrorObject,\n DuplicateRequestErrorResponse,\n ClientDisconnectedErrorResponse,\n // Meta types\n ResponseMeta,\n PaginationMeta,\n // Utility response types\n HealthResponse,\n ApiInfoResponse,\n} from \"./types/index.js\";\n"]}
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: Triqai Transaction Enrichment API
4
- version: 1.5.17
4
+ version: 1.5.51
5
5
  description: |
6
6
  The Triqai API provides transaction enrichment capabilities for financial applications.
7
7
 
@@ -157,6 +157,14 @@ paths:
157
157
  name: 'Starbucks'
158
158
  location:
159
159
  cityName: 'Amsterdam'
160
+ person_to_person:
161
+ summary: Known person-to-person transfer
162
+ value:
163
+ title: 'BILL PAYMENT TO J D MORGAN REF RENT'
164
+ country: 'GB'
165
+ type: 'expense'
166
+ options:
167
+ p2p: true
160
168
  with_filters:
161
169
  summary: Skip intermediary and location extraction
162
170
  value:
@@ -182,6 +190,12 @@ paths:
182
190
  $ref: '#/components/responses/Forbidden'
183
191
  '409':
184
192
  $ref: '#/components/responses/DuplicateRequest'
193
+ '410':
194
+ description: Transaction persistence refused because the transaction was erased or the organization is inactive. This response is terminal and must not be retried automatically.
195
+ content:
196
+ application/json:
197
+ schema:
198
+ $ref: '#/components/schemas/ErrorResponse'
185
199
  '422':
186
200
  $ref: '#/components/responses/ValidationError'
187
201
  '429':
@@ -281,6 +295,9 @@ paths:
281
295
  tags:
282
296
  - Transactions
283
297
  summary: Delete transaction
298
+ description: |
299
+ Deletes the retained transaction and its temporary private data. If cleanup is
300
+ incomplete, returns 503; retry the same request to continue cleanup.
284
301
  operationId: deleteTransaction
285
302
  parameters:
286
303
  - $ref: '#/components/parameters/IdPath'
@@ -303,6 +320,8 @@ paths:
303
320
  $ref: '#/components/responses/RateLimited'
304
321
  '500':
305
322
  $ref: '#/components/responses/InternalError'
323
+ '503':
324
+ $ref: '#/components/responses/ServiceUnavailable'
306
325
 
307
326
  /v1/transactions/count:
308
327
  get:
@@ -350,7 +369,9 @@ paths:
350
369
  - `afterDate` — delete all transactions created on or after the given ISO 8601 date
351
370
  - `ids` — delete specific transactions by UUID (max 1000)
352
371
 
353
- Associated KV cache entries and DLQ entries are purged after deletion.
372
+ Temporary private data is purged after deletion. If cleanup is incomplete,
373
+ returns 503; retry the same request to continue cleanup, even if the
374
+ transaction records have already been deleted.
354
375
  operationId: batchDeleteTransactions
355
376
  requestBody:
356
377
  required: true
@@ -390,6 +411,8 @@ paths:
390
411
  $ref: '#/components/responses/RateLimited'
391
412
  '500':
392
413
  $ref: '#/components/responses/InternalError'
414
+ '503':
415
+ $ref: '#/components/responses/ServiceUnavailable'
393
416
 
394
417
  /v1/categories:
395
418
  get:
@@ -942,11 +965,27 @@ components:
942
965
  type: object
943
966
  description: |
944
967
  Optional enrichment controls. Use `filters` to skip specific entity types,
945
- or pre-fill known entity data to improve accuracy and reduce latency.
968
+ pre-fill known entity data to improve accuracy and reduce latency, or set
969
+ `p2p` when you already know whether the payment went to a person.
946
970
 
947
971
  **Mutual exclusivity:** a filter flag (e.g. `noMerchant`) cannot be combined with
948
- pre-filled data for the same entity type.
972
+ pre-filled data for the same entity type, and `p2p: true` cannot be combined with
973
+ pre-filled `merchant` data.
949
974
  properties:
975
+ p2p:
976
+ type: boolean
977
+ description: |
978
+ Whether the transaction is a person-to-person transfer, when you know it from the
979
+ payment rail (for example an account transfer to a payee, or a card payment).
980
+
981
+ - `true`: the counterparty is a private person. No merchant is returned; the
982
+ response has a `person` entity when the title names the person, and the
983
+ `Peer to Peer` category.
984
+ - `false`: the counterparty is a business or organization. No `person` entity
985
+ and never the `Peer to Peer` category.
986
+ - Omitted: Triqai decides from the title and web evidence.
987
+
988
+ Requests with different `p2p` values are cached separately.
950
989
  filters:
951
990
  $ref: '#/components/schemas/EnrichmentFilterOptions'
952
991
  merchant:
@@ -960,6 +999,21 @@ components:
960
999
  items:
961
1000
  $ref: '#/components/schemas/PrefilledIntermediary'
962
1001
  allOf:
1002
+ - if:
1003
+ required: [p2p]
1004
+ properties:
1005
+ p2p:
1006
+ const: true
1007
+ then:
1008
+ not:
1009
+ required: [merchant]
1010
+ properties:
1011
+ merchant:
1012
+ type: object
1013
+ anyOf:
1014
+ - required: [id]
1015
+ - required: [name]
1016
+ - required: [domain]
963
1017
  - if:
964
1018
  required: [filters]
965
1019
  properties:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triqai",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Official TypeScript SDK for the Triqai Transaction Enrichment API",
5
5
  "author": "Triqai <hello@triqai.com>",
6
6
  "license": "MIT",