// src/services/userService.ts import * as db from './db/index.db'; import { AddressRepository } from './db/address.db'; import { UserRepository } from './db/user.db'; import type { Address, UserProfile } from '../types'; /** * Encapsulates user-related business logic that may involve multiple repository calls. */ class UserService { /** * Per ADR-002, this function encapsulates a multi-write operation within a transaction. * It creates or updates a user's address and links it to their profile atomically. * * @param user The user profile object. * @param addressData The address data to upsert. * @returns The ID of the upserted address. */ async upsertUserAddress(user: UserProfile, addressData: Partial
): Promise