From 1045d55efaadb0353646f3ccc2bfebddee2d5bfd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 6 Jan 2026 15:34:38 +0000 Subject: [PATCH] Fix critical TypeScript errors and 157 linting issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Generate Prisma client types (fixed all TS compilation errors) - Remove unnecessary async keywords from stub functions - Fix strict boolean expression errors in 15+ files - Replace logical OR with nullish coalescing operators - Remove non-null assertions - Fix implicit any types - Progress: 866 → 709 linting errors (157 fixed) Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- .../[packageId]/handlers/put-package-data.ts | 2 +- .../ui-page-renderer/UIPageRenderer.tsx | 2 +- frontends/nextjs/src/hooks/useDBAL.ts | 2 +- .../src/lib/github/fetch-workflow-run-logs.ts | 2 +- .../config/get-package-repo-config.ts | 4 ++-- .../config/validate-package-repo-config.ts | 6 ++--- .../functions/check-dependencies.ts | 4 ++-- .../packages/unified/get-package-metadata.ts | 2 +- .../src/lib/packages/unified/load-package.ts | 2 +- .../declarative-component-renderer.ts | 20 ++++++++--------- .../routing/auth/validate-package-route.ts | 8 +++---- frontends/nextjs/src/lib/routing/index.ts | 20 ++++++++--------- .../nextjs/src/lib/routing/route-parser.ts | 5 +++-- .../nextjs/src/lib/schema/schema-registry.ts | 22 +++++++++++-------- frontends/nextjs/src/lib/seed/index.ts | 2 +- .../src/lib/ui-pages/load-page-from-db.ts | 2 +- .../ui-pages/load-page-from-lua-packages.ts | 2 +- frontends/nextjs/src/middleware.ts | 6 ++--- .../src/tests/package-integration.test.ts | 2 +- frontends/nextjs/src/theme/components.ts | 2 +- frontends/nextjs/src/theme/index.ts | 6 ++--- .../nextjs/src/types/monaco-editor-react.d.ts | 2 +- 22 files changed, 65 insertions(+), 60 deletions(-) diff --git a/frontends/nextjs/src/app/api/packages/data/[packageId]/handlers/put-package-data.ts b/frontends/nextjs/src/app/api/packages/data/[packageId]/handlers/put-package-data.ts index 6ac65a576..00969862d 100644 --- a/frontends/nextjs/src/app/api/packages/data/[packageId]/handlers/put-package-data.ts +++ b/frontends/nextjs/src/app/api/packages/data/[packageId]/handlers/put-package-data.ts @@ -18,7 +18,7 @@ interface RouteParams { export async function PUT(request: NextRequest, { params }: RouteParams) { try { const body = await readJson(request) - if (!body || !body.data || Array.isArray(body.data)) { + if (!body?.data || Array.isArray(body.data)) { return NextResponse.json({ error: 'Package data is required' }, { status: 400 }) } diff --git a/frontends/nextjs/src/components/ui-page-renderer/UIPageRenderer.tsx b/frontends/nextjs/src/components/ui-page-renderer/UIPageRenderer.tsx index 29d3ed9ec..bc7e376a6 100644 --- a/frontends/nextjs/src/components/ui-page-renderer/UIPageRenderer.tsx +++ b/frontends/nextjs/src/components/ui-page-renderer/UIPageRenderer.tsx @@ -16,7 +16,7 @@ interface UIPageRendererProps { */ export function UIPageRenderer({ pageData }: UIPageRendererProps) { // Convert JSON layout to LuaUIComponent structure - const layout = pageData.layout as unknown as LuaUIComponent + const layout = pageData.layout as LuaUIComponent // Create React elements from component tree const elements = generateComponentTree(layout) diff --git a/frontends/nextjs/src/hooks/useDBAL.ts b/frontends/nextjs/src/hooks/useDBAL.ts index c30e82bda..a7800e656 100644 --- a/frontends/nextjs/src/hooks/useDBAL.ts +++ b/frontends/nextjs/src/hooks/useDBAL.ts @@ -61,7 +61,7 @@ export function useDBAL() { }, list: async (entity: string, params?: Record) => { const queryString = params ? `?${new URLSearchParams(params as Record).toString()}` : '' - return request('GET', `${entity}${queryString}`) as Promise + return request('GET', `${entity}${queryString}`) }, create: async (entity: string, data: unknown) => { return request('POST', entity, data) diff --git a/frontends/nextjs/src/lib/github/fetch-workflow-run-logs.ts b/frontends/nextjs/src/lib/github/fetch-workflow-run-logs.ts index 5c1261638..bfd20cd35 100644 --- a/frontends/nextjs/src/lib/github/fetch-workflow-run-logs.ts +++ b/frontends/nextjs/src/lib/github/fetch-workflow-run-logs.ts @@ -95,7 +95,7 @@ export async function fetchWorkflowRunLogs( })) let logsText = '' - let truncated = false + const truncated = false if (includeLogs) { // Download logs for the workflow run diff --git a/frontends/nextjs/src/lib/packages/package-glue/config/get-package-repo-config.ts b/frontends/nextjs/src/lib/packages/package-glue/config/get-package-repo-config.ts index 57d6467bf..13687ccd4 100644 --- a/frontends/nextjs/src/lib/packages/package-glue/config/get-package-repo-config.ts +++ b/frontends/nextjs/src/lib/packages/package-glue/config/get-package-repo-config.ts @@ -4,7 +4,7 @@ import { DEVELOPMENT_PACKAGE_REPO_CONFIG } from './development-config' import { PRODUCTION_PACKAGE_REPO_CONFIG } from './production-config' export function getPackageRepoConfig(): PackageRepoConfig { - const env = process.env.NODE_ENV || 'development' + const env = process.env.NODE_ENV?.length !== undefined && process.env.NODE_ENV.length > 0 ? process.env.NODE_ENV : 'development' const enableRemote = process.env.NEXT_PUBLIC_ENABLE_REMOTE_PACKAGES === 'true' let config: PackageRepoConfig @@ -28,7 +28,7 @@ export function getPackageRepoConfig(): PackageRepoConfig { } const authToken = process.env.PACKAGE_REGISTRY_AUTH_TOKEN - if (authToken) { + if (authToken !== undefined && authToken.length > 0) { config.sources = config.sources.map((source) => ({ ...source, authToken: source.type === 'remote' ? authToken : undefined, diff --git a/frontends/nextjs/src/lib/packages/package-glue/config/validate-package-repo-config.ts b/frontends/nextjs/src/lib/packages/package-glue/config/validate-package-repo-config.ts index 684d88e93..eb0f5ccce 100644 --- a/frontends/nextjs/src/lib/packages/package-glue/config/validate-package-repo-config.ts +++ b/frontends/nextjs/src/lib/packages/package-glue/config/validate-package-repo-config.ts @@ -3,13 +3,13 @@ import type { PackageRepoConfig } from './types' export function validatePackageRepoConfig(config: PackageRepoConfig): string[] { const errors: string[] = [] - if (!config.sources || config.sources.length === 0) { + if (config.sources.length === 0) { errors.push('At least one package source is required') } const ids = new Set() for (const source of config.sources) { - if (!source.id) { + if (source.id.length === 0) { errors.push('Source ID is required') } if (ids.has(source.id)) { @@ -17,7 +17,7 @@ export function validatePackageRepoConfig(config: PackageRepoConfig): string[] { } ids.add(source.id) - if (!source.url) { + if (source.url.length === 0) { errors.push(`Source ${source.id}: URL is required`) } diff --git a/frontends/nextjs/src/lib/packages/package-glue/functions/check-dependencies.ts b/frontends/nextjs/src/lib/packages/package-glue/functions/check-dependencies.ts index 275e458ba..0e0af6487 100644 --- a/frontends/nextjs/src/lib/packages/package-glue/functions/check-dependencies.ts +++ b/frontends/nextjs/src/lib/packages/package-glue/functions/check-dependencies.ts @@ -10,7 +10,7 @@ export function checkDependencies( packageId: string ): DependencyCheckResult { const pkg = registry[packageId] - if (!pkg) return { satisfied: false, missing: [packageId] } - const missing = (pkg.dependencies ?? []).filter((dep) => !registry[dep]) + if (pkg === null || pkg === undefined) return { satisfied: false, missing: [packageId] } + const missing = (pkg.dependencies ?? []).filter((dep) => registry[dep] === null || registry[dep] === undefined) return { satisfied: missing.length === 0, missing } } diff --git a/frontends/nextjs/src/lib/packages/unified/get-package-metadata.ts b/frontends/nextjs/src/lib/packages/unified/get-package-metadata.ts index 7ee49298d..bb76a383a 100644 --- a/frontends/nextjs/src/lib/packages/unified/get-package-metadata.ts +++ b/frontends/nextjs/src/lib/packages/unified/get-package-metadata.ts @@ -4,7 +4,7 @@ export async function getPackageMetadata( packageId: string ): Promise<{ name: string; description: string; version: string } | null> { const pkg = await loadPackage(packageId) - if (!pkg) return null + if (pkg === null) return null return { name: pkg.name, diff --git a/frontends/nextjs/src/lib/packages/unified/load-package.ts b/frontends/nextjs/src/lib/packages/unified/load-package.ts index ad2b3a189..a77385181 100644 --- a/frontends/nextjs/src/lib/packages/unified/load-package.ts +++ b/frontends/nextjs/src/lib/packages/unified/load-package.ts @@ -24,7 +24,7 @@ export async function loadPackage(packageId: string): Promise> = * and a `components` array (or object) with component definitions. */ export function loadPackageComponents(packageContent: JsonValue): void { - if (!packageContent || typeof packageContent !== 'object') return + if (packageContent === null || packageContent === undefined || typeof packageContent !== 'object') return const pkg = packageContent as JsonObject const metadata = pkg?.metadata const packageId = - (metadata && typeof metadata === 'object' && !Array.isArray(metadata) + (metadata !== null && metadata !== undefined && typeof metadata === 'object' && !Array.isArray(metadata) ? (metadata as JsonObject)['packageId'] - : undefined) || - pkg?.['package'] || + : undefined) ?? + pkg?.['package'] ?? pkg?.['packageId'] - if (!packageId || typeof packageId !== 'string') return + if (packageId === null || packageId === undefined || typeof packageId !== 'string') return const compsArray: JsonValue[] = - Array.isArray(pkg.components) && pkg.components.length + Array.isArray(pkg.components) && pkg.components.length > 0 ? pkg.components : Array.isArray((pkg.ui as JsonObject)?.components) ? ((pkg.ui as JsonObject).components as JsonValue[]) @@ -41,20 +41,20 @@ export function loadPackageComponents(packageContent: JsonValue): void { const compMap: Record = {} for (const c of compsArray) { - if (!c || typeof c !== 'object' || Array.isArray(c)) continue + if (c === null || c === undefined || typeof c !== 'object' || Array.isArray(c)) continue const comp = c as JsonObject - if (!comp.id || typeof comp.id !== 'string') continue + if (comp.id === null || comp.id === undefined || typeof comp.id !== 'string') continue compMap[comp.id] = comp } PACKAGE_COMPONENT_REGISTRY[packageId] = { - ...(PACKAGE_COMPONENT_REGISTRY[packageId] || {}), + ...(PACKAGE_COMPONENT_REGISTRY[packageId] ?? {}), ...compMap, } } export function getRegisteredComponent(packageId: string, componentId: string): ComponentDef | null { - return PACKAGE_COMPONENT_REGISTRY[packageId]?.[componentId] || null + return PACKAGE_COMPONENT_REGISTRY[packageId]?.[componentId] ?? null } export function listRegisteredPackages(): string[] { diff --git a/frontends/nextjs/src/lib/routing/auth/validate-package-route.ts b/frontends/nextjs/src/lib/routing/auth/validate-package-route.ts index 494f66718..635dfdd03 100644 --- a/frontends/nextjs/src/lib/routing/auth/validate-package-route.ts +++ b/frontends/nextjs/src/lib/routing/auth/validate-package-route.ts @@ -12,21 +12,21 @@ export interface RouteValidationResult { } } -export async function validatePackageRoute( +export function validatePackageRoute( _b_package: string, _b_entity: string, _userId?: unknown -): Promise { +): RouteValidationResult { // TODO: Implement route validation return { allowed: true } } -export async function canBePrimaryPackage(_b_packageId: string): Promise { +export function canBePrimaryPackage(_b_packageId: string): boolean { // TODO: Implement primary package check return true } -export async function loadPackageMetadata(_b_packageId: string): Promise { +export function loadPackageMetadata(_b_packageId: string): unknown { // TODO: Implement package metadata loading return null } diff --git a/frontends/nextjs/src/lib/routing/index.ts b/frontends/nextjs/src/lib/routing/index.ts index 28a492086..d3cef4aa2 100644 --- a/frontends/nextjs/src/lib/routing/index.ts +++ b/frontends/nextjs/src/lib/routing/index.ts @@ -34,10 +34,10 @@ export function errorResponse(message: string, status = STATUS.ERROR) { } export interface SessionUser { - user: unknown | null + user: Record | null } -export async function getSessionUser(_req?: Request): Promise { +export function getSessionUser(_req?: Request): SessionUser { // TODO: Implement session user retrieval return { user: null } } @@ -54,29 +54,29 @@ export interface RestfulContext { dbalOp: unknown } -export async function parseRestfulRequest( +export function parseRestfulRequest( _req: Request, _params: { slug: string[] } -): Promise { +): RestfulContext | { error: string; status: number } { // TODO: Implement RESTful request parsing return { error: 'Not implemented', status: 500 } } -export async function executeDbalOperation( +export function executeDbalOperation( _op: unknown, _context?: unknown -): Promise<{ success: boolean; data?: unknown; error?: string; meta?: unknown }> { +): { success: boolean; data?: unknown; error?: string; meta?: unknown } { // TODO: Implement DBAL operation execution return { success: false, error: 'Not implemented' } } -export async function executePackageAction( +export function executePackageAction( _packageId: unknown, _entity: unknown, _action: unknown, _id: unknown, _context?: unknown -): Promise<{ success: boolean; data?: unknown; error?: string }> { +): { success: boolean; data?: unknown; error?: string } { // TODO: Implement package action execution return { success: false, error: 'Not implemented' } } @@ -87,11 +87,11 @@ export interface TenantValidationResult { tenant?: unknown } -export async function validateTenantAccess( +export function validateTenantAccess( _user: unknown, _tenant: unknown, _minLevel: unknown -): Promise { +): TenantValidationResult { // TODO: Implement tenant access validation return { allowed: false, reason: 'Not implemented' } } diff --git a/frontends/nextjs/src/lib/routing/route-parser.ts b/frontends/nextjs/src/lib/routing/route-parser.ts index 352146d5e..524d2cc2f 100644 --- a/frontends/nextjs/src/lib/routing/route-parser.ts +++ b/frontends/nextjs/src/lib/routing/route-parser.ts @@ -18,7 +18,7 @@ export function parseRoute(_b_url: string): ParsedRoute { export function getPrefixedEntity(entity: string, prefix?: string): string { // TODO: Implement entity prefixing - return prefix ? `${prefix}_${entity}` : entity + return prefix !== undefined && prefix.length > 0 ? `${prefix}_${entity}` : entity } export function getTableName(entity: string, _tenantId?: string): string { @@ -28,5 +28,6 @@ export function getTableName(entity: string, _tenantId?: string): string { export function isReservedPath(b_path: string): boolean { // TODO: Implement reserved path checking - return RESERVED_PATHS.includes(b_path.split('/')[1] || b_path) + const segment = b_path.split('/')[1] + return RESERVED_PATHS.includes(segment ?? b_path) } diff --git a/frontends/nextjs/src/lib/schema/schema-registry.ts b/frontends/nextjs/src/lib/schema/schema-registry.ts index e83252036..d0948c6aa 100644 --- a/frontends/nextjs/src/lib/schema/schema-registry.ts +++ b/frontends/nextjs/src/lib/schema/schema-registry.ts @@ -26,7 +26,7 @@ export class SchemaRegistry { export const schemaRegistry = new SchemaRegistry() export function loadSchemaRegistry(path?: string): SchemaRegistry { - const schemaPath = path || join(process.cwd(), 'schemas', 'registry.json') + const schemaPath = path ?? join(process.cwd(), 'schemas', 'registry.json') if (!existsSync(schemaPath)) { return schemaRegistry @@ -34,14 +34,18 @@ export function loadSchemaRegistry(path?: string): SchemaRegistry { try { const data = readFileSync(schemaPath, 'utf-8') - const { schemas, packages } = JSON.parse(data) + const parsed: unknown = JSON.parse(data) - if (Array.isArray(schemas)) { - schemas.forEach((schema: ModelSchema) => schemaRegistry.register(schema)) - } - - if (packages) { - schemaRegistry.packages = packages + if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) { + const { schemas, packages } = parsed as { schemas?: unknown; packages?: unknown } + + if (Array.isArray(schemas)) { + schemas.forEach((schema: ModelSchema) => schemaRegistry.register(schema)) + } + + if (packages !== null && packages !== undefined && typeof packages === 'object') { + schemaRegistry.packages = packages as Record + } } } catch (error) { console.warn(`Failed to load schema registry from ${schemaPath}:`, error instanceof Error ? error.message : String(error)) @@ -51,7 +55,7 @@ export function loadSchemaRegistry(path?: string): SchemaRegistry { } export function saveSchemaRegistry(registry: SchemaRegistry, path?: string): void { - const schemaPath = path || join(process.cwd(), 'schemas', 'registry.json') + const schemaPath = path ?? join(process.cwd(), 'schemas', 'registry.json') try { const data = { diff --git a/frontends/nextjs/src/lib/seed/index.ts b/frontends/nextjs/src/lib/seed/index.ts index ecb42d947..02045b34a 100644 --- a/frontends/nextjs/src/lib/seed/index.ts +++ b/frontends/nextjs/src/lib/seed/index.ts @@ -5,6 +5,6 @@ // Export seed functionality from database-admin // This is a placeholder - actual implementation in db/database-admin -export const seedDefaultData = async () => { +export const seedDefaultData = () => { console.warn('seedDefaultData: Not yet implemented') } diff --git a/frontends/nextjs/src/lib/ui-pages/load-page-from-db.ts b/frontends/nextjs/src/lib/ui-pages/load-page-from-db.ts index c31b97488..4b82af5fb 100644 --- a/frontends/nextjs/src/lib/ui-pages/load-page-from-db.ts +++ b/frontends/nextjs/src/lib/ui-pages/load-page-from-db.ts @@ -11,7 +11,7 @@ export interface UIPageData { actions?: Record } -export async function loadPageFromDb(_path: string, _tenantId?: string): Promise { +export function loadPageFromDb(_path: string, _tenantId?: string): PageConfig | null { // TODO: Implement page loading from database return null } diff --git a/frontends/nextjs/src/lib/ui-pages/load-page-from-lua-packages.ts b/frontends/nextjs/src/lib/ui-pages/load-page-from-lua-packages.ts index 61d7a5345..79a67cfa4 100644 --- a/frontends/nextjs/src/lib/ui-pages/load-page-from-lua-packages.ts +++ b/frontends/nextjs/src/lib/ui-pages/load-page-from-lua-packages.ts @@ -4,7 +4,7 @@ import type { PageConfig } from '../types/level-types' -export async function loadPageFromLuaPackages(_b_path: string): Promise { +export function loadPageFromLuaPackages(_b_path: string): PageConfig | null { // TODO: Implement page loading from Lua packages return null } diff --git a/frontends/nextjs/src/middleware.ts b/frontends/nextjs/src/middleware.ts index 4b2e741d9..531071069 100644 --- a/frontends/nextjs/src/middleware.ts +++ b/frontends/nextjs/src/middleware.ts @@ -14,7 +14,7 @@ export function middleware(request: NextRequest) { // Skip reserved paths const firstSegment = pathname.split('/')[1] - if (!firstSegment || isReservedPath(firstSegment)) { + if (firstSegment === undefined || firstSegment.length === 0 || isReservedPath(firstSegment)) { return NextResponse.next() } @@ -28,10 +28,10 @@ export function middleware(request: NextRequest) { // Add tenant info to headers for downstream use const response = NextResponse.next() - if (tenant) { + if (tenant !== undefined && tenant.length > 0) { response.headers.set('x-tenant-id', tenant) } - if (pkg) { + if (pkg !== undefined && pkg.length > 0) { response.headers.set('x-package-id', pkg) } diff --git a/frontends/nextjs/src/tests/package-integration.test.ts b/frontends/nextjs/src/tests/package-integration.test.ts index 8e7047824..550c7e885 100644 --- a/frontends/nextjs/src/tests/package-integration.test.ts +++ b/frontends/nextjs/src/tests/package-integration.test.ts @@ -70,7 +70,7 @@ describe('Package System Integration', () => { visited.add(pkgId) const pkg = packages.find(p => p.packageId === pkgId) - if (!pkg) return visited + if (pkg === null || pkg === undefined) return visited pkg.dependencies.forEach((depId: string) => { getDependencies(depId, new Set(visited)) diff --git a/frontends/nextjs/src/theme/components.ts b/frontends/nextjs/src/theme/components.ts index f28fc6a5a..da734ca46 100644 --- a/frontends/nextjs/src/theme/components.ts +++ b/frontends/nextjs/src/theme/components.ts @@ -17,7 +17,7 @@ const alpha = (color: string, opacity: number): string => { // Handle rgb/rgba colors if (color.startsWith('rgb')) { const match = color.match(/\d+/g) - if (match && match.length >= 3) { + if (match !== null && match.length >= 3) { return `rgba(${match[0]}, ${match[1]}, ${match[2]}, ${opacity})` } } diff --git a/frontends/nextjs/src/theme/index.ts b/frontends/nextjs/src/theme/index.ts index 7432f6c03..30bf29102 100644 --- a/frontends/nextjs/src/theme/index.ts +++ b/frontends/nextjs/src/theme/index.ts @@ -25,9 +25,9 @@ export type ThemeVars = Record */ export const applyTheme = ( theme: Record, - element: HTMLElement = typeof document !== 'undefined' ? document.documentElement : null! + element: HTMLElement | null = typeof document !== 'undefined' ? document.documentElement : null ): void => { - if (!element) return + if (element === null) return Object.entries(theme).forEach(([key, value]) => { element.style.setProperty(key, value) }) @@ -57,7 +57,7 @@ export const themeToCSS = ( */ export const cssVar = (varName: string, fallback?: string): string => { const name = varName.startsWith('--') ? varName : `--${varName}` - return fallback ? `var(${name}, ${fallback})` : `var(${name})` + return fallback !== undefined && fallback.length > 0 ? `var(${name}, ${fallback})` : `var(${name})` } /** diff --git a/frontends/nextjs/src/types/monaco-editor-react.d.ts b/frontends/nextjs/src/types/monaco-editor-react.d.ts index 0a775cb8b..81aaa7e64 100644 --- a/frontends/nextjs/src/types/monaco-editor-react.d.ts +++ b/frontends/nextjs/src/types/monaco-editor-react.d.ts @@ -30,5 +30,5 @@ declare module '@monaco-editor/react' { export default Editor export function useMonaco(): Monaco | null - export function loader(): Promise + export function loader(): Promise }