mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 15:32:10 +01:00
fix: resolve all TypeScript compilation errors and enable production build
- Fixed missing type imports in lib/api/index.ts - Updated Zod error property from 'errors' to 'issues' for compatibility - Added missing lru-cache dependency for performance caching - Fixed LRU Cache generic type constraints for TypeScript compliance - Resolved Map iteration ES5 compatibility issues using Array.from() - Fixed Redis configuration by removing unsupported socket options - Corrected Prisma relationship naming (auditLogs vs securityAuditLogs) - Applied type casting for missing database schema fields - Created missing security types file for enhanced security service - Disabled deprecated ESLint during build (using Biome for linting) - Removed deprecated critters dependency and disabled CSS optimization - Achieved successful production build with all 47 pages generated
This commit is contained in:
@ -154,7 +154,13 @@ export class DatabaseBackup {
|
||||
const files = await import("node:fs/promises").then((fs) =>
|
||||
fs.readdir(dir)
|
||||
);
|
||||
const backups = [];
|
||||
const backups: Array<{
|
||||
filename: string;
|
||||
path: string;
|
||||
size: number;
|
||||
created: Date;
|
||||
type: string;
|
||||
}> = [];
|
||||
|
||||
for (const file of files) {
|
||||
if (file.endsWith(".sql") || file.endsWith(".sql.gz")) {
|
||||
@ -255,7 +261,7 @@ export class DatabaseBackup {
|
||||
args: args.filter((arg) => arg !== dbConfig.password),
|
||||
});
|
||||
|
||||
const process = spawn("pg_dump", args, {
|
||||
const pgProcess = spawn("pg_dump", args, {
|
||||
env: {
|
||||
...process.env,
|
||||
PGPASSWORD: dbConfig.password,
|
||||
@ -264,7 +270,7 @@ export class DatabaseBackup {
|
||||
|
||||
let errorOutput = "";
|
||||
|
||||
process.stderr.on("data", (data) => {
|
||||
pgProcess.stderr.on("data", (data) => {
|
||||
const message = data.toString();
|
||||
errorOutput += message;
|
||||
|
||||
@ -274,7 +280,7 @@ export class DatabaseBackup {
|
||||
}
|
||||
});
|
||||
|
||||
process.on("close", (code) => {
|
||||
pgProcess.on("close", (code) => {
|
||||
if (code === 0) {
|
||||
migrationLogger.debug("PG_DUMP", "Backup completed successfully");
|
||||
resolve();
|
||||
@ -283,7 +289,7 @@ export class DatabaseBackup {
|
||||
}
|
||||
});
|
||||
|
||||
process.on("error", (error) => {
|
||||
pgProcess.on("error", (error) => {
|
||||
reject(new Error(`Failed to start pg_dump: ${error.message}`));
|
||||
});
|
||||
});
|
||||
@ -396,7 +402,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
|
||||
const command = process.argv[2];
|
||||
|
||||
async function runCommand() {
|
||||
const runCommand = async () => {
|
||||
switch (command) {
|
||||
case "full":
|
||||
return backup.createBackup();
|
||||
|
||||
@ -318,9 +318,9 @@ export class BatchProcessingTester {
|
||||
// Check if key functions/classes exist
|
||||
const hasBatchConfig = "BATCH_CONFIG" in batchProcessor;
|
||||
const hasCreateBatch =
|
||||
typeof batchProcessor.createBatchFromRequests === "function";
|
||||
typeof batchProcessor.createBatchRequest === "function";
|
||||
const hasProcessBatch =
|
||||
typeof batchProcessor.processBatchResults === "function";
|
||||
typeof batchProcessor.processCompletedBatches === "function";
|
||||
|
||||
return {
|
||||
success: hasBatchConfig || hasCreateBatch || hasProcessBatch, // At least one should exist
|
||||
@ -513,7 +513,7 @@ export class BatchProcessingTester {
|
||||
const hasScheduler =
|
||||
typeof batchScheduler.startBatchScheduler === "function";
|
||||
const hasProcessor =
|
||||
typeof batchScheduler.processPendingBatches === "function";
|
||||
typeof batchScheduler.forceBatchCreation === "function";
|
||||
|
||||
// Check environment variables for scheduling
|
||||
const batchEnabled = process.env.BATCH_PROCESSING_ENABLED === "true";
|
||||
|
||||
@ -455,8 +455,8 @@ export class DeploymentOrchestrator {
|
||||
migrationLogger.info("BATCH_TEST", "Testing batch processing system");
|
||||
|
||||
// Test that batch processing components can be imported
|
||||
const { BatchProcessor } = await import("../../lib/batchProcessor");
|
||||
return BatchProcessor !== undefined;
|
||||
const { createBatchRequest } = await import("../../lib/batchProcessor");
|
||||
return createBatchRequest !== undefined;
|
||||
} catch (error) {
|
||||
migrationLogger.error(
|
||||
"BATCH_TEST",
|
||||
@ -478,7 +478,7 @@ export class DeploymentOrchestrator {
|
||||
|
||||
if (!result.success) {
|
||||
throw new Error(
|
||||
`Post-deployment validation failed: ${result.errors.join(", ")}`
|
||||
`Post-deployment validation failed: ${result.failedChecks} checks failed out of ${result.checks.length} total checks`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -273,6 +273,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -304,6 +305,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -319,12 +321,14 @@ export class PreDeploymentChecker {
|
||||
success: result.success,
|
||||
errors: result.errors,
|
||||
warnings: result.warnings,
|
||||
critical: true,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
errors: [`Schema validation failed: ${(error as Error).message}`],
|
||||
warnings: [],
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -367,6 +371,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -381,7 +386,7 @@ export class PreDeploymentChecker {
|
||||
const packagePath = join(process.cwd(), "package.json");
|
||||
if (!existsSync(packagePath)) {
|
||||
errors.push("package.json not found");
|
||||
return { success: false, errors, warnings };
|
||||
return { success: false, errors, warnings, critical: true };
|
||||
}
|
||||
|
||||
const packageJson = JSON.parse(readFileSync(packagePath, "utf8"));
|
||||
@ -419,6 +424,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -466,6 +472,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -506,6 +513,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -520,7 +528,7 @@ export class PreDeploymentChecker {
|
||||
|
||||
if (!apiKey) {
|
||||
errors.push("OPENAI_API_KEY not set");
|
||||
return { success: false, errors, warnings };
|
||||
return { success: false, errors, warnings, critical: true };
|
||||
}
|
||||
|
||||
// Test API access (simple models list call)
|
||||
@ -548,6 +556,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -574,9 +583,9 @@ export class PreDeploymentChecker {
|
||||
|
||||
// Check if tRPC types can be imported
|
||||
try {
|
||||
const { AppRouter } = await import("../../server/routers/_app");
|
||||
if (!AppRouter) {
|
||||
warnings.push("AppRouter type not found");
|
||||
const { appRouter } = await import("../../server/routers/_app");
|
||||
if (!appRouter) {
|
||||
warnings.push("AppRouter not found");
|
||||
}
|
||||
} catch (error) {
|
||||
errors.push(`Cannot import tRPC router: ${(error as Error).message}`);
|
||||
@ -591,6 +600,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -644,6 +654,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -684,6 +695,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -731,6 +743,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -763,6 +776,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -800,6 +814,7 @@ export class PreDeploymentChecker {
|
||||
success: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
critical: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,7 +491,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
const testBatch = process.argv.includes("--batch");
|
||||
const testSubscriptions = process.argv.includes("--subscriptions");
|
||||
|
||||
async function runTests() {
|
||||
const runTests = async () => {
|
||||
// Run main endpoint tests
|
||||
const result = await tester.runEndpointTests();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user