diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7075e22 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +# .dockerignore +node_modules +vendor +.git +test-srts +*.log +CODEBASE_REFERENCE.md +docker-compose.dev.yaml +subsyncarr-plus.db +builds +testlogs \ No newline at end of file diff --git a/.env.example b/.env.example deleted file mode 100644 index 754a125..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -MEDIA_PATH=/path/to/your/media -TZ=America/New_York # Adjust timezone as needed diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 247c858..627ead1 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -26,7 +26,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: mrorbitman/subsyncarr + images: tomtomw123/subsyncarr-plus tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} @@ -64,27 +64,37 @@ jobs: Pull the image using: ```bash - docker pull mrorbitman/subsyncarr:${{ github.ref_name }} + docker pull tomtomw123/subsyncarr-plus:${{ github.ref_name }} # or - docker pull mrorbitman/subsyncarr:latest + docker pull tomtomw123/subsyncarr-plus:latest ``` Example docker-compose.yaml: ``` - version: "3.8" + name: subsyncarr-plus services: - subsyncarr: - image: mrorbitman/subsyncarr:latest - container_name: subsyncarr - volumes: - - ${MEDIA_PATH:-/path/to/your/media}:/scan_dir - restart: unless-stopped - environment: - - TZ=${TZ:-UTC} + subsyncarr-plus: + image: tomtomw123/subsyncarr-plus:latest + container_name: subsyncarr-plus + volumes: + # Any path configured with SCAN_PATHS env var must be mounted + # If no scan paths are specified, it defaults to scan `/scan_dir` like example below. + # - ${MEDIA_PATH:-/path/to/your/media}:/scan_dir + - /path/to/movies:/movies + - /path/to/tv:/tv + - /path/to/anime:/anime + restart: unless-stopped + environment: + - TZ=${TZ:-UTC} + - CRON_SCHEDULE=0 0 * * * # Runs every day at midnight by default + - SCAN_PATHS=/movies,/tv,/anime # Remember to mount these as volumes. Must begin with /. Default valus is `/scan_dir` + - EXCLUDE_PATHS=/movies/temp,/tv/downloads # Exclude certain sub-directories from the scan + - MAX_CONCURRENT_SYNC_TASKS=1 + - INCLUDE_ENGINES=ffsubsync,autosubsync # If not set, all engines are used by default ``` - Docker Hub URL: https://hub.docker.com/r/mrorbitman/subsyncarr/tags + Docker Hub URL: https://hub.docker.com/r/tomtomw123/subsyncarr-plus/tags draft: false prerelease: false diff --git a/.gitignore b/.gitignore index 458abbf..402945c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,12 @@ /dist /coverage .eslintcache -.env \ No newline at end of file +.env +/test-srts +CODEBASE_REFERENCE.md +docker-compose.dev.yaml +subsyncarr-plus.db +builds +*.tar +*.tar.gz +testlogs \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 6a3a6a3..d99cb02 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,4 +7,5 @@ dist .prettierignore .husky Dockerfile -.env* \ No newline at end of file +.env* +/app \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7289383..2a410c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,63 +1,79 @@ # Use Node.js LTS (Long Term Support) as base image FROM node:20-bullseye -# Set working directory -WORKDIR /app +# Create app user and group with configurable UID/GID +ENV PUID=1000 +ENV PGID=1000 + +RUN mkdir -p /app +RUN chown node:node /app + +# Modify existing node user instead of creating new one +RUN groupmod -g ${PGID} node && \ + usermod -u ${PUID} -g ${PGID} node && \ + chown -R node:node /home/node +RUN apt-get clean -# Install system dependencies including ffmpeg, Python, and cron +# Install system dependencies including ffmpeg, Python, cron, and build tools RUN apt-get update && apt-get install -y \ ffmpeg \ python3 \ python3-pip \ python3-venv \ cron \ + build-essential \ && rm -rf /var/lib/apt/lists/* -# Install pipx -RUN python3 -m pip install --user pipx \ - && python3 -m pipx ensurepath - -# Add pipx to PATH -ENV PATH="/root/.local/bin:$PATH" - -# Install ffsubsync and autosubsync using pipx -RUN pipx install ffsubsync \ - && pipx install autosubsync +USER node +# Set working directory +WORKDIR /app # Copy package.json and package-lock.json (if available) -COPY package*.json ./ +COPY --chown=node:node package*.json ./ # Install Node.js dependencies while skipping husky installation ENV HUSKY=0 RUN npm install --ignore-scripts +# Rebuild native modules for the container's platform +RUN npm rebuild better-sqlite3 + # Copy the rest of your application -COPY . . +COPY --chown=node:node . . +RUN mkdir -p /home/node/.local/bin/ +RUN cp bin/* /home/node/.local/bin/ # Build TypeScript RUN npm run build +# Create data directory for SQLite database +RUN mkdir -p /app/data && chown node:node /app/data + # Create startup script -RUN echo '#!/bin/bash\n\ -# Add cron job\n\ -echo "0 0 * * * cd /app && /usr/local/bin/node /app/dist/index.js >> /var/log/cron.log 2>&1" > /etc/cron.d/subsyncarr\n\ -chmod 0644 /etc/cron.d/subsyncarr\n\ -crontab /etc/cron.d/subsyncarr\n\ -\n\ -# Start cron\n\ -service cron start\n\ -\n\ -# Run the initial instance of the app\n\ -node dist/index.js\n\ -\n\ -# Keep container running\n\ -tail -f /var/log/cron.log' > /app/startup.sh - -# Make startup script executable -RUN chmod +x /app/startup.sh - -# Create log file -RUN touch /var/log/cron.log - -# Use startup script as entrypoint -CMD ["/app/startup.sh"] +# Set default cron schedule (if not provided by environment variable) +ENV CRON_SCHEDULE="0 0 * * *" + +# Install pipx +RUN python3 -m pip install --user pipx \ + && python3 -m pipx ensurepath + +# Add pipx to PATH +ENV PATH="/home/node/.local/bin:$PATH" + +# Install ffsubsync and autosubsync using pipx +# Clean caches after installation to reduce memory footprint +RUN pipx install ffsubsync \ + && pipx install autosubsync \ + && python3 -m pip cache purge \ + && find /home/node/.local/share/pipx -type f -name "*.pyc" -delete 2>/dev/null || true \ + && find /home/node/.local/share/pipx -type d -name "__pycache__" -delete 2>/dev/null || true + +# Expose web UI port +EXPOSE 3000 + +# Use server as entrypoint (which includes cron scheduling) +# Memory optimization flags: increased heap to 512MB to prevent OOM with file-based logging +CMD ["node", \ + "--max-old-space-size=512", \ + "--optimize-for-size", \ + "dist/index-server.js"] diff --git a/README.md b/README.md index 8e13947..92c38f9 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,292 @@ -# Subsyncarr +# Subsyncarr Plus -An automated subtitle synchronization tool that runs as a Docker container. It watches a directory for video files with matching subtitles and automatically synchronizes them using both ffsubsync and autosubsync. +An automated subtitle synchronization tool that runs as a Docker container. It continuously monitors your media directories for video files with out-of-sync subtitles and automatically synchronizes them using three sync engines (ffsubsync, autosubsync, and alass). This is a fork from the software [subsyncarr](https://github.com/johnpc/subsyncarr). + +**Docker Hub:** [tomtomw123/subsyncarr-plus](https://hub.docker.com/r/tomtomw123/subsyncarr-plus) ## Features -- Automatically scans directory for video files and their corresponding subtitles -- Uses both ffsubsync and autosubsync for maximum compatibility -- Runs on a schedule (daily at midnight) and on container startup -- Supports common video formats (mkv, mp4, avi, mov) -- Docker-based for easy deployment -- Generates synchronized subtitle files with `.ffsubsync.srt` and `.autosubsync.srt` extensions +### Core Functionality + +- **Automated Subtitle Synchronization** - Syncs subtitles for your entire media library or specific folders. +- **Multiple Sync Engines** - Uses ffsubsync, autosubsync, and alass for maximum compatibility and success rate +- **Scheduled Processing** - Runs on a configurable cron schedule (default: daily at midnight) and on container startup +- **Parallel Processing** - Configure concurrent subtitle processing for faster library syncing +- **Skip Already Synced Files** - Avoids re-processing files that already have synchronized subtitles or where an engine repeatedly fails. +- **Processing History** - View past runs with detailed statistics, results, and logs +- **Configuration Dashboard** - View current settings, monitored paths, and schedule status +- **Configurable Timeouts** - Set per-engine timeout limits to prevent hung processes +- **Log Management** - Configurable retention policies with automatic trimming and deletion +- **Non Destructive** - Creates new files for each engine so no original files are altered. Allows easy switching between engines while watching content. ## Quick Start ### Using Docker Compose (Recommended) -#### 1. Create a new directory for your project: +1. **Create a docker-compose.yaml file** with the following content: -```bash -mkdir subsyncarr && cd subsyncarr +```yaml +name: subsyncarr-plus + +services: + subsyncarr-plus: + image: tomtomw123/subsyncarr-plus:latest + container_name: subsyncarr-plus + user: '1000:10' + ports: + - '3000:3000' # Web UI + volumes: + # Mount your media directories + - /path/to/movies:/movies + - /path/to/tv:/tv + - /path/to/anime:/anime + - ./data:/app/data # Persist database across restarts + restart: unless-stopped + deploy: + resources: + limits: + memory: 768M # Hard limit + reservations: + memory: 128M # Minimum guaranteed memory + environment: + - TZ=Etc/UTC # Replace with your own timezone + - PUID=1000 + - PGID=10 + - CRON_SCHEDULE=0 0 * * * # Runs every day at midnight by default + - SCAN_PATHS=/movies,/tv # Comma-separated paths to scan + - EXCLUDE_PATHS=/movies/temp,/tv/downloads # Optional: exclude directories + - MAX_CONCURRENT_SYNC_TASKS=1 # Number of parallel processing tasks + - INCLUDE_ENGINES=ffsubsync,autosubsync,alass # Engines to use ``` -#### 2. Download the docker-compose.yml and .env.example files: +2. **Update the configuration:** + + - Replace `/path/to/movies`, `/path/to/tv`, etc. with your actual media paths + - Update `TZ` to your timezone (e.g., `America/New_York`, `Europe/London`) + - Update `PUID` and `PGID` to match your user (run `id` command to find these) + - Adjust `SCAN_PATHS` to match your mounted volumes + +3. **Start the container:** ```bash -curl -O https://raw.githubusercontent.com/johnpc/subsyncarr/main/docker-compose.yml -curl -O https://raw.githubusercontent.com/johnpc/subsyncarr/main/.env.example +docker compose up -d ``` -#### 3. Create your .env file: +4. **Access the Web UI:** + +Open your browser to [http://localhost:3000](http://localhost:3000) or whatever port you've mapped to inside docker. + +### Using Docker Run ```bash -cp .env.example .env +docker run -d \ + --name subsyncarr-plus \ + --user 1000:10 \ + -p 3000:3000 \ + -v /path/to/movies:/movies \ + -v /path/to/tv:/tv \ + -v ./data:/app/data \ + -e TZ=Etc/UTC \ + -e PUID=1000 \ + -e PGID=10 \ + -e CRON_SCHEDULE="0 0 * * *" \ + -e SCAN_PATHS=/movies,/tv \ + -e MAX_CONCURRENT_SYNC_TASKS=1 \ + tomtomw123/subsyncarr-plus:latest +``` + +## Configuration + +### Core Configuration + +| Variable | Default | Description | +| --------------------------- | ----------------------------- | -------------------------------------------------------------------------------- | +| `SCAN_PATHS` | `/scan_dir` | Comma-separated directories to scan for SRT files (must be mounted as volumes) | +| `EXCLUDE_PATHS` | _(none)_ | Comma-separated directories to exclude from scanning | +| `CRON_SCHEDULE` | `0 0 * * *` | Cron expression for sync schedule (daily at midnight), or `disabled` to turn off | +| `MAX_CONCURRENT_SYNC_TASKS` | `1` | Number of subtitle files to process in parallel (higher = faster but more CPU) | +| `INCLUDE_ENGINES` | `ffsubsync,autosubsync,alass` | Which sync engines to use (comma-separated) | +| `SYNC_ENGINE_TIMEOUT_MS` | `1800000` | Timeout for each sync engine in milliseconds (30 min default) | +| `TZ` | _(system)_ | Timezone for logging and cron scheduling (e.g., `America/New_York`) | +| `PUID` | `1000` | User ID for file permissions (run `id -u` to find yours) | +| `PGID` | `1000` | Group ID for file permissions (run `id -g` to find yours) | + +### Database & Log Configuration + +| Variable | Default | Description | +| ---------------------------------- | ------------------------------ | ------------------------------------------- | +| `DB_PATH` | `/app/data/subsyncarr-plus.db` | SQLite database location | +| `LOG_BUFFER_SIZE` | `1000` | Ring buffer size for in-memory logs | +| `RETENTION_KEEP_RUNS_DAYS` | `30` | Keep complete runs for N days | +| `RETENTION_TRIM_LOGS_DAYS` | `7` | Trim logs after N days (keeps summary only) | +| `RETENTION_MAX_LOG_SIZE` | `10000` | Max size for trimmed logs in bytes | +| `RETENTION_CLEANUP_INTERVAL_HOURS` | `24` | How often to run cleanup (in hours) | + +### Timeout Configuration + +The `SYNC_ENGINE_TIMEOUT_MS` environment variable controls how long each sync engine can run before being terminated. This prevents hung processes from blocking the queue. + +Example configuration: + +```yaml +environment: + - SYNC_ENGINE_TIMEOUT_MS=3600000 # 60 minutes for large files +``` + +### Directory Structure + +Your media directory should be organized with video files and their corresponding subtitle files using matching names: + +```txt +/movies +├── Movie Title (2024).mkv +├── Movie Title (2024).srt # Will be synchronized +├── Movie Title (2024).ffsubsync.srt # Generated output +└── Another Movie.mp4 + └── Another Movie.srt + +/tv +├── Show Name/ +│ ├── Season 01/ +│ │ ├── Show.S01E01.mkv +│ │ └── Show.S01E01.srt ``` -#### 4. Edit the .env file with your settings: +The app follows standard naming conventions compatible with Plex, Jellyfin, Emby, and Bazarr. + +## Web UI + +Subsyncarr Plus includes a comprehensive web-based monitoring interface accessible at `http://localhost:3000` after starting the container. + +### UI Features + +**Real-time Monitoring:** + +- Live progress bars showing current processing status +- File-by-file status updates via WebSocket +- Engine-level detail (see which sync engine is running) +- Current and queued files display + +**Manual Control:** + +- **Start Full Run** - Process all configured directories immediately +- **Scan Specific Path** - Process a custom directory on demand +- **Stop Processing** - Cancel all remaining files in current run +- **Skip File** - Cancel processing for individual files + +**File Management:** + +- View completed and skipped files +- Clear processed files from the UI +- Track file status (pending, processing, completed, skipped, error) +- See matched video files for each subtitle + +**Processing History:** + +- Sortable run history table with timestamps +- Per-run statistics (total, completed, skipped, failed counts) +- Engine-level results summary with notation: + - **F** = ffsubsync result + - **Au** = autosubsync result + - **Al** = alass result +- Duration tracking for each run +- View detailed logs for any past run with copy-to-clipboard functionality + +**Configuration Dashboard:** + +- Display of monitored paths and excluded paths +- Schedule status with next run time +- Human-readable cron schedule translation + +### Database Persistence + +Processing history is stored in SQLite and persists across container restarts. Ensure the data volume is mounted: + +```yaml +volumes: + - ./data:/app/data # Database and logs stored here +``` + +## Advanced Features + +### Auto-Skip on Repeated Failures + +The app intelligently tracks failures for each file/engine combination. After 3 consecutive failures, that engine will be automatically skipped for that specific file, preventing wasted processing time. You can reset skip status via the API endpoint `/api/skip-status/reset`. + +### Memory Management + +Optimized for low-memory environments with: + +- Configurable memory limits (768MB default, 128MB minimum) +- SQLite optimizations for low RAM usage +- File-based logging with buffering to reduce memory pressure +- Automatic database vacuuming and cleanup +- Ring buffer for in-memory logs + +### Log Retention & Cleanup + +Automatic cleanup keeps your database size manageable: + +- Complete runs retained for 30 days (configurable) +- Logs trimmed after 7 days, keeping only summaries +- Runs beyond retention period are automatically deleted +- Cleanup runs every 24 hours (configurable) + +## Troubleshooting + +### View Container Logs ```bash -MEDIA_PATH=/path/to/your/media -TZ=America/New_York # Adjust to your timezone +docker logs -f subsyncarr-plus ``` -#### 5. Start the container: +### Check Web UI Logs + +Detailed processing logs are available in the Web UI under "Processing History" - click on any run to view full logs. + +### Permission Issues + +If you encounter permission errors, ensure `PUID` and `PGID` match your host user: ```bash -docker-compose up -d +id -u # Get your user ID +id -g # Get your group ID ``` -## Configuration +Then update your docker-compose.yaml with these values. -The container is configured to: +### Memory Issues -- Scan for subtitle files in the mounted directory -- Run synchronization at container startup -- Run daily at midnight (configurable via cron) -- Generate synchronized subtitle versions using different tools (currently ffsubsync and autosubsync) +If the container is being killed due to OOM (Out Of Memory): -### Directory Structure +1. Reduce `MAX_CONCURRENT_SYNC_TASKS` to 1 +2. Increase memory limit in docker-compose.yaml +3. Reduce `SYNC_ENGINE_TIMEOUT_MS` for faster timeouts +4. Exclude large files or problematic directories with `EXCLUDE_PATHS` -Your media directory should be organized as follows: +### Files Not Being Processed -/media -├── movie1.mkv -├── movie1.srt -├── movie2.mp4 -└── movie2.srt +Check that: -It should follow the naming conventions expected by other services like Bazarr and Jellyfin. +1. Your subtitle files are named to match video files (e.g., `movie.mkv` and `movie.srt`) +2. `SCAN_PATHS` matches your mounted volumes +3. Files haven't already been synced (check for `.ffsubsync.srt` files) +4. Files aren't being auto-skipped due to repeated failures (check skip status in Web UI) -## Logs +## Docker Hub -View container logs: +Pull the latest image: ```bash -docker logs -f subsyncarr +docker pull tomtomw123/subsyncarr-plus:latest ``` + +**Docker Hub Repository:** [tomtomw123/subsyncarr-plus](https://hub.docker.com/r/tomtomw123/subsyncarr-plus) + +## Contributing + +Issues and pull requests are welcome! Please report bugs or suggest features via GitHub Issues. + +## License + +See LICENSE file for details. diff --git a/bin/alass b/bin/alass new file mode 100755 index 0000000..417f598 Binary files /dev/null and b/bin/alass differ diff --git a/docker-compose.yaml b/docker-compose.yaml index 8c0fa07..b01f6f3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,11 +1,41 @@ -version: '3.8' +name: subsyncarr-plus services: - subsyncarr: - image: mrorbitman/subsyncarr:latest - container_name: subsyncarr + subsyncarr-plus: + image: tomtomw123/subsyncarr-plus:latest + container_name: subsyncarr-plus + user: "1000:10" + ports: + - '3000:3000' # Web UI volumes: - - ${MEDIA_PATH:-/path/to/your/media}:/scan_dir + # Any path configured with SCAN_PATHS env var must be mounted + # If no scan paths are specified, it defaults to scan `/scan_dir` like example below. + # - /path/to/your/media:/scan_dir + - /path/to/movies:/movies + - /path/to/tv:/tv + - /path/to/anime:/anime + - ./data:/app/data # Persist database across restarts restart: unless-stopped + deploy: + resources: + limits: + memory: 768M # Hard limit - increased for file-based logging and large runs + reservations: + memory: 128M # Minimum guaranteed memory environment: - - TZ=${TZ:-UTC} + - TZ=Etc/UTC # Replace with your own timezone + - PUID=1000 + - PGID=10 + - CRON_SCHEDULE=0 0 * * * # Runs every day at midnight by default + - SCAN_PATHS=/movies,/tv # Remember to mount these as volumes. Must begin with /. Default valus is `/scan_dir` + - EXCLUDE_PATHS=/movies/temp,/tv/downloads # Exclude certain sub-directories from the scan + - MAX_CONCURRENT_SYNC_TASKS=1 # Defaults to 1 if not set. Higher number will consume more CPU but sync your library faster + - INCLUDE_ENGINES=ffsubsync,autosubsync # If not set, all engines are used by default + # Timeout configuration (optional - uncomment and adjust if needed): + # - SYNC_ENGINE_TIMEOUT_MS=1800000 # 30 minutes (default) + # - SYNC_ENGINE_TIMEOUT_MS=3600000 # 60 minutes for very large files + # - SYNC_ENGINE_TIMEOUT_MS=600000 # 10 minutes for smaller files + # Web UI configuration (optional): + # - WEB_PORT=3000 # Port for web UI (default: 3000) + # - WEB_HOST=127.0.0.1 # Host to bind to (default: 127.0.0.1, use 0.0.0.0 for all interfaces) + # - DB_PATH=/app/data/subsyncarr-plus.db # SQLite database location (default: /app/data/subsyncarr-plus.db) diff --git a/package-lock.json b/package-lock.json index f5de677..44cd0a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,33 @@ { - "name": "@johnpc/subsyncarr", + "name": "@johnpc/subsyncarr-plus", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@johnpc/subsyncarr", + "name": "@johnpc/subsyncarr-plus", "version": "0.1.0", "license": "UNLICENSED", + "dependencies": { + "better-sqlite3": "^9.4.0", + "cron-parser": "^5.4.0", + "cronstrue": "^3.9.0", + "express": "^4.18.2", + "node-cron": "^3.0.3", + "ws": "^8.16.0" + }, "devDependencies": { "@babel/core": "^7.24.7", "@babel/preset-env": "^7.24.7", "@babel/preset-typescript": "^7.24.7", "@tsconfig/node18": "^18.2.4", + "@types/better-sqlite3": "^7.6.8", + "@types/express": "^4.17.21", "@types/jest": "^29.5.12", "@types/node": "^22.10.10", + "@types/node-cron": "^3.0.11", "@types/uuid": "^10.0.0", + "@types/ws": "^8.5.10", "babel-jest": "^29.7.0", "eslint": "^8.2.0", "eslint-config-airbnb-base": "^15.0.0", @@ -23,6 +35,7 @@ "eslint-plugin-import": "^2.25.2", "eslint-plugin-prettier": "^5.2.1", "globals": "^15.4.0", + "husky": "^9.0.11", "jest": "^29.7.0", "jest-mock": "^29.7.0", "lint-staged": "^15.2.10", @@ -2524,6 +2537,63 @@ "@babel/types": "^7.20.7" } }, + "node_modules/@types/better-sqlite3": { + "version": "7.6.13", + "resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.13.tgz", + "integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/body-parser": { + "version": "1.19.6", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz", + "integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/express": { + "version": "4.17.25", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.25.tgz", + "integrity": "sha512-dVd04UKsfpINUnK0yBoYHDF3xu7xVH4BuDotC/xGuycx4CgbP48X/KF/586bcObxT0HENHXEU8Nqtu6NR+eKhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.33", + "@types/qs": "*", + "@types/serve-static": "^1" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "4.19.7", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.7.tgz", + "integrity": "sha512-FvPtiIf1LfhzsaIXhv/PHan/2FeQBbtBDtfX2QfvPxdUelMDEckK08SM6nqo1MIZY3RUlfA+HV8+hFUSio78qg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, "node_modules/@types/graceful-fs": { "version": "4.1.9", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", @@ -2534,6 +2604,13 @@ "@types/node": "*" } }, + "node_modules/@types/http-errors": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz", + "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", @@ -2579,6 +2656,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/mime": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", + "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "22.10.10", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.10.tgz", @@ -2589,6 +2673,60 @@ "undici-types": "~6.20.0" } }, + "node_modules/@types/node-cron": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/@types/node-cron/-/node-cron-3.0.11.tgz", + "integrity": "sha512-0ikrnug3/IyneSHqCBeslAhlK2aBfYek1fGo4bP4QnZPmiqSGRK+Oy7ZMisLWkesffJvQ1cqAcBnJC+8+nxIAg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/range-parser": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz", + "integrity": "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/serve-static": { + "version": "1.15.10", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.10.tgz", + "integrity": "sha512-tRs1dB+g8Itk72rlSI2ZrW6vZg0YrLI81iQSTkMmOqnqCaNr/8Ek4VwWcN5vZgCYWbg/JJSGBlUaYGAOP73qBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/http-errors": "*", + "@types/node": "*", + "@types/send": "<1" + } + }, + "node_modules/@types/serve-static/node_modules/@types/send": { + "version": "0.17.6", + "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.6.tgz", + "integrity": "sha512-Uqt8rPBE8SY0RK8JB1EzVOIZ32uqy8HwdxCnoCOsYrvnswqmFZ/k+9Ikidlk/ImhsdvBsloHbAlewb2IEBV/Og==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mime": "^1", + "@types/node": "*" + } + }, "node_modules/@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -2603,6 +2741,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/yargs": { "version": "17.0.33", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", @@ -2859,6 +3007,19 @@ "dev": true, "license": "ISC" }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/acorn": { "version": "8.14.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", @@ -2982,6 +3143,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, "node_modules/array-includes": { "version": "3.1.8", "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.8.tgz", @@ -3268,6 +3435,96 @@ "dev": true, "license": "MIT" }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/better-sqlite3": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-9.6.0.tgz", + "integrity": "sha512-yR5HATnqeYNVnkaUTf4bOP2dJSnyhP4puJN/QPRyx4YkBEEUxib422n2XzPqDEHjQQqazoYoADdAm5vE15+dAQ==", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "bindings": "^1.5.0", + "prebuild-install": "^7.1.1" + } + }, + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "license": "MIT", + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "license": "MIT", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/body-parser": { + "version": "1.20.4", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz", + "integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.14.0", + "raw-body": "~2.5.3", + "type-is": "~1.6.18", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/body-parser/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/body-parser/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -3335,6 +3592,30 @@ "node-int64": "^0.4.0" } }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -3342,6 +3623,15 @@ "dev": true, "license": "MIT" }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/call-bind": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", @@ -3365,7 +3655,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.1.tgz", "integrity": "sha512-BhYE+WDaywFg2TBWYNXAE+8B1ATnThNBqXHP5nQu0jWJdVvY2hvkpyB3qOmtmDePiS5/BDQ8wASEWGMWRG148g==", - "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -3379,7 +3668,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.3.tgz", "integrity": "sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==", - "dev": true, "license": "MIT", "dependencies": { "call-bind-apply-helpers": "^1.0.1", @@ -3460,6 +3748,12 @@ "node": ">=10" } }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "license": "ISC" + }, "node_modules/ci-info": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", @@ -3650,6 +3944,27 @@ "dev": true, "license": "MIT" }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -3657,6 +3972,21 @@ "dev": true, "license": "MIT" }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, "node_modules/core-js-compat": { "version": "3.40.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.40.0.tgz", @@ -3693,6 +4023,27 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/cron-parser": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-5.4.0.tgz", + "integrity": "sha512-HxYB8vTvnQFx4dLsZpGRa0uHp6X3qIzS3ZJgJ9v6l/5TJMgeWQbLkR5yiJ5hOxGbc9+jCADDnydIe15ReLZnJA==", + "license": "MIT", + "dependencies": { + "luxon": "^3.7.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/cronstrue": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/cronstrue/-/cronstrue-3.9.0.tgz", + "integrity": "sha512-T3S35zmD0Ai2B4ko6+mEM+k9C6tipe2nB9RLiGT6QL2Wn0Vsn2cCZAC8Oeuf4CaE00GZWVdpYitbpWCNlIWqdA==", + "license": "MIT", + "bin": { + "cronstrue": "bin/cli.js" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -3780,6 +4131,21 @@ } } }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "license": "MIT", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/dedent": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.3.tgz", @@ -3795,6 +4161,15 @@ } } }, + "node_modules/deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "license": "MIT", + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -3848,6 +4223,34 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -3898,7 +4301,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "dev": true, "license": "MIT", "dependencies": { "call-bind-apply-helpers": "^1.0.1", @@ -3909,6 +4311,12 @@ "node": ">= 0.4" } }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, "node_modules/electron-to-chromium": { "version": "1.5.87", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.87.tgz", @@ -3936,6 +4344,24 @@ "dev": true, "license": "MIT" }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, "node_modules/environment": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", @@ -4029,7 +4455,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -4039,7 +4464,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -4049,7 +4473,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", - "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0" @@ -4112,6 +4535,12 @@ "node": ">=6" } }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -4559,6 +4988,15 @@ "node": ">=0.10.0" } }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/eventemitter3": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", @@ -4599,6 +5037,15 @@ "node": ">= 0.8.0" } }, + "node_modules/expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "license": "(MIT OR WTFPL)", + "engines": { + "node": ">=6" + } + }, "node_modules/expect": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz", @@ -4616,6 +5063,67 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/express": { + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz", + "integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "~1.20.3", + "content-disposition": "~0.5.4", + "content-type": "~1.0.4", + "cookie": "~0.7.1", + "cookie-signature": "~1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.3.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "~0.1.12", + "proxy-addr": "~2.0.7", + "qs": "~6.14.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "~0.19.0", + "serve-static": "~1.16.2", + "setprototypeof": "1.2.0", + "statuses": "~2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/express/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -4707,7 +5215,13 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/fill-range": { + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "license": "MIT" + }, + "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", @@ -4720,6 +5234,39 @@ "node": ">=8" } }, + "node_modules/finalhandler": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", + "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "statuses": "~2.0.2", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/finalhandler/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/finalhandler/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, "node_modules/find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", @@ -4766,6 +5313,30 @@ "is-callable": "^1.1.3" } }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "license": "MIT" + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -4792,7 +5363,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -4866,7 +5436,6 @@ "version": "1.2.7", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.7.tgz", "integrity": "sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==", - "dev": true, "license": "MIT", "dependencies": { "call-bind-apply-helpers": "^1.0.1", @@ -4901,7 +5470,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", - "dev": true, "license": "MIT", "dependencies": { "dunder-proto": "^1.0.1", @@ -4942,6 +5510,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", + "license": "MIT" + }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -5032,7 +5606,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -5111,7 +5684,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -5140,7 +5712,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dev": true, "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -5156,6 +5727,26 @@ "dev": true, "license": "MIT" }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -5166,6 +5757,54 @@ "node": ">=10.17.0" } }, + "node_modules/husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "dev": true, + "license": "MIT", + "bin": { + "husky": "bin.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -5249,7 +5888,12 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, + "license": "ISC" + }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "license": "ISC" }, "node_modules/internal-slot": { @@ -5267,6 +5911,15 @@ "node": ">= 0.4" } }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/is-array-buffer": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", @@ -6869,6 +7522,15 @@ "yallist": "^3.0.2" } }, + "node_modules/luxon": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.7.2.tgz", + "integrity": "sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew==", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", @@ -6912,12 +7574,29 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" } }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -6935,6 +7614,15 @@ "node": ">= 8" } }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -6949,6 +7637,39 @@ "node": ">=8.6" } }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -6972,6 +7693,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -6989,17 +7722,27 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "license": "MIT" + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, + "license": "MIT" + }, + "node_modules/napi-build-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz", + "integrity": "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==", "license": "MIT" }, "node_modules/natural-compare": { @@ -7009,6 +7752,51 @@ "dev": true, "license": "MIT" }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-abi": { + "version": "3.85.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.85.0.tgz", + "integrity": "sha512-zsFhmbkAzwhTft6nd3VxcG0cvJsT70rL+BIGHWVq5fi6MwGrHwzqKaxXE+Hl2GmnGItnDKPPkO5/LQqjVkIdFg==", + "license": "MIT", + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-abi/node_modules/semver": { + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-cron": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.3.tgz", + "integrity": "sha512-dOal67//nohNgYWb+nWmg5dkFdIwDm8EpeGYMekPMrngV3637lqnX0lbUcCtgibHTz6SEz7DAIjKvKDFYCnO1A==", + "license": "ISC", + "dependencies": { + "uuid": "8.3.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -7050,7 +7838,6 @@ "version": "1.13.3", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", "integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -7158,11 +7945,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, "license": "ISC", "dependencies": { "wrappy": "1" @@ -7307,6 +8105,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -7344,6 +8151,12 @@ "dev": true, "license": "MIT" }, + "node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "license": "MIT" + }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -7420,6 +8233,32 @@ "node": ">= 0.4" } }, + "node_modules/prebuild-install": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz", + "integrity": "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==", + "license": "MIT", + "dependencies": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^2.0.0", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -7501,6 +8340,29 @@ "node": ">= 6" } }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/pump": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz", + "integrity": "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==", + "license": "MIT", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -7528,6 +8390,21 @@ ], "license": "MIT" }, + "node_modules/qs": { + "version": "6.14.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz", + "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -7549,6 +8426,54 @@ ], "license": "MIT" }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "license": "(BSD-2-Clause OR MIT OR Apache-2.0)", + "dependencies": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" + } + }, + "node_modules/rc/node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", @@ -7556,6 +8481,20 @@ "dev": true, "license": "MIT" }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/reflect.getprototypeof": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", @@ -7877,6 +8816,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/safe-push-apply": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/safe-push-apply/-/safe-push-apply-1.0.0.tgz", @@ -7912,6 +8871,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, "node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -7922,6 +8887,60 @@ "semver": "bin/semver.js" } }, + "node_modules/send": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz", + "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.4.1", + "range-parser": "~1.2.1", + "statuses": "~2.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/send/node_modules/debug/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", + "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "~0.19.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -7971,6 +8990,12 @@ "node": ">= 0.4" } }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -7998,7 +9023,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", - "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -8018,7 +9042,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", - "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -8035,7 +9058,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", - "dev": true, "license": "MIT", "dependencies": { "call-bound": "^1.0.2", @@ -8054,7 +9076,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", - "dev": true, "license": "MIT", "dependencies": { "call-bound": "^1.0.2", @@ -8077,6 +9098,51 @@ "dev": true, "license": "ISC" }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, "node_modules/sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", @@ -8175,6 +9241,24 @@ "node": ">=8" } }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, "node_modules/string-argv": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz", @@ -8394,6 +9478,34 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/tar-fs": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", + "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", + "license": "MIT", + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "license": "MIT", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -8436,6 +9548,15 @@ "node": ">=8.0" } }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, "node_modules/ts-api-utils": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.3.tgz", @@ -8492,6 +9613,18 @@ "dev": true, "license": "0BSD" }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -8528,6 +9661,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/typed-array-buffer": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", @@ -8717,6 +9863,15 @@ "node": ">=4" } }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/update-browserslist-db": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.2.tgz", @@ -8758,6 +9913,30 @@ "punycode": "^2.1.0" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", @@ -8773,6 +9952,15 @@ "node": ">=10.12.0" } }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", @@ -8961,7 +10149,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true, "license": "ISC" }, "node_modules/write-file-atomic": { @@ -8978,6 +10165,27 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/ws": { + "version": "8.18.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", + "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index a56edee..d27de46 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@johnpc/subsyncarr", + "name": "@johnpc/subsyncarr-plus", "version": "0.1.0", "license": "UNLICENSED", "engines": { @@ -7,27 +7,41 @@ }, "scripts": { "clean": "rm -rf dist; rm -rf node_modules; rm -rf build/* && rm -rf build", - "build": "prettier --write \"**/*\" && tsc", + "build": "tsc", + "start": "node dist/index-server.js", + "start:legacy": "node dist/index.js", "watch": "tsc -w", "lint": "eslint .", - "lint:fix": "npm run lint -- --fix", + "lint:fix": "prettier --write \"**/*\" && npm run lint -- --fix", "test": "echo \"todo: write tests\"", - "prepare": "husky" + "prepare": "husky || true" }, - "main": "./dist/index.js", - "exports": "./dist/index.js", + "main": "./dist/index-server.js", + "exports": "./dist/index-server.js", "files": [ "dist/", "!**/__tests__/**" ], + "dependencies": { + "better-sqlite3": "^9.4.0", + "cron-parser": "^5.4.0", + "cronstrue": "^3.9.0", + "express": "^4.18.2", + "node-cron": "^3.0.3", + "ws": "^8.16.0" + }, "devDependencies": { "@babel/core": "^7.24.7", "@babel/preset-env": "^7.24.7", "@babel/preset-typescript": "^7.24.7", "@tsconfig/node18": "^18.2.4", + "@types/better-sqlite3": "^7.6.8", + "@types/express": "^4.17.21", "@types/jest": "^29.5.12", "@types/node": "^22.10.10", + "@types/node-cron": "^3.0.11", "@types/uuid": "^10.0.0", + "@types/ws": "^8.5.10", "babel-jest": "^29.7.0", "eslint": "^8.2.0", "eslint-config-airbnb-base": "^15.0.0", @@ -35,6 +49,7 @@ "eslint-plugin-import": "^2.25.2", "eslint-plugin-prettier": "^5.2.1", "globals": "^15.4.0", + "husky": "^9.0.11", "jest": "^29.7.0", "jest-mock": "^29.7.0", "lint-staged": "^15.2.10", diff --git a/public/app.js b/public/app.js new file mode 100644 index 0000000..9929892 --- /dev/null +++ b/public/app.js @@ -0,0 +1,568 @@ +class SubsyncarrPlusClient { + constructor() { + this.ws = null; + this.state = { currentRun: null, files: [], isRunning: false }; + this.reconnectInterval = 3000; + + this.initWebSocket(); + this.setupEventHandlers(); + this.fetchInitialState(); + this.fetchConfigStatus(); + } + + initWebSocket() { + const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:'; + this.ws = new WebSocket(`${protocol}//${location.host}/ws`); + + this.ws.onopen = () => { + console.log('WebSocket connected'); + }; + + this.ws.onmessage = (event) => { + const msg = JSON.parse(event.data); + this.handleMessage(msg); + }; + + this.ws.onclose = () => { + console.log('WebSocket disconnected, reconnecting...'); + setTimeout(() => this.initWebSocket(), this.reconnectInterval); + }; + + this.ws.onerror = (error) => { + console.error('WebSocket error:', error); + }; + } + + handleMessage(msg) { + switch (msg.type) { + case 'state': + this.state = msg.data; + this.render(); + break; + case 'run:started': + this.state.currentRun = msg.data; + this.state.isRunning = true; + this.render(); + break; + case 'run:completed': + this.state.currentRun = msg.data; + this.state.isRunning = false; + this.render(); + this.fetchHistory(); + break; + case 'run:cancelled': + this.state.currentRun = msg.data; + this.state.isRunning = false; + this.render(); + this.fetchHistory(); + break; + case 'file:updated': + this.updateFile(msg.data.file); + if (msg.data.run) { + this.state.currentRun = msg.data.run; + } + this.render(); + break; + case 'files:cleared': + this.state.currentRun = msg.data.currentRun; + this.state.files = msg.data.files; + this.render(); + break; + } + } + + updateFile(fileData) { + const index = this.state.files.findIndex((f) => f.file_path === fileData.file_path); + if (index >= 0) { + this.state.files[index] = fileData; + } else { + this.state.files.push(fileData); + } + } + + async fetchInitialState() { + const response = await fetch('/api/status'); + const data = await response.json(); + this.state = data; + this.render(); + this.fetchHistory(); + } + + async fetchHistory() { + const response = await fetch('/api/history'); + const history = await response.json(); + + // Fetch file results for each run to calculate engine stats + const historyWithStats = await Promise.all( + history.map(async (run) => { + try { + const filesResponse = await fetch(`/api/runs/${run.id}`); + const data = await filesResponse.json(); + return { ...run, files: data.files || [] }; + } catch (error) { + console.error(`Failed to fetch files for run ${run.id}:`, error); + return { ...run, files: [] }; + } + }) + ); + + this.renderHistory(historyWithStats); + } + + async fetchConfigStatus() { + try { + const response = await fetch('/api/config'); + const config = await response.json(); + this.renderConfigStatus(config); + } catch (error) { + console.error('Failed to fetch config status:', error); + this.renderConfigStatus({ isConfigured: false, paths: [], excludePaths: [] }); + } + } + + renderConfigStatus(config) { + // Render path status + const light = document.getElementById('statusLight'); + const label = document.getElementById('statusLabel'); + const paths = document.getElementById('statusPaths'); + + if (config.isConfigured) { + light.className = 'status-light active'; + label.textContent = 'Watching Folders'; + const pathsList = config.paths.join(', '); + paths.textContent = pathsList; + paths.title = pathsList; // Show full path on hover + } else { + light.className = 'status-light inactive'; + label.textContent = 'No Paths Configured'; + paths.textContent = 'Using default: /scan_dir'; + } + + // Render schedule status + this.renderScheduleStatus(config.schedule); + } + + renderScheduleStatus(schedule) { + const scheduleLabel = document.getElementById('scheduleLabel'); + const scheduleTime = document.getElementById('scheduleTime'); + + if (schedule && schedule.enabled) { + scheduleLabel.textContent = 'Next Scheduled Scan'; + + if (schedule.nextRun) { + const nextRunDate = new Date(schedule.nextRun); + const now = new Date(); + const diff = nextRunDate - now; + + // Format time until next run + const timeUntil = this.formatTimeUntil(diff); + scheduleTime.textContent = `${nextRunDate.toLocaleString()} (${timeUntil})`; + scheduleTime.title = `Schedule: ${schedule.description}`; + + // Update countdown every minute + if (this.scheduleUpdateTimer) { + clearInterval(this.scheduleUpdateTimer); + } + this.scheduleUpdateTimer = setInterval(() => { + this.fetchConfigStatus(); + }, 60000); // Update every minute + } else { + scheduleTime.textContent = schedule.description || schedule.cron; + } + } else { + scheduleLabel.textContent = 'Auto-Scan Disabled'; + scheduleTime.textContent = 'Manual runs only'; + } + } + + formatTimeUntil(milliseconds) { + const seconds = Math.floor(milliseconds / 1000); + const minutes = Math.floor(seconds / 60); + const hours = Math.floor(minutes / 60); + const days = Math.floor(hours / 24); + + if (days > 0) { + return `in ${days} day${days > 1 ? 's' : ''}`; + } else if (hours > 0) { + return `in ${hours} hour${hours > 1 ? 's' : ''}`; + } else if (minutes > 0) { + return `in ${minutes} minute${minutes > 1 ? 's' : ''}`; + } else { + return 'very soon'; + } + } + + setupEventHandlers() { + document.getElementById('startRun').addEventListener('click', () => { + this.startRun(); + }); + + document.getElementById('startCustom').addEventListener('click', () => { + document.getElementById('customPathModal').classList.remove('hidden'); + document.getElementById('customPaths').value = ''; // Clear previous input + }); + + document.getElementById('stopRun').addEventListener('click', () => { + this.stopRun(); + }); + + document.getElementById('closeModal').addEventListener('click', () => { + console.log('Close button clicked'); + document.getElementById('customPathModal').classList.add('hidden'); + document.getElementById('customPaths').value = ''; + }); + + document.getElementById('cancelCustom').addEventListener('click', () => { + document.getElementById('customPathModal').classList.add('hidden'); + document.getElementById('customPaths').value = ''; + }); + + document.getElementById('submitCustom').addEventListener('click', () => { + const paths = document + .getElementById('customPaths') + .value.split('\n') + .map((p) => p.trim()) + .filter((p) => p.length > 0); + + document.getElementById('customPathModal').classList.add('hidden'); + document.getElementById('customPaths').value = ''; + this.startRun(paths); + }); + + // Close modal when clicking outside + document.getElementById('customPathModal').addEventListener('click', (e) => { + if (e.target.id === 'customPathModal') { + document.getElementById('customPathModal').classList.add('hidden'); + document.getElementById('customPaths').value = ''; + } + }); + + // Logs modal handlers + document.getElementById('closeLogsModal').addEventListener('click', () => { + document.getElementById('logsModal').classList.add('hidden'); + }); + + document.getElementById('closeLogsButton').addEventListener('click', () => { + document.getElementById('logsModal').classList.add('hidden'); + }); + + document.getElementById('copyLogs').addEventListener('click', async () => { + const logsContent = document.getElementById('logsContent').textContent; + try { + await navigator.clipboard.writeText(logsContent); + const btn = document.getElementById('copyLogs'); + const originalText = btn.textContent; + btn.textContent = '✓ Copied!'; + setTimeout(() => { + btn.textContent = originalText; + }, 2000); + } catch (err) { + console.error('Failed to copy logs:', err); + // Fallback method for older browsers or permission issues + const textArea = document.createElement('textarea'); + textArea.value = logsContent; + textArea.style.position = 'fixed'; + textArea.style.left = '-999999px'; + document.body.appendChild(textArea); + textArea.select(); + try { + document.execCommand('copy'); + const btn = document.getElementById('copyLogs'); + const originalText = btn.textContent; + btn.textContent = '✓ Copied!'; + setTimeout(() => { + btn.textContent = originalText; + }, 2000); + } catch (execErr) { + console.error('Fallback copy also failed:', execErr); + alert('Failed to copy logs to clipboard'); + } + document.body.removeChild(textArea); + } + }); + + // Close logs modal when clicking outside + document.getElementById('logsModal').addEventListener('click', (e) => { + if (e.target.id === 'logsModal') { + document.getElementById('logsModal').classList.add('hidden'); + } + }); + + // Clear completed files + document.getElementById('clearCompleted').addEventListener('click', () => { + this.clearCompleted(); + }); + } + + async startRun(paths = null) { + try { + const response = await fetch('/api/run/start', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ paths }), + }); + + if (!response.ok) { + const error = await response.json(); + alert(`Failed to start run: ${error.error}`); + } + } catch (error) { + alert(`Failed to start run: ${error.message}`); + } + } + + async stopRun() { + if (!confirm('Are you sure you want to stop the current run? All processing will be halted.')) { + return; + } + + try { + const response = await fetch('/api/run/stop', { + method: 'POST', + }); + + if (!response.ok) { + const error = await response.json(); + alert(`Failed to stop run: ${error.error}`); + } + } catch (error) { + alert(`Failed to stop run: ${error.message}`); + } + } + + async skipFile(filePath) { + try { + await fetch('/api/file/skip', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ filePath }), + }); + } catch (error) { + console.error('Failed to skip file:', error); + } + } + + async viewLogs(runId) { + try { + const response = await fetch(`/api/runs/${runId}/logs`); + const data = await response.json(); + + document.getElementById('logsContent').textContent = data.logs || 'No logs available'; + document.getElementById('logsModal').classList.remove('hidden'); + } catch (error) { + console.error('Failed to fetch logs:', error); + alert('Failed to load logs'); + } + } + + async clearCompleted() { + if (!confirm('Are you sure you want to clear all completed and skipped files?')) { + return; + } + + try { + const response = await fetch('/api/files/clear', { + method: 'POST', + }); + + if (!response.ok) { + throw new Error('Failed to clear files'); + } + + // State will be updated via WebSocket message + } catch (error) { + console.error('Failed to clear files:', error); + alert('Failed to clear files'); + } + } + + render() { + this.renderProgress(); + this.renderFiles(); + this.updateButtonVisibility(); + } + + updateButtonVisibility() { + const stopButton = document.getElementById('stopRun'); + const startButton = document.getElementById('startRun'); + const customButton = document.getElementById('startCustom'); + + if (this.state.isRunning) { + stopButton.classList.remove('hidden'); + startButton.classList.add('hidden'); + customButton.classList.add('hidden'); + } else { + stopButton.classList.add('hidden'); + startButton.classList.remove('hidden'); + customButton.classList.remove('hidden'); + } + } + + renderProgress() { + const { currentRun } = this.state; + const section = document.getElementById('currentRun'); + + if (!currentRun || currentRun.status === 'completed') { + section.classList.add('hidden'); + return; + } + + section.classList.remove('hidden'); + + // Use engine-level progress for more granular updates + const percent = + currentRun.total_engines > 0 ? (currentRun.completed_engines / currentRun.total_engines) * 100 : 0; + document.getElementById('progressFill').style.width = `${percent}%`; + document.getElementById('progressText').textContent = `${currentRun.completed} / ${currentRun.total_files} files (${Math.round(percent)}%)`; + } + + renderFiles() { + const processing = this.state.files.filter((f) => f.status === 'processing'); + const completed = this.state.files.filter((f) => ['completed', 'skipped', 'error'].includes(f.status)); + + // Render processing files + const progressHtml = processing + .map((file) => { + const engines = JSON.parse(file.engines); + return ` +
+
+
${this.basename(file.file_path)}
+ +
+
+ ${file.current_engine ? `⚙️ Working on ${file.current_engine}` : 'Starting...'} +
+ ${this.renderEngineResults(engines)} +
+ `; + }) + .join(''); + + document.getElementById('filesInProgress').innerHTML = progressHtml; + + // Render completed files + const completedHtml = completed + .map((file) => { + const engines = JSON.parse(file.engines); + return ` +
+
${this.basename(file.file_path)}
+ ${this.renderEngineResults(engines)} +
+ `; + }) + .join(''); + + document.getElementById('completedList').innerHTML = + completedHtml || '

No completed files yet

'; + } + + renderEngineResults(engines) { + return Object.entries(engines) + .map(([name, result]) => { + const icon = result.success ? '✓' : '✗'; + const className = result.success ? 'success' : 'error'; + const duration = (result.duration / 1000).toFixed(1); + + return ` +
+ ${icon} ${name} + ${duration}s +
+ `; + }) + .join(''); + } + + calculateEngineStats(files) { + const stats = { + ffsubsync: { pass: 0, fail: 0 }, + autosubsync: { pass: 0, fail: 0 }, + alass: { pass: 0, fail: 0 }, + }; + + files.forEach((file) => { + try { + const engines = JSON.parse(file.engines); + Object.entries(engines).forEach(([engineName, result]) => { + if (stats[engineName]) { + if (result.success) { + stats[engineName].pass++; + } else { + stats[engineName].fail++; + } + } + }); + } catch (error) { + console.error('Error parsing engine data:', error); + } + }); + + return stats; + } + + renderEngineCell(engineStats) { + if (engineStats.pass === 0 && engineStats.fail === 0) { + return '-'; + } + + const parts = []; + if (engineStats.pass > 0) { + parts.push(`${engineStats.pass}`); + } + if (engineStats.fail > 0) { + parts.push(`${engineStats.fail}`); + } + + return `${parts.join('/')}`; + } + + renderHistory(runs) { + const html = runs + .map((run) => { + const duration = run.end_time ? ((run.end_time - run.start_time) / 1000).toFixed(0) + 's' : 'Running...'; + const engineStats = this.calculateEngineStats(run.files || []); + + return ` + + ${new Date(run.start_time).toLocaleString()} + ${run.status} + ${run.total_files} + ${run.completed} + ${run.skipped} + ${run.failed} + ${this.renderEngineCell(engineStats.ffsubsync)} + ${this.renderEngineCell(engineStats.autosubsync)} + ${this.renderEngineCell(engineStats.alass)} + ${duration} + + + + + `; + }) + .join(''); + + document.getElementById('historyBody').innerHTML = + html || 'No runs yet'; + } + + basename(path) { + return path.split('/').pop(); + } +} + +// Initialize client when DOM is ready +let client; +if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', () => { + client = new SubsyncarrPlusClient(); + }); +} else { + client = new SubsyncarrClient(); +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..da9499c --- /dev/null +++ b/public/index.html @@ -0,0 +1,121 @@ + + + + + + Subsyncarr+ + + + + +
+
+
+
+

🧬 Subsyncarr+

+

Subtitle Synchronization

+
+
+
+
+
+
Loading...
+
+
+
+
+
+
+
Loading...
+
+
+
+
+
+
+ + + +
+
+ + + +
+
+

Completed & Skipped Files

+ +
+
+
+ +
+

Run History

+
+ Engine Results Key: + 1-9 = Passed files + 1-9 = Failed files + Engines: F=ffsubsync, Au=autosubsync, Al=alass +
+ + + + + + + + + + + + + + + + + +
Start TimeStatusFilesCompletedSkippedFailedFAuAlDurationActions
+
+
+ + + + + + + + diff --git a/public/styles.css b/public/styles.css new file mode 100644 index 0000000..45ad449 --- /dev/null +++ b/public/styles.css @@ -0,0 +1,528 @@ +:root { + --primary: #3b82f6; + --primary-dark: #2563eb; + --success: #10b981; + --error: #ef4444; + --warning: #f59e0b; + --background: #f9fafb; + --card-bg: #ffffff; + --border: #e5e7eb; + --text: #111827; + --text-secondary: #6b7280; +} + +* { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; + background: var(--background); + color: var(--text); + line-height: 1.5; +} + +.container { + max-width: 1200px; + margin: 0 auto; + padding: 20px; +} + +header { + background: var(--card-bg); + padding: 24px; + border-radius: 8px; + margin-bottom: 20px; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); +} + +.header-top { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 16px; + gap: 20px; +} + +h1 { + font-size: 28px; + margin-bottom: 4px; +} + +.subtitle { + color: var(--text-secondary); + margin-bottom: 0; +} + +.status-indicators { + display: flex; + flex-direction: column; + gap: 8px; +} + +.status-indicator, +.schedule-indicator { + display: flex; + align-items: center; + gap: 12px; + padding: 12px 16px; + background: var(--background); + border-radius: 6px; + min-width: 200px; +} + +.status-light { + width: 16px; + height: 16px; + border-radius: 50%; + flex-shrink: 0; +} + +.status-light.active { + background: #10b981; + box-shadow: 0 0 8px rgba(16, 185, 129, 0.6); + animation: pulse-green 2s infinite; +} + +.status-light.inactive { + background: #f59e0b; + box-shadow: 0 0 8px rgba(245, 158, 11, 0.6); + animation: pulse-orange 2s infinite; +} + +@keyframes pulse-green { + 0%, 100% { + box-shadow: 0 0 8px rgba(16, 185, 129, 0.6); + } + 50% { + box-shadow: 0 0 16px rgba(16, 185, 129, 0.9), 0 0 24px rgba(16, 185, 129, 0.4); + } +} + +@keyframes pulse-orange { + 0%, 100% { + box-shadow: 0 0 8px rgba(245, 158, 11, 0.6); + } + 50% { + box-shadow: 0 0 16px rgba(245, 158, 11, 0.9), 0 0 24px rgba(245, 158, 11, 0.4); + } +} + +.status-text { + display: flex; + flex-direction: column; + gap: 2px; + min-width: 0; +} + +.status-label { + font-weight: 600; + font-size: 13px; + color: var(--text); +} + +.status-paths { + font-size: 11px; + color: var(--text-secondary); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.schedule-icon { + font-size: 16px; + flex-shrink: 0; + width: 16px; + text-align: center; +} + +.controls { + display: flex; + gap: 12px; +} + +.btn { + padding: 10px 20px; + border: none; + border-radius: 6px; + font-size: 14px; + font-weight: 500; + cursor: pointer; + transition: all 0.2s; +} + +.btn-primary { + background: var(--primary); + color: white; +} + +.btn-primary:hover { + background: var(--primary-dark); +} + +.btn-secondary { + background: var(--border); + color: var(--text); +} + +.btn-secondary:hover { + background: #d1d5db; +} + +.btn-danger { + background: var(--error); + color: white; +} + +.btn-danger:hover { + background: #dc2626; +} + +.btn-skip { + padding: 6px 12px; + background: var(--error); + color: white; + border: none; + border-radius: 4px; + font-size: 12px; + cursor: pointer; +} + +.btn-skip:hover { + opacity: 0.9; +} + +section { + background: var(--card-bg); + padding: 24px; + border-radius: 8px; + margin-bottom: 20px; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); +} + +h2 { + font-size: 18px; + margin-bottom: 16px; + color: var(--text); +} + +.section-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 16px; +} + +.section-header h2 { + margin-bottom: 0; +} + +.btn-sm { + padding: 6px 12px; + font-size: 13px; +} + +.hidden { + display: none !important; +} + +.progress-wrapper { + display: flex; + align-items: center; + gap: 12px; + margin-bottom: 20px; +} + +.progress-bar { + flex: 1; + height: 32px; + background: var(--border); + border-radius: 6px; + overflow: hidden; + position: relative; +} + +.progress-fill { + height: 100%; + background: var(--primary); + transition: width 0.3s ease; +} + +.progress-text { + font-weight: 600; + color: var(--text); + min-width: 80px; + text-align: right; +} + +.file-card { + background: #f9fafb; + padding: 16px; + border-radius: 6px; + margin-bottom: 12px; + border-left: 4px solid transparent; +} + +.file-card.processing { + border-left-color: var(--primary); +} + +.file-card.completed { + border-left-color: var(--success); +} + +.file-card.error { + border-left-color: var(--error); +} + +.file-card.skipped { + border-left-color: var(--warning); +} + +.file-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; +} + +.file-name { + font-weight: 500; + word-break: break-all; +} + +.engine-status { + color: var(--text-secondary); + font-size: 14px; + margin-bottom: 8px; +} + +.engine-result { + display: inline-flex; + align-items: center; + justify-content: space-between; + gap: 8px; + padding: 4px 12px; + border-radius: 4px; + font-size: 13px; + margin-right: 8px; + margin-top: 4px; +} + +.engine-result.success { + background: #d1fae5; + color: #065f46; +} + +.engine-result.error { + background: #fee2e2; + color: #991b1b; +} + +.duration { + font-size: 12px; + opacity: 0.7; +} + +table { + width: 100%; + border-collapse: collapse; +} + +thead { + background: var(--background); +} + +th { + text-align: left; + padding: 12px; + font-weight: 600; + font-size: 14px; + color: var(--text-secondary); +} + +td { + padding: 12px; + border-top: 1px solid var(--border); +} + +.status-badge { + padding: 4px 8px; + border-radius: 4px; + font-size: 12px; + font-weight: 500; +} + +.status-badge.running { + background: #dbeafe; + color: #1e40af; +} + +.status-badge.completed { + background: #d1fae5; + color: #065f46; +} + +.status-badge.cancelled { + background: #fef3c7; + color: #92400e; +} + +.no-data { + color: var(--text-secondary); + text-align: center; + padding: 20px; +} + +.modal { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.5); + display: flex; + align-items: center; + justify-content: center; + z-index: 1000; +} + +.modal-content { + background: var(--card-bg); + padding: 24px; + border-radius: 8px; + max-width: 500px; + width: 90%; +} + +.modal-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 16px; +} + +.modal-header h3 { + margin: 0; +} + +.btn-close { + background: none; + border: none; + font-size: 32px; + line-height: 1; + color: var(--text-secondary); + cursor: pointer; + padding: 0; + width: 32px; + height: 32px; + display: flex; + align-items: center; + justify-content: center; + border-radius: 4px; + transition: all 0.2s; +} + +.btn-close:hover { + background: var(--border); + color: var(--text); +} + +#customPaths { + width: 100%; + min-height: 120px; + padding: 12px; + border: 1px solid var(--border); + border-radius: 6px; + font-family: monospace; + font-size: 14px; + margin-bottom: 16px; + resize: vertical; +} + +.modal-actions { + display: flex; + gap: 12px; + justify-content: flex-end; +} + +.file-list { + max-height: 400px; + overflow-y: auto; +} + +.btn-view-logs { + padding: 6px 12px; + background: var(--primary); + color: white; + border: none; + border-radius: 4px; + font-size: 12px; + cursor: pointer; + transition: all 0.2s; +} + +.btn-view-logs:hover { + background: var(--primary-dark); +} + +.modal-content.logs-modal { + max-width: 900px; + width: 90%; + max-height: 80vh; + display: flex; + flex-direction: column; +} + +.logs-content { + flex: 1; + background: #1e1e1e; + color: #d4d4d4; + padding: 16px; + border-radius: 6px; + font-family: 'Consolas', 'Monaco', 'Courier New', monospace; + font-size: 12px; + line-height: 1.5; + overflow: auto; + margin-bottom: 16px; + white-space: pre-wrap; + word-wrap: break-word; +} + +.engine-key { + background: var(--background); + padding: 12px 16px; + border-radius: 6px; + margin-bottom: 16px; + font-size: 13px; + display: flex; + flex-wrap: wrap; + gap: 16px; + align-items: center; +} + +.key-title { + font-weight: 600; + color: var(--text); +} + +.key-item { + color: var(--text-secondary); +} + +.engine-cell { + text-align: center; + font-weight: 500; +} + +.engine-pass { + color: #059669; + font-weight: 600; +} + +.engine-fail { + color: #dc2626; + font-weight: 600; +} diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..5318e85 --- /dev/null +++ b/src/config.ts @@ -0,0 +1,62 @@ +export interface ScanConfig { + includePaths: string[]; + excludePaths: string[]; +} + +export interface RetentionConfig { + keepRunsDays: number; // Keep complete runs for N days + trimLogsDays: number; // Trim logs after N days + maxLogSizeBytes: number; // Max size for trimmed logs + cleanupIntervalHours: number; // How often to run cleanup +} + +function validatePath(path: string): boolean { + // Add any path validation logic you need + return path.startsWith('/') && !path.includes('..'); +} + +export function getScanConfig(): ScanConfig { + const scanPaths = process.env.SCAN_PATHS?.split(',').filter(Boolean) || ['/scan_dir']; + const excludePaths = process.env.EXCLUDE_PATHS?.split(',').filter(Boolean) || []; + + // Validate paths + const validIncludePaths = scanPaths.filter((path) => { + const isValid = validatePath(path); + if (!isValid) { + console.warn(`${new Date().toLocaleString()} Invalid include path: ${path}`); + } + return isValid; + }); + + const validExcludePaths = excludePaths.filter((path) => { + const isValid = validatePath(path); + if (!isValid) { + console.warn(`${new Date().toLocaleString()} Invalid exclude path: ${path}`); + } + return isValid; + }); + + if (validIncludePaths.length === 0) { + console.warn(`${new Date().toLocaleString()} No valid scan paths provided, defaulting to /scan_dir`); + validIncludePaths.push('/scan_dir'); + } + + console.log(`${new Date().toLocaleString()} Scan configuration:`, { + includePaths: validIncludePaths, + excludePaths: validExcludePaths, + }); + + return { + includePaths: validIncludePaths, + excludePaths: validExcludePaths, + }; +} + +export function getRetentionConfig(): RetentionConfig { + return { + keepRunsDays: parseInt(process.env.RETENTION_KEEP_RUNS_DAYS || '30', 10), + trimLogsDays: parseInt(process.env.RETENTION_TRIM_LOGS_DAYS || '7', 10), + maxLogSizeBytes: parseInt(process.env.RETENTION_MAX_LOG_SIZE || '10000', 10), + cleanupIntervalHours: parseInt(process.env.RETENTION_CLEANUP_INTERVAL_HOURS || '24', 10), + }; +} diff --git a/src/coordinator.ts b/src/coordinator.ts new file mode 100644 index 0000000..4a76025 --- /dev/null +++ b/src/coordinator.ts @@ -0,0 +1,160 @@ +import { ProcessingEngine } from './processingEngine'; +import { StateManager } from './stateManager'; +import { ScanConfig } from './config'; +import { findMatchingVideoFile } from './findMatchingVideoFile'; + +export class ProcessingCoordinator { + private processingPromise: Promise | null = null; + private enabledEngines: string[]; + + constructor( + private engine: ProcessingEngine, + private stateManager: StateManager, + ) { + this.enabledEngines = process.env.INCLUDE_ENGINES?.split(',') || ['ffsubsync', 'autosubsync', 'alass']; + + // Inject stateManager into engine so it can check skip status + this.engine.stateManager = this.stateManager; + + this.setupEventHandlers(); + } + + private setupEventHandlers() { + let currentRunId: string | null = null; + + this.engine.on('log', (message: string) => { + if (currentRunId) { + this.stateManager.appendLog(currentRunId, message); + } + }); + + this.engine.on('run:files_found', (files: string[]) => { + currentRunId = this.stateManager.startRun(files.length, this.enabledEngines); + + // Add all files to database as pending + files.forEach((filePath) => { + const videoPath = findMatchingVideoFile(filePath); + this.stateManager.addFile(currentRunId!, filePath, videoPath); + }); + }); + + this.engine.on('file:started', ({ srtPath }: { srtPath: string }) => { + if (currentRunId) { + this.stateManager.updateFileStatus(currentRunId, srtPath, 'processing', null); + } + }); + + this.engine.on('file:engine_started', ({ srtPath, engine }: { srtPath: string; engine: string }) => { + if (currentRunId) { + this.stateManager.updateFileStatus(currentRunId, srtPath, 'processing', engine); + } + }); + + this.engine.on( + 'file:engine_completed', + ({ + srtPath, + engine, + result, + }: { + srtPath: string; + engine: string; + result: { + success: boolean; + duration: number; + message: string; + stdout?: string; + stderr?: string; + skipped?: boolean; + }; + }) => { + if (currentRunId) { + this.stateManager.updateFileEngine(currentRunId, srtPath, engine, result); + this.stateManager.incrementCompletedEngines(currentRunId); + } + }, + ); + + this.engine.on('file:completed', ({ srtPath }: { srtPath: string }) => { + if (currentRunId) { + this.stateManager.updateFileStatus(currentRunId, srtPath, 'completed', null); + this.stateManager.incrementRunCounter(currentRunId, 'completed'); + } + }); + + this.engine.on('file:skipped', ({ srtPath }: { srtPath: string }) => { + if (currentRunId) { + this.stateManager.updateFileStatus(currentRunId, srtPath, 'skipped', null); + this.stateManager.incrementRunCounter(currentRunId, 'skipped'); + } + }); + + this.engine.on('file:no_video', ({ srtPath }: { srtPath: string }) => { + if (currentRunId) { + this.stateManager.updateFileStatus(currentRunId, srtPath, 'error', null); + this.stateManager.incrementRunCounter(currentRunId, 'failed'); + } + }); + + this.engine.on('file:failed', ({ srtPath }: { srtPath: string }) => { + if (currentRunId) { + this.stateManager.updateFileStatus(currentRunId, srtPath, 'error', null); + this.stateManager.incrementRunCounter(currentRunId, 'failed'); + } + }); + } + + async startRun(config?: ScanConfig): Promise { + if (this.processingPromise) { + console.log(`[${new Date().toISOString()}] Cannot start run: Another run is already in progress`); + throw new Error('A run is already in progress'); + } + + console.log(`[${new Date().toISOString()}] Starting new processing run...`); + this.engine.reset(); + + this.processingPromise = this.engine.processRun(config).finally(() => { + this.processingPromise = null; + const run = this.stateManager.getCurrentRun(); + if (run) { + console.log( + `[${new Date().toISOString()}] Run completed - Total: ${run.total_files}, Completed: ${run.completed}, Skipped: ${run.skipped}, Failed: ${run.failed}`, + ); + this.stateManager.completeRun(run.id); + } + }); + + // Wait a bit for run to be created + await new Promise((resolve) => setTimeout(resolve, 100)); + + const run = this.stateManager.getCurrentRun(); + console.log(`[${new Date().toISOString()}] Run created with ID: ${run!.id}`); + return run!.id; + } + + skipFile(filePath: string): void { + const fileName = filePath.split('/').pop(); + console.log(`[${new Date().toISOString()}] Skip requested for: ${fileName}`); + this.engine.skipFile(filePath); + } + + stopRun(): void { + console.log(`[${new Date().toISOString()}] Stop run requested`); + const run = this.stateManager.getCurrentRun(); + if (!run) { + throw new Error('No run is currently in progress'); + } + + // Get all files and cancel them + const files = this.stateManager.getFileResults(run.id); + const allFilePaths = files.map((f) => f.file_path); + this.engine.stopAllProcessing(allFilePaths); + + // Mark run as cancelled + this.stateManager.cancelRun(run.id); + } + + isRunning(): boolean { + return this.processingPromise !== null; + } +} diff --git a/src/database.ts b/src/database.ts new file mode 100644 index 0000000..5e553c5 --- /dev/null +++ b/src/database.ts @@ -0,0 +1,405 @@ +import Database from 'better-sqlite3'; + +export interface Run { + id: string; + start_time: number; + end_time: number | null; + total_files: number; + completed: number; + skipped: number; + failed: number; + total_engines: number; + completed_engines: number; + status: 'running' | 'completed' | 'cancelled'; + logs: string; +} + +export interface FileResult { + id: number; + run_id: string; + file_path: string; + video_path: string | null; + status: 'pending' | 'processing' | 'completed' | 'skipped' | 'error'; + current_engine: string | null; + engines: string; // JSON stringified { ffsubsync?: {...}, autosubsync?: {...}, alass?: {...} } + created_at: number; + updated_at: number; +} + +export interface EngineFailureTracking { + id: number; + file_path: string; + engine: string; + consecutive_failures: number; + last_failure_time: number | null; + last_success_time: number | null; + is_skipped: boolean; + created_at: number; + updated_at: number; +} + +export class SubsyncarrPlusDatabase { + private db: Database.Database; + + constructor(dbPath: string) { + this.db = new Database(dbPath); + this.initSchema(); + } + + private initSchema() { + // Optimize SQLite for low memory usage + this.db.pragma('cache_size = -1000'); // 1MB cache (negative means KB) + this.db.pragma('mmap_size = 0'); // Disable memory-mapping + this.db.pragma('journal_mode = WAL'); // Better concurrency + this.db.pragma('temp_store = MEMORY'); // Keep temp data in memory + this.db.pragma('auto_vacuum = INCREMENTAL'); // Reclaim space gradually + + this.db.exec(` + CREATE TABLE IF NOT EXISTS runs ( + id TEXT PRIMARY KEY, + start_time INTEGER NOT NULL, + end_time INTEGER, + total_files INTEGER NOT NULL, + completed INTEGER DEFAULT 0, + skipped INTEGER DEFAULT 0, + failed INTEGER DEFAULT 0, + total_engines INTEGER DEFAULT 0, + completed_engines INTEGER DEFAULT 0, + status TEXT NOT NULL, + logs TEXT DEFAULT '' + ); + + CREATE TABLE IF NOT EXISTS file_results ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + run_id TEXT NOT NULL, + file_path TEXT NOT NULL, + video_path TEXT, + status TEXT NOT NULL, + current_engine TEXT, + engines TEXT DEFAULT '{}', + created_at INTEGER NOT NULL, + updated_at INTEGER NOT NULL, + FOREIGN KEY(run_id) REFERENCES runs(id) + ); + + CREATE INDEX IF NOT EXISTS idx_file_results_run + ON file_results(run_id); + CREATE INDEX IF NOT EXISTS idx_file_results_status + ON file_results(status); + `); + + // Migration: Add logs column if it doesn't exist + const columns = this.db.pragma('table_info(runs)') as Array<{ name: string }>; + const hasLogsColumn = columns.some((col) => col.name === 'logs'); + if (!hasLogsColumn) { + this.db.exec(`ALTER TABLE runs ADD COLUMN logs TEXT DEFAULT ''`); + } + + // Migration: Add total_engines and completed_engines columns if they don't exist + const hasTotalEnginesColumn = columns.some((col) => col.name === 'total_engines'); + if (!hasTotalEnginesColumn) { + this.db.exec(`ALTER TABLE runs ADD COLUMN total_engines INTEGER DEFAULT 0`); + } + const hasCompletedEnginesColumn = columns.some((col) => col.name === 'completed_engines'); + if (!hasCompletedEnginesColumn) { + this.db.exec(`ALTER TABLE runs ADD COLUMN completed_engines INTEGER DEFAULT 0`); + } + + // Migration: Create engine_failure_tracking table + const tables = this.db + .prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='engine_failure_tracking'") + .all(); + if (tables.length === 0) { + this.db.exec(` + CREATE TABLE engine_failure_tracking ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + file_path TEXT NOT NULL, + engine TEXT NOT NULL, + consecutive_failures INTEGER DEFAULT 0, + last_failure_time INTEGER, + last_success_time INTEGER, + is_skipped BOOLEAN DEFAULT 0, + created_at INTEGER NOT NULL, + updated_at INTEGER NOT NULL, + UNIQUE(file_path, engine) + ); + + CREATE INDEX idx_failure_tracking_file ON engine_failure_tracking(file_path); + CREATE INDEX idx_failure_tracking_skipped ON engine_failure_tracking(is_skipped); + `); + } + } + + // Run methods + createRun(id: string, totalFiles: number): void { + const stmt = this.db.prepare(` + INSERT INTO runs (id, start_time, total_files, status) + VALUES (?, ?, ?, 'running') + `); + stmt.run(id, Date.now(), totalFiles); + } + + updateRun(id: string, updates: Partial): void { + const fields = Object.keys(updates) + .map((k) => `${k} = ?`) + .join(', '); + const values = Object.values(updates); + this.db.prepare(`UPDATE runs SET ${fields} WHERE id = ?`).run(...values, id); + } + + getRun(id: string): Run | null { + const result = this.db.prepare('SELECT * FROM runs WHERE id = ?').get(id); + return result ? (result as Run) : null; + } + + getRunHistory(limit: number = 50): Run[] { + return this.db + .prepare( + ` + SELECT * FROM runs + ORDER BY start_time DESC + LIMIT ? + `, + ) + .all(limit) as Run[]; + } + + /** + * Delete old runs and their associated file results + */ + deleteOldRuns(olderThanDays: number): number { + const cutoffTime = Date.now() - olderThanDays * 24 * 60 * 60 * 1000; + + // Use transaction for atomicity + const deleteFiles = this.db.prepare( + 'DELETE FROM file_results WHERE run_id IN (SELECT id FROM runs WHERE start_time < ?)', + ); + const deleteRuns = this.db.prepare('DELETE FROM runs WHERE start_time < ?'); + + const transaction = this.db.transaction(() => { + deleteFiles.run(cutoffTime); + const result = deleteRuns.run(cutoffTime); + return result.changes; + }); + + return transaction(); + } + + /** + * Trim logs for runs older than specified days, keeping only summary + */ + trimOldLogs(olderThanDays: number, maxLogLength: number = 1000): number { + const cutoffTime = Date.now() - olderThanDays * 24 * 60 * 60 * 1000; + + const stmt = this.db.prepare(` + UPDATE runs + SET logs = SUBSTR(logs, 1, ?) || '\n... (log trimmed to save space)' + WHERE start_time < ? AND LENGTH(logs) > ? + `); + + const result = stmt.run(maxLogLength, cutoffTime, maxLogLength); + return result.changes; + } + + /** + * Vacuum database to reclaim space after deletions + */ + vacuum(): void { + this.db.pragma('incremental_vacuum'); + } + + /** + * Get database file size statistics + */ + getDatabaseStats(): { sizeBytes: number; pageCount: number; pageSize: number } { + const pageCount = this.db.pragma('page_count', { simple: true }) as number; + const pageSize = this.db.pragma('page_size', { simple: true }) as number; + + return { + pageCount, + pageSize, + sizeBytes: pageCount * pageSize, + }; + } + + // File methods + createFileResult(runId: string, filePath: string, videoPath: string | null): void { + const stmt = this.db.prepare(` + INSERT INTO file_results + (run_id, file_path, video_path, status, created_at, updated_at) + VALUES (?, ?, ?, 'pending', ?, ?) + `); + const now = Date.now(); + stmt.run(runId, filePath, videoPath, now, now); + } + + updateFileResult(runId: string, filePath: string, updates: Partial): void { + const updatesWithTimestamp = { ...updates, updated_at: Date.now() }; + const fields = Object.keys(updatesWithTimestamp) + .map((k) => `${k} = ?`) + .join(', '); + const values = Object.values(updatesWithTimestamp); + this.db + .prepare( + ` + UPDATE file_results + SET ${fields} + WHERE run_id = ? AND file_path = ? + `, + ) + .run(...values, runId, filePath); + } + + getFileResults(runId: string): FileResult[] { + return this.db + .prepare( + ` + SELECT * FROM file_results + WHERE run_id = ? + ORDER BY created_at ASC + `, + ) + .all(runId) as FileResult[]; + } + + // Engine failure tracking methods + getEngineFailureTracking(filePath: string, engine: string): EngineFailureTracking | null { + return this.db + .prepare( + `SELECT * FROM engine_failure_tracking + WHERE file_path = ? AND engine = ?`, + ) + .get(filePath, engine) as EngineFailureTracking | null; + } + + getAllSkippedEngines(filePath: string): string[] { + const results = this.db + .prepare( + `SELECT engine FROM engine_failure_tracking + WHERE file_path = ? AND is_skipped = 1`, + ) + .all(filePath) as Array<{ engine: string }>; + return results.map((r) => r.engine); + } + + recordEngineFailure(filePath: string, engine: string): void { + const existing = this.getEngineFailureTracking(filePath, engine); + const now = Date.now(); + + if (existing) { + const newFailureCount = existing.consecutive_failures + 1; + const isSkipped = newFailureCount >= 3; + + this.db + .prepare( + ` + UPDATE engine_failure_tracking + SET consecutive_failures = ?, + last_failure_time = ?, + is_skipped = ?, + updated_at = ? + WHERE file_path = ? AND engine = ? + `, + ) + .run(newFailureCount, now, isSkipped ? 1 : 0, now, filePath, engine); + } else { + this.db + .prepare( + ` + INSERT INTO engine_failure_tracking + (file_path, engine, consecutive_failures, last_failure_time, + is_skipped, created_at, updated_at) + VALUES (?, ?, 1, ?, 0, ?, ?) + `, + ) + .run(filePath, engine, now, now, now); + } + } + + recordEngineSuccess(filePath: string, engine: string): void { + const existing = this.getEngineFailureTracking(filePath, engine); + const now = Date.now(); + + if (existing) { + this.db + .prepare( + ` + UPDATE engine_failure_tracking + SET consecutive_failures = 0, + last_success_time = ?, + is_skipped = 0, + updated_at = ? + WHERE file_path = ? AND engine = ? + `, + ) + .run(now, now, filePath, engine); + } else { + this.db + .prepare( + ` + INSERT INTO engine_failure_tracking + (file_path, engine, consecutive_failures, last_success_time, + is_skipped, created_at, updated_at) + VALUES (?, ?, 0, ?, 0, ?, ?) + `, + ) + .run(filePath, engine, now, now, now); + } + } + + resetEngineSkipStatus(filePath: string, engine?: string): void { + const now = Date.now(); + + if (engine) { + // Reset specific engine for specific file + this.db + .prepare( + ` + UPDATE engine_failure_tracking + SET consecutive_failures = 0, + is_skipped = 0, + updated_at = ? + WHERE file_path = ? AND engine = ? + `, + ) + .run(now, filePath, engine); + } else { + // Reset all engines for specific file + this.db + .prepare( + ` + UPDATE engine_failure_tracking + SET consecutive_failures = 0, + is_skipped = 0, + updated_at = ? + WHERE file_path = ? + `, + ) + .run(now, filePath); + } + } + + getFailureTrackingStats(): { + totalSkipped: number; + skippedByEngine: Record; + } { + const totalSkipped = this.db + .prepare('SELECT COUNT(DISTINCT file_path) as count FROM engine_failure_tracking WHERE is_skipped = 1') + .get() as { count: number }; + + const byEngine = this.db + .prepare('SELECT engine, COUNT(*) as count FROM engine_failure_tracking WHERE is_skipped = 1 GROUP BY engine') + .all() as Array<{ engine: string; count: number }>; + + const skippedByEngine: Record = {}; + byEngine.forEach((row) => { + skippedByEngine[row.engine] = row.count; + }); + + return { totalSkipped: totalSkipped.count, skippedByEngine }; + } + + close() { + this.db.close(); + } +} diff --git a/src/findAllSrtFiles.ts b/src/findAllSrtFiles.ts index 2dae965..50611d9 100644 --- a/src/findAllSrtFiles.ts +++ b/src/findAllSrtFiles.ts @@ -1,10 +1,16 @@ import { readdir } from 'fs/promises'; import { extname, join } from 'path'; +import { ScanConfig } from './config'; -export async function findAllSrtFiles(dir: string): Promise { +export async function findAllSrtFiles(config: ScanConfig): Promise { const files: string[] = []; async function scan(directory: string): Promise { + // Check if this directory should be excluded + if (config.excludePaths.some((excludePath) => directory.startsWith(excludePath))) { + return; + } + const entries = await readdir(directory, { withFileTypes: true }); for (const entry of entries) { @@ -12,12 +18,22 @@ export async function findAllSrtFiles(dir: string): Promise { if (entry.isDirectory()) { await scan(fullPath); - } else if (entry.isFile() && extname(entry.name).toLowerCase() === '.srt') { + } else if ( + entry.isFile() && + extname(entry.name).toLowerCase() === '.srt' && + !entry.name.includes('.ffsubsync.') && + !entry.name.includes('.alass.') && + !entry.name.includes('.autosubsync.') + ) { files.push(fullPath); } } } - await scan(dir); + // Scan all included paths + for (const includePath of config.includePaths) { + await scan(includePath); + } + return files; } diff --git a/src/findMatchingVideoFile.ts b/src/findMatchingVideoFile.ts index 02ce510..250c553 100644 --- a/src/findMatchingVideoFile.ts +++ b/src/findMatchingVideoFile.ts @@ -8,7 +8,7 @@ export function findMatchingVideoFile(srtPath: string): string | null { const directory = dirname(srtPath); const srtBaseName = basename(srtPath, '.srt'); - // Try to find a video file with the same name but different extension + // Try exact match first for (const ext of VIDEO_EXTENSIONS) { const possibleVideoPath = join(directory, `${srtBaseName}${ext}`); if (existsSync(possibleVideoPath)) { @@ -16,5 +16,19 @@ export function findMatchingVideoFile(srtPath: string): string | null { } } + // Progressive tag removal - split by dots and try removing one segment at a time + const segments = srtBaseName.split('.'); + while (segments.length > 1) { + segments.pop(); // Remove the last segment + const baseNameToTry = segments.join('.'); + + for (const ext of VIDEO_EXTENSIONS) { + const possibleVideoPath = join(directory, `${baseNameToTry}${ext}`); + if (existsSync(possibleVideoPath)) { + return possibleVideoPath; + } + } + } + return null; } diff --git a/src/generateAlassSubtitles.ts b/src/generateAlassSubtitles.ts new file mode 100644 index 0000000..fa16688 --- /dev/null +++ b/src/generateAlassSubtitles.ts @@ -0,0 +1,53 @@ +import { basename, dirname, join } from 'path'; +import { execPromise, ProcessingResult } from './helpers'; +import { existsSync } from 'fs'; + +export async function generateAlassSubtitles(srtPath: string, videoPath: string): Promise { + const directory = dirname(srtPath); + const srtBaseName = basename(srtPath, '.srt'); + const outputPath = join(directory, `${srtBaseName}.alass.srt`); + + const exists = existsSync(outputPath); + if (exists) { + return { + success: true, + message: `Skipping ${outputPath} - already processed`, + }; + } + + try { + const command = `alass "${videoPath}" "${srtPath}" "${outputPath}"`; + console.log(`${new Date().toLocaleString()} Processing: ${command}`); + const { stdout, stderr } = await execPromise(command); + return { + success: true, + message: `Successfully processed: ${outputPath}`, + stdout: stdout || undefined, + stderr: stderr || undefined, + }; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + const isTimeout = errorMessage.includes('SIGTERM') || errorMessage.includes('timed out'); + + // Extract stdout/stderr from error if available + const execError = error as { stdout?: string; stderr?: string }; + const stdout = execError.stdout || ''; + const stderr = execError.stderr || ''; + + if (isTimeout) { + return { + success: false, + message: `Timeout: ${outputPath} took longer than allowed timeout`, + stdout: stdout || undefined, + stderr: stderr || undefined, + }; + } + + return { + success: false, + message: `Error processing ${outputPath}: ${errorMessage}`, + stdout: stdout || undefined, + stderr: stderr || undefined, + }; + } +} diff --git a/src/generateAutosubsyncSubtitles.ts b/src/generateAutosubsyncSubtitles.ts index c47a7b8..e2f1174 100644 --- a/src/generateAutosubsyncSubtitles.ts +++ b/src/generateAutosubsyncSubtitles.ts @@ -1,36 +1,53 @@ -import { access } from 'fs/promises'; import { basename, dirname, join } from 'path'; import { execPromise, ProcessingResult } from './helpers'; +import { existsSync } from 'fs'; export async function generateAutosubsyncSubtitles(srtPath: string, videoPath: string): Promise { const directory = dirname(srtPath); const srtBaseName = basename(srtPath, '.srt'); const outputPath = join(directory, `${srtBaseName}.autosubsync.srt`); - // Check if synced subtitle already exists - try { - await access(outputPath); + const exists = existsSync(outputPath); + if (exists) { return { success: true, message: `Skipping ${outputPath} - already processed`, }; - } catch (error) { - // File doesn't exist, proceed with sync } try { const command = `autosubsync "${videoPath}" "${srtPath}" "${outputPath}"`; console.log(`${new Date().toLocaleString()} Processing: ${command}`); - await execPromise(command); + const { stdout, stderr } = await execPromise(command); return { success: true, message: `Successfully processed: ${outputPath}`, + stdout: stdout || undefined, + stderr: stderr || undefined, }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : 'Unknown error'; + const errorMessage = error instanceof Error ? error.message : String(error); + const isTimeout = errorMessage.includes('SIGTERM') || errorMessage.includes('timed out'); + + // Extract stdout/stderr from error if available + const execError = error as { stdout?: string; stderr?: string }; + const stdout = execError.stdout || ''; + const stderr = execError.stderr || ''; + + if (isTimeout) { + return { + success: false, + message: `Timeout: ${outputPath} took longer than allowed timeout`, + stdout: stdout || undefined, + stderr: stderr || undefined, + }; + } + return { success: false, message: `Error processing ${outputPath}: ${errorMessage}`, + stdout: stdout || undefined, + stderr: stderr || undefined, }; } } diff --git a/src/generateFfsubsyncSubtitles.ts b/src/generateFfsubsyncSubtitles.ts index 2cd5373..304fa1a 100644 --- a/src/generateFfsubsyncSubtitles.ts +++ b/src/generateFfsubsyncSubtitles.ts @@ -1,6 +1,6 @@ -import { access } from 'fs/promises'; import { basename, dirname, join } from 'path'; import { execPromise, ProcessingResult } from './helpers'; +import { existsSync } from 'fs'; export async function generateFfsubsyncSubtitles(srtPath: string, videoPath: string): Promise { const directory = dirname(srtPath); @@ -8,29 +8,47 @@ export async function generateFfsubsyncSubtitles(srtPath: string, videoPath: str const outputPath = join(directory, `${srtBaseName}.ffsubsync.srt`); // Check if synced subtitle already exists - try { - await access(outputPath); + const exists = existsSync(outputPath); + if (exists) { return { success: true, message: `Skipping ${outputPath} - already processed`, }; - } catch (error) { - // File doesn't exist, proceed with sync } try { const command = `ffsubsync "${videoPath}" -i "${srtPath}" -o "${outputPath}"`; console.log(`${new Date().toLocaleString()} Processing: ${command}`); - await execPromise(command); + const { stdout, stderr } = await execPromise(command); return { success: true, message: `Successfully processed: ${outputPath}`, + stdout: stdout || undefined, + stderr: stderr || undefined, }; } catch (error) { - const errorMessage = error instanceof Error ? error.message : 'Unknown error'; + const errorMessage = error instanceof Error ? error.message : String(error); + const isTimeout = errorMessage.includes('SIGTERM') || errorMessage.includes('timed out'); + + // Extract stdout/stderr from error if available + const execError = error as { stdout?: string; stderr?: string }; + const stdout = execError.stdout || ''; + const stderr = execError.stderr || ''; + + if (isTimeout) { + return { + success: false, + message: `Timeout: ${outputPath} took longer than allowed timeout`, + stdout: stdout || undefined, + stderr: stderr || undefined, + }; + } + return { success: false, message: `Error processing ${outputPath}: ${errorMessage}`, + stdout: stdout || undefined, + stderr: stderr || undefined, }; } } diff --git a/src/helpers.ts b/src/helpers.ts index b65a596..676e980 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -4,6 +4,22 @@ import { exec } from 'child_process'; export interface ProcessingResult { success: boolean; message: string; + stdout?: string; + stderr?: string; + skipped?: boolean; } -export const execPromise = promisify(exec); +export const execPromise = (command: string, timeoutMs?: number): Promise<{ stdout: string; stderr: string }> => { + // Read from env var with default of 30 minutes (1800000ms) + const defaultTimeout = process.env.SYNC_ENGINE_TIMEOUT_MS + ? parseInt(process.env.SYNC_ENGINE_TIMEOUT_MS, 10) + : 1800000; + + const timeout = timeoutMs ?? defaultTimeout; + + // Use promisified exec with timeout option + return promisify(exec)(command, { + timeout, + maxBuffer: 1024 * 1024 * 10, // 10MB buffer for command output + }); +}; diff --git a/src/index-server.ts b/src/index-server.ts new file mode 100644 index 0000000..47c4d54 --- /dev/null +++ b/src/index-server.ts @@ -0,0 +1,109 @@ +import { ProcessingEngine } from './processingEngine'; +import { StateManager } from './stateManager'; +import { ProcessingCoordinator } from './coordinator'; +import { SubsyncarrPlusServer } from './server'; +import { schedule } from 'node-cron'; +import { getRetentionConfig } from './config'; + +async function main() { + const dbPath = process.env.DB_PATH || '/app/data/subsyncarr-plus.db'; + const port = parseInt(process.env.WEB_PORT || '3000', 10); + const host = process.env.WEB_HOST || '127.0.0.1'; + + console.log(`[${new Date().toISOString()}] Initializing Subsyncarr Plus Server...`); + + const stateManager = new StateManager(dbPath); + const engine = new ProcessingEngine(); + const coordinator = new ProcessingCoordinator(engine, stateManager); + const server = new SubsyncarrPlusServer(coordinator, stateManager); + + // Start HTTP server + server.start(port, host); + + // Setup cron scheduler for automatic runs + const cronSchedule = process.env.CRON_SCHEDULE || '0 0 * * *'; + + if (cronSchedule !== 'disabled') { + schedule(cronSchedule, async () => { + console.log(`[${new Date().toISOString()}] Starting scheduled run (${cronSchedule})`); + try { + await coordinator.startRun(); + } catch (error) { + console.error(`[${new Date().toISOString()}] Scheduled run failed:`, error); + } + }); + + console.log(`[${new Date().toISOString()}] Scheduled runs: ${cronSchedule}`); + } else { + console.log(`[${new Date().toISOString()}] Automatic scheduling disabled`); + } + + // Setup periodic database cleanup + const retentionConfig = getRetentionConfig(); + const cleanupIntervalMs = retentionConfig.cleanupIntervalHours * 60 * 60 * 1000; + + setInterval(() => { + console.log(`[${new Date().toISOString()}] Running database cleanup...`); + + const db = stateManager.getDatabase(); + const logFileManager = stateManager.getLogFileManager(); + + // Trim old logs first (database field is now unused but kept for compatibility) + const trimmed = db.trimOldLogs(retentionConfig.trimLogsDays, retentionConfig.maxLogSizeBytes); + if (trimmed > 0) { + console.log(`[${new Date().toISOString()}] Trimmed logs for ${trimmed} runs`); + } + + // Delete old log files + const deletedLogFiles = logFileManager.deleteOldLogs(retentionConfig.keepRunsDays); + if (deletedLogFiles > 0) { + console.log(`[${new Date().toISOString()}] Deleted ${deletedLogFiles} old log files`); + } + + // Delete very old runs + const deleted = db.deleteOldRuns(retentionConfig.keepRunsDays); + if (deleted > 0) { + console.log(`[${new Date().toISOString()}] Deleted ${deleted} old runs`); + db.vacuum(); // Reclaim space + console.log(`[${new Date().toISOString()}] Database vacuumed`); + } + + const stats = db.getDatabaseStats(); + console.log(`[${new Date().toISOString()}] Database size: ${(stats.sizeBytes / 1024 / 1024).toFixed(2)} MB`); + }, cleanupIntervalMs); + + // Run cleanup on startup after 5 seconds + setTimeout(() => { + console.log(`[${new Date().toISOString()}] Running initial database cleanup...`); + const db = stateManager.getDatabase(); + const logFileManager = stateManager.getLogFileManager(); + db.trimOldLogs(retentionConfig.trimLogsDays, retentionConfig.maxLogSizeBytes); + logFileManager.deleteOldLogs(retentionConfig.keepRunsDays); + db.deleteOldRuns(retentionConfig.keepRunsDays); + db.vacuum(); + }, 5000); + + // Log memory usage periodically + setInterval( + () => { + const usage = process.memoryUsage(); + console.log( + `[${new Date().toISOString()}] Memory: RSS=${(usage.rss / 1024 / 1024).toFixed(1)}MB, Heap=${(usage.heapUsed / 1024 / 1024).toFixed(1)}MB/${(usage.heapTotal / 1024 / 1024).toFixed(1)}MB`, + ); + }, + 5 * 60 * 1000, + ); // Every 5 minutes + + // Graceful shutdown + process.on('SIGTERM', () => { + console.log(`[${new Date().toISOString()}] SIGTERM received, shutting down gracefully...`); + server.close(); + stateManager.close(); + process.exit(0); + }); +} + +main().catch((error) => { + console.error('Failed to start server:', error); + process.exit(1); +}); diff --git a/src/index.ts b/src/index.ts index 2227dc1..64ce8bb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,36 +1,27 @@ -import { basename } from 'path'; import { findAllSrtFiles } from './findAllSrtFiles'; -import { findMatchingVideoFile } from './findMatchingVideoFile'; -import { generateFfsubsyncSubtitles } from './generateFfsubsyncSubtitles'; -import { generateAutosubsyncSubtitles } from './generateAutosubsyncSubtitles'; - -const SCAN_DIR = '/scan_dir'; +import { getScanConfig } from './config'; +import { processSrtFile } from './processSrtFile'; async function main(): Promise { - const scanDir = SCAN_DIR; - console.log(`${new Date().toLocaleString()} scanning ${scanDir} for .srt files (this could take a while)...`); - try { // Find all .srt files - const srtFiles = await findAllSrtFiles(scanDir); + const scanConfig = getScanConfig(); + const srtFiles = await findAllSrtFiles(scanConfig); console.log(`${new Date().toLocaleString()} Found ${srtFiles.length} SRT files`); - // Process each SRT file - for (const srtFile of srtFiles) { - const videoFile = findMatchingVideoFile(srtFile); + const maxConcurrentSyncTasks = process.env.MAX_CONCURRENT_SYNC_TASKS + ? parseInt(process.env.MAX_CONCURRENT_SYNC_TASKS) + : 1; - if (videoFile) { - const ffsubsyncResult = await generateFfsubsyncSubtitles(srtFile, videoFile); - console.log(`${new Date().toLocaleString()} ffsubsync result: ${ffsubsyncResult.message}`); - const autosubsyncResult = await generateAutosubsyncSubtitles(srtFile, videoFile); - console.log(`${new Date().toLocaleString()} autosubsync result: ${autosubsyncResult.message}`); - } else { - console.log(`${new Date().toLocaleString()} No matching video file found for: ${basename(srtFile)}`); - } + for (let i = 0; i < srtFiles.length; i += maxConcurrentSyncTasks) { + const chunk = srtFiles.slice(i, i + maxConcurrentSyncTasks); + await Promise.all(chunk.map((srtFile) => processSrtFile(srtFile))); } } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; - console.error('Error:', errorMessage); + console.error(`${new Date().toLocaleString()} Error:`, errorMessage); + } finally { + console.log(`${new Date().toLocaleString()} subsyncarr-plus completed.`); } } diff --git a/src/logFileManager.ts b/src/logFileManager.ts new file mode 100644 index 0000000..6b2324e --- /dev/null +++ b/src/logFileManager.ts @@ -0,0 +1,155 @@ +import * as fs from 'fs'; +import * as path from 'path'; + +export class LogFileManager { + private logDir: string; + private currentLogStream: fs.WriteStream | null = null; + private currentRunId: string | null = null; + private writeBuffer: string[] = []; + private flushInterval: NodeJS.Timeout | null = null; + private flushIntervalMs: number = 5000; // Flush every 5 seconds + + constructor(logDir: string) { + this.logDir = logDir; + + // Ensure log directory exists + if (!fs.existsSync(this.logDir)) { + fs.mkdirSync(this.logDir, { recursive: true }); + } + } + + startRun(runId: string): void { + // Close any existing stream + this.closeCurrentStream(); + + this.currentRunId = runId; + const logFilePath = this.getLogFilePath(runId); + + // Create write stream in append mode + this.currentLogStream = fs.createWriteStream(logFilePath, { flags: 'a' }); + + // Start periodic flush + this.flushInterval = setInterval(() => { + this.flush(); + }, this.flushIntervalMs); + } + + appendLog(runId: string, message: string): void { + if (runId !== this.currentRunId) { + // If this is for a different run, write directly (shouldn't happen often) + const logFilePath = this.getLogFilePath(runId); + fs.appendFileSync(logFilePath, message + '\n'); + return; + } + + // Add to buffer for periodic flush + this.writeBuffer.push(message); + + // If buffer gets too large, flush immediately + if (this.writeBuffer.length >= 100) { + this.flush(); + } + } + + private flush(): void { + if (!this.currentLogStream || this.writeBuffer.length === 0) { + return; + } + + const content = this.writeBuffer.join('\n') + '\n'; + this.writeBuffer = []; + + this.currentLogStream.write(content, (err) => { + if (err) { + console.error(`[${new Date().toISOString()}] Error writing to log file:`, err); + } + }); + } + + endRun(runId: string): void { + if (runId === this.currentRunId) { + this.closeCurrentStream(); + } + } + + private closeCurrentStream(): void { + // Flush any remaining buffered logs + this.flush(); + + // Stop periodic flush + if (this.flushInterval) { + clearInterval(this.flushInterval); + this.flushInterval = null; + } + + // Close stream + if (this.currentLogStream) { + this.currentLogStream.end(); + this.currentLogStream = null; + } + + this.currentRunId = null; + } + + readLog(runId: string): string { + const logFilePath = this.getLogFilePath(runId); + + if (!fs.existsSync(logFilePath)) { + return ''; + } + + try { + return fs.readFileSync(logFilePath, 'utf-8'); + } catch (error) { + console.error(`[${new Date().toISOString()}] Error reading log file:`, error); + return ''; + } + } + + deleteLog(runId: string): void { + const logFilePath = this.getLogFilePath(runId); + + if (fs.existsSync(logFilePath)) { + try { + fs.unlinkSync(logFilePath); + } catch (error) { + console.error(`[${new Date().toISOString()}] Error deleting log file:`, error); + } + } + } + + deleteOldLogs(keepDays: number): number { + const now = Date.now(); + const maxAgeMs = keepDays * 24 * 60 * 60 * 1000; + let deletedCount = 0; + + try { + const files = fs.readdirSync(this.logDir); + + for (const file of files) { + if (!file.endsWith('.log')) continue; + + const filePath = path.join(this.logDir, file); + const stats = fs.statSync(filePath); + const fileAge = now - stats.mtimeMs; + + if (fileAge > maxAgeMs) { + fs.unlinkSync(filePath); + deletedCount++; + } + } + } catch (error) { + console.error(`[${new Date().toISOString()}] Error cleaning up old log files:`, error); + } + + return deletedCount; + } + + getLogFilePath(runId: string): string { + return path.join(this.logDir, `${runId}.log`); + } + + close(): void { + this.closeCurrentStream(); + } +} diff --git a/src/processSrtFile.ts b/src/processSrtFile.ts new file mode 100644 index 0000000..58a80bd --- /dev/null +++ b/src/processSrtFile.ts @@ -0,0 +1,33 @@ +import { basename } from 'path'; +import { findMatchingVideoFile } from './findMatchingVideoFile'; +import { generateAutosubsyncSubtitles } from './generateAutosubsyncSubtitles'; +import { generateFfsubsyncSubtitles } from './generateFfsubsyncSubtitles'; +import { generateAlassSubtitles } from './generateAlassSubtitles'; + +export const processSrtFile = async (srtFile: string) => { + const videoFile = findMatchingVideoFile(srtFile); + const includeEngines = process.env.INCLUDE_ENGINES?.split(',') || ['ffsubsync', 'autosubsync', 'alass']; + + if (videoFile) { + if (includeEngines.includes('ffsubsync')) { + const startTime = Date.now(); + const ffsubsyncResult = await generateFfsubsyncSubtitles(srtFile, videoFile); + const duration = Date.now() - startTime; + console.log(`${new Date().toLocaleString()} ffsubsync result: ${ffsubsyncResult.message} (${duration}ms)`); + } + if (includeEngines.includes('autosubsync')) { + const startTime = Date.now(); + const autosubsyncResult = await generateAutosubsyncSubtitles(srtFile, videoFile); + const duration = Date.now() - startTime; + console.log(`${new Date().toLocaleString()} autosubsync result: ${autosubsyncResult.message} (${duration}ms)`); + } + if (includeEngines.includes('alass')) { + const startTime = Date.now(); + const alassResult = await generateAlassSubtitles(srtFile, videoFile); + const duration = Date.now() - startTime; + console.log(`${new Date().toLocaleString()} alass result: ${alassResult.message} (${duration}ms)`); + } + } else { + console.log(`${new Date().toLocaleString()} No matching video file found for: ${basename(srtFile)}`); + } +}; diff --git a/src/processingEngine.ts b/src/processingEngine.ts new file mode 100644 index 0000000..c5d85e5 --- /dev/null +++ b/src/processingEngine.ts @@ -0,0 +1,203 @@ +import EventEmitter from 'events'; +import { ScanConfig, getScanConfig } from './config'; +import { findAllSrtFiles } from './findAllSrtFiles'; +import { findMatchingVideoFile } from './findMatchingVideoFile'; +import { generateFfsubsyncSubtitles } from './generateFfsubsyncSubtitles'; +import { generateAutosubsyncSubtitles } from './generateAutosubsyncSubtitles'; +import { generateAlassSubtitles } from './generateAlassSubtitles'; +import { StateManager } from './stateManager'; + +export class ProcessingEngine extends EventEmitter { + private cancelledFiles: Set = new Set(); + private maxConcurrent: number; + private enabledEngines: string[]; + private logBuffer: string[] = []; + private maxLogBufferSize: number; + public stateManager?: StateManager; + + constructor() { + super(); + this.maxConcurrent = parseInt(process.env.MAX_CONCURRENT_SYNC_TASKS || '1', 10); + this.enabledEngines = process.env.INCLUDE_ENGINES?.split(',') || ['ffsubsync', 'autosubsync', 'alass']; + this.maxLogBufferSize = parseInt(process.env.LOG_BUFFER_SIZE || '1000', 10); + } + + private log(message: string): void { + console.log(message); + + // Ring buffer - remove oldest if at capacity + if (this.logBuffer.length >= this.maxLogBufferSize) { + this.logBuffer.shift(); // Remove oldest + } + + this.logBuffer.push(message); + this.emit('log', message); + } + + getLogs(): string[] { + return [...this.logBuffer]; + } + + clearLogs(): void { + this.logBuffer = []; + } + + async processRun(config?: ScanConfig): Promise { + const scanConfig = config || getScanConfig(); + this.log(`[${new Date().toISOString()}] Scanning for subtitle files...`); + this.log(`[${new Date().toISOString()}] Scan paths: ${JSON.stringify(scanConfig.includePaths)}`); + + const srtFiles = await findAllSrtFiles(scanConfig); + this.log(`[${new Date().toISOString()}] Found ${srtFiles.length} subtitle files`); + + this.emit('run:files_found', srtFiles); + this.cancelledFiles.clear(); + + // Process in batches + this.log(`[${new Date().toISOString()}] Processing with concurrency: ${this.maxConcurrent}`); + this.log(`[${new Date().toISOString()}] Enabled engines: ${this.enabledEngines.join(', ')}`); + + for (let i = 0; i < srtFiles.length; i += this.maxConcurrent) { + const batch = srtFiles.slice(i, i + this.maxConcurrent); + this.log( + `[${new Date().toISOString()}] Processing batch ${Math.floor(i / this.maxConcurrent) + 1}/${Math.ceil(srtFiles.length / this.maxConcurrent)} (${batch.length} files)`, + ); + await Promise.all(batch.map((file) => this.processFile(file))); + } + + this.log(`[${new Date().toISOString()}] All files processed`); + } + + private async processFile(srtPath: string): Promise { + const fileName = srtPath.split('/').pop(); + this.log(`[${new Date().toISOString()}] Processing: ${fileName}`); + + // Check if cancelled + if (this.cancelledFiles.has(srtPath)) { + this.log(`[${new Date().toISOString()}] Skipped (cancelled): ${fileName}`); + this.emit('file:skipped', { srtPath, reason: 'cancelled' }); + return; + } + + const videoPath = findMatchingVideoFile(srtPath); + + this.emit('file:started', { srtPath, videoPath }); + + if (!videoPath) { + this.log(`[${new Date().toISOString()}] No matching video found for: ${fileName}`); + this.emit('file:no_video', { srtPath }); + return; + } + + this.log(`[${new Date().toISOString()}] Found video: ${videoPath.split('/').pop()}`); + + // Process with each enabled engine + let anyEngineSucceeded = false; + for (const engine of this.enabledEngines) { + // Check cancellation before each engine + if (this.cancelledFiles.has(srtPath)) { + this.log(`[${new Date().toISOString()}] Skipped (cancelled): ${fileName}`); + this.emit('file:skipped', { srtPath, reason: 'cancelled' }); + return; + } + + // Check if engine should be skipped due to consecutive failures + if (this.stateManager?.shouldSkipEngine(srtPath, engine)) { + this.log(`[${new Date().toISOString()}] ⊘ Skipping ${engine} (3+ consecutive failures): ${fileName}`); + this.emit('file:engine_completed', { + srtPath, + engine, + result: { + success: false, + duration: 0, + message: 'Skipped due to 3+ consecutive failures', + skipped: true, + }, + }); + continue; // Skip to next engine + } + + this.log(`[${new Date().toISOString()}] Starting ${engine} for: ${fileName}`); + this.emit('file:engine_started', { srtPath, engine }); + + const startTime = Date.now(); + let result; + + try { + switch (engine) { + case 'ffsubsync': + result = await generateFfsubsyncSubtitles(srtPath, videoPath); + break; + case 'autosubsync': + result = await generateAutosubsyncSubtitles(srtPath, videoPath); + break; + case 'alass': + result = await generateAlassSubtitles(srtPath, videoPath); + break; + default: + continue; + } + + const duration = Date.now() - startTime; + const status = result.success ? '✓' : '✗'; + this.log( + `[${new Date().toISOString()}] ${status} ${engine} completed (${(duration / 1000).toFixed(1)}s): ${fileName}`, + ); + if (!result.success) { + this.log(`[${new Date().toISOString()}] Error: ${result.message}`); + // Log stderr if available for debugging + if (result.stderr) { + this.log(`[${new Date().toISOString()}] Stderr: ${result.stderr.substring(0, 500)}`); + } + } + + if (result.success) { + anyEngineSucceeded = true; + } + + this.emit('file:engine_completed', { + srtPath, + engine, + result: { ...result, duration }, + }); + } catch (error) { + const duration = Date.now() - startTime; + this.log(`[${new Date().toISOString()}] ✗ ${engine} failed (${(duration / 1000).toFixed(1)}s): ${fileName}`); + this.log(`[${new Date().toISOString()}] Error: ${error instanceof Error ? error.message : String(error)}`); + + this.emit('file:engine_completed', { + srtPath, + engine, + result: { + success: false, + message: error instanceof Error ? error.message : String(error), + duration, + }, + }); + } + } + + if (anyEngineSucceeded) { + this.log(`[${new Date().toISOString()}] ✓ Completed successfully for: ${fileName}`); + this.emit('file:completed', { srtPath }); + } else { + this.log(`[${new Date().toISOString()}] ✗ All engines failed for: ${fileName}`); + this.emit('file:failed', { srtPath }); + } + } + + skipFile(filePath: string): void { + this.cancelledFiles.add(filePath); + this.emit('file:skip_requested', { filePath }); + } + + stopAllProcessing(allFiles: string[]): void { + this.log(`[${new Date().toISOString()}] Stop requested - cancelling all remaining files`); + allFiles.forEach((file) => this.cancelledFiles.add(file)); + } + + reset(): void { + this.cancelledFiles.clear(); + this.clearLogs(); + } +} diff --git a/src/server.ts b/src/server.ts new file mode 100644 index 0000000..5caa21c --- /dev/null +++ b/src/server.ts @@ -0,0 +1,306 @@ +import express from 'express'; +import { WebSocketServer, WebSocket } from 'ws'; +import { createServer } from 'http'; +import { ProcessingCoordinator } from './coordinator'; +import { StateManager } from './stateManager'; +import { join } from 'path'; +import { getScanConfig } from './config'; +import cronstrue from 'cronstrue'; +import parseExpression from 'cron-parser'; + +export class SubsyncarrPlusServer { + private app = express(); + private httpServer = createServer(this.app); + private wss = new WebSocketServer({ server: this.httpServer, path: '/ws' }); + private clients: Set = new Set(); + + constructor( + private coordinator: ProcessingCoordinator, + private stateManager: StateManager, + ) { + this.setupMiddleware(); + this.setupRoutes(); + this.setupWebSocket(); + } + + private setupMiddleware() { + this.app.use(express.json()); + this.app.use(express.static(join(__dirname, '../public'))); + } + + private setupRoutes() { + // Get configuration status + this.app.get('/api/config', (req, res) => { + console.log(`[${new Date().toISOString()}] GET /api/config`); + const config = getScanConfig(); + const isDefaultPath = config.includePaths.length === 1 && config.includePaths[0] === '/scan_dir'; + + // Get cron schedule info + const cronSchedule = process.env.CRON_SCHEDULE || '0 0 * * *'; + let scheduleDescription = ''; + let nextRun = null; + + if (cronSchedule !== 'disabled') { + try { + scheduleDescription = cronstrue.toString(cronSchedule); + const interval = parseExpression.parse(cronSchedule); + nextRun = interval.next().toDate().getTime(); + } catch (error) { + console.error('Error parsing cron schedule:', error); + scheduleDescription = cronSchedule; + } + } + + res.json({ + paths: config.includePaths, + excludePaths: config.excludePaths, + isConfigured: !isDefaultPath, + schedule: { + enabled: cronSchedule !== 'disabled', + cron: cronSchedule, + description: scheduleDescription, + nextRun: nextRun, + }, + }); + }); + + // Get current status + this.app.get('/api/status', (req, res) => { + console.log(`[${new Date().toISOString()}] GET /api/status`); + const currentRun = this.stateManager.getCurrentRun(); + res.json({ + currentRun, + files: currentRun ? this.stateManager.getFileResults(currentRun.id) : [], + isRunning: this.coordinator.isRunning(), + }); + }); + + // Get run history + this.app.get('/api/history', (req, res) => { + const limit = parseInt(req.query.limit as string, 10) || 50; + console.log(`[${new Date().toISOString()}] GET /api/history (limit: ${limit})`); + res.json(this.stateManager.getRunHistory(limit)); + }); + + // Get specific run details + this.app.get('/api/runs/:id', (req, res) => { + console.log(`[${new Date().toISOString()}] GET /api/runs/${req.params.id}`); + const currentRun = this.stateManager.getCurrentRun(); + const requestedId = req.params.id; + + // Check current run first + if (currentRun && currentRun.id === requestedId) { + return res.json({ + run: currentRun, + files: this.stateManager.getFileResults(currentRun.id), + }); + } + + // Check history + const history = this.stateManager.getRunHistory(1000); + const run = history.find((r) => r.id === requestedId); + + if (!run) { + return res.status(404).json({ error: 'Run not found' }); + } + + res.json({ + run, + files: this.stateManager.getFileResults(run.id), + }); + }); + + // Get logs for a specific run + this.app.get('/api/runs/:id/logs', (req, res) => { + console.log(`[${new Date().toISOString()}] GET /api/runs/${req.params.id}/logs`); + const requestedId = req.params.id; + + // Check if run exists (current or historical) + const currentRun = this.stateManager.getCurrentRun(); + const history = this.stateManager.getRunHistory(1000); + const run = currentRun?.id === requestedId ? currentRun : history.find((r) => r.id === requestedId); + + if (!run) { + return res.status(404).json({ error: 'Run not found' }); + } + + // Read logs from file + const logs = this.stateManager.getRunLogs(requestedId); + res.json({ logs }); + }); + + // Start a new run + this.app.post('/api/run/start', async (req, res) => { + const { paths } = req.body; + console.log( + `[${new Date().toISOString()}] POST /api/run/start${paths ? ` (custom paths: ${paths.join(', ')})` : ' (default paths)'}`, + ); + + try { + if (this.coordinator.isRunning()) { + console.log(`[${new Date().toISOString()}] Request rejected: Run already in progress`); + return res.status(409).json({ error: 'A run is already in progress' }); + } + + const config = paths ? { includePaths: paths, excludePaths: [] } : undefined; + + const runId = await this.coordinator.startRun(config); + res.json({ runId }); + } catch (error) { + console.log( + `[${new Date().toISOString()}] Error starting run: ${error instanceof Error ? error.message : 'Unknown error'}`, + ); + res.status(500).json({ + error: error instanceof Error ? error.message : 'Unknown error', + }); + } + }); + + // Stop current run + this.app.post('/api/run/stop', (_req, res) => { + console.log(`[${new Date().toISOString()}] POST /api/run/stop`); + try { + this.coordinator.stopRun(); + res.json({ success: true }); + } catch (error) { + console.log( + `[${new Date().toISOString()}] Error stopping run: ${error instanceof Error ? error.message : 'Unknown error'}`, + ); + res.status(500).json({ + error: error instanceof Error ? error.message : 'Unknown error', + }); + } + }); + + // Skip a file + this.app.post('/api/file/skip', (req, res) => { + const { filePath } = req.body; + + if (!filePath) { + console.log(`[${new Date().toISOString()}] POST /api/file/skip - Missing filePath`); + return res.status(400).json({ error: 'filePath required' }); + } + + console.log(`[${new Date().toISOString()}] POST /api/file/skip - ${filePath.split('/').pop()}`); + this.coordinator.skipFile(filePath); + res.json({ success: true }); + }); + + // Clear completed files + this.app.post('/api/files/clear', (req, res) => { + console.log(`[${new Date().toISOString()}] POST /api/files/clear`); + this.stateManager.clearCompletedFiles(); + + // Broadcast updated state to all clients + const currentRun = this.stateManager.getCurrentRun(); + this.broadcast({ + type: 'files:cleared', + data: { + currentRun, + files: currentRun + ? this.stateManager.getFileResults(currentRun.id).filter((f) => f.status === 'processing') + : [], + }, + }); + + res.json({ success: true }); + }); + + // Get skip status statistics + this.app.get('/api/skip-status', (_req, res) => { + console.log(`[${new Date().toISOString()}] GET /api/skip-status`); + const stats = this.stateManager.getFailureStats(); + res.json(stats); + }); + + // Get skip status for specific file + this.app.get('/api/skip-status/:filePath(*)', (req, res) => { + const filePath = decodeURIComponent(req.params.filePath); + console.log(`[${new Date().toISOString()}] GET /api/skip-status/${filePath.split('/').pop()}`); + + const skippedEngines = this.stateManager.getSkippedEngines(filePath); + res.json({ filePath, skippedEngines }); + }); + + // Reset skip status for a file + this.app.post('/api/skip-status/reset', (req, res) => { + const { filePath, engine } = req.body; + + if (!filePath) { + return res.status(400).json({ error: 'filePath required' }); + } + + console.log( + `[${new Date().toISOString()}] POST /api/skip-status/reset - ${filePath.split('/').pop()}${engine ? ` (${engine})` : ' (all engines)'}`, + ); + + this.stateManager.resetSkipStatus(filePath, engine); + res.json({ success: true }); + }); + } + + private setupWebSocket() { + this.wss.on('connection', (ws) => { + console.log(`[${new Date().toISOString()}] WebSocket client connected (total: ${this.clients.size + 1})`); + this.clients.add(ws); + + // Send initial state + const currentRun = this.stateManager.getCurrentRun(); + ws.send( + JSON.stringify({ + type: 'state', + data: { + currentRun, + files: currentRun ? this.stateManager.getFileResults(currentRun.id) : [], + isRunning: this.coordinator.isRunning(), + }, + }), + ); + + ws.on('close', () => { + this.clients.delete(ws); + console.log(`[${new Date().toISOString()}] WebSocket client disconnected (total: ${this.clients.size})`); + }); + }); + + // Broadcast state changes to all clients + this.stateManager.on('run:started', (run) => { + console.log(`[${new Date().toISOString()}] Broadcasting run:started to ${this.clients.size} clients`); + this.broadcast({ type: 'run:started', data: run }); + }); + + this.stateManager.on('run:completed', (run) => { + console.log(`[${new Date().toISOString()}] Broadcasting run:completed to ${this.clients.size} clients`); + this.broadcast({ type: 'run:completed', data: run }); + }); + + this.stateManager.on('run:cancelled', (run) => { + console.log(`[${new Date().toISOString()}] Broadcasting run:cancelled to ${this.clients.size} clients`); + this.broadcast({ type: 'run:cancelled', data: run }); + }); + + this.stateManager.on('file:updated', ({ file, run }) => { + this.broadcast({ type: 'file:updated', data: { file, run } }); + }); + } + + private broadcast(message: unknown) { + const data = JSON.stringify(message); + this.clients.forEach((client) => { + if (client.readyState === WebSocket.OPEN) { + client.send(data); + } + }); + } + + start(port: number = 3000, host: string = '127.0.0.1') { + this.httpServer.listen(port, host, () => { + console.log(`[${new Date().toISOString()}] Subsyncarr Plus UI available at http://${host}:${port}`); + }); + } + + close() { + this.httpServer.close(); + this.wss.close(); + } +} diff --git a/src/stateManager.ts b/src/stateManager.ts new file mode 100644 index 0000000..8fa533e --- /dev/null +++ b/src/stateManager.ts @@ -0,0 +1,233 @@ +import EventEmitter from 'events'; +import { SubsyncarrPlusDatabase, Run, FileResult } from './database'; +import { randomUUID } from 'crypto'; +import { LogFileManager } from './logFileManager'; +import * as path from 'path'; + +export class StateManager extends EventEmitter { + private db: SubsyncarrPlusDatabase; + private currentRunId: string | null = null; + private logFileManager: LogFileManager; + + constructor(dbPath: string) { + super(); + this.db = new SubsyncarrPlusDatabase(dbPath); + + // Create log file manager in same directory as database + const logDir = path.join(path.dirname(dbPath), 'logs'); + this.logFileManager = new LogFileManager(logDir); + + this.handleIncompleteRuns(); + } + + private handleIncompleteRuns(): void { + // Find any runs that are still marked as 'running' from a previous session + const history = this.db.getRunHistory(100); + const incompleteRuns = history.filter((run) => run.status === 'running'); + + incompleteRuns.forEach((run) => { + console.log(`[${new Date().toISOString()}] Found incomplete run from previous session: ${run.id}`); + this.db.updateRun(run.id, { + status: 'cancelled', + end_time: run.start_time, // Use start time since we don't know when it actually stopped + }); + console.log(`[${new Date().toISOString()}] Marked run ${run.id} as cancelled`); + }); + } + + // Run management + startRun(totalFiles: number, enabledEngines: string[] = ['ffsubsync', 'autosubsync', 'alass']): string { + const runId = randomUUID(); + this.db.createRun(runId, totalFiles); + + // Set the total number of engines that will run (total_files * enabled_engines) + const totalEngines = totalFiles * enabledEngines.length; + this.db.updateRun(runId, { total_engines: totalEngines }); + + this.currentRunId = runId; + + // Start log file for this run + this.logFileManager.startRun(runId); + + const run = this.db.getRun(runId)!; + this.emit('run:started', run); + return runId; + } + + completeRun(runId: string): void { + this.db.updateRun(runId, { + end_time: Date.now(), + status: 'completed', + }); + + // End log file for this run + this.logFileManager.endRun(runId); + + if (this.currentRunId === runId) { + this.currentRunId = null; + } + + const run = this.db.getRun(runId)!; + this.emit('run:completed', run); + } + + cancelRun(runId: string): void { + this.db.updateRun(runId, { + end_time: Date.now(), + status: 'cancelled', + }); + + // End log file for this run + this.logFileManager.endRun(runId); + + if (this.currentRunId === runId) { + this.currentRunId = null; + } + + const run = this.db.getRun(runId)!; + this.emit('run:cancelled', run); + } + + incrementRunCounter(runId: string, field: 'completed' | 'skipped' | 'failed'): void { + const run = this.db.getRun(runId)!; + this.db.updateRun(runId, { + [field]: run[field] + 1, + }); + } + + incrementCompletedEngines(runId: string): void { + const run = this.db.getRun(runId)!; + this.db.updateRun(runId, { + completed_engines: run.completed_engines + 1, + }); + } + + // File management + addFile(runId: string, filePath: string, videoPath: string | null): void { + this.db.createFileResult(runId, filePath, videoPath); + this.emitFileUpdate(runId, filePath); + } + + updateFileStatus(runId: string, filePath: string, status: FileResult['status'], currentEngine?: string | null): void { + const updates: Partial = { status }; + if (currentEngine !== undefined) { + updates.current_engine = currentEngine; + } + + this.db.updateFileResult(runId, filePath, updates); + this.emitFileUpdate(runId, filePath); + } + + updateFileEngine( + runId: string, + filePath: string, + engine: string, + result: { + success: boolean; + duration: number; + message: string; + stdout?: string; + stderr?: string; + skipped?: boolean; + }, + ): void { + const files = this.db.getFileResults(runId); + const file = files.find((f) => f.file_path === filePath); + + if (file) { + const engines = JSON.parse(file.engines); + engines[engine] = result; + + this.db.updateFileResult(runId, filePath, { + engines: JSON.stringify(engines), + }); + + // Update failure tracking + if (result.skipped) { + // Skipped engines don't affect failure count + } else if (result.success) { + this.db.recordEngineSuccess(filePath, engine); + } else { + this.db.recordEngineFailure(filePath, engine); + } + + this.emitFileUpdate(runId, filePath); + } + } + + private emitFileUpdate(runId: string, filePath: string): void { + const files = this.db.getFileResults(runId); + const file = files.find((f) => f.file_path === filePath); + if (file) { + const run = this.db.getRun(runId); + this.emit('file:updated', { file, run }); + } + } + + clearCompletedFiles(): void { + if (!this.currentRunId) { + return; + } + + const files = this.db.getFileResults(this.currentRunId); + files.forEach((file) => { + if (['completed', 'skipped', 'error'].includes(file.status)) { + this.emit('file:cleared', file); + } + }); + } + + // Query methods + getCurrentRun(): Run | null { + return this.currentRunId ? this.db.getRun(this.currentRunId) : null; + } + + getRunHistory(limit?: number): Run[] { + return this.db.getRunHistory(limit); + } + + getFileResults(runId: string): FileResult[] { + return this.db.getFileResults(runId); + } + + appendLog(runId: string, logMessage: string): void { + // Write to log file instead of database + this.logFileManager.appendLog(runId, logMessage); + } + + getRunLogs(runId: string): string { + // Read logs from file + return this.logFileManager.readLog(runId); + } + + getDatabase(): SubsyncarrPlusDatabase { + return this.db; + } + + getLogFileManager(): LogFileManager { + return this.logFileManager; + } + + // Engine skip logic methods + getSkippedEngines(filePath: string): string[] { + return this.db.getAllSkippedEngines(filePath); + } + + shouldSkipEngine(filePath: string, engine: string): boolean { + const tracking = this.db.getEngineFailureTracking(filePath, engine); + return tracking ? tracking.is_skipped : false; + } + + resetSkipStatus(filePath: string, engine?: string): void { + this.db.resetEngineSkipStatus(filePath, engine); + } + + getFailureStats() { + return this.db.getFailureTrackingStats(); + } + + close() { + this.logFileManager.close(); + this.db.close(); + } +}