Files
metabuilder/frontends/nextjs/src/lib/ui-pages/load-page-from-db.ts
copilot-swe-agent[bot] af2a59ee6a fix: Resolve TypeScript errors and dependency issues
- Fixed Storybook dependency version mismatch (downgraded to 8.6.15)
- Added @types/better-sqlite3 for better-sqlite3 type definitions
- Fixed Prisma adapter import (PrismaBetterSqlite3 vs PrismaBetterSQLite3)
- Removed datasource URL from Prisma schema (Prisma 7 requirement)
- Generated DBAL types.generated.ts from Prisma schema
- Added index signatures to Update*Input types for Record<string, unknown> compatibility
- Fixed ErrorBoundary override modifiers
- Fixed Zod record schema (requires both key and value types)
- Fixed orderBy syntax in get-error-logs (array format)
- Fixed type safety in API routes (user type assertions)
- Fixed hook imports and exports
- Fixed conditional expression type guards
- Added .npmrc for legacy peer deps support

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2026-01-08 01:26:50 +00:00

41 lines
1.1 KiB
TypeScript

/**
* Load UI page from database
*/
import type { PageConfig } from '../types/level-types'
import { prisma } from '@/lib/config/prisma'
export async function loadPageFromDb(path: string, tenantId?: string): Promise<PageConfig | null> {
// Prisma client typing is generated; suppress lint in environments without generated types.
const page = await prisma.pageConfig.findFirst({
where: {
path,
tenantId: tenantId ?? null,
isPublished: true,
},
}) as PageConfig | null
if (page === null) {
return null
}
return {
id: page.id,
tenantId: page.tenantId,
packageId: page.packageId,
path: page.path,
title: page.title,
description: page.description,
icon: page.icon,
component: page.component,
componentTree: JSON.parse(String(page.componentTree)),
level: page.level,
requiresAuth: page.requiresAuth,
requiredRole: page.requiredRole,
accessLevel: page.level,
createdAt: page.createdAt !== undefined ? Number(page.createdAt) : undefined,
updatedAt: page.updatedAt !== undefined ? Number(page.updatedAt) : undefined,
}
}