import { isAfter, subWeeks } from 'date-fns'; import type { Tool } from './tools.types'; type WithOptional = Omit & Partial>; export function defineTool(tool: WithOptional) { const isNew = tool.createdAt ? isAfter(tool.createdAt, subWeeks(new Date(), 2)) : false; return { isNew, ...tool, }; }