feat: add reminders page, BMad skills upgrade, MCP server refactor
- Add reminders page with navigation support - Upgrade BMad builder module to skills-based architecture - Refactor MCP server: extract tools and auth into separate modules - Add connections cache, custom AI provider support - Update prisma schema and generated client - Various UI/UX improvements and i18n updates - Add service worker for PWA support Made-with: Cursor
This commit is contained in:
@@ -101,7 +101,6 @@ export function getEmbeddingsProvider(config?: Record<string, string>): AIProvid
|
||||
return getProviderInstance(provider, config || {}, modelName, embeddingModelName);
|
||||
}
|
||||
|
||||
// Legacy function for backward compatibility
|
||||
export function getAIProvider(config?: Record<string, string>): AIProvider {
|
||||
return getTagsProvider(config);
|
||||
return getEmbeddingsProvider(config);
|
||||
}
|
||||
|
||||
37
keep-notes/lib/connections-cache.ts
Normal file
37
keep-notes/lib/connections-cache.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
// Cache with TTL for 15 minutes
|
||||
const CACHE_TTL = 15 * 60 * 1000 // 15 minutes
|
||||
|
||||
interface CacheEntry {
|
||||
count: number
|
||||
timestamp: number
|
||||
}
|
||||
|
||||
const cache = new Map<string, CacheEntry>()
|
||||
|
||||
export async function getConnectionsCount(noteId: string): Promise<number> {
|
||||
const now = Date.now()
|
||||
const cached = cache.get(noteId)
|
||||
|
||||
if (cached && (now - cached.timestamp) < CACHE_TTL) {
|
||||
return cached.count
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(`/api/ai/echo/connections?noteId=${noteId}&limit=1`)
|
||||
if (!res.ok) {
|
||||
throw new Error('Failed to fetch connections')
|
||||
}
|
||||
const data = await res.json()
|
||||
const count = data.pagination?.total || 0
|
||||
|
||||
// Update cache for future calls
|
||||
if (count > 0) {
|
||||
cache.set(noteId, { count, timestamp: Date.now() })
|
||||
}
|
||||
|
||||
return count
|
||||
} catch (error) {
|
||||
console.error('[ConnectionsCache] Failed to fetch connections:', error)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@@ -57,9 +57,11 @@ export interface Note {
|
||||
images: string[] | null;
|
||||
links: LinkMetadata[] | null;
|
||||
reminder: Date | null;
|
||||
isReminderDone: boolean;
|
||||
reminderRecurrence: string | null;
|
||||
reminderLocation: string | null;
|
||||
isMarkdown: boolean;
|
||||
dismissedFromRecent?: boolean;
|
||||
size: NoteSize;
|
||||
order: number;
|
||||
createdAt: Date;
|
||||
|
||||
@@ -1,11 +1,55 @@
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
import { LABEL_COLORS, LabelColorName, QueryType } from "./types"
|
||||
import { LABEL_COLORS, LabelColorName, QueryType, Note } from "./types"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
/**
|
||||
* Deep equality check for two values
|
||||
* More performant than JSON.stringify for comparison
|
||||
*/
|
||||
export function deepEqual(a: unknown, b: unknown): boolean {
|
||||
if (a === b) return true
|
||||
if (a === null || b === null) return a === b
|
||||
if (typeof a !== typeof b) return false
|
||||
|
||||
if (Array.isArray(a) && Array.isArray(b)) {
|
||||
if (a.length !== b.length) return false
|
||||
return a.every((item, index) => deepEqual(item, b[index]))
|
||||
}
|
||||
|
||||
if (typeof a === 'object' && typeof b === 'object') {
|
||||
const keysA = Object.keys(a as Record<string, unknown>)
|
||||
const keysB = Object.keys(b as Record<string, unknown>)
|
||||
if (keysA.length !== keysB.length) return false
|
||||
return keysA.every(key => deepEqual(
|
||||
(a as Record<string, unknown>)[key],
|
||||
(b as Record<string, unknown>)[key]
|
||||
))
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a database note object into a typed Note
|
||||
* Handles JSON string fields that are stored in the database
|
||||
*/
|
||||
export function parseNote(dbNote: any): Note {
|
||||
return {
|
||||
...dbNote,
|
||||
checkItems: dbNote.checkItems ? JSON.parse(dbNote.checkItems) : null,
|
||||
labels: dbNote.labels ? JSON.parse(dbNote.labels) : null,
|
||||
images: dbNote.images ? JSON.parse(dbNote.images) : null,
|
||||
links: dbNote.links ? JSON.parse(dbNote.links) : null,
|
||||
embedding: dbNote.embedding ? JSON.parse(dbNote.embedding) : null,
|
||||
sharedWith: dbNote.sharedWith ? JSON.parse(dbNote.sharedWith) : [],
|
||||
size: dbNote.size || 'small',
|
||||
}
|
||||
}
|
||||
|
||||
export function getHashColor(name: string): LabelColorName {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < name.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user