/** * Mexico Clients Resource * * Extends ClientsResource with Mexico-specific behavior: * - Accepts flattened CreateMexClientInput (MX fields at root level) * - Automatically injects scopes: ["MX"] * - Transforms flattened filters to nested format * - Returns MexClient models */ import type { AtomicBatchResult, ClientFilter, ClientRelationshipType, ClientSort, CreateAddressInput, CreateBankAccountInput, CreateClientInput, CreateContactMethodInput, CreateMexAddressInput, CreateMexClientInput, LinkedClient as LinkedClientInput, ListOptions, MexClientFilter, MexClientSort, PaginatedResponse, PartialBatchResult, SyncCreateDocumentInput, SyncItem, SyncResult, SyncUpdateDocumentInput, UpdateAddressInput, UpdateBankAccountInput, UpdateClientInput, UpdateContactMethodInput, UpdateMexAddressInput, UpdateMexClientInput, UpsertMexClientInput, UpsertResult } from "@artu-ai/shared"; import { type ClientData, ContactMethod, Document, LinkedClient, MexAddress, MexBankAccount, MexClient } from "../../models"; import { type ClientIncludeMap, ClientsResource } from "../clients"; import type { RelatedPartyParent, RelatedPartySubresource } from "../related-parties/base"; /** * Mexico-scoped clients resource. * * Provides the same operations as ClientsResource but with: * - Flattened input types (MX fields at root level) * - Automatic scopes injection on create/update * - MexClient model return type * * @example * ```typescript * // Using the Mexico SDK entry point * import { ComplianceSDK } from "@artu-ai/compliance-sdk/mx"; * * const mexSdk = new ComplianceSDK({ * apiKey, * environment: "test", * }); * * // Create with flattened input * const client = await mexSdk.clients.create({ * type: ClientType.Person, * name: "Juan García", * rfc: "GAJL850101ABC", // MX field at root * curp: "GAJL850101HDFRRL09", // MX field at root * actividadVulnerable: { // Activity data keyed by code * AVI: { username: "JGARCIA" }, * }, * }); * * // List clients * const { data } = await mexSdk.clients.list(); * // data is MexClient[] * ``` */ export declare class MexClientsResource extends ClientsResource { readonly legalRepresentatives: RelatedPartySubresource; readonly controllingBeneficiaries: RelatedPartySubresource; protected relatedPartyParent(): RelatedPartyParent; /** * Creates a new Mexico client with flattened input. * * @param data - Client creation data with MX fields at root level * @returns The created MexClient model */ create(data: CreateMexClientInput): Promise; /** * Retrieves a client by ID. */ retrieve(id: string, options?: { include?: ClientIncludeMap; crossScope?: boolean; }): Promise; /** * Retrieves a Mexico client by externalId. */ retrieveByExternalId(externalId: string, opts?: { crossScope?: boolean; }): Promise; /** * Updates a Mexico client with flattened input. */ update(id: string, data: UpdateMexClientInput): Promise; /** * Lists Mexico clients with optional filtering. * * Accepts flattened Mexico filter (MX fields at root level) and * transforms to nested format before calling the API. * * @example * ```typescript * // Filter with flattened MX fields * const { data } = await mexSdk.clients.list({ * filter: { * name: { contains: "García" }, * rfc: { startsWith: "GAJL" }, // MX field at root! * }, * }); * ``` */ list(options?: ListOptions & { includePrimaryContacts?: boolean; includeNonPrimary?: boolean; crossScope?: boolean; }): Promise>; /** * Counts Mexico clients matching the given filter. * * @param filter - Optional filter criteria (with MX fields at root level) * @returns The count of matching clients */ count(filter?: MexClientFilter, options?: { includeNonPrimary?: boolean; crossScope?: boolean; }): Promise; /** * Iterates over Mexico clients. * * Accepts flattened Mexico filter (MX fields at root level) and * transforms to nested format before calling the API. */ iterate(options?: { filter?: MexClientFilter; sort?: TSort; pageSize?: number; crossScope?: boolean; }): AsyncGenerator; /** * Creates multiple Mexico clients with flattened input. */ createMany(clients: CreateMexClientInput[], options?: { atomic?: true; }): Promise>; createMany(clients: CreateMexClientInput[], options: { atomic: false; }): Promise>; /** * Updates multiple Mexico clients. */ updateMany(updates: { id: string; data: UpdateMexClientInput; }[], options?: { atomic?: true; }): Promise>; updateMany(updates: { id: string; data: UpdateMexClientInput; }[], options: { atomic: false; }): Promise>; /** * Creates or updates a Mexico client by externalId. * * @param data - Client upsert data with MX fields at root level (must include externalId) * @returns The created or updated client with action indicator */ upsertByExternalId(data: UpsertMexClientInput): Promise>; /** * Creates or updates multiple Mexico clients by externalId. * * @param clients - Array of client upsert data (each must include externalId) * @param options - Batch options (atomic: true by default) * @returns Atomic result with data array, or partial result with succeeded/failed */ upsertManyByExternalId(clients: UpsertMexClientInput[], options?: { atomic?: true; }): Promise>>; upsertManyByExternalId(clients: UpsertMexClientInput[], options: { atomic: false; }): Promise>>; linkClient(parentClientId: string, childClientId: string, relationshipType: ClientRelationshipType, metadata?: Record): Promise; unlinkClient(parentClientId: string, childClientId: string, relationshipType: ClientRelationshipType): Promise; listLinkedClients(parentClientId: string, relationshipType?: ClientRelationshipType): Promise; setLinkedClients(parentClientId: string, linkedClients: LinkedClientInput[]): Promise; /** * Atomically creates or updates a Mexico client and all related resources in a single transaction. * * Accepts flattened Mexico address input types for convenience. */ syncAll(clientId: undefined, data: { client: CreateMexClientInput; addresses?: SyncItem[]; contactMethods?: SyncItem[]; bankAccounts?: SyncItem[]; documents?: SyncItem[]; linkedClients?: LinkedClientInput[]; }, options?: { replaceMode?: boolean; }): Promise<{ client: MexClient; addresses: SyncResult; contactMethods: SyncResult; bankAccounts: SyncResult; documents: SyncResult; }>; syncAll(clientId: string, data: { client?: UpdateMexClientInput; addresses?: SyncItem[]; contactMethods?: SyncItem[]; bankAccounts?: SyncItem[]; documents?: SyncItem[]; linkedClients?: LinkedClientInput[]; }, options: { replaceMode: true; }): Promise<{ client: MexClient; addresses: SyncResult; contactMethods: SyncResult; bankAccounts: SyncResult; documents: SyncResult; }>; syncAll(clientId: string, data: { client?: UpdateMexClientInput; addresses?: SyncItem[]; contactMethods?: SyncItem[]; bankAccounts?: SyncItem[]; documents?: SyncItem[]; linkedClients?: LinkedClientInput[]; }, options?: { replaceMode?: boolean; }): Promise<{ client: MexClient; addresses: SyncResult; contactMethods: SyncResult; bankAccounts: SyncResult; documents: SyncResult; }>; /** * Transforms a flattened MexClientFilter to nested ClientFilter format. * * Extracts MX-specific fields (rfc, curp, actividadEconomica, giroMercantil, * actividadVulnerable) from root level and nests them under scopeData.MX. * * Note: This method only transforms filters, it does not automatically add * scope scoping. Use explicit filters if you need to scope by scope. */ protected applyScopeToFilter(filter?: MexClientFilter): ClientFilter | undefined; /** * Transforms a flattened MexClientSort to nested ClientSort format. * * Maps flattened field names (rfc, curp, actividadVulnerable.AVI.username) * to their full API paths (scopeData.MX.rfc, etc.). * * Note: Uses unknown parameter to allow derived classes to override with their own sort types. */ protected applyScopeToSort(sort?: TSort): ClientSort | undefined; /** * Transforms flattened MX input to nested API format. */ protected transformToNested(data: CreateMexClientInput): CreateClientInput; /** * Transforms flattened MX update input to nested API format. * * NOTE: Always includes `scopeData: { MX: {} }` even if no MX-specific * fields are provided. This ensures that records touched via the Mexico SDK * can be filtered by `availableJurisdictions: { in: ["MX"] }`. */ protected transformUpdateToNested(data: UpdateMexClientInput): UpdateClientInput; /** * Transforms a flattened MX address sync item to nested API format. */ protected transformAddressSyncItem(item: SyncItem): SyncItem; /** * Transforms flattened MX address input to nested API format. */ protected transformAddressToNested(data: CreateMexAddressInput): CreateAddressInput; /** * Transforms flattened MX address update input to nested API format. * * NOTE: Always includes `scopeData: { MX: {} }` even if no MX-specific * fields are provided. This ensures that records touched via the Mexico SDK * retain their MX scope data. */ protected transformAddressUpdateToNested(data: UpdateMexAddressInput): UpdateAddressInput; /** * Instantiates a MexClient model. */ protected instantiate(data: ClientData): MexClient; /** Materializes a raw payload into a {@link MexClient} (return type narrowed via the `instantiate` override). */ materialize(data: ClientData): MexClient; }