/**
 * ShareRotated Event
 *
 * Emitted when a share is rotated (replaced with a new share).
 */

import { DomainEvent } from './domain-event.base';

export class ShareRotatedEvent extends DomainEvent {
  constructor(
    public readonly newShareId: string,
    public readonly oldShareId: string,
    public readonly partyId: string,
    public readonly sessionId: string,
  ) {
    super();
  }

  get eventType(): string {
    return 'ShareRotated';
  }

  get aggregateId(): string {
    return this.newShareId;
  }

  get aggregateType(): string {
    return 'PartyShare';
  }

  get payload(): Record<string, unknown> {
    return {
      newShareId: this.newShareId,
      oldShareId: this.oldShareId,
      partyId: this.partyId,
      sessionId: this.sessionId,
    };
  }
}
