Commit Graph
57 Commits
Author SHA1 Message Date
john-okeefe b4730caea6 test(api): add Bruno API tests for new collection endpoints
Add comprehensive Bruno tests for Phase 9 limitations features:

Test Collection Rules.bru:
- Test rule: genre equals "Science Fiction"
- Test rule: author contains "Asimov"
- Test rule: copyright_year greater than 2000
- Test rule: non-existent genre (expects 0 matches)
- Test validation: empty rules array (expects 400)

Bulk Remove Books.bru:
- Setup: Create test collection
- Add multiple books to collection
- Test 1: Bulk remove all books
- Test 2: Bulk remove with some invalid IDs
- Test 3: Empty list validation
- Test 4: Single book removal (bulk should work for 1 too)
- Cleanup: Delete test collection

Test Coverage:
- Rule evaluation API endpoint
- Bulk remove API endpoint
- Request validation
- Response structure verification
- Edge cases and error handling

Bruno Test Format:
- JSON request bodies
- Status code assertions
- Response structure validation
- Setup/teardown for integration tests

These tests ensure the new Phase 9 API endpoints work correctly
and maintain backward compatibility.
2026-02-01 01:02:20 -05:00
john-okeefe d6d208c3d1 test(bruno): Add API tests for Kobo, Koreader, OPDS, collections
- Add Kobo bookmark/markup sync tests
- Add Koreader progress/bookmark sync tests
- Add OPDS feed tests
- Add collection tests
- Add sync tests for book linking
2026-01-31 22:32:56 -05:00
john-okeefe 60380a043d docs: Update bruno test files 2026-01-31 22:31:54 -05:00
john-okeefe 4d87beb540 test: add Bruno API collections for sync features
- Add device registration and management API tests
- Add conflicts resolution API tests
- Add queue management API tests
- Add KOReader sync protocol tests
- Add Kobo sync protocol tests
2026-01-31 18:25:32 -05:00
john-okeefe 31fae3cea8 Add Bruno API collection for device cap management
- Update User Max Devices - Complete API documentation
- Update User Max Devices - Success test case
- Update User Max Devices - Invalid Zero test case
- Update User Max Devices - Exceeds Maximum test case
- Update User Max Devices - Missing ID test case
- Include validation rules and example payloads
- Document all status codes and error responses
2026-01-31 13:06:46 -05:00
john-okeefe 2d2d643873 Add sync conflict detection and resolution system
Implement conflict detection for concurrent reading progress updates from different devices. Adds conflict management endpoints for listing, viewing, and resolving conflicts.

- Add ConflictHandler with CRUD endpoints for conflict management
- Implement automatic conflict detection in KOReader progress updates
- Add WebSocket broadcast for real-time conflict notifications
- Add database query for listing user conflicts by status
- Add integration tests and Bruno API test collection
2026-01-31 11:45:52 -05:00
john-okeefe 45ba922c68 test: add Bruno API test collections for Kobo and media endpoints 2026-01-31 00:29:40 -05:00
john-okeefe a3aa9f67ac feat: add Kobo device sync support and fix device route protection
- Add Kobo sync handler with markup, bookmark, analytics, and initialization endpoints
- Add Kobo integration tests and Bruno API test collection
- Move device approve/reject routes from public to protected routes
- Enhance test infrastructure with DATABASE_URL support and helper functions
- Fix device GetDevice handler nil pointer handling
- Clean up test reports and session files
2026-01-30 23:58:34 -05:00
john-okeefe b49ba7909f docs: add Bruno API request for WebSocket connection
Add Bruno v3.0 request for testing WebSocket endpoint:
- WebSocket connection type
- JWT token authentication via query parameter
- Ping message body for heartbeat testing
- Assertions for successful WebSocket upgrade (101 status)

