/**
 * Page Repository Port Interface
 *
 * Port for Page aggregate operations.
 * Implementations (Drizzle, etc.) are adapters.
 */

import type { Page, NewPage } from '../schema.js';

/**
 * Data for creating a new page.
 * Omits system-managed fields (id, createdAt, updatedAt).
 */
export type CreatePageData = Omit<NewPage, 'id' | 'createdAt' | 'updatedAt'> & { id?: string };

/**
 * Data for updating a page.
 */
export type UpdatePageData = Partial<Pick<NewPage, 'title' | 'content' | 'sortOrder'>>;

/**
 * Page Repository Port
 */
export interface PageRepository {
  create(data: CreatePageData): Promise<Page>;
  findById(id: string): Promise<Page | null>;
  findByIds(ids: string[]): Promise<Page[]>;
  findByInitiativeId(initiativeId: string): Promise<Page[]>;
  findByParentPageId(parentPageId: string): Promise<Page[]>;
  findRootPage(initiativeId: string): Promise<Page | null>;
  getOrCreateRootPage(initiativeId: string): Promise<Page>;
  update(id: string, data: UpdatePageData): Promise<Page>;
  delete(id: string): Promise<void>;
}
