Commit Graph

2 Commits

Author SHA1 Message Date
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
95c86b6600 Implement async/await support with AsyncWikiJSClient
Phase 2, Task 2.1, Steps 1-3 Complete: Async Client Architecture

This commit introduces comprehensive async/await support for the Wiki.js
Python SDK, providing high-performance concurrent operations using aiohttp.

Key Features:
------------

1. **AsyncWikiJSClient** (wikijs/aio/client.py)
   - Full async/await support with aiohttp
   - Connection pooling (100 connections, 30 per host)
   - Async context manager support (async with)
   - Same interface as sync client for easy migration
   - Proper resource cleanup and session management
   - DNS caching for improved performance

2. **Async Endpoints** (wikijs/aio/endpoints/)
   - AsyncBaseEndpoint - Base class for all async endpoints
   - AsyncPagesEndpoint - Complete async Pages API
     * list() - List pages with filtering
     * get() - Get page by ID
     * get_by_path() - Get page by path
     * create() - Create new page
     * update() - Update existing page
     * delete() - Delete page
     * search() - Search pages
     * get_by_tags() - Filter by tags

3. **Architecture**
   - Mirrors sync client structure for consistency
   - Reuses existing models, exceptions, and utilities
   - Optional dependency (aiohttp) via extras_require
   - Zero breaking changes to sync API

Performance Benefits:
--------------------
- Designed for >3x throughput vs sync client
- Efficient connection pooling and reuse
- Concurrent request handling
- Reduced latency with TCP keepalive

Usage Example:
--------------
```python
from wikijs.aio import AsyncWikiJSClient

async with AsyncWikiJSClient(url, auth='key') as client:
    # Concurrent operations
    pages = await client.pages.list()
    page = await client.pages.get(123)

    # Create/Update/Delete
    new_page = await client.pages.create(page_data)
    updated = await client.pages.update(123, updates)
    await client.pages.delete(123)
```

Installation:
-------------
```bash
pip install wikijs-python-sdk[async]
```

Quality Metrics:
----------------
-  All imports successful
-  Black formatting applied
-  Flake8 passing (complexity warnings expected)
-  MyPy type checking (minor issues in base models)
-  Zero breaking changes to sync API

Next Steps:
-----------
- Comprehensive async unit tests
- Integration tests with real Wiki.js instance
- Performance benchmarks (async vs sync)
- Documentation and usage examples

This lays the foundation for high-performance async operations
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:07:29 +00:00