Provides API documentation and testing capability for
WebSocket connection functionality per project standards.
2026-01-30 21:48:38 -05:00
john-okeefe f8a6c3d227 Phase 3 Week 7: Add KOReader routes, tests, and documentation
- Add KOReader sync endpoints to main application router
- Create Bruno API collection for testing KOReader endpoints
- Add integration tests for KOReader functionality
- Include comprehensive README with setup instructions
- Test coverage for progress, metadata, library, and bookmarks sync
- Part of Phase 3 KOReader Integration implementation
2026-01-30 20:55:20 -05:00
john-okeefe 0e784f6d3f Add Bruno API collection for Phase 1 universal progress endpoints
Bruno API Requests Added:
- universal-progress/Get Progress History.bru
  * Fetch reading progress history for a book
  * Returns historical progress data with timestamps

- universal-progress/Update Universal Progress.bru
  * Update reading progress with automatic format conversion
  * Supports percentage, epubcfi, character, chapter tracking

- universal-progress/Get Universal Progress.bru
  * Get comprehensive progress with all location references
  * Returns percentage, epubcfi, character, chapter data
  * Includes device-specific progress tracking

Collection Features:
- Environment variables: baseUrl, token, deviceId
- Consistent request/response structure
- Proper authentication headers
- JSON request/response bodies

Test Coverage:
- Multi-format progress tracking
- Progress conversion between formats
- Historical progress queries
- Device-specific progress retrieval

Integration:
- Works with Phase 1 universal progress system
- Tests format group detection (reflowable, fixed_layout, comic_archive)
- Validates progress conversion engine
2026-01-30 16:57:18 -05:00
john-okeefe 23ad70158c Phase 2 Week 5: Device Registration & Management
Implement device registration and management system for universal sync.

Database Changes:
- Add device queries to queries.sql (CRUD operations, registration, auth)
- Add sync queue management queries
- Add conflict resolution queries
- Regenerate sqlc models with new device-related types

Device Handler (devices.go):
- InitiateRegistration: Start device registration with auth URL and QR code
- CheckRegistrationStatus: Poll for registration approval
- ListDevices: Get all devices for current user
- GetDevice: Get specific device details
- UpdateDevice: Update device settings (name, sync settings, frequency)
- DeleteDevice: Remove device from account
- ApproveDevice: User approves device registration via web
- RejectDevice: Reject pending device registration
- ListPendingRegistrations: Show all pending registrations
- generateDeviceToken: Generate secure Bearer token for devices

Device Authentication Middleware (device_auth.go):
- Authenticate: Validate device Bearer tokens
- RequirePermission: Check device permissions by type
- hasPermission: Define permissions per device type
- UpdateLastSeen: Auto-update device last_seen timestamp

Configuration:
- Add BaseURL field to Config for device setup URLs

API Endpoints:
POST /api/devices/register - Initiate device registration
POST /api/devices/register/status - Check registration status
GET /api/devices/approve/:id - Approve device (web UI)
POST /api/devices/reject/:id - Reject device
GET /api/devices - List user's devices
GET /api/devices/:id - Get device details
PUT /api/devices/:id - Update device settings
DELETE /api/devices/:id - Delete device
GET /api/devices/pending - List pending registrations

Bruno API Collection:
- Initiate Device Registration
- Check Registration Status
- List Devices
- Get Device
- Update Device
- Delete Device

Dependencies:
- github.com/skip2/go-qrcode for QR code generation

Device Types Supported:
- koreader: Calibre-compatible sync
- kobo: Kobo sync protocol
- web: Web interface
- mobile: Mobile apps

Device Permissions:
- sync:progress
- sync:annotations
- sync:metadata
- device:manage (web only)
2026-01-30 16:45:10 -05:00
john-okeefe 75ff657e58 feat: add 16 missing Bruno requests for complete API coverage
Add missing Bruno requests for all API endpoints:

Library Management:
- Get Library - retrieve single library details
- Update Library - modify existing library
- Delete Library - remove library and media items
- Delete Library Folder - remove folder from library
- Get Library Stats - retrieve library statistics

Media Items Management:
- Create Media Item - add new media with full metadata
- Update Media Item - modify existing media metadata
- Delete Media Item - remove media from library
- Get Media Rating - retrieve single media rating
- Delete Media Rating - remove user's media rating

