Skip to content

Add TypeScript Runtime Support and add Prisma 7 Compatibility#354

Merged
michelroegl-brunner merged 53 commits intomainfrom
bugfixing_bumps
Nov 28, 2025
Merged

Add TypeScript Runtime Support and add Prisma 7 Compatibility#354
michelroegl-brunner merged 53 commits intomainfrom
bugfixing_bumps

Conversation

@MickLesk
Copy link
Member

@MickLesk MickLesk commented Nov 28, 2025

Closes: #347 #346 #345 #344 #343


✍️ Description

This PR introduces comprehensive TypeScript runtime support via tsx and resolves critical compatibility issues with Prisma 7, enabling the application to run successfully in production. The changes span type safety improvements, module resolution fixes, and production deployment readiness.


📋 Changes Summary (30 Commits)

🔧 Core Infrastructure Changes

TypeScript Runtime Support

  • Added tsx@^4.19.4 as a production dependency
  • Updated start script: node server.jsnode --import tsx server.js
  • Updated dev:server script for consistency: node --import tsx server.js
  • Enables native TypeScript execution without compilation step
  • Supports .ts file loading in production environment

Module Resolution & Imports

  • Fixed import paths across all service files for ESM compatibility
  • Added .ts extensions to TypeScript imports where required
  • Updated relative imports to work with tsx loader
  • Ensured consistent import patterns across codebase

🐛 Bug Fixes

Prisma 7 Compatibility

  • Updated src/server/db.js to properly import Prisma 7 client
  • Fixed path resolution for prisma/generated/prisma/client.ts
  • Handled ESM/CJS interoperability issues with Prisma
  • Resolved module resolution errors in generated Prisma types

Server Initialization Issues

  • Added missing initializeRepositories() export to src/server/lib/autoSyncInit.ts
  • Fixed repository initialization on server startup
  • Resolved TypeError: autoSyncModule.initializeRepositories is not a function
  • Ensured default repositories are loaded before API requests

Service Module Exports

  • Fixed exports in src/server/services/autoSyncService.js
  • Fixed exports in src/server/services/repositoryService.js
  • Fixed exports in src/server/services/githubJsonService.js
  • Ensured all service modules properly export their functions

Dynamic Import Implementation

  • Converted static imports to dynamic imports for autoSyncInit module
  • Added comprehensive logging for debugging module loading
  • Implemented error handling for failed module imports
  • Better error messages during server initialization

✨ Features & Improvements

Development Experience

  • dev:server command for development with TypeScript support
  • Detailed logging for module initialization debugging
  • Better error messages showing available vs. requested exports
  • Improved troubleshooting for module resolution issues

Production Readiness

  • Full TypeScript support in production environment
  • Proper module caching and tsx handling
  • Graceful error handling during server startup
  • WebSocket server initialization logging

Type Safety

  • TypeScript strict mode compatible code
  • Proper type definitions for all service modules
  • Better IDE support with TypeScript paths
  • Type checking via npm run typecheck

📝 Files Modified

Category Files Changes
Configuration package.json Added tsx dependency; Updated start/dev scripts
Core Server server.js Added dynamic imports with detailed logging
Database src/server/db.js Fixed Prisma client import paths
Initialization src/server/lib/autoSyncInit.ts Added initializeRepositories() export; Added TypeScript definitions
Services src/server/services/autoSyncService.js Fixed import paths and exports
Services src/server/services/repositoryService.js Fixed import paths and exports
Services src/server/services/githubJsonService.js Fixed import paths and exports
Type Definitions src/server/database-prisma.ts Fixed any type issues; Added explicit return types

🔍 Technical Details

What Was Wrong

  1. Prisma 7 generates TypeScript but production was trying to run JavaScript
  2. Module exports were missing from some .ts files while .js versions had them
  3. Import paths were inconsistent - some with extensions, some without
  4. Static imports failed due to tsx caching issues
  5. No logging made debugging difficult

How It Was Fixed

  1. Added tsx runtime to handle TypeScript in production
  2. Synced .ts and .js exports to match
  3. Standardized import paths for ESM compatibility
  4. Switched to dynamic imports for better module loading
  5. Added comprehensive logging for troubleshooting

✅ Testing & Verification

  • npm install completes without errors
  • npm run build completes successfully
  • npm run typecheck passes with no errors
  • npm run lint and npm run format:check pass
  • npm start runs without errors
  • ✅ Server initializes all services (WebSocket, auto-sync, repositories)

📊 Commit Overview

30 commits across:

  • Type safety improvements (6 commits)
  • Import path fixes (8 commits)
  • Module export fixes (7 commits)
  • Service configuration (5 commits)
  • Documentation and logging (4 commits)

🔗 Related Issues

  • Production deployment failures with Prisma 7
  • TypeScript/ESM module resolution
  • Server initialization on startup
  • Missing service exports

✅ Prerequisites

  • Self-review completed – Code follows project standards
  • Tested thoroughly – Verified on multiple environments
  • No security risks – No hardcoded secrets or privilege escalations

🛠️ Type of Change

  • 🐞 Bug fix only
  • New feature – TypeScript runtime support via tsx
  • 💥 Breaking change – Production startup mechanism changed

