Fix strict-boolean-expressions in routes, error logs, and god-credentials

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-06 16:17:42 +00:00
parent 0d2908c69e
commit 79bed9998d
5 changed files with 31 additions and 34 deletions

View File

@@ -36,9 +36,9 @@ export default async function EntityPage({ params }: EntityPageProps) {
if (id === 'new') {
viewType = 'create'
} else if (id && action === 'edit') {
} else if (id !== null && id !== undefined && action === 'edit') {
viewType = 'edit'
} else if (id) {
} else if (id !== null && id !== undefined) {
viewType = 'detail'
}
@@ -49,7 +49,7 @@ export default async function EntityPage({ params }: EntityPageProps) {
<a href={`/${tenant}/${pkg}`}>{pkg}</a>
{' / '}
<span>{entity}</span>
{id && id !== 'new' && (
{(id !== null && id !== undefined) && id !== 'new' && (
<>
{' / '}
<span>{id}</span>
@@ -69,12 +69,12 @@ export default async function EntityPage({ params }: EntityPageProps) {
/>
)}
{viewType === 'detail' && (
{viewType === 'detail' && id !== null && id !== undefined && (
<EntityDetailView
tenant={tenant}
pkg={pkg}
entity={entity}
id={id!}
id={id}
/>
)}
@@ -86,12 +86,12 @@ export default async function EntityPage({ params }: EntityPageProps) {
/>
)}
{viewType === 'edit' && (
{viewType === 'edit' && id !== null && id !== undefined && (
<EntityEditView
tenant={tenant}
pkg={pkg}
entity={entity}
id={id!}
id={id}
/>
)}
</main>
@@ -202,13 +202,13 @@ function EntityEditView({ tenant, pkg, entity, id }: {
export async function generateMetadata({ params }: EntityPageProps) {
const { tenant, package: pkg, slug } = await params
const entity = slug?.[0] || 'unknown'
const entity = slug?.[0] ?? 'unknown'
const id = slug?.[1]
let title = `${entity} - ${pkg}`
if (id === 'new') {
title = `New ${entity} - ${pkg}`
} else if (id) {
} else if (id !== null && id !== undefined) {
title = `${entity} #${id} - ${pkg}`
}

View File

@@ -84,10 +84,10 @@ export function TenantProvider({
getTableName: (entity: string) => getTableName(packageId, entity),
buildApiUrl: (entity: string, id?: string, action?: string, pkg?: string) => {
const targetPkg = pkg || packageId
const targetPkg = pkg ?? packageId
let url = `/api/v1/${tenant}/${targetPkg}/${entity}`
if (id) url += `/${id}`
if (action) url += `/${action}`
if (id !== null && id !== undefined) url += `/${id}`
if (action !== null && action !== undefined) url += `/${action}`
return url
},
@@ -110,7 +110,7 @@ export function TenantProvider({
export function useTenant(): TenantContextValue {
const context = useContext(TenantContext)
if (!context) {
if (context === null || context === undefined) {
throw new Error('useTenant must be used within a TenantProvider')
}

View File

@@ -23,7 +23,7 @@ const getPrismaOutputPath = () => path.join(process.cwd(), '..', '..', '..', 'pr
* Note: This endpoint is for admin/system use.
* For tenant-scoped data, use /api/v1/{tenant}/{package}/{entity}
*/
export async function GET() {
export function GET() {
try {
const registryPath = getRegistryPath()
const registry = loadSchemaRegistry(registryPath)
@@ -92,7 +92,7 @@ export async function POST(request: Request) {
}
}
async function handleScan(registry: SchemaRegistry, registryPath: string) {
function handleScan(registry: SchemaRegistry, registryPath: string) {
// TODO: Import scanAllPackages when schema-scanner is implemented
// const { scanAllPackages } = await import('@/lib/schema/schema-scanner')
// const result = await scanAllPackages(registry)
@@ -113,7 +113,7 @@ function handleGenerate(registry: SchemaRegistry) {
const fragment = generatePrismaFragment(registry)
const prismaOutputPath = getPrismaOutputPath()
if (!fragment.trim()) {
if (fragment.trim().length === 0) {
return NextResponse.json({
status: 'ok',
action: 'generate',
@@ -135,7 +135,7 @@ function handleGenerate(registry: SchemaRegistry) {
}
function handleApprove(registry: SchemaRegistry, registryPath: string, id?: string) {
if (!id) {
if (id === null || id === undefined) {
return NextResponse.json(
{ status: 'error', error: 'Migration ID required' },
{ status: 400 }

View File

@@ -13,15 +13,15 @@ export async function addErrorLog(log: Omit<ErrorLog, 'id'>): Promise<string> {
timestamp: BigInt(log.timestamp),
level: log.level,
message: log.message,
stack: log.stack || null,
context: log.context || null,
userId: log.userId || null,
username: log.username || null,
tenantId: log.tenantId || null,
source: log.source || null,
stack: log.stack ?? null,
context: log.context ?? null,
userId: log.userId ?? null,
username: log.username ?? null,
tenantId: log.tenantId ?? null,
source: log.source ?? null,
resolved: log.resolved,
resolvedAt: log.resolvedAt ? BigInt(log.resolvedAt) : null,
resolvedBy: log.resolvedBy || null,
resolvedAt: log.resolvedAt !== null && log.resolvedAt !== undefined ? BigInt(log.resolvedAt) : null,
resolvedBy: log.resolvedBy ?? null,
})
return id

View File

@@ -6,9 +6,8 @@ import { getAdapter } from '../core/dbal-client'
export async function getGodCredentialsExpiry(): Promise<number> {
const adapter = getAdapter()
const result = await adapter.list('SystemConfig')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const config = (result.data as any[]).find((c: any) => c.key === 'godCredentialsExpiry')
return config?.value ? Number(config.value) : 0
const config = (result.data as Array<{ key: string; value?: string }>).find((c) => c.key === 'godCredentialsExpiry')
return (config?.value !== null && config?.value !== undefined) ? Number(config.value) : 0
}
/**
@@ -31,11 +30,10 @@ export async function setGodCredentialsExpiry(timestamp: number): Promise<void>
export async function getFirstLoginFlags(): Promise<Record<string, boolean>> {
const adapter = getAdapter()
const result = await adapter.list('User')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const users = result.data as any[]
const users = result.data as Array<{ id?: string; firstLogin?: boolean }>
const flags: Record<string, boolean> = {}
for (const user of users) {
if (user.id && user.firstLogin !== undefined) {
if (user.id !== null && user.id !== undefined && user.firstLogin !== undefined) {
flags[user.id] = Boolean(user.firstLogin)
}
}
@@ -56,9 +54,8 @@ export async function setFirstLoginFlag(userId: string, flag: boolean): Promise<
export async function getGodCredentialsExpiryDuration(): Promise<number> {
const adapter = getAdapter()
const result = await adapter.list('SystemConfig')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const config = (result.data as any[]).find((c: any) => c.key === 'godCredentialsExpiryDuration')
return config?.value ? Number(config.value) : 300000 // Default 5 minutes
const config = (result.data as Array<{ key: string; value?: string }>).find((c) => c.key === 'godCredentialsExpiryDuration')
return (config?.value !== null && config?.value !== undefined) ? Number(config.value) : 300000 // Default 5 minutes
}
/**