Coverage now complete: 47/47 API endpoints have Bruno requests
Organized requests in proper folder structure for maintainability
2026-01-30 14:26:22 -05:00
john-okeefe ba31e1491e refactor: update Bruno API collection for media-items system
- Remove all ebook-specific API requests (15 files deleted)
- Rename Scan Ebooks.bru to Scan Media Items.bru
- Update API paths from /api/ebooks to /api/media-items
- Update base URL and environment configuration
- Maintain all existing media-items, library, auth, and progress tests

Aligns Bruno collection with unified media-items API architecture
2026-01-30 13:52:06 -05:00
john-okeefe f5a01ece46 Add tests for sorting and filtering functionality
- Add integration tests for sorting (sorting_test.go)
  - Test sort by title, author, page_count, copyright_year, genre
  - Test pagination with sorting
  - Test invalid sort parameter defaults
  - Cover no user, user, and admin contexts
- Add integration tests for filtering (filtering_test.go)
  - Test filter by genre, language, year range, has_cover
  - Test combining multiple filters
  - Test filtering with pagination and sorting
  - Cover no user, user, and admin contexts
- Add Bruno API test for sorting
- Add Bruno API test for filtering
2026-01-30 08:33:03 -05:00
john-okeefe ff44115be2 fix: correct user context type extraction in CreateLibrary handler
- Use c.Get("user").(database.Users) instead of c.Get("user_id").(string)
- Extract userUUID from user.ID.Bytes ([16]byte)
- Properly convert to pgtype.UUID for service layer
- Remove unnecessary uuid.Parse call

This fixes 500 Internal Server Error when creating libraries via API.
The JWT middleware sets user as database.Users struct, not string.

Related to Bruno Create Library request testing.
2026-01-29 21:16:26 -05:00
john-okeefe cec0b17bde test: add search tests and Bruno API collection
- Add comprehensive search integration tests (search_test.go)
- Test no user, user, and admin contexts
- Test partial matching, fuzzy fallback, special characters
- Add Bruno API test for search endpoint
- Fix missing closing parenthesis in test structure
2026-01-29 20:21:01 -05:00
john-okeefe 0276e3312c chore(bruno): update Bruno test files with minor formatting improvements 2026-01-29 11:03:14 -05:00
john-okeefe 66f1eb11a0 feat(ebooks): add ISBN normalization and graceful library requirement handling
- Increase ISBN column from VARCHAR(13) to VARCHAR(17) to support ISBN-13 with hyphens
- Add normalize_isbn() database function to automatically remove hyphens and spaces
- Create trigger to auto-normalize ISBNs on INSERT/UPDATE operations
- Update all Ebook and MediaItem queries to use ISBN normalization
- Add GetEbookLibraryID query to check for existing ebook libraries
- Add graceful error handling when no ebook library exists
- Return helpful error message: 'no ebook library found. Please create an ebook library first'
- Create comprehensive tests for ISBN normalization and library selection
- Add Bruno test files for various ISBN formats and error scenarios
- Update documentation with ISBN normalization details
2026-01-29 10:52:14 -05:00
john-okeefe 6ed69005b5 refactor(bruno): standardize all variables to snake_case naming convention
Standardize all Bruno environment variables to use snake_case convention
(aligned with Go naming practices) and remove duplicate camelCase variants.

Changes:
- Environment file cleanup:
  - Remove: baseUrl, ebookid, fakebookid, libraryId, mediaItemId, isVisible, refreshToken
  - Standardize: fakebookid → fake_book_id, isVisible → is_visible, refreshToken → refresh_token
  - All variables now use consistent snake_case format

- Update all Bruno requests to use standardized variables:
  - ebooks: {{ebookid}} → {{ebook_id}}
  - library: {{libraryId}} → {{library_id}}
  - media-items: {{mediaItemId}} → {{media_item_id}}
  - visibility: {{isVisible}} → {{is_visible}}
  - auth: {{refreshToken}} → {{refresh_token}}

Benefits:
- Single source of truth for each variable
- Consistent with Go naming conventions
- No ambiguity about which variable name to use
- Cleaner, more maintainable codebase
2026-01-29 10:06:00 -05:00
john-okeefe 92dbfec27b fix(bruno): add missing variables to environment and remove invalid vars sections
- Add missing variables to Bookmann environment:
  - library_id (snake_case variant)
  - media_item_id (snake_case variant)
  - job_id for scan status tracking
  - baseUrl (camelCase variant for compatibility)
  - refreshToken to secret vars
