Activity Stream: - Add UserActivity model with ActivityType enum to track user actions - Create activity logging service with fire-and-forget pattern - Add /api/user/activity endpoint with cursor pagination - Add cleanup cron job for 90-day activity retention - Integrate activity logging into 18 mutation API routes - Add DashboardActivityStream component with virtualized rendering API Improvements: - Add distributed rate limiting via Vercel KV (with in-memory fallback) - Add rate limiting to chat endpoint (30 req/min) - Optimize BM25 search with database-level pre-filtering - Fix JSON parse crash in search endpoint - Add pagination to collection tools response (toolsLimit/toolsOffset) - Add take limits to agent detail query to prevent excessive data fetch - Fix hardcoded tool count calculation in agents dashboard Schema Extraction: - Add schemaExtractionAttemptAt and schemaExtractionError fields - Separate rate limiting for failed (1 min) vs successful (1 hour) attempts - Allow retry of failed extractions Standardization: - Create api-response.ts with standardized response helpers - Add apiSuccess, apiError, apiNotFound, apiForbidden, etc. - Update agents routes to use standardized format Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| prisma | ||
| src | ||
| .env.example | ||
| .gitignore | ||
| check-tool.js | ||
| check-tool.mjs | ||
| package.json | ||
| README.md | ||
| sync-single-tool.mjs | ||
| test-query.mjs | ||
| tsconfig.json | ||
@tpmjs/db
Database package for TPMJS NPM Registry. Provides Prisma ORM setup and database client for storing tool metadata.
Setup
1. Create Neon Database
- Go to https://neon.tech/
- Create a new project
- Copy the connection string
2. Configure Environment
cp .env.example .env
# Edit .env and add your DATABASE_URL
3. Run Migrations
pnpm db:migrate
pnpm db:seed
Usage
import { prisma } from '@tpmjs/db';
// Query tools
const tools = await prisma.tool.findMany({
where: {
category: 'web-scraping',
isOfficial: true,
},
orderBy: {
qualityScore: 'desc',
},
take: 10,
});
// Update sync checkpoint
await prisma.syncCheckpoint.update({
where: { source: 'changes-feed' },
data: {
checkpoint: {
sequence: '12345',
lastProcessed: new Date().toISOString(),
},
},
});
Scripts
pnpm db:generate- Generate Prisma clientpnpm db:push- Push schema to database (for development)pnpm db:migrate- Create and run migrations (for production)pnpm db:studio- Open Prisma Studio GUIpnpm db:seed- Seed initial data
Schema
Tool
Stores NPM packages with TPMJS metadata from their package.json.
SyncCheckpoint
Tracks progress of sync workers (changes feed, keyword search, metrics).
SyncLog
Audit trail of all sync operations.