Commit Graph

14 Commits

Author SHA1 Message Date
Claude
59cdf5ee01 refactor: Rename package from wikijs-python-sdk to py-wikijs and migrate to GitHub
Complete package renaming and platform migration:

Package Name Changes:
- Rename package from 'wikijs-python-sdk' to 'py-wikijs'
- Update setup.py package name
- Update pyproject.toml package name
- Users can now install with: pip install py-wikijs

URL Migration (Gitea → GitHub):
- Replace all Gitea URLs with GitHub URLs
- Update repository: github.com/l3ocho/py-wikijs
- Update issue tracker: github.com/l3ocho/py-wikijs/issues
- Update documentation links
- Fix URL path format (/src/branch/main/ → /blob/main/)

Documentation Updates:
- Update README.md badges (PyPI, GitHub)
- Update installation instructions (pip install py-wikijs)
- Update all doc references to new package name
- Update all examples with GitHub URLs
- Update DEPLOYMENT_READY.md with new package name
- Update deployment.md with new package name

Testing:
- Successfully built py_wikijs-0.1.0.tar.gz (138 KB)
- Successfully built py_wikijs-0.1.0-py3-none-any.whl (66 KB)
- Package installs correctly: pip install py-wikijs
- Imports work: from wikijs import WikiJSClient
- Package metadata correct (Home-page: github.com/l3ocho/py-wikijs)

Breaking Changes:
- Package name changed from wikijs-python-sdk to py-wikijs
- Repository migrated from Gitea to GitHub
- All URLs updated to GitHub

Users should now:
pip install py-wikijs  # Instead of wikijs-python-sdk

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 20:23:50 +00:00
Claude
5cd55e65af docs: Add comprehensive Wiki.js version compatibility documentation
Add detailed compatibility documentation and version detection:

- Add Wiki.js 2.x compatibility badge and requirements to README
- Create comprehensive docs/compatibility.md guide
  - Detailed version support matrix (2.2 through 2.5.308+)
  - API schema differences between 2.x and 3.x
  - Version detection examples and troubleshooting
  - Known compatibility issues and solutions
  - Future 3.x support planning
- Enhance test_connection() in both sync and async clients
  - Add API version compatibility detection
  - Better error messages for incompatible versions
  - Detect Wiki.js 3.x and provide clear guidance
- Update package metadata
  - Add Wiki.js compatibility keywords to setup.py and pyproject.toml
  - Add compatibility documentation link to project URLs

SDK supports Wiki.js 2.x (versions 2.2 - 2.5.308+)
Wiki.js 3.x (alpha) not yet supported due to different API schema

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 20:01:14 +00:00
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
d2003a0005 Implement Assets API with file/asset management operations
Implementation:
- Asset data models (wikijs/models/asset.py)
  - Asset, AssetFolder models
  - AssetUpload, AssetRename, AssetMove models
  - FolderCreate model
  - File size helpers (size_mb, size_kb)
  - Field validation and normalization

- Sync AssetsEndpoint (wikijs/endpoints/assets.py)
  - list(folder_id, kind) - List assets with filtering
  - get(asset_id) - Get single asset
  - rename(asset_id, new_filename) - Rename asset
  - move(asset_id, folder_id) - Move asset between folders
  - delete(asset_id) - Delete asset
  - list_folders() - List all folders
  - create_folder(slug, name) - Create new folder
  - delete_folder(folder_id) - Delete folder
  - Note: upload/download require multipart support (future enhancement)

- Async AsyncAssetsEndpoint (wikijs/aio/endpoints/assets.py)
  - Complete async implementation
  - Identical interface to sync version
  - All asset and folder management operations

- Integration with clients
  - WikiJSClient.assets
  - AsyncWikiJSClient.assets

GraphQL operations for asset and folder management.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 20:34:50 +00:00
Claude
fc96472d55 Implement Groups API with complete CRUD operations
Implementation:
- Group data models (wikijs/models/group.py)
  - Group, GroupCreate, GroupUpdate models
  - GroupPermission, GroupPageRule, GroupUser models
  - GroupAssignUser, GroupUnassignUser models
  - Field validation and normalization

- Sync GroupsEndpoint (wikijs/endpoints/groups.py)
  - list() - List all groups with users
  - get(group_id) - Get single group
  - create(group_data) - Create new group
  - update(group_id, group_data) - Update existing group
  - delete(group_id) - Delete group
  - assign_user(group_id, user_id) - Add user to group
  - unassign_user(group_id, user_id) - Remove user from group

- Async AsyncGroupsEndpoint (wikijs/aio/endpoints/groups.py)
  - Complete async implementation
  - Identical interface to sync version
  - All CRUD operations + user management

- Integration with clients
  - WikiJSClient.groups
  - AsyncWikiJSClient.groups

GraphQL operations for all group management features.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 20:27:22 +00:00
Claude
930fe50e60 Implement Users API with complete CRUD operations
Phase 2, Task 2.2.1: Users API Implementation (Sync)

This commit adds comprehensive user management capabilities to the
Wiki.js Python SDK with full CRUD operations.