- Remove invalid vars sections from request files
  - Variables should be referenced directly from environment
  - Vars sections are for request-specific overrides, not env references
- All variables now properly defined and accessible
2026-01-29 09:55:41 -05:00
john-okeefe fc61b6de6e docs(scanner): update Bruno requests for new scanner endpoints
- Update Scan Ebooks.bru to reflect async background scanning
- Add Get Scan Status.bru for checking job progress
- Add Start Watch Mode.bru for instant file monitoring
- Add Stop Watch Mode.bru for stopping library monitoring
- Add Get Watch Mode Status.bru for checking watched libraries
- Document all new endpoints with examples and status codes
2026-01-29 09:50:46 -05:00
john-okeefe 1e04ef4861 test(security): add comprehensive security tests
- Test password complexity requirements
- Test account lockout mechanism
- Test rate limiting functionality
- Test JWT expiration (1 hour)
- Test refresh token expiration (7 days)
- Test password requirements list
- Verify transaction manager and error handler types
- All tests passing
2026-01-29 09:23:34 -05:00
john-okeefe d3b728c458 fix: resolve registration database connection error
- Fix database authentication error by exposing actual database error messages
- Update error handling to follow pgx v5 standards with detailed error reporting
- Restore token environment variable management in Register User.bru for subsequent requests
- Enable proper debugging of database connection issues during user registration

The registration API now provides detailed error messages instead of generic 'failed to check existing users'
when database connection or authentication fails, making debugging easier.
2026-01-28 20:57:15 -05:00
john-okeefe 8db5939892 refactor: standardize Bruno API requests with bruToJsonV2 format
- Convert all JSON tests to JavaScript functions for bruToJsonV2 compatibility
- Update authentication to use 'inherit' instead of manual headers
- Fix hardcoded URLs to use {{base_url}} variables
- Standardize variable syntax from {{ _.var }} to {{var}}
- Add comprehensive API documentation to all requests
- Update environment variables with missing required fields
- Apply consistent structure: meta, http method, headers, tests, vars, settings, docs
- Enhanced validation with proper error handling and field checks
2026-01-28 20:13:56 -05:00
john-okeefe 78851a940a feat: add comprehensive Bruno API tests for annotations
- Add complete Bruno collection for notes API (5 endpoints)
- Add complete Bruno collection for highlights API (5 endpoints)
- Include detailed request/response documentation
- Add proper validation examples and error cases
- Support both media-items and ebook endpoint testing
- Add environment variable support for dynamic IDs
2026-01-28 15:43:05 -05:00
john-okeefe 81fa177fe6 feat: create Bruno requests for library system API
- Add library management requests (CRUD operations)
- Create media items API requests for library content
- Implement library visibility controls
- Add user library access management
- Update deprecated ebook folder endpoints with migration guide
- Include comprehensive documentation and test cases
- Replace collection.bru with proper dashboard request

Complete Bruno collection supporting new multi-library architecture
2026-01-28 11:15:36 -05:00
john-okeefe ffbf9d8717 fixed formatting so it would show in bruno 2026-01-27 20:43:19 -05:00
john-okeefe 49ee68e905 chore: Clean up and reorganize Bruno collection after rebuild
- Remove duplicate Get Admin Dashboard.bru (same as /admin route)
- Reorder sequence numbers for logical grouping
- Add missing body: none to GET requests
- Standardize folder path examples to /app/uploads
- Fix file formatting and add missing newlines
2026-01-27 16:50:49 -05:00
john-okeefe ad64c044a7 fix: Remove hardcoded example from Scan Ebooks Bruno request
- Remove hardcoded folder_paths example from request body
- Allow flexible folder path configuration per request
- Improve request flexibility for different scan scenarios
2026-01-27 16:25:01 -05:00
john-okeefe 23ead6cf0c feat: Add admin ebook CRUD operations to Bruno collection
- Add POST /api/ebooks for creating new ebook entries
- Add PUT /api/ebooks/:id for updating existing ebook metadata
- Add DELETE /api/ebooks/:id for deleting ebooks from database
- Include complete request/response examples with all metadata fields
- Support file path, metadata, and publication information updates
2026-01-27 16:23:50 -05:00
john-okeefe 4a71376ed5 feat: Add admin ebook folder management routes to Bruno collection
- Add POST /api/auth/ebook-folders for adding ebook folders
- Add GET /api/auth/ebook-folders for retrieving configured folders
- Add DELETE /api/auth/ebook-folders for removing ebook folders
- Include comprehensive documentation and request examples
- Support path normalization and admin-only access
2026-01-27 16:23:42 -05:00
john-okeefe 7116af9a77 feat: Implement precise user registration restrictions
- Implement numbered requirements for user account creation:
  1. No users exist: First user becomes admin
  2. Admins exist: Anyone can register as regular user
  3. Admin logged in: Can create admins and regular users
  4. User logged in: Cannot create any accounts

