rwadurian/backend/services/mpc-service/src/domain/repositories/party-share.repository.inte...

95 lines
2.3 KiB
TypeScript

/**
* PartyShare Repository Interface
*
* Defines the contract for party share persistence.
* Implementation will be in the infrastructure layer.
*/
import { PartyShare } from '../entities/party-share.entity';
import { ShareId, PartyId, SessionId, PublicKey } from '../value-objects';
import { PartyShareStatus, PartyShareType } from '../enums';
export interface PartyShareFilters {
partyId?: string;
status?: PartyShareStatus;
shareType?: PartyShareType;
publicKey?: string;
}
export interface Pagination {
page: number;
limit: number;
}
export interface PartyShareRepository {
/**
* Save a new party share
*/
save(share: PartyShare): Promise<void>;
/**
* Update an existing party share
*/
update(share: PartyShare): Promise<void>;
/**
* Find a share by its ID
*/
findById(id: ShareId): Promise<PartyShare | null>;
/**
* Find a share by party ID and public key
*/
findByPartyIdAndPublicKey(partyId: PartyId, publicKey: PublicKey): Promise<PartyShare | null>;
/**
* Find a share by party ID and session ID
*/
findByPartyIdAndSessionId(partyId: PartyId, sessionId: SessionId): Promise<PartyShare | null>;
/**
* Find all shares for a given session
*/
findBySessionId(sessionId: SessionId): Promise<PartyShare[]>;
/**
* Find all shares for a given party
*/
findByPartyId(partyId: PartyId): Promise<PartyShare[]>;
/**
* Find all active shares for a given party
*/
findActiveByPartyId(partyId: PartyId): Promise<PartyShare[]>;
/**
* Find share by public key
*/
findByPublicKey(publicKey: PublicKey): Promise<PartyShare | null>;
/**
* Find shares with filters and pagination
*/
findMany(filters?: PartyShareFilters, pagination?: Pagination): Promise<PartyShare[]>;
/**
* Count shares matching filters
*/
count(filters?: PartyShareFilters): Promise<number>;
/**
* Check if a share exists for the given party and public key
*/
existsByPartyIdAndPublicKey(partyId: PartyId, publicKey: PublicKey): Promise<boolean>;
/**
* Delete a share (soft delete - mark as revoked)
*/
delete(id: ShareId): Promise<void>;
}
/**
* Symbol for dependency injection
*/
export const PARTY_SHARE_REPOSITORY = Symbol('PARTY_SHARE_REPOSITORY');