MickLesk and others added 30 commits November 28, 2025 11:44
Upgraded multiple dependencies and devDependencies in package.json to their latest versions for improved stability and features. Changed the TypeScript 'jsx' compiler option from 'react-jsx' to 'preserve' in tsconfig.json to better align with project requirements.
…nal-chain, unescaped-entities, unused-vars, type-safety
Improves type safety and normalization in filter, repository, and script status handling across multiple components. Refactors ScriptsGrid for better readability, deduplication, and error messaging, and updates UI markup for consistency. Also adds explicit types for auto-sync settings and ensures string conversion for credential fields.
Replaces many uses of logical OR (||) with nullish coalescing (??) for more accurate handling of undefined/null values. Adds explicit type annotations and interfaces to improve type safety, especially in API routes and server-side code. Updates SSH connection test handling and config parsing in installedScripts router for better reliability. Minor fixes to deduplication logic, cookie handling, and error reporting.
Standardizes quote usage, formatting, and code style in InstalledScriptsTab.tsx. Improves readability and maintains consistent conventions across the file without changing logic or functionality.
Updated InstalledScriptsTab.tsx to use double quotes and consistent formatting throughout the file. Improved type annotations, code readability, and standardized state initialization and mutation usage. No functional changes were made; this is a style and maintainability refactor.
Added and updated eslint-disable comments in repositoryService, restoreService, and storageService to cover additional TypeScript rules. Simplified error handling by removing unused variables and catch parameters, and removed unused imports and variables in restoreService for cleaner code.
Replaces @eslint/eslintrc and FlatCompat with eslint-config-next/core-web-vitals for ESLint configuration. Updates linting scripts in package.json to use eslint directly instead of next lint. Removes @eslint/eslintrc from devDependencies.
Switched to using FlatCompat for ESLint configuration and extended the ignore list to include 'next-env.d.ts', 'postcss.config.js', and 'prettier.config.js'. This improves compatibility and prevents linting of config and environment files.
Added explicit type annotations to array mapping functions for better type safety. Updated incorrect TypeScript import extensions from .ts to .js for compatibility. Ensured default values for optional parameters and improved code clarity in API routers.
Updated several components to use explicit TypeScript types for better type safety. Normalized appriseUrls to always be an array in auto-sync settings API. Improved handling of optional server_id in BackupsTab and adjusted IP detection logic in InstalledScriptsTab. Removed unnecessary eslint-disable comments and improved code clarity in various places.
Set `checkJs` to true to allow type checking for JavaScript files. Updated include/exclude patterns to support JS and CJS files in the project.
Replaces usage of PrismaBetterSQLite3 with PrismaBetterSqlite3 for consistency and correct casing. Updates type annotations in several components and API router for improved type safety. Also adjusts PrismaClient import paths in db files.
Enhanced type safety and documentation in several files, including adding explicit type annotations for script objects and function parameters. Improved error handling and code clarity in scriptDownloader.js, and updated autoSyncService.js to remove unnecessary cron job options. Refactored prisma.config.ts for schema configuration and updated server.js to support backup storage and improve parameter defaults.
Upgraded Prisma and related dependencies to version 7.0.1 and added @prisma/adapter-better-sqlite3 and better-sqlite3 to support the new adapter. This enables improved SQLite integration and compatibility with the latest Prisma features.
Added detailed JSDoc comments and type annotations to ScriptDownloaderService for better maintainability and clarity. Refactored initialization logic to always set scriptsDirectory and repoUrl. Enhanced autoSyncService to specify cron job timezone and options. Updated PrismaClient import path for compatibility with generated client structure.
Removed or updated unnecessary eslint-disable comments across several server and service files to improve code clarity. Fixed import paths and added TypeScript ignore comments where needed for compatibility. Minor formatting adjustments were made for readability.
Updated import statements across several server files to omit explicit file extensions. This improves compatibility with module resolution and aligns with common import practices.
Updated the initialization logic to use the 'recursive' option when creating the data/ssh-keys directory, ensuring parent directories are created if they do not exist.
This commit adds TypeScript type definitions for database entities and updates all methods in DatabaseServicePrisma to use explicit type annotations and return types. This improves type safety, code clarity, and maintainability by ensuring consistent return values and better integration with Prisma-generated types.
@MickLesk MickLesk changed the title tbd Add TypeScript Runtime Support and Fix Prisma 7 Compatibility for Production Nov 28, 2025
@MickLesk MickLesk marked this pull request as ready for review November 28, 2025 13:45
@MickLesk MickLesk requested a review from a team as a code owner November 28, 2025 13:45
@MickLesk MickLesk changed the title Add TypeScript Runtime Support and Fix Prisma 7 Compatibility for Production Add TypeScript Runtime Support and add Prisma 7 Compatibility for Production Nov 28, 2025
@MickLesk MickLesk changed the title Add TypeScript Runtime Support and add Prisma 7 Compatibility for Production Add TypeScript Runtime Support and add Prisma 7 Compatibility Nov 28, 2025
@michelroegl-brunner michelroegl-brunner merged commit 0da802b into main Nov 28, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants