Phase 2: Fix strict boolean expression errors in database and app files

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-06 16:57:56 +00:00
parent 524360db5f
commit 1b0439d132
15 changed files with 24 additions and 24 deletions

View File

@@ -67,11 +67,11 @@ async function handleRequest(
const tenantResult = await validateTenantAccess(
user,
route.tenant,
packageResult.package?.minLevel || 1
packageResult.package?.minLevel ?? 1
)
if (!tenantResult.allowed) {
const status = !user ? STATUS.UNAUTHORIZED : STATUS.FORBIDDEN
return errorResponse(tenantResult.reason || 'Access denied', status)
if (tenantResult.allowed === false) {
const status = user === null ? STATUS.UNAUTHORIZED : STATUS.FORBIDDEN
return errorResponse(tenantResult.reason ?? 'Access denied', status)
}
// 5. Execute the DBAL operation

View File

@@ -4,7 +4,7 @@ import { ThemeContext } from './theme-context'
export function useTheme() {
const context = useContext(ThemeContext)
if (!context) {
if (context === null || context === undefined) {
throw new Error('useTheme must be used within Providers')
}
return context

View File

@@ -24,7 +24,7 @@ interface PageProps {
*/
export default async function DynamicUIPage({ params }: PageProps) {
const resolvedParams = await params
const slug = resolvedParams.slug || []
const slug = resolvedParams.slug ?? []
const path = '/' + slug.join('/')
// Prefer Lua package-based UI pages, fallback to database-backed pages
@@ -51,7 +51,7 @@ export default async function DynamicUIPage({ params }: PageProps) {
*/
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
const resolvedParams = await params
const slug = resolvedParams.slug || []
const slug = resolvedParams.slug ?? []
const path = '/' + slug.join('/')
const pageData = (await loadPageFromLuaPackages(path)) ?? (await loadPageFromDb(path))

View File

@@ -51,5 +51,5 @@ const iconMap: Record<string, ComponentType<IconProps>> = {
export function getComponentIcon(iconName: string, props?: IconProps): ReactElement | null {
const Icon = iconMap[iconName]
return Icon ? <Icon {...props} /> : null
return Icon !== null && Icon !== undefined ? <Icon {...props} /> : null
}

View File

@@ -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>
)

View File

@@ -42,7 +42,7 @@ export const authenticateUser = async (
where: { username },
})
if (!userRecord) {
if (userRecord === null || userRecord === undefined) {
return { success: false, user: null, error: 'user_not_found' }
}

View File

@@ -15,11 +15,11 @@ export const getUserByEmail = async (
const record = await adapter.findFirst('User', {
where: {
email,
...(options?.tenantId ? { tenantId: options.tenantId } : {}),
...(options?.tenantId !== null && options?.tenantId !== undefined ? { tenantId: options.tenantId } : {}),
},
})
if (!record) {
if (record === null || record === undefined) {
return null
}

View File

@@ -15,11 +15,11 @@ export const getUserByUsername = async (
const record = await adapter.findFirst('User', {
where: {
username,
...(options?.tenantId ? { tenantId: options.tenantId } : {}),
...(options?.tenantId !== null && options?.tenantId !== undefined ? { tenantId: options.tenantId } : {}),
},
})
if (!record) {
if (record === null || record === undefined) {
return null
}

View File

@@ -11,7 +11,7 @@ export async function addComment(comment: Comment): Promise<void> {
userId: comment.userId,
content: comment.content,
createdAt: BigInt(comment.createdAt),
updatedAt: comment.updatedAt ? BigInt(comment.updatedAt) : null,
parentId: comment.parentId,
updatedAt: comment.updatedAt !== null && comment.updatedAt !== undefined ? BigInt(comment.updatedAt) : null,
parentId: comment.parentId ?? null,
})
}

View File

@@ -25,7 +25,7 @@ export async function getComments(): Promise<Comment[]> {
entityId: c.entityId,
content: c.content,
createdAt: Number(c.createdAt),
updatedAt: c.updatedAt ? Number(c.updatedAt) : undefined,
parentId: c.parentId || undefined,
updatedAt: (c.updatedAt !== null && c.updatedAt !== undefined) ? Number(c.updatedAt) : undefined,
parentId: (c.parentId !== null && c.parentId !== undefined) ? c.parentId : undefined,
}))
}

View File

@@ -24,8 +24,8 @@ export async function setComments(comments: Comment[]): Promise<void> {
userId: comment.userId,
content: comment.content,
createdAt: BigInt(comment.createdAt),
updatedAt: comment.updatedAt ? BigInt(comment.updatedAt) : null,
parentId: comment.parentId,
updatedAt: comment.updatedAt !== null && comment.updatedAt !== undefined ? BigInt(comment.updatedAt) : null,
parentId: comment.parentId ?? null,
})
}
}

View File

@@ -9,7 +9,7 @@ export async function addComponentConfig(config: ComponentConfig): Promise<void>
props: JSON.stringify(config.props),
styles: JSON.stringify(config.styles),
events: JSON.stringify(config.events),
conditionalRendering: config.conditionalRendering
conditionalRendering: config.conditionalRendering !== null && config.conditionalRendering !== undefined
? JSON.stringify(config.conditionalRendering)
: null,
})

View File

@@ -12,7 +12,7 @@ export async function updateComponentConfig(
if (updates.styles !== undefined) data.styles = JSON.stringify(updates.styles)
if (updates.events !== undefined) data.events = JSON.stringify(updates.events)
if (updates.conditionalRendering !== undefined) {
data.conditionalRendering = updates.conditionalRendering
data.conditionalRendering = updates.conditionalRendering !== null && updates.conditionalRendering !== undefined
? JSON.stringify(updates.conditionalRendering)
: null
}

View File

@@ -22,7 +22,7 @@ export async function setComponentConfigs(configs: Record<string, ComponentConfi
props: JSON.stringify(config.props),
styles: JSON.stringify(config.styles),
events: JSON.stringify(config.events),
conditionalRendering: config.conditionalRendering
conditionalRendering: config.conditionalRendering !== null && config.conditionalRendering !== undefined
? JSON.stringify(config.conditionalRendering)
: null,
})

View File

@@ -18,7 +18,7 @@ export async function getComponentHierarchy(): Promise<Record<string, ComponentN
hierarchy[node.id] = {
id: node.id,
type: node.type,
parentId: node.parentId || undefined,
parentId: node.parentId !== null && node.parentId !== undefined ? node.parentId : undefined,
childIds: JSON.parse(node.childIds),
order: node.order,
pageId: node.pageId,