mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
Fix additional TypeScript strict mode errors in src directory
- Add non-null assertions for array access after length checks - Fix middleware to check for undefined before setting headers - Add type assertions for DBAL result data mapping - Fix entity page to validate all params before use - Provide default empty object for optional action handlers - Down to 19 errors in src directory (from ~26) Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -23,11 +23,11 @@ interface EntityPageProps {
|
||||
export default async function EntityPage({ params }: EntityPageProps) {
|
||||
const { tenant, package: pkg, slug } = await params
|
||||
|
||||
if (!slug || slug.length === 0) {
|
||||
if (!tenant || !pkg || !slug || slug.length === 0) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const entity = slug[0]
|
||||
const entity = slug[0]! // Safe: checked slug.length > 0
|
||||
const id = slug[1]
|
||||
const action = slug[2]
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export default async function RootPage() {
|
||||
}> }
|
||||
|
||||
if (godPanelRoutes.data.length > 0) {
|
||||
const route = godPanelRoutes.data[0]
|
||||
const route = godPanelRoutes.data[0]! // Safe: length check ensures element exists
|
||||
|
||||
// TODO: Implement proper session/user context for permission checks
|
||||
// For now, we'll allow access to public routes and skip auth checks
|
||||
|
||||
@@ -23,7 +23,7 @@ export function UIPageRenderer({ pageData }: UIPageRendererProps) {
|
||||
|
||||
// Provide action handlers via context
|
||||
return (
|
||||
<UIPageActionsContext.Provider value={pageData.actions}>
|
||||
<UIPageActionsContext.Provider value={pageData.actions || {}}>
|
||||
{elements}
|
||||
</UIPageActionsContext.Provider>
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@ export async function deleteSessionByToken(token: string): Promise<boolean> {
|
||||
data: DBALSessionRecord[]
|
||||
}
|
||||
if (!result.data.length) return false
|
||||
const session = result.data[0]
|
||||
const session = result.data[0]! // Safe: checked length > 0
|
||||
await adapter.delete('Session', session.id)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ export async function listSessions(options?: ListSessionsOptions): Promise<Sessi
|
||||
? await adapter.list('Session', { filter: { userId: options.userId } })
|
||||
: await adapter.list('Session')
|
||||
|
||||
const sessions = result.data.map(mapSessionRecord)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const sessions = (result.data as any[]).map(mapSessionRecord)
|
||||
|
||||
if (options?.includeExpired) {
|
||||
return sessions
|
||||
|
||||
@@ -4,5 +4,6 @@ import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dba
|
||||
export async function blobList(this: any, prefix?: string): Promise<string[]> {
|
||||
if (!this.blobStorage) throw new Error('DBAL not initialized')
|
||||
const result = await this.blobStorage.list({ prefix })
|
||||
return result.items.map(item => item.key)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return result.items.map((item: any) => item.key)
|
||||
}
|
||||
|
||||
@@ -28,8 +28,12 @@ export function middleware(request: NextRequest) {
|
||||
|
||||
// Add tenant info to headers for downstream use
|
||||
const response = NextResponse.next()
|
||||
response.headers.set('x-tenant-id', tenant)
|
||||
response.headers.set('x-package-id', pkg)
|
||||
if (tenant) {
|
||||
response.headers.set('x-tenant-id', tenant)
|
||||
}
|
||||
if (pkg) {
|
||||
response.headers.set('x-package-id', pkg)
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user