/** * Addresses Resource * * Manages physical and mailing addresses for clients. */ import type { AddressFilter, AddressSort, AddressType, AtomicBatchResult, CreateAddressInput, ListOptions, PaginatedResponse, PartialBatchResult, SyncItem, SyncResult, UpdateAddressInput, UpsertAddressInput, UpsertResult } from "@artu-ai/shared"; import { z } from "zod"; import { Address, type AddressData } from "../models/Address"; import { BaseResource } from "./base"; /** * Resource for managing client addresses. * * @example * ```typescript * // Create an address for a client * const address = await sdk.addresses.create({ * clientId: "client_123", * type: "home", * street1: "Avenida Reforma 123", * city: "Ciudad de México", * state: "CDMX", * postalCode: "06600", * country: "MX", * isPrimary: true, * }); * * // List all addresses for a client * const addresses = await sdk.addresses.listByClient("client_123"); * ``` */ export declare class AddressesResource extends BaseResource { protected get createSchema(): z.ZodType; protected get updateSchema(): z.ZodType; protected get upsertSchema(): z.ZodType; /** * Creates an address for a client * * @param data - Address data including clientId * @returns The created Address */ create(data: CreateAddressInput): Promise
; /** * Retrieves an address by ID * * @param id - The address ID * @returns The Address */ retrieve(id: string): Promise
; /** * Retrieves an address by metadata key/value. */ retrieveByMetadata(key: string, value: string): Promise
; /** * Retrieves an address by externalId */ retrieveByExternalId(externalId: string): Promise
; /** * Updates an address * * @param id - The address ID * @param data - Fields to update * @returns The updated Address */ update(id: string, data: UpdateAddressInput): Promise
; /** * Deletes an address * * @param id - The address ID */ delete(id: string): Promise; /** * Lists addresses with optional filtering * * @param options - Filtering and pagination options * @returns Paginated list of Addresses */ list(options?: ListOptions): Promise>; /** * Lists all addresses for a specific client * * @param clientId - The client ID * @param options - Optional pagination options * @returns Paginated list of Addresses */ listByClient(clientId: string, options?: { cursor?: string; limit?: number; }): Promise>; /** * Counts addresses matching the given filter. * * @param filter - Optional filter criteria * @returns The count of matching addresses */ count(filter?: AddressFilter): Promise; /** * Returns an async iterator over all addresses matching the filter. */ iterate(options?: { filter?: AddressFilter; sort?: TSort; pageSize?: number; }): AsyncGenerator; /** * Creates multiple addresses in a single request. * * @param addresses - Array of address creation data (each includes clientId) * @param options - Batch options (atomic: true by default) * @returns Atomic result with data array, or partial result with succeeded/failed */ createMany(addresses: CreateAddressInput[], options?: { atomic?: true; }): Promise>; createMany(addresses: CreateAddressInput[], options: { atomic: false; }): Promise>; /** * Updates multiple addresses in a single request. * * @param updates - Array of { id, data } updates * @param options - Batch options (atomic: true by default) * @returns Atomic result with data array, or partial result with succeeded/failed */ updateMany(updates: { id: string; data: UpdateAddressInput; }[], options?: { atomic?: true; }): Promise>; updateMany(updates: { id: string; data: UpdateAddressInput; }[], options: { atomic: false; }): Promise>; /** * Syncs addresses for a client - handles create, update, and delete in bulk. * * This is the most efficient way to reconcile a set of addresses for a client. * * @param clientId - The client ID * @param items - Array of sync items: * - Without `id`: create new address * - With `id` and `_delete: true`: delete existing address * - With `id` (no `_delete`): update existing address * @param options - Sync options * @param options.replaceMode - When true, items not in the array are deleted (default: false) * @returns Sync result with created, updated, and deleted arrays * * @example * ```typescript * // Patch mode (default) - only mentioned items are affected * const result = await sdk.addresses.sync("client_123", [ * // Create new address (no id) * { street: "123 New St", city: "Mexico City", country: "MX" }, * // Update existing address (has id) * { id: "addr_456", street: "456 Updated Ave" }, * // Delete address (has id and _delete: true) * { id: "addr_789", _delete: true }, * ]); * * // Replace mode - provided array becomes the complete set * const result = await sdk.addresses.sync("client_123", addresses, { replaceMode: true }); * * console.log(result.created); // newly created addresses * console.log(result.updated); // updated addresses * console.log(result.deleted); // array of deleted address IDs * ``` */ sync(clientId: string, items: SyncItem[], options?: { replaceMode: true; }): Promise>; sync(clientId: string, items: SyncItem[], options?: { replaceMode?: boolean; }): Promise>; /** * Creates or updates an address by externalId. * * If an address with the given externalId exists, it will be updated. * Otherwise, a new address will be created. * * @param data - Address upsert data (must include externalId and clientId) * @returns The created or updated address with action indicator */ upsertByExternalId(data: UpsertAddressInput): Promise>; /** * Creates or updates multiple addresses by externalId in a single request. * * @param addresses - Array of address upsert data (each must include externalId and clientId) * @param options - Batch options (atomic: true by default) * @returns Atomic result with data array, or partial result with succeeded/failed */ upsertManyByExternalId(addresses: UpsertAddressInput[], options?: { atomic?: true; }): Promise>>; upsertManyByExternalId(addresses: UpsertAddressInput[], options: { atomic: false; }): Promise>>; /** * Gets the primary address for a client * * @param clientId - The client ID * @param type - Optional address type filter * @returns The primary Address or null */ getPrimary(clientId: string, type?: AddressType): Promise
; protected instantiate(data: AddressData): Address; }