Calendar: - GET /api/domains/[domainId]/calendar/events?from=&to= — returns tasks, habits, projects, milestones - PATCH /api/domains/[domainId]/tasks/[id]/schedule — drag-to-reschedule with activity feed - Calendar UI with month/week/day views via react-big-calendar - Drag-to-reschedule with SSE updates - Filter by entity type and domain - Keyboard shortcuts: t=today, m/w/d=view, ←/→=navigate - Mobile: auto-switches to day view on small screens Dashboard: - GET/PUT /api/domains/[domainId]/dashboard — layout stored in domain custom_fields - 8 per-widget data endpoints (today-tasks, habit-checklist, weekly-stats, project-progress, upcoming-calendar, recent-notes, activity-feed, quick-capture) - react-grid-layout with responsive breakpoints (12/8/4 cols) - Drag-to-reorder, resize, add/remove widgets - Edit mode toggle, per-workspace layout persistence - Widget error boundary Search: - tsvector columns + GIN indexes on tasks, notes, projects, habits, domains - GET /api/search?q=&types=&domain= — ranked results with ts_headline snippets - Dedicated search page with grouped results, filters, recent searches (localStorage) - Empty state with hints Schema: - Added custom_fields jsonb column to domains table (migration 0002) - Removed stale root app/ directory Build: passes, typecheck: passes, tests: 18/18 wikilink-parser tests pass
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
// AGENT INSTRUCTION: After every write (INSERT/UPDATE/DELETE), you MUST:
|
|
// 1. Insert activity feed entry
|
|
// 2. Call pg.notify('project_e_events', JSON.stringify({ type, action, id, workspace_id }))
|
|
// See AGENTS.md for full rules.
|
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
import { withAuth, createErrorResponse } from '@/lib/auth';
|
|
import { searchEntities } from '@/lib/search-service';
|
|
|
|
// GET /api/search?q=&type=&domain=&limit=&offset=
|
|
// Full-text search across all entity types using PostgreSQL tsvector/tsquery
|
|
export const GET = withAuth(async (request: NextRequest, user) => {
|
|
const { searchParams } = new URL(request.url);
|
|
const q = (searchParams.get('q') || '').trim();
|
|
const types = searchParams.get('types')?.split(',').filter(Boolean) || ['task', 'note', 'project', 'habit', 'domain'];
|
|
const domain = searchParams.get('domain') || undefined;
|
|
const limit = Math.max(1, Math.min(50, parseInt(searchParams.get('limit') || '20')));
|
|
const offset = Math.max(0, parseInt(searchParams.get('offset') || '0'));
|
|
|
|
if (!q) {
|
|
return NextResponse.json({ results: [], totalCount: 0 });
|
|
}
|
|
|
|
try {
|
|
const { results, totalCount } = await searchEntities({
|
|
query: q,
|
|
types,
|
|
domainId: domain,
|
|
limit,
|
|
offset,
|
|
});
|
|
|
|
return NextResponse.json({
|
|
results,
|
|
totalCount,
|
|
query: q,
|
|
});
|
|
} catch (error) {
|
|
console.error('[search GET] error:', error);
|
|
return createErrorResponse('INTERNAL_ERROR', 'Search failed', 500);
|
|
}
|
|
});
|