User Data Models (wikijs/models/user.py):
-----------------------------------------

1. **User** - Complete user data model
   - Profile information (name, email, location, job title)
   - Authentication details (provider, verified, active status)
   - Group memberships with UserGroup nested model
   - Timestamps (created, updated, last login)
   - Email validation with pydantic EmailStr
   - Name validation (2-255 characters)

2. **UserCreate** - User creation model
   - Required: email, name, password
   - Optional: groups, profile fields, provider settings
   - Validation: email format, password strength (min 6 chars)
   - Welcome email configuration
   - Password change enforcement

3. **UserUpdate** - User update model
   - All fields optional for partial updates
   - Email, name, password updates
   - Profile field updates
   - Group membership changes
   - Status flags (active, verified)

4. **UserGroup** - Group membership model
   - Group ID and name
   - Used in User model for group associations

Users Endpoint (wikijs/endpoints/users.py):
-------------------------------------------

Complete CRUD Operations:

1. **list()** - List users with filtering
   - Pagination (limit, offset)
   - Search by name/email
   - Ordering (name, email, createdAt, lastLoginAt)
   - Client-side pagination fallback

2. **get(user_id)** - Get user by ID
   - Fetch single user with full details
   - Include group memberships
   - Comprehensive error handling

3. **create(user_data)** - Create new user
   - Accept UserCreate object or dict
   - Full validation before API call
   - Returns created User object
   - Handles creation failures gracefully

4. **update(user_id, user_data)** - Update existing user
   - Partial updates supported
   - Only sends changed fields
   - Returns updated User object
   - Validates all updates

5. **delete(user_id)** - Delete user
   - Permanent deletion
   - Returns boolean success
   - Clear error messages

6. **search(query)** - Search users
   - Search by name or email
   - Optional result limiting
   - Uses list() with search filter

Helper Methods:
   - _normalize_user_data() - API response normalization
   - Handles field name mapping (camelCase → snake_case)
   - Group data structure conversion

Integration:
------------
- Added UsersEndpoint to WikiJSClient
- Updated endpoints module exports
- Added user models to main package exports
- Installed email-validator dependency for EmailStr

GraphQL Queries:
----------------
- users.list - List/search users
- users.single - Get user by ID
- users.create - Create new user
- users.update - Update existing user
- users.delete - Delete user

All queries include proper error handling and response validation.

Code Quality:
-------------
 Compiles without errors
 Type hints on all methods
 Comprehensive docstrings
 Input validation
 Proper exception handling
 Follows existing code patterns

Next Steps:
-----------
- Implement AsyncUsersEndpoint (async version)
- Write comprehensive tests
- Add usage documentation
- Create examples

Phase 2, Task 2.2.1 Progress: ~50% Complete
Users API (sync):  COMPLETE
Users API (async):  IN PROGRESS

This establishes the foundation for complete user management
in the Wiki.js Python SDK.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 18:21:46 +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
bfb0589953 Fix whitespace in blank line (W293)
- Removed trailing whitespace from blank line in client.py:66
- All flake8 checks now pass

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 21:00:35 -04:00
b0c1599958 Fix mypy type checking errors
- Updated mypy configuration to use Python 3.9+
- Added missing type annotations to all function parameters
- Fixed type compatibility issues in variable assignments
- Resolved unreachable code and return type warnings
- All mypy checks now pass successfully

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 20:56:29 -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
18a82711cb ready for try 2025-07-29 20:16:11 -04:00
29001b02a5 Complete Task 1.3 - Authentication System Implementation
 Implemented comprehensive authentication system:
- Abstract AuthHandler base class with pluggable architecture
- APIKeyAuth for API key authentication (string auto-conversion)
- JWTAuth for JWT token authentication with expiration handling
- NoAuth for testing and public instances
- Full integration with WikiJSClient for automatic header management

🔧 Fixed packaging issues:
- Updated pyproject.toml with required project metadata fields
- Fixed utility function exports in utils/__init__.py
- Package now installs correctly in virtual environments

🧪 Validated with comprehensive tests:
- All authentication methods working correctly
- Proper error handling for invalid credentials
- Type validation and security features

📊 Progress: Phase 1 MVP Development now 60% complete
🎯 Next: Task 1.4 - Pages API implementation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 15:06:11 -04:00
11b6be87c8 Complete Phase 1 foundation: Tasks 1.1 and 1.2
 Task 1.1 - Project Foundation Setup:
- Repository structure with Python packaging (setup.py, pyproject.toml)
- Development dependencies and requirements
- Contributing guidelines and MIT license
- GitHub workflows for CI/CD (test.yml, release.yml)
- Issue and PR templates for community contributions
- Comprehensive project documentation

 Task 1.2 - Core Client Structure:
- wikijs package with proper module organization
- Core client class foundation in client.py
- Exception hierarchy for error handling
- Base model classes and page models
- Type checking support (py.typed)
- Utility modules and helper functions

📊 Progress: Phase 1 MVP Development now 40% complete
🎯 Next: Task 1.3 - Authentication System implementation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-29 13:25:36 -04:00