- Update registration logic in auth.go to validate roles based on existing admin accounts and authentication status
- Add comprehensive error handling for unauthorized user creation attempts
- Ensure security while maintaining usability for regular users

BREAKING CHANGES:
- User accounts creation now restricted based on authentication state
- Regular users cannot create accounts when logged in
- Admin privileges enforced for user management operations
2026-01-27 15:57:52 -05:00
john-okeefe 481adaa71e feat: Implement role-based registration restrictions and reorganize Bruno collection
- Add role-based restrictions to POST /api/auth/register endpoint
- Only admins can create admin accounts if any admin already exists
- First user automatically gets admin role regardless of request
- Regular users can only create user accounts, not admin accounts
- Unauthenticated users can only create first admin, not subsequent admins
- Reorganize Bruno collection into logical subfolders (auth/, admin/, profile/)
- Update documentation to reflect new registration restrictions and security rules

BREAKING CHANGES:
- /api/auth/register now enforces role-based creation restrictions
- Bruno collection reorganized with subfolder structure
2026-01-27 14:15:06 -05:00
john-okeefe 71584c1b55 feat: Enhance admin user management system
- Add admin override capability to DELETE /api/auth/account endpoint
- Move /api/auth/users to admin-only with complete user fields (first_name, last_name, role, theme)
- Consolidate Bruno requests: remove duplicate List Users (Admin), merge Delete Account functionality
- Update all documentation to reflect enhanced capabilities
- Implement pgx 5 standards compliance with proper error handling

BREAKING CHANGES:
- /api/auth/users endpoint now requires admin role (was previously accessible)
- DELETE /api/auth/account accepts optional user_id parameter for admin deletion
2026-01-27 13:36:11 -05:00
john-okeefe 9262a35f68 feat: Restore manual scanner requests for testing
- Recreate Scan Ebooks request with optional folder_paths parameter
- Recreate Start Scanner request for real-time monitoring
- Recreate Stop Scanner request for monitoring control
- All scanner requests remain admin-only as intended
- Essential for testing ebook discovery and scanning functionality
2026-01-26 21:21:43 -05:00
john-okeefe f2994f9147 refactor: Reorganize Bruno requests by role permissions
- Create separate admin folder for admin-only operations
- Move admin endpoints (Create/Update/Delete Ebook, Scanner, Folder Management) to /bruno/admin/
- Add admin dashboard, profile, and library page requests
- Add Register Admin User request with explicit admin role
- Update Register User request to include role field
- Remove empty scanner folder structure

