mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
Fix critical TypeScript errors and 157 linting issues
- 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>
This commit is contained in:
@@ -18,7 +18,7 @@ interface RouteParams {
|
||||
export async function PUT(request: NextRequest, { params }: RouteParams) {
|
||||
try {
|
||||
const body = await readJson<PackageDataPayload>(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 })
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -61,7 +61,7 @@ export function useDBAL() {
|
||||
},
|
||||
list: async (entity: string, params?: Record<string, unknown>) => {
|
||||
const queryString = params ? `?${new URLSearchParams(params as Record<string, string>).toString()}` : ''
|
||||
return request('GET', `${entity}${queryString}`) as Promise<unknown[] | null>
|
||||
return request('GET', `${entity}${queryString}`)
|
||||
},
|
||||
create: async (entity: string, data: unknown) => {
|
||||
return request('POST', entity, data)
|
||||
|
||||
@@ -95,7 +95,7 @@ export async function fetchWorkflowRunLogs(
|
||||
}))
|
||||
|
||||
let logsText = ''
|
||||
let truncated = false
|
||||
const truncated = false
|
||||
|
||||
if (includeLogs) {
|
||||
// Download logs for the workflow run
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<string>()
|
||||
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`)
|
||||
}
|
||||
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function loadPackage(packageId: string): Promise<UnifiedPackage | n
|
||||
}
|
||||
|
||||
const legacyEntry = PACKAGE_CATALOG[packageId]
|
||||
if (legacyEntry) {
|
||||
if (legacyEntry !== null && legacyEntry !== undefined) {
|
||||
const data = legacyEntry()
|
||||
return {
|
||||
packageId: data.manifest.id,
|
||||
|
||||
@@ -19,20 +19,20 @@ const PACKAGE_COMPONENT_REGISTRY: Record<string, Record<string, ComponentDef>> =
|
||||
* 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<string, ComponentDef> = {}
|
||||
|
||||
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[] {
|
||||
|
||||
@@ -12,21 +12,21 @@ export interface RouteValidationResult {
|
||||
}
|
||||
}
|
||||
|
||||
export async function validatePackageRoute(
|
||||
export function validatePackageRoute(
|
||||
_b_package: string,
|
||||
_b_entity: string,
|
||||
_userId?: unknown
|
||||
): Promise<RouteValidationResult> {
|
||||
): RouteValidationResult {
|
||||
// TODO: Implement route validation
|
||||
return { allowed: true }
|
||||
}
|
||||
|
||||
export async function canBePrimaryPackage(_b_packageId: string): Promise<boolean> {
|
||||
export function canBePrimaryPackage(_b_packageId: string): boolean {
|
||||
// TODO: Implement primary package check
|
||||
return true
|
||||
}
|
||||
|
||||
export async function loadPackageMetadata(_b_packageId: string): Promise<unknown> {
|
||||
export function loadPackageMetadata(_b_packageId: string): unknown {
|
||||
// TODO: Implement package metadata loading
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ export function errorResponse(message: string, status = STATUS.ERROR) {
|
||||
}
|
||||
|
||||
export interface SessionUser {
|
||||
user: unknown | null
|
||||
user: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export async function getSessionUser(_req?: Request): Promise<SessionUser> {
|
||||
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 }> {
|
||||
): 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> {
|
||||
): TenantValidationResult {
|
||||
// TODO: Implement tenant access validation
|
||||
return { allowed: false, reason: 'Not implemented' }
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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<string, unknown>
|
||||
}
|
||||
}
|
||||
} 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 = {
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export interface UIPageData {
|
||||
actions?: Record<string, LuaActionHandler>
|
||||
}
|
||||
|
||||
export async function loadPageFromDb(_path: string, _tenantId?: string): Promise<PageConfig | null> {
|
||||
export function loadPageFromDb(_path: string, _tenantId?: string): PageConfig | null {
|
||||
// TODO: Implement page loading from database
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import type { PageConfig } from '../types/level-types'
|
||||
|
||||
export async function loadPageFromLuaPackages(_b_path: string): Promise<PageConfig | null> {
|
||||
export function loadPageFromLuaPackages(_b_path: string): PageConfig | null {
|
||||
// TODO: Implement page loading from Lua packages
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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})`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ export type ThemeVars = Record<ThemeVarKey, string>
|
||||
*/
|
||||
export const applyTheme = (
|
||||
theme: Record<string, string>,
|
||||
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})`
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,5 +30,5 @@ declare module '@monaco-editor/react' {
|
||||
export default Editor
|
||||
|
||||
export function useMonaco(): Monaco | null
|
||||
export function loader(): Promise<Monaco>
|
||||
export function loader(): Promise<Monaco | never>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user