fix: reports API - add DB table, rewrite routes with Drizzle, fix TipTap type errors

Added reports table to PostgreSQL and Drizzle schema. Rewrote reports API routes to use Drizzle ORM instead of PocketBase stub. Fixed shared schema to match frontend field names. Fixed TipTap v3 type errors in note-editor.tsx and report-editor.tsx (StarterKit cast+chain as any).
This commit is contained in:
Hermes
2026-08-02 02:22:31 +00:00
parent 0df6d1c1c8
commit 7297b7075e
6 changed files with 171 additions and 79 deletions
+26
View File
@@ -506,6 +506,32 @@ export const webhookDeliveries = pgTable(
// ── API Keys ─────────────────────────────────────────────────────────────────────
// ── Reports ──────────────────────────────────────────────────────────────────
export const reports = pgTable(
'reports',
{
id: uuid('id').defaultRandom().primaryKey(),
title: text('title').notNull().default('Untitled report'),
content: text('content'),
reportType: text('report_type').notNull().default('custom'),
dateRangeStart: timestamp('date_range_start', { withTimezone: true }),
dateRangeEnd: timestamp('date_range_end', { withTimezone: true }),
domain: text('domain').notNull().default('personal'),
projectId: uuid('project_id').references((): any => projects.id, { onDelete: 'set null' }),
isDraft: boolean('is_draft').default(true),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
},
(table) => [
index('reports_domain_idx').on(table.domain),
index('reports_type_idx').on(table.reportType),
index('reports_created_at_idx').on(table.createdAt),
]
);
export const apiKeys = pgTable(
'api_keys',
{