API organization:
- Admin requests: /bruno/admin/ (require admin role)
- User requests: /bruno/user/ (available to all authenticated users)
- Environment: Single {{token}} variable works for both roles
2026-01-26 21:19:19 -05:00
john-okeefe 48b6796bcd docs: Update documentation for role-based access control
- Update README.md with admin system documentation
- Add admin setup instructions and role permissions
- Update API endpoint documentation with access requirements
- Update Bruno collection to reflect admin-only operations
- Document shared library concept and security model
- Add comprehensive admin setup guide
2026-01-26 16:56:35 -05:00
john-okeefe 012242dcad test: Update API collection for rating system changes
- Update rating examples to use 1-10 scale
- Document half-star precision in API collections
- Add rating conversion examples for testing
- Update Get Ebook Rating docs with scale explanation
- Update Create/Update Rating with new validation rules
2026-01-26 13:49:25 -05:00
john-okeefe baa46a8a63 Update documentation to reflect interactive rating system and API changes
- Update README.md with interactive rating system details
- Document zero-rating behavior in GET /api/ebooks/:id/rating
- Add comprehensive rating system documentation section
- Update Bruno collection files to reflect new API behavior
- Enhance API testing documentation with rating 0 fallback
2026-01-26 11:54:53 -05:00
john-okeefe 64afdf6803 Clean up Bruno scanner documentation formatting
- Remove example request body template
- Improve documentation spacing and formatting
- Clarify API endpoint usage and response structure
2026-01-26 11:29:40 -05:00
john-okeefe 068d686fa1 added a fake ebook id to test for errors 2026-01-26 11:02:00 -05:00
john-okeefe 08e80ae84b refactor: reorganize project structure and update configurations
- Move migrations/ to database/schema/ for clarity on database schema definitions
- Move sqlc.yaml to internal/database/ to group with database code
- Move static/ to cmd/server/static/ to co-locate with server
- Update all configuration files and documentation
- Follow Go project conventions for better organization
2026-01-24 23:40:31 -05:00
john-okeefe 7c70e9e85a Update Bruno API tests for user endpoints including new profile management 2026-01-23 21:27:13 -05:00
john-okeefe 11621462f2 feat: create admin dashboard with user preferences and library settings
- Add admin dashboard at /admin route consolidating all user settings
- Move user preferences (username, email, password, theme) from separate page
- Add ebook library preferences section with folder management
- Add scan settings (frequency and auto-scan toggle) with database persistence
- Create database migration for scan_frequency_minutes and auto_scan_enabled columns
- Add API endpoints for scan settings management:
  - PUT /api/library/scan-settings - Update scan preferences
  - GET /api/library/scan-settings - Get current scan settings
- Update dashboard navigation to link to admin dashboard
- Remove old preferences.html template (functionality moved to admin)
- Create Bruno API testing files for library endpoints
- Add real-time folder loading and management in admin interface
- Implement scan settings persistence and retrieval from database
2026-01-23 09:38:40 -05:00
john-okeefe 2dba1d6eb9 feat: add user preferences dashboard
- Add /preferences route and preferences.html template for user settings
- Implement username, email, password, and theme update functionality
- Add account deletion feature with confirmation
- Add navigation link to preferences from dashboard
- Create API endpoints:
  - PUT /api/user/username - Update username
  - PUT /api/user/email - Update email address
  - PUT /api/user/password - Change password with verification
  - DELETE /api/user/account - Delete user account
- Add database queries for user updates and account deletion
- Create Bruno API testing files for all user preference endpoints
- Add proper validation, error handling, and security checks
2026-01-23 09:30:15 -05:00
john-okeefe c29183a14f fix: minor formatting fix in Bruno ebook rating file
- Remove extra space in 'body: json' declaration
- Ensure file ends with proper newline
2026-01-23 09:22:34 -05:00
john-okeefe b9edb92af2 refactor: rename bruno/auth folder to bruno/user
The auth folder now contains user management endpoints beyond just authentication:
- User registration/login (auth)
- Profile management (user)
- Theme settings (user preferences)
- Ebook folder management (user settings)

Renaming to 'user' better reflects the expanded scope covering user accounts, preferences, and settings management.
2026-01-23 09:11:42 -05:00
john-okeefe 6c33ee4364 feat: add Bruno API testing files for multiple folder functionality
- Add auth/Add Ebook Folder.bru - test adding folders to user account
- Add auth/Get Ebook Folders.bru - test listing user's folders
- Add auth/Delete Ebook Folder.bru - test removing folders
- Add scanner/Scan Ebooks.bru - test manual scanning of multiple folders
- Add scanner/Start Scanner.bru - test starting folder monitoring
- Add scanner/Stop Scanner.bru - test stopping folder monitoring
- Update all scanner endpoints to use folder_paths array format
2026-01-23 09:03:15 -05:00
john-okeefe e5ca12117c added ratings and updated ebook struct 2026-01-22 20:54:39 -05:00