/** * ProjectRepository - Repository interface for project persistence. * * Uses Effect `Context.Tag` for dependency injection and returns typed * domain errors for all operations. * * @module ProjectRepository */ import type { ProjectAddInput, ProjectAddResult, ProjectListResult, ProjectRemoveInput, ProjectUpdateScriptsInput, ProjectUpdateScriptsResult, } from "@t3tools/contracts"; import { ServiceMap } from "effect"; import type { Effect } from "effect"; import type { ProjectRepositoryError } from "../Errors.ts"; export interface ProjectRepositoryShape { /** * List all persisted projects. * * @returns Effect containing all project records. */ readonly list: () => Effect.Effect; /** * Add a project by cwd, or return the existing project when the cwd already exists. * * @param input - Project creation payload. * @returns Effect containing the project and whether it was newly created. */ readonly add: (input: ProjectAddInput) => Effect.Effect; /** * Remove a persisted project. * * @param input - Project removal payload. * @returns Effect containing void. */ readonly remove: (input: ProjectRemoveInput) => Effect.Effect; /** * Update the scripts for an existing project. * * @param input - Script update payload. * @returns Effect containing the updated project. */ readonly updateScripts: ( input: ProjectUpdateScriptsInput, ) => Effect.Effect; /** * Remove projects whose cwd no longer exists on disk. * * @returns Effect containing void. */ readonly pruneMissing: () => Effect.Effect; } /** * ProjectRepository - Context tag for project persistence dependency injection. * * @example * ```ts * const program = Effect.gen(function* () { * const projects = yield* ProjectRepository * return yield* projects.list() * }) * ``` */ export class ProjectRepository extends ServiceMap.Service< ProjectRepository, ProjectRepositoryShape >()("persistence/ProjectRepository") {}