Claude
dc0d72c896
feat: Add caching layer and batch operations for improved performance
...
Implement Phase 3 improvements: intelligent caching and batch operations
to significantly enhance SDK performance and usability.
**1. Caching Layer Implementation**
Added complete caching infrastructure with LRU eviction and TTL support:
- `wikijs/cache/base.py`: Abstract BaseCache interface with CacheKey structure
- `wikijs/cache/memory.py`: MemoryCache implementation with:
* LRU (Least Recently Used) eviction policy
* Configurable TTL (time-to-live) expiration
* Cache statistics (hits, misses, hit rate)
* Resource-specific invalidation
* Automatic cleanup of expired entries
**Cache Integration:**
- Modified `WikiJSClient` to accept optional `cache` parameter
- Integrated caching into `PagesEndpoint.get()`:
* Check cache before API request
* Store successful responses in cache
* Invalidate cache on write operations (update, delete)
**2. Batch Operations**
Added efficient batch methods to Pages API:
- `create_many(pages_data)`: Batch create multiple pages
- `update_many(updates)`: Batch update pages with partial success handling
- `delete_many(page_ids)`: Batch delete with detailed error reporting
All batch methods include:
- Partial success support (continue on errors)
- Detailed error tracking with indices
- Comprehensive error messages
**3. Comprehensive Testing**
Added 27 new tests (all passing):
- `tests/test_cache.py`: 17 tests for caching (99% coverage)
* CacheKey string generation
* TTL expiration
* LRU eviction policy
* Cache invalidation (specific & all resources)
* Statistics tracking
- `tests/endpoints/test_pages_batch.py`: 10 tests for batch operations
* Successful batch creates/updates/deletes
* Partial failure handling
* Empty list edge cases
* Validation error handling
**Performance Benefits:**
- Caching reduces API calls for frequently accessed pages
- Batch operations reduce network overhead for bulk actions
- Configurable cache size and TTL for optimization
**Example Usage:**
```python
from wikijs import WikiJSClient
from wikijs.cache import MemoryCache
# Enable caching
cache = MemoryCache(ttl=300, max_size=1000)
client = WikiJSClient('https://wiki.example.com ', auth='key', cache=cache)
# Cached GET requests
page = client.pages.get(123) # Fetches from API
page = client.pages.get(123) # Returns from cache
# Batch operations
pages = client.pages.create_many([
PageCreate(title="Page 1", path="page-1", content="Content 1"),
PageCreate(title="Page 2", path="page-2", content="Content 2"),
])
updates = client.pages.update_many([
{"id": 1, "content": "Updated content"},
{"id": 2, "is_published": False},
])
result = client.pages.delete_many([1, 2, 3])
print(f"Deleted {result['successful']} pages")
```
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-23 14:46:58 +00:00
Claude
8e9bd5973a
Add comprehensive Assets API tests - increase coverage from 43% to 81%
...
Add 19 new tests for Assets endpoint covering:
Move operations:
- test_move_asset (success case)
- test_move_asset_validation_error (edge cases)
Folder operations:
- test_create_folder (full params)
- test_create_folder_minimal (minimal params)
- test_create_folder_validation_error
- test_delete_folder (success)
- test_delete_folder_validation_error
List operations with filters:
- test_list_assets_with_folder_filter
- test_list_assets_with_kind_filter
- test_list_assets_empty
Error handling:
- test_get_asset_not_found
- test_delete_asset_failure
- test_rename_asset_failure
- test_move_asset_failure
- test_create_folder_failure
- test_delete_folder_failure
Pagination & edge cases:
- test_iter_all_assets (pagination iterator)
- test_normalize_asset_data_minimal
- test_list_folders_empty
Impact:
- Assets endpoint: 43% → 81% coverage (+38%)
- Total tests: 423 → 442 tests (+19)
- Overall coverage: 77.10% → 79.32% (+2.22%)
- All tests passing (442/442)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-23 01:59:14 +00:00
Claude
8f6a81154c
Add JWT base_url validation tests
...
Add 2 additional JWT authentication tests:
- test_init_with_empty_base_url_raises_error
- test_init_with_whitespace_base_url_raises_error
Improves JWT auth coverage slightly and adds validation coverage
for base_url parameter.
Tests: 442 → 444 (+2)
Coverage: 79.32% → 79.35% (+0.03%)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-23 01:59:14 +00:00
Claude
40b6640590
Implement auto-pagination iterators for all endpoints
...
Implementation:
- Added iter_all() method to all sync endpoints
- PagesEndpoint.iter_all() - automatic pagination for pages
- UsersEndpoint.iter_all() - automatic pagination for users
- GroupsEndpoint.iter_all() - iterate over all groups
- AssetsEndpoint.iter_all() - iterate over all assets
- Added async iter_all() to all async endpoints
- AsyncPagesEndpoint - async generator with pagination
- AsyncUsersEndpoint - async generator with pagination
- AsyncGroupsEndpoint - async iterator
- AsyncAssetsEndpoint - async iterator
Features:
- Automatic batch fetching (configurable batch size, default: 50)
- Transparent pagination - users don't manage offsets
- Memory efficient - fetches data in chunks
- Filtering support - pass through all filter parameters
- Consistent interface across all endpoints
Usage:
# Sync iteration
for page in client.pages.iter_all(batch_size=100):
print(page.title)
# Async iteration
async for user in client.users.iter_all():
print(user.name)
Tests:
- 7 comprehensive pagination tests
- Single batch, multiple batch, and empty result scenarios
- Both sync and async iterator testing
- All tests passing (100%)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-22 20:45:59 +00:00
Claude
cbbf801d7c
Add comprehensive tests for Assets API (14 tests)
...
Tests include:
- Asset model validation (8 tests)
- Asset, AssetRename, FolderCreate models
- Field validation, filename validation
- Size helper methods (size_mb, size_kb)
- Slug normalization
- Sync AssetsEndpoint (6 tests)
- List, get, rename, delete operations
- Folder listing
- Validation error handling
All 14 tests passing. Achieves comprehensive coverage for Assets API.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-22 20:36:01 +00:00
Claude
5c0de7f70b
Add comprehensive tests for Groups API (24 tests)
...
Tests include:
- Group model validation (8 tests)
- Group, GroupCreate, GroupUpdate models
- Field validation, name validation
- Minimal and full field tests
- Sync GroupsEndpoint (8 tests)
- List, get, create, update, delete operations
- User assignment/unassignment operations
- Validation error handling
- Async AsyncGroupsEndpoint (8 tests)
- Complete async coverage matching sync API
- All CRUD operations tested
- User management operations
All 24 tests passing. Achieves comprehensive coverage for Groups API.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-22 20:29:11 +00:00
Claude
2ea3936b5c
Add comprehensive tests for Users API (70 tests total)
...
Tests include:
- User model validation (22 tests)
- UserGroup, User, UserCreate, UserUpdate models
- Field validation, email validation, password strength
- CamelCase alias support
- Sync UsersEndpoint (24 tests)
- List, get, create, update, delete operations
- Search functionality
- Pagination and filtering
- Error handling and validation
- Data normalization
- Async AsyncUsersEndpoint (24 tests)
- Complete async coverage matching sync API
- All CRUD operations tested
- Validation and error handling
All 70 tests passing. Achieves >95% coverage for Users API code.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-22 20:18:27 +00:00
Claude
0fa290d67b
Add comprehensive async tests - all 37 tests passing
...
Phase 2, Task 2.1, Step 4 Complete: Async Testing Suite
This commit adds a complete test suite for the async client and
async pages endpoint, achieving 100% pass rate for async functionality.
Test Coverage:
--------------
1. **AsyncWikiJSClient Tests** (test_async_client.py)
- Initialization tests (5 tests)
* API key string initialization
* Auth handler initialization
* Invalid auth parameter handling
* Custom settings configuration
* Pages endpoint availability
- HTTP Request tests (5 tests)
* Successful API requests
* 401 authentication errors
* API error handling (500 errors)
* Connection error handling
* Timeout error handling
- Connection Testing (4 tests)
* Successful connection test
* GraphQL error handling
* Invalid response format detection
* Missing configuration detection
- Context Manager tests (2 tests)
* Async context manager protocol
* Manual close handling
- Session Creation tests (3 tests)
* Session creation and configuration
* Lazy session initialization
* Session reuse
2. **AsyncPagesEndpoint Tests** (test_async_pages.py)
- Initialization test
- List operations (3 tests)
* Basic listing
* Parameterized filtering
* Validation errors
- Get operations (3 tests)
* Get by ID
* Validation errors
* Not found handling
- Get by path operation
- Create operations (2 tests)
* Successful creation
* Failed creation handling
- Update operation
- Delete operations (2 tests)
* Successful deletion
* Failed deletion handling
- Search operation
- Get by tags operation
- GraphQL error handling
- Data normalization tests (2 tests)
Bug Fixes:
----------
- Fixed exception handling order in AsyncWikiJSClient._request()
* ServerTimeoutError now caught before ClientConnectionError
* Prevents timeout errors being misclassified as connection errors
- Fixed test mocking for async context managers
* Properly mock __aenter__ and __aexit__ methods
* Fixed session creation in async context
Test Results:
-------------
✅ 37/37 tests passing (100% pass rate)
✅ Async client tests: 19/19 passing
✅ Async pages tests: 18/18 passing
✅ 53% overall code coverage (includes async code)
✅ Zero flake8 errors
✅ All imports successful
Quality Metrics:
----------------
- Test coverage for async module: >85%
- All edge cases covered (errors, validation, not found)
- Proper async/await usage throughout
- Mock objects properly configured
- Clean test structure and organization
Next Steps:
-----------
- Create async usage examples
- Write async documentation
- Performance benchmarks (async vs sync)
- Integration tests with real Wiki.js instance
This establishes a solid foundation for async development
with comprehensive test coverage ensuring reliability.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-22 18:12:29 +00:00
Claude
66f4471e53
Fix 3 critical issues identified in repository review
...
**Critical Fixes:**
1. **Fixed Error Hierarchy** (wikijs/exceptions.py)
- ConnectionError and TimeoutError now properly inherit from APIError
- Ensures consistent exception handling across the SDK
- Added proper __init__ methods with status_code=None
2. **Fixed test_connection Method** (wikijs/client.py)
- Changed from basic HTTP GET to proper GraphQL query validation
- Now uses query { site { title } } to validate API connectivity
- Provides better error messages for authentication failures
- Validates both connectivity AND API access
3. **Implemented JWT Token Refresh** (wikijs/auth/jwt.py)
- Added base_url parameter to JWTAuth class
- Implemented complete refresh() method with HTTP request to /api/auth/refresh
- Handles token, refresh token, and expiration updates
- Proper error handling for network failures and auth errors
**Bonus Fixes:**
- Dynamic user agent version (uses __version__ from version.py instead of hardcoded)
- Updated all JWT tests to include required base_url parameter
- Updated test mocks to match new GraphQL-based test_connection
**Test Results:**
- All 231 tests passing ✅
- Test coverage: 91.64% (target: 85%) ✅
- No test failures or errors
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-10-22 17:44:44 +00:00
19362ddeb3
testing adjustments
2025-07-30 21:34:55 -04:00
ade9aacf56
Fix code formatting and linting issues
...
- Updated GitHub Actions workflow to use correct flake8 configuration
- Fixed line length issues by using 88 characters as configured
- Removed unused imports and trailing whitespace
- Fixed f-string placeholders and unused variables
- All linting checks now pass with project configuration
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-07-30 20:49:40 -04:00
db95a4c1be
changed to github deployment for the first version.
2025-07-30 19:43:23 -04:00
18a82711cb
ready for try
2025-07-29 20:16:11 -04:00