import type { Capability } from '@feltdb/core'; import { projects, type Project } from '../src/feltdb'; export interface ProjectSearchResult { id: string; name: string; description: string } export const projectSearch: Capability = { id: 'project-search', name: 'Project search', async execute(query: string): Promise { // The collection read crosses FeltDB's normal authorization boundary. The // capability narrows results; it never grants access to additional rows. const words = query.trim().toLowerCase(); const authorized = await projects.all() as Project[]; return authorized.filter(project => `${project.name} ${project.description}`.toLowerCase().includes(words)).map(({ id, name, description }) => ({ id, name, description })); }, };