/** * ComplianceSDK - Main SDK entry point * * This class provides access to all compliance API resources. * It initializes the tRPC client and all resource managers. * * The SDK can be scoped to a specific scope/activity via the `scope` field, * which automatically applies to all resource operations. * * @example * ```typescript * // Unscoped SDK - works with any scope * const sdk = new ComplianceSDK({ * apiKey: process.env.COMPLIANCE_API_KEY!, * environment: "test", * }); * * // Mexico-scoped SDK * const mexSDK = new ComplianceSDK({ * apiKey: process.env.COMPLIANCE_API_KEY!, * environment: "test", * scope: "MX", * }); * * // Mexico AVI-scoped SDK * const aviSDK = new ComplianceSDK({ * apiKey: process.env.COMPLIANCE_API_KEY!, * environment: "test", * scope: "MX:AV:AVI", * }); * * // When scoped, resources automatically use the scope * const client = await aviSDK.clients.create({ * type: ClientType.Person, * name: "Juan García", * }); * ``` */ import type { Locale, Scope } from "@artu-ai/shared"; import { type SDKSessionOptions, type SDKSessionOptionsWithReturnTo, type SessionResultWithoutRedirect, type SessionResultWithRedirect } from "../utils/session"; import { type APIVersion } from "../utils/trpc-client"; import { type UnscopedSDKOptions } from "./base"; import { type AVIComplianceSDK, type AVISDKOptions } from "./mx/av/avi/types"; import { type JYSComplianceSDK, type JYSSDKOptions } from "./mx/av/jys/types"; import { type TSCComplianceSDK, type TSCSDKOptions } from "./mx/av/tsc/types"; import { type TransmisorComplianceSDK, type TransmisorSDKOptions } from "./mx/cnbv/transmisor/types"; import { type ComplianceSDKOptionsMexico, type MexicoComplianceSDK, type MexicoSDKOptions } from "./mx/types"; import { type BaseComplianceSDK, type ComplianceAuthMode, type Environment, type FetchCredentials } from "./types"; export type { ComplianceSDKOptionsBase } from "./types"; import { AddressesResource, type AlertsResource, ApiKeysResource, AuditLogsResource, BankAccountsResource, type ClientsResource, ContactMethodsResource, DocumentsResource, EvidenceResource, ExchangeRatesResource, ProductsResource, ReferenceDataResource, ReportsResource, RolesResource, SignableTemplatesResource, TagsResource, TenantResource, type TransactionsResource, UsersResource, WorkflowsResource } from "../resources"; import { IdentityResource } from "../resources/identity"; import { ScreeningResource } from "../resources/screening"; export type { ComplianceSDKOptionsMexico, MexicoSDKOptions, AVISDKOptions, JYSSDKOptions, TSCSDKOptions, TransmisorSDKOptions, MexicoComplianceSDK, AVIComplianceSDK, JYSComplianceSDK, TSCComplianceSDK, TransmisorComplianceSDK, }; /** * SDK configuration options. * * Use `scope` to target a specific scope/activity. */ export type ComplianceSDKOptions = UnscopedSDKOptions | ComplianceSDKOptionsMexico; /** * Unscoped SDK - uses base resource types */ export interface UnscopedComplianceSDK extends BaseComplianceSDK { readonly clients: ClientsResource; readonly transactions: TransactionsResource; readonly alerts: AlertsResource; readonly products: ProductsResource; readonly bankAccounts: BankAccountsResource; readonly addresses: AddressesResource; readonly contactMethods: ContactMethodsResource; readonly documents: DocumentsResource; readonly evidence: EvidenceResource; readonly exchangeRates: ExchangeRatesResource; readonly referenceData: ReferenceDataResource; readonly reports: ReportsResource; readonly workflows: WorkflowsResource; readonly tenant: TenantResource; readonly signableTemplates: SignableTemplatesResource; readonly tags: TagsResource; readonly roles: RolesResource; readonly users: UsersResource; readonly apiKeys: ApiKeysResource; readonly auditLogs: AuditLogsResource; readonly screening: ScreeningResource; readonly identity: IdentityResource; } /** * Main entry point for the Compliance SDK. * * Provides access to all API resources: * - `clients` - Client management (individuals, companies, trusts) * - `transactions` - Transaction management * - `addresses` - Address management * - `contactMethods` - Contact method management * - `bankAccounts` - Bank account management * - `documents` - Document upload and management * - `alerts` - Regulatory alert generation and submission * * ## Scoping * * The SDK can be scoped to a specific scope/activity: * * ```typescript * // Unscoped - generic SDK * const sdk = new ComplianceSDK({ apiKey, environment: "test" }); * * // Scoped to Mexico * const mexSDK = new ComplianceSDK({ * apiKey, * environment: "test", * scope: "MX", * }); * * // Scoped to Mexico AVI actividadVulnerable * const aviSDK = new ComplianceSDK({ * apiKey, * environment: "test", * scope: "MX:AV:AVI", * }); * ``` * * When scoped: * - Create operations default to the specified scope * - List operations filter by the specified scope * - Models returned are the appropriate type for the scope * * @example * ```typescript * import { ComplianceSDK, ClientType } from "@artu/compliance-sdk"; * * const sdk = new ComplianceSDK({ * apiKey: process.env.COMPLIANCE_API_KEY!, * environment: "test", * scope: "MX:AV:AVI", * }); * * // Check scope * console.log(sdk.scope); // "MX:AV:AVI" * console.log(sdk.isScoped); // true * * // Create a client - scope is auto-applied * const client = await sdk.clients.create({ * type: ClientType.Person, * name: "Juan García", * }); * ``` */ export declare class ComplianceSDKImpl { /** Current environment */ protected readonly _environment: Environment; /** Current API version */ protected readonly _apiVersion: APIVersion; /** Current locale */ protected _locale: Locale; /** SDK scope */ protected readonly _scope: Scope | undefined; /** Resolved base URL */ protected readonly _baseUrl: string; /** Auth mode */ protected readonly _authMode: ComplianceAuthMode; /** Credentials policy (cookie mode) */ protected readonly _credentials?: FetchCredentials; /** Custom headers (cookie mode, for server-side cookie forwarding) */ protected readonly _headers?: Record; /** Organization ID for session login (cookie mode) */ protected readonly _organizationId?: string; /** API key for API key auth mode (stored for session() calls) */ protected readonly _apiKey?: string; /** * Clients resource manager. * * Provides CRUD operations for clients (individuals, companies, trusts). * When SDK is scoped, creates and lists are automatically scoped. */ readonly clients: ClientsResource; /** * Transactions resource manager. * * Provides CRUD operations for transactions and client linking. * When SDK is scoped, creates and lists are automatically scoped. */ readonly transactions: TransactionsResource; /** * Addresses resource manager. * * Provides CRUD operations for client addresses. */ readonly addresses: AddressesResource; /** * Contact methods resource manager. * * Provides CRUD operations for client contact methods (email, phone). */ readonly contactMethods: ContactMethodsResource; /** * Bank accounts resource manager. * * Provides CRUD operations for client bank accounts. */ readonly bankAccounts: BankAccountsResource; /** * Documents resource manager. * * Provides upload, download, and management for client documents. */ readonly documents: DocumentsResource; /** * Evidence resource manager. * * Provides upload, download, and management for compliance evidence records. */ readonly evidence: EvidenceResource; /** * Alerts resource manager. * * Provides CRUD operations for regulatory alerts. * When SDK is scoped, creates and lists are automatically scoped. */ readonly alerts: AlertsResource; /** * Products resource manager. * * Provides CRUD operations for products. * When SDK is scoped, creates and lists are automatically scoped. */ readonly products: ProductsResource; /** * Exchange rates resource. * * Provides exchange rate lookups with multi-level caching. */ readonly exchangeRates: ExchangeRatesResource; /** * Reference data resource. * * Provides read-only access to external reference datasets. * * @example * ```typescript * // Look up postal code settlements * const settlements = await sdk.referenceData.mex.postalCodes.lookup("06600"); * * // Get Basel AML score for a country * const entry = await sdk.referenceData.global.baselAml.byCountry({ * countryCode: "MX", * }); * ``` */ readonly referenceData: ReferenceDataResource; /** * Reports resource manager. * * Provides read-only access to generated report files. */ readonly reports: ReportsResource; /** * Workflows resource manager. * * Provides access to workflow-related sub-resources (variables, executions, templates). */ readonly workflows: WorkflowsResource; /** * Tenant resource. * * Singleton resource for managing organization-level metadata. */ readonly tenant: TenantResource; /** * Roles resource. * * Manage organization roles and user role assignments. */ readonly roles: RolesResource; /** * Signable Templates resource. * * Admin catalog over the unified `signable_templates` table — privacy * notices, NDAs, contracts, declarations, and other signable PDFs. */ readonly signableTemplates: SignableTemplatesResource; /** * Users resource. * * Organization member management: list members, invite users, * remove members, manage invitations, assign/revoke roles. */ readonly users: UsersResource; /** * Tags resource. * * Org-scoped tag management (shared across test/live). */ readonly tags: TagsResource; /** * API Keys resource. * * Manage API keys with role-based permissions. * Roles are immutable after key creation. */ readonly apiKeys: ApiKeysResource; /** * Audit Logs resource. * * Read-only access to the immutable audit trail of all resource mutations. */ readonly auditLogs: AuditLogsResource; /** * Screening resource (top-level, global). * * Screening surface for sanctions / PEP / blacklist checks. */ readonly screening: ScreeningResource; /** * Identity resource (top-level, global). * * Identity-verification surface for CURP / INE / RFC checks. */ readonly identity: IdentityResource; constructor(options: ComplianceSDKOptions); /** * Current environment ("test" or "live"). */ get environment(): Environment; /** * Current API version. */ get apiVersion(): APIVersion; /** * Current locale used for SDK-owned API requests. */ get locale(): Locale; /** * Updates the locale used by subsequent SDK-owned API requests. */ setLocale(locale: Locale | string): void; /** * Resolved base URL the SDK targets (e.g. `https://api.artu.ai`, * `http://localhost:4000`). Useful when a UI needs to surface a * derived URL to the user (e.g. the public API trigger endpoint URL) * without re-implementing the resolution chain. */ get baseUrl(): string; /** * Whether SDK is running in test environment. */ get isTest(): boolean; /** * Whether SDK is running in live environment. */ get isLive(): boolean; /** * The SDK scope, or undefined if unscoped. * * @example * ```typescript * console.log(sdk.scope); // "MX:AV:AVI" or undefined * ``` */ get scope(): Scope | undefined; /** * Whether SDK is scoped. */ get isScoped(): boolean; /** * Fetches current session info from the API (/auth/me). * Works in both cookie auth mode and API key mode. */ session(options: SDKSessionOptionsWithReturnTo): Promise; session(options?: SDKSessionOptions): Promise; } /** * ComplianceSDK constructor with overloaded signatures. * * This interface enables `new ComplianceSDK(options)` to return the correct * typed SDK interface based on the scope option. * * @example * ```typescript * // Unscoped SDK - base types * const sdk = new ComplianceSDK({ * apiKey: "...", * environment: "test", * }); * * // Mexico-scoped SDK * const mexSdk = new ComplianceSDK({ * apiKey: "...", * environment: "test", * scope: "MX", * }); * * // AVI-scoped SDK * const aviSdk = new ComplianceSDK({ * apiKey: "...", * environment: "test", * scope: "MX:AV:AVI", * }); * ``` */ export interface ComplianceSDKConstructor { new (options: AVISDKOptions): AVIComplianceSDK; new (options: JYSSDKOptions): JYSComplianceSDK; new (options: TSCSDKOptions): TSCComplianceSDK; new (options: TransmisorSDKOptions): TransmisorComplianceSDK; new (options: MexicoSDKOptions): MexicoComplianceSDK; new (options: UnscopedSDKOptions): UnscopedComplianceSDK; new (options: ComplianceSDKOptions): ComplianceSDK; } export declare const ComplianceSDK: ComplianceSDKConstructor; export type ComplianceSDK = InstanceType;