mirror of
https://github.com/unraid/api.git
synced 2025-12-30 04:59:51 -06:00
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added developer CLI tools for toggling GraphQL sandbox and modal testing utilities. * Introduced a "Show Activation Modal" developer component for UI testing. * Added system initial setup detection and related GraphQL queries. * Enhanced login and welcome pages with dynamic server info and initial setup state. * Improved SSO button with internationalization and error handling. * Added internal CLI admin API key management service and internal GraphQL client service. * Introduced comprehensive API report generation service for system and service status. * Added CLI commands and GraphQL mutations/queries for plugin and SSO user management. * Added new modal target components and improved teleport target detection. * **Enhancements** * Refined modal dialog targeting and teleportation for flexible UI placement. * Updated modal components and stores for improved activation/welcome modal control. * Improved plugin and SSO user management via CLI through GraphQL API. * Refactored partner logo components to use props instead of store dependencies. * Enhanced styling and accessibility for buttons and modals. * Streamlined Tailwind CSS integration with shared styles and updated theme variables. * Improved GraphQL module configuration to avoid directive conflicts in tests. * Adjusted Vite config for better dependency handling in test mode. * Improved error handling and logging in CLI commands and services. * Reordered imports and refined component class bindings for UI consistency. * **Bug Fixes** * Resolved issues with duplicate script tags and component registration in the web UI. * Fixed modal close button visibility and activation modal state handling. * Added error handling and logging improvements across CLI commands and services. * Fixed newline issues in last-download-time fixture files. * **Chores** * Added and updated numerous tests for CLI commands, services, and UI components. * Updated translation files and localization resources for new UI messages. * Adjusted environment, configuration, and dependency files for improved development and test workflows. * Cleaned up unused imports and mocks in tests. * Reorganized exports and barrel files in shared and UI modules. * Added integration and dependency resolution tests for core modules. * **Removals & Refactoring** * Removed legacy Redux state management, configuration, and UPnP logic from the backend. * Eliminated deprecated GraphQL subscriptions and client code related to registration and mothership. * Removed direct store manipulation and replaced with service-based approaches in CLI commands. * Deleted unused or redundant test files and configuration listeners. * Refactored SSO user service to consolidate add/remove operations into a single update method. * Simplified API key services with new methods for automatic key management. * Replaced direct plugin and SSO user service calls with GraphQL client interactions in CLI commands. * Removed complex theme fallback and dark mode CSS rules, replacing with streamlined static theme variables. * Cleaned up Tailwind CSS configuration and removed deprecated local styles. * Removed multiple internal utility files and replaced with simplified or centralized implementations. * Removed deprecated local configuration and synchronization files and listeners. * Removed UPnP helper functions and job management classes. * Refactored server resolver to dynamically construct local server data internally. * Removed CORS handler and replaced with simplified or externalized logic. * Removed store synchronization and registration event pubsub handling. * Removed GraphQL client creation utilities for internal API communication. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
5.1 KiB
5.1 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is the Unraid API monorepo containing multiple packages that provide API functionality for Unraid servers. It uses pnpm workspaces with the following structure:
/api- Core NestJS API server with GraphQL/web- Nuxt.js frontend application/unraid-ui- Vue 3 component library/plugin- Unraid plugin package (.plg)/packages- Shared packages and API plugins
Essential Commands
Development
pnpm install # Install all dependencies
pnpm dev # Run all dev servers concurrently
pnpm build # Build all packages
pnpm build:watch # Watch mode with local plugin build
Testing & Code Quality
pnpm test # Run all tests
pnpm lint # Run linting
pnpm lint:fix # Fix linting issues
pnpm type-check # TypeScript type checking
API Development
cd api && pnpm dev # Run API server (http://localhost:3001)
cd api && pnpm test:watch # Run tests in watch mode
cd api && pnpm codegen # Generate GraphQL types
Deployment
pnpm unraid:deploy <SERVER_IP> # Deploy all to Unraid server
Developer Tools
unraid-api developer # Interactive prompt for tools
unraid-api developer --sandbox true # Enable GraphQL sandbox
unraid-api developer --sandbox false # Disable GraphQL sandbox
unraid-api developer --enable-modal # Enable modal testing tool
unraid-api developer --disable-modal # Disable modal testing tool
Architecture Notes
API Structure (NestJS)
- Modules:
auth,config,plugins,emhttp,monitoring - GraphQL API with Apollo Server at
/graphql - Redux store for state management in
src/store/ - Plugin system for extending functionality
- Entry points:
src/index.ts(server),src/cli.ts(CLI)
Key Patterns
- TypeScript imports use
.jsextensions (ESM compatibility) - NestJS dependency injection with decorators
- GraphQL schema-first approach with code generation
- API plugins follow specific structure (see
api/docs/developer/api-plugins.md)
Authentication
- API key authentication via headers
- Cookie-based session management
- Keys stored in
/boot/config/plugins/unraid-api/
Development Workflow
- Work Intent required before starting development
- Fork from
mainbranch - Reference Work Intent in PR
- No direct pushes to main
Debug Mode
LOG_LEVEL=debug unraid-api start --debug
Enables GraphQL playground at http://tower.local/graphql
Coding Guidelines
General Rules
- Never add comments unless they are needed for clarity of function
- Never add comments for obvious things, and avoid commenting when starting and ending code blocks
- Be CONCISE, keep replies shorter than a paragraph if at all possible
API Development Rules (api/**/*)
- Use pnpm ONLY for package management
- Always run scripts from api/package.json unless requested
- Prefer adding new files to the NestJS repo located at
api/src/unraid-api/instead of the legacy code - Test suite is VITEST, do not use jest
- Run tests with:
pnpm --filter ./api test - Prefer to not mock simple dependencies
Web Development Rules (web/**/*)
- Always run
pnpm codegenfor GraphQL code generation in the web directory - GraphQL queries must be placed in
.query.tsfiles - GraphQL mutations must be placed in
.mutation.tsfiles - All GraphQL under
web/must follow this naming convention
Testing Guidelines
Vue Component Testing
- This is a Nuxt.js app but we are testing with vitest outside of the Nuxt environment
- Nuxt is currently set to auto import so some vue files may need compute or ref imported
- Use pnpm when running terminal commands and stay within the web directory
- Tests are located under
web/__test__, run withpnpm test - Use
mountfrom Vue Test Utils for component testing - Stub complex child components that aren't the focus of the test
- Mock external dependencies and services
- Test component behavior and output, not implementation details
- Use
createTestingPinia()for mocking stores in components - Find elements with semantic queries like
find('button')rather than data-test IDs - Use
await nextTick()for DOM updates - Always await async operations before making assertions
Store Testing with Pinia
- Use
createPinia()andsetActivePiniawhen testing Store files - Only use
createTestingPiniaif you specifically need its testing features - Let stores initialize with their natural default state
- Don't mock the store being tested
- Ensure Vue reactivity imports are added to store files (computed, ref, watchEffect)
- Place all mock declarations at the top level
- Use factory functions for module mocks to avoid hoisting issues
- Clear mocks between tests to ensure isolation
Development Memories
- We are using tailwind v4 we do not need a tailwind config anymore
- always search the internet for tailwind v4 documentation when making tailwind related style changes