31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
/**
|
|
* Ports (driven interfaces). Domain owns them; infrastructure implements them.
|
|
* All operations are scoped by userId so ownership is enforced in the query.
|
|
*/
|
|
import type {
|
|
CustomerListOptions,
|
|
CustomerListResult,
|
|
CustomerSummary,
|
|
Profile,
|
|
ProfilePatch,
|
|
} from './profile.js';
|
|
import type { Address, AddressPatch, NewAddress } from './address.js';
|
|
|
|
export interface ProfileRepository {
|
|
findByUserId(userId: string): Promise<Profile | undefined>;
|
|
/** Idempotent upsert; only provided fields change. */
|
|
upsert(userId: string, patch: ProfilePatch): Promise<Profile>;
|
|
list(): Promise<Profile[]>;
|
|
listCustomers(opts: CustomerListOptions): Promise<CustomerListResult>;
|
|
findCustomerById(userId: string): Promise<CustomerSummary | undefined>;
|
|
}
|
|
|
|
export interface AddressRepository {
|
|
listByUserId(userId: string): Promise<Address[]>;
|
|
create(userId: string, input: NewAddress): Promise<Address>;
|
|
/** Returns undefined when the address does not belong to userId. */
|
|
update(userId: string, addressId: string, patch: AddressPatch): Promise<Address | undefined>;
|
|
/** Returns false when the address does not belong to userId. */
|
|
delete(userId: string, addressId: string): Promise<boolean>;
|
|
}
|