/** * Base Transaction Model * * Pure data model with no API calls. * Provides type-safe access to common transaction properties. */ import type { EmbeddedTag, RelatedClient, RiskAssessmentSnapshot, RiskAssessments, Scope, TransactionResponse } from "@artu-ai/shared"; import { TransactionStatus } from "@artu-ai/shared"; import { BaseModel } from "./base"; /** * Transaction data as returned from the API. * Extends the base schema with server-generated fields. */ export interface TransactionData extends Omit { id: string; timestamp: string; createdAt: string; updatedAt: string; isAlerted: boolean; alertedAt: string | null; productId?: string; riskAssessments?: RiskAssessments; tags?: EmbeddedTag[]; } /** * Base Transaction Model. * * Pure data model with no API calls. * Extended by scope-specific models (MexTransaction, etc.). * * @example * ```typescript * const txn = await sdk.transactions.retrieve("txn_123"); * console.log(txn.formattedAmount); * console.log(txn.status); * ``` */ export declare class Transaction extends BaseModel { /** * Unique identifier */ get id(): string; /** * Transaction status */ get status(): TransactionStatus; /** * Whether the transaction is completed */ get isCompleted(): boolean; /** * Whether the transaction is pending */ get isPending(): boolean; /** * Transaction amount as a precision-safe string. * Use `Number(transaction.amount)` if you need a numeric value. */ get amount(): string; /** * Currency code (ISO 4217) */ get currency(): string; /** * Formats amount with currency */ get formattedAmount(): string; /** * IDs of clients related to this transaction */ get relatedClientIds(): string[]; /** * Per-link client payload (with `role` + `metadata`) when the API * populated it — `retrieve` and mutation responses include this. * List endpoints may return only `relatedClientIds` for cost reasons, * in which case this getter returns the same set with no role/metadata. */ get relatedClients(): RelatedClient[]; /** * Whether this transaction is referenced by at least one active alert item */ get isAlerted(): boolean; /** * When the transaction was first added to an active alert (null if not alerted) */ get alertedAt(): string | null; /** * External ID for integration with other systems */ get externalId(): string | undefined; /** * Transaction description */ get description(): string | undefined; /** * Associated product ID */ get productId(): string | undefined; /** * Scopes this transaction belongs to (e.g. ["MX", "MX:AV:AVI"]). */ get scopes(): string[]; /** * Tags applied to this transaction. */ get tags(): EmbeddedTag[]; /** * Checks if transaction has data for a specific scope */ hasScope(scope: Scope): boolean; /** * Raw scope data object */ get scopeData(): TransactionResponse["scopeData"]; /** * Raw risk assessments map — keyed by assessment name, each value is an * append-only array of snapshots representing the assessment history. */ get riskAssessments(): RiskAssessments; /** * Names of all risk assessments attached to this transaction. */ get riskAssessmentNames(): string[]; /** * Retrieve a specific risk assessment snapshot by name and optional version. * Version is the 0-based index in the append-only history array. * Defaults to the latest (most recent) version. * * @param name - The assessment name * @param version - Optional 0-based version index (defaults to latest) * @returns The snapshot, or undefined if not found */ riskAssessment(name: string, version?: number): RiskAssessmentSnapshot | undefined; /** * List all available versions for a named risk assessment. * * @param name - The assessment name * @returns Array of `{ version, calculatedAt }` entries, or empty array if not found */ riskAssessmentVersions(name: string): { version: number; calculatedAt: string; }[]; /** * Get the overall score for a risk assessment. * * - With a name: returns the overall score of the latest version of that assessment. * - Without a name: returns the overall score of the most recently calculated * assessment across all assessments (by `calculatedAt`). * * @param name - Optional assessment name * @returns The overall score, or undefined if no assessments exist */ riskAssessmentScore(name?: string): number | undefined; /** * Get the display-ready risk score for the most recent assessment. * Returns the score scaled to maxScore and rounded per the stored mode, * along with the maxScore denominator. * * @returns `{ score, maxScore }` or undefined if no assessments exist */ riskAssessmentDisplayScore(): { score: number; minScore: number; maxScore: number; label?: string; } | undefined; /** Find the most recently calculated snapshot across all assessments */ private _latestRiskSnapshot; /** * When the transaction was executed/occurred */ get timestamp(): Date; /** * Custom metadata */ get metadata(): Record | undefined; /** * Exchange rates for currency conversion. * Format: Record * Example: { "MXN": "17.5" } means 1 unit of transaction currency = 17.5 MXN */ get exchangeRates(): Record | undefined; /** * When the transaction record was created */ get createdAt(): Date; /** * When the transaction record was last updated */ get updatedAt(): Date; toString(): string; } /** * Check if value is any type of Transaction model */ export declare function isTransaction(value: unknown): value is Transaction;