- Add errand-repository.ts port with ErrandRepository, ErrandWithAlias, ErrandStatus types - Add DrizzleErrandRepository adapter with create, findById (left-joins agents for alias), findAll (optional projectId/status filters, desc by createdAt), update, delete - Wire exports into repositories/index.ts and repositories/drizzle/index.ts - Add migration 0035_faulty_human_fly.sql (CREATE TABLE errands) and drizzle snapshot - Add 13 tests covering CRUD, filtering, ordering, agentAlias join, cascade/set-null FK behaviour - Update docs/database.md to document the errands table and ErrandRepository Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
16 lines
718 B
TypeScript
16 lines
718 B
TypeScript
import type { Errand, NewErrand } from '../schema.js';
|
|
|
|
export type ErrandStatus = 'active' | 'pending_review' | 'conflict' | 'merged' | 'abandoned';
|
|
export type ErrandWithAlias = Errand & { agentAlias: string | null };
|
|
|
|
export type CreateErrandData = Omit<NewErrand, 'createdAt' | 'updatedAt'>;
|
|
export type UpdateErrandData = Partial<Omit<NewErrand, 'id' | 'createdAt'>>;
|
|
|
|
export interface ErrandRepository {
|
|
create(data: CreateErrandData): Promise<Errand>;
|
|
findById(id: string): Promise<ErrandWithAlias | undefined>;
|
|
findAll(opts?: { projectId?: string; status?: ErrandStatus }): Promise<ErrandWithAlias[]>;
|
|
update(id: string, data: UpdateErrandData): Promise<Errand>;
|
|
delete(id: string): Promise<void>;
|
|
}
|