mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
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>
This commit is contained in:
@@ -3,7 +3,7 @@ import type { DBALAdapter } from '../adapter'
|
|||||||
export interface User {
|
export interface User {
|
||||||
id: string
|
id: string
|
||||||
username: string
|
username: string
|
||||||
role: 'user' | 'admin' | 'god' | 'supergod'
|
role: 'user' | 'admin' | 'god' | 'supergod' | 'public' | 'moderator'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ACLRule {
|
export interface ACLRule {
|
||||||
|
|||||||
@@ -48,7 +48,11 @@ const applySort = (
|
|||||||
if (!sort || Object.keys(sort).length === 0) {
|
if (!sort || Object.keys(sort).length === 0) {
|
||||||
return records
|
return records
|
||||||
}
|
}
|
||||||
const [key, direction] = Object.entries(sort)[0]
|
const sortEntries = Object.entries(sort)[0]
|
||||||
|
if (sortEntries === undefined) {
|
||||||
|
return records
|
||||||
|
}
|
||||||
|
const [key, direction] = sortEntries
|
||||||
return [...records].sort((left, right) => {
|
return [...records].sort((left, right) => {
|
||||||
const a = left[key]
|
const a = left[key]
|
||||||
const b = right[key]
|
const b = right[key]
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export interface CreateSessionInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateSessionInput {
|
export interface UpdateSessionInput {
|
||||||
|
[key: string]: unknown
|
||||||
userId?: string
|
userId?: string
|
||||||
token?: string
|
token?: string
|
||||||
expiresAt?: bigint
|
expiresAt?: bigint
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export interface CreateWorkflowInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateWorkflowInput {
|
export interface UpdateWorkflowInput {
|
||||||
|
[key: string]: unknown
|
||||||
name?: string
|
name?: string
|
||||||
description?: string
|
description?: string
|
||||||
nodes?: string
|
nodes?: string
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export interface CreatePageInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdatePageInput {
|
export interface UpdatePageInput {
|
||||||
|
[key: string]: unknown
|
||||||
tenantId?: string | null
|
tenantId?: string | null
|
||||||
packageId?: string | null
|
packageId?: string | null
|
||||||
path?: string
|
path?: string
|
||||||
@@ -57,6 +58,7 @@ export interface CreateComponentNodeInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateComponentNodeInput {
|
export interface UpdateComponentNodeInput {
|
||||||
|
[key: string]: unknown
|
||||||
type?: string
|
type?: string
|
||||||
parentId?: string | null
|
parentId?: string | null
|
||||||
childIds?: string
|
childIds?: string
|
||||||
|
|||||||
@@ -25,10 +25,12 @@ export interface PackageData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CreatePackageDataInput {
|
export interface CreatePackageDataInput {
|
||||||
|
[key: string]: unknown
|
||||||
packageId: string
|
packageId: string
|
||||||
data: string
|
data: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdatePackageDataInput {
|
export interface UpdatePackageDataInput {
|
||||||
|
[key: string]: unknown
|
||||||
data?: string
|
data?: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export interface CreateUserInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateUserInput {
|
export interface UpdateUserInput {
|
||||||
|
[key: string]: unknown
|
||||||
username?: string
|
username?: string
|
||||||
email?: string
|
email?: string
|
||||||
role?: UserRole
|
role?: UserRole
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
"@eslint/js": "^9.39.2",
|
"@eslint/js": "^9.39.2",
|
||||||
"@tanstack/react-query": "^5.90.16",
|
"@tanstack/react-query": "^5.90.16",
|
||||||
"@testing-library/react": "^16.3.1",
|
"@testing-library/react": "^16.3.1",
|
||||||
|
"@types/better-sqlite3": "^7.6.12",
|
||||||
"@types/node": "^25.0.3",
|
"@types/node": "^25.0.3",
|
||||||
"@types/react": "^19.2.7",
|
"@types/react": "^19.2.7",
|
||||||
"@types/react-dom": "^19.2.3",
|
"@types/react-dom": "^19.2.3",
|
||||||
|
|||||||
@@ -54,7 +54,14 @@ async function handleRequest(
|
|||||||
const { route, operation, dbalOp } = context
|
const { route, operation, dbalOp } = context
|
||||||
|
|
||||||
// 2. Get current user session (may be null for public routes)
|
// 2. Get current user session (may be null for public routes)
|
||||||
const { user } = await getSessionUser()
|
const { user: rawUser } = await getSessionUser()
|
||||||
|
|
||||||
|
// Type-safe user with required fields
|
||||||
|
const user = rawUser !== null ? {
|
||||||
|
id: String(rawUser.id ?? ''),
|
||||||
|
role: String(rawUser.role ?? 'public'),
|
||||||
|
tenantId: rawUser.tenantId !== undefined && rawUser.tenantId !== null ? String(rawUser.tenantId) : null,
|
||||||
|
} : null
|
||||||
|
|
||||||
// 3. Validate package exists and user has required level
|
// 3. Validate package exists and user has required level
|
||||||
const packageResult = validatePackageRoute(route.package, route.entity, user)
|
const packageResult = validatePackageRoute(route.package, route.entity, user)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundarySt
|
|||||||
return { hasError: true, error }
|
return { hasError: true, error }
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
|
override componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
|
||||||
// Log error in development
|
// Log error in development
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
console.error('ErrorBoundary caught an error:', error)
|
console.error('ErrorBoundary caught an error:', error)
|
||||||
@@ -43,7 +43,7 @@ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundarySt
|
|||||||
this.props.onError?.(error, errorInfo)
|
this.props.onError?.(error, errorInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): ReactNode {
|
override render(): ReactNode {
|
||||||
if (this.state.hasError) {
|
if (this.state.hasError) {
|
||||||
// Return custom fallback if provided
|
// Return custom fallback if provided
|
||||||
if (this.props.fallback !== undefined) {
|
if (this.props.fallback !== undefined) {
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ export function useLevelRouting(): LevelRouting {
|
|||||||
|
|
||||||
const redirectToLevel = (targetLevel: number): void => {
|
const redirectToLevel = (targetLevel: number): void => {
|
||||||
const route = LEVEL_ROUTES[targetLevel] ?? LEVEL_ROUTES[0]
|
const route = LEVEL_ROUTES[targetLevel] ?? LEVEL_ROUTES[0]
|
||||||
router.push(route)
|
if (route !== undefined) {
|
||||||
|
router.push(route)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ export { useFileTree } from './useFileTree'
|
|||||||
export type { WorkflowRun } from './useGitHubFetcher'
|
export type { WorkflowRun } from './useGitHubFetcher'
|
||||||
export { useGitHubFetcher } from './useGitHubFetcher'
|
export { useGitHubFetcher } from './useGitHubFetcher'
|
||||||
export { useKV } from './useKV'
|
export { useKV } from './useKV'
|
||||||
export { useLevelRouting } from './useLevelRouting'
|
export { useLevelRouting } from './data/useLevelRouting'
|
||||||
export { useResolvedUser } from './useResolvedUser'
|
export { useResolvedUser } from './data/useResolvedUser'
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ export function useGitHubFetcher() {
|
|||||||
setError(null)
|
setError(null)
|
||||||
try {
|
try {
|
||||||
const { listWorkflowRuns } = await import('@/lib/github/workflows/listing/list-workflow-runs')
|
const { listWorkflowRuns } = await import('@/lib/github/workflows/listing/list-workflow-runs')
|
||||||
const workflowRuns = await listWorkflowRuns()
|
// TODO: Get owner/repo from environment or context
|
||||||
|
const workflowRuns = await listWorkflowRuns({ owner: 'owner', repo: 'repo' })
|
||||||
setRuns(workflowRuns)
|
setRuns(workflowRuns)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err as Error)
|
setError(err as Error)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
// Prisma client types are generated; when they resolve as error types in linting,
|
// Prisma client types are generated; when they resolve as error types in linting,
|
||||||
// these assignments/calls are safe for runtime but look unsafe to the linter.
|
// these assignments/calls are safe for runtime but look unsafe to the linter.
|
||||||
import { PrismaClient } from '@prisma/client'
|
import { PrismaClient } from '@prisma/client'
|
||||||
import { PrismaBetterSQLite3 } from '@prisma/adapter-better-sqlite3'
|
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3'
|
||||||
import Database from 'better-sqlite3'
|
import Database from 'better-sqlite3'
|
||||||
|
|
||||||
const globalForPrisma = globalThis as unknown as {
|
const globalForPrisma = globalThis as unknown as {
|
||||||
@@ -40,7 +40,7 @@ const createIntegrationPrisma = (): PrismaClient => {
|
|||||||
if (globalForPrisma.prismaTestDb === undefined) {
|
if (globalForPrisma.prismaTestDb === undefined) {
|
||||||
globalForPrisma.prismaTestDb = new Database(':memory:')
|
globalForPrisma.prismaTestDb = new Database(':memory:')
|
||||||
}
|
}
|
||||||
const adapter = new PrismaBetterSQLite3(globalForPrisma.prismaTestDb)
|
const adapter = new PrismaBetterSqlite3(globalForPrisma.prismaTestDb)
|
||||||
return new PrismaClient({ adapter })
|
return new PrismaClient({ adapter })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export async function getErrorLogs(options?: {
|
|||||||
|
|
||||||
const result = await adapter.list('ErrorLog', {
|
const result = await adapter.list('ErrorLog', {
|
||||||
filter: Object.keys(filter).length > 0 ? filter : undefined,
|
filter: Object.keys(filter).length > 0 ? filter : undefined,
|
||||||
orderBy: { timestamp: 'desc' },
|
orderBy: [{ timestamp: 'desc' }],
|
||||||
take: options?.limit,
|
take: options?.limit,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ describe('getErrorLogs', () => {
|
|||||||
expect(mockList).toHaveBeenCalledWith('ErrorLog', {
|
expect(mockList).toHaveBeenCalledWith('ErrorLog', {
|
||||||
filter: expectedFilter,
|
filter: expectedFilter,
|
||||||
orderBy: { timestamp: 'desc' },
|
orderBy: { timestamp: 'desc' },
|
||||||
take: options?.limit,
|
take: options?.limit ?? undefined,
|
||||||
})
|
})
|
||||||
expect(result).toHaveLength(dbData.length)
|
expect(result).toHaveLength(dbData.length)
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { prisma } from '@/lib/config/prisma'
|
|||||||
*/
|
*/
|
||||||
export const getComments = async (): Promise<Comment[]> => {
|
export const getComments = async (): Promise<Comment[]> => {
|
||||||
const comments = await prisma.comment.findMany()
|
const comments = await prisma.comment.findMany()
|
||||||
return comments.map(c => ({
|
return comments.map((c: Record<string, unknown>) => ({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
userId: c.userId,
|
userId: c.userId,
|
||||||
entityType: c.entityType,
|
entityType: c.entityType,
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ export function resolveGitHubRepo(params: URLSearchParams | string): GitHubRepo
|
|||||||
if (typeof params === 'string') {
|
if (typeof params === 'string') {
|
||||||
const [owner, repo] = params.split('/')
|
const [owner, repo] = params.split('/')
|
||||||
return {
|
return {
|
||||||
owner: owner !== '' ? owner : '',
|
owner: owner ?? '',
|
||||||
repo: repo !== undefined && repo !== '' ? repo : ''
|
repo: repo ?? ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ownerParam = params.get('owner')
|
const ownerParam = params.get('owner')
|
||||||
const repoParam = params.get('repo')
|
const repoParam = params.get('repo')
|
||||||
return {
|
return {
|
||||||
owner: ownerParam !== null && ownerParam !== '' ? ownerParam : '',
|
owner: ownerParam ?? '',
|
||||||
repo: repoParam !== null && repoParam !== '' ? repoParam : '',
|
repo: repoParam ?? '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,11 +258,11 @@ function evaluateSimpleExpression(expr: string, context: RenderContext): JsonVal
|
|||||||
// Handle ternary operator
|
// Handle ternary operator
|
||||||
if (part.includes('?')) {
|
if (part.includes('?')) {
|
||||||
const [condition, branches] = part.split('?')
|
const [condition, branches] = part.split('?')
|
||||||
if (condition.length === 0 || branches === undefined || branches.length === 0) {
|
if (condition === undefined || condition.length === 0 || branches === undefined || branches.length === 0) {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
const [trueBranch, falseBranch] = branches.split(':')
|
const [trueBranch, falseBranch] = branches.split(':')
|
||||||
if (trueBranch.length === 0 || falseBranch === undefined || falseBranch.length === 0) {
|
if (trueBranch === undefined || trueBranch.length === 0 || falseBranch === undefined || falseBranch.length === 0) {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
const conditionValue = evaluateSimpleExpression(condition.trim(), context)
|
const conditionValue = evaluateSimpleExpression(condition.trim(), context)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export async function loadPageFromDb(path: string, tenantId?: string): Promise<P
|
|||||||
description: page.description,
|
description: page.description,
|
||||||
icon: page.icon,
|
icon: page.icon,
|
||||||
component: page.component,
|
component: page.component,
|
||||||
componentTree: JSON.parse(page.componentTree),
|
componentTree: JSON.parse(String(page.componentTree)),
|
||||||
level: page.level,
|
level: page.level,
|
||||||
requiresAuth: page.requiresAuth,
|
requiresAuth: page.requiresAuth,
|
||||||
requiredRole: page.requiredRole,
|
requiredRole: page.requiredRole,
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ export const PackageSchemas = {
|
|||||||
installConfig: z.object({
|
installConfig: z.object({
|
||||||
packageId: z.string(),
|
packageId: z.string(),
|
||||||
enabled: z.boolean().default(true),
|
enabled: z.boolean().default(true),
|
||||||
config: z.record(z.unknown()).optional(),
|
config: z.record(z.string(), z.unknown()).optional(),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
datasource db {
|
datasource db {
|
||||||
provider = "sqlite"
|
provider = "sqlite"
|
||||||
url = env("DATABASE_URL")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
generator client {
|
generator client {
|
||||||
|
|||||||
@@ -19,14 +19,14 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@storybook/addon-essentials": "^8.6.15",
|
"@storybook/addon-essentials": "^8.6.15",
|
||||||
"@storybook/addon-interactions": "^8.6.15",
|
"@storybook/addon-interactions": "^8.6.15",
|
||||||
"@storybook/react": "^10.1.11",
|
"@storybook/react": "^8.6.15",
|
||||||
"@storybook/react-vite": "^10.1.11",
|
"@storybook/react-vite": "^8.6.15",
|
||||||
"@storybook/test": "^8.6.15",
|
"@storybook/test": "^8.6.15",
|
||||||
"@types/react": "^18.3.18",
|
"@types/react": "^18.3.18",
|
||||||
"@types/react-dom": "^18.3.5",
|
"@types/react-dom": "^18.3.5",
|
||||||
"@vitejs/plugin-react": "^5.1.2",
|
"@vitejs/plugin-react": "^5.1.2",
|
||||||
"sass": "^1.97.1",
|
"sass": "^1.97.1",
|
||||||
"storybook": "^10.1.11",
|
"storybook": "^8.6.15",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vite": "^7.3.0"
|
"vite": "^7.3.0"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user