Metadata-Version: 2.4
Name: aio-sf
Version: 0.1.0b1
Summary: Async Salesforce library for Python with Bulk API 2.0 support
Project-URL: Homepage, https://github.com/callawaycloud/aio-salesforce
Project-URL: Repository, https://github.com/callawaycloud/aio-salesforce
Project-URL: Issues, https://github.com/callawaycloud/aio-salesforce/issues
Author-email: Jonas <charlie@callaway.cloud>
License: MIT License
        
        Copyright (c) 2025 Callaway Cloud
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Requires-Dist: httpx>=0.25.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: all
Requires-Dist: boto3>=1.34.0; extra == 'all'
Requires-Dist: pandas>=2.0.0; extra == 'all'
Requires-Dist: pyarrow>=10.0.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: black>=23.0.0; extra == 'dev'
Requires-Dist: mypy>=1.5.0; extra == 'dev'
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.10.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Requires-Dist: types-requests>=2.31.0; extra == 'dev'
Provides-Extra: exporter
Requires-Dist: boto3>=1.34.0; extra == 'exporter'
Requires-Dist: pandas>=2.0.0; extra == 'exporter'
Requires-Dist: pyarrow>=10.0.0; extra == 'exporter'
Description-Content-Type: text/markdown

# aio-sf

An async Salesforce library for Python with Bulk API 2.0 support.

## Features

### ✅ Supported APIs
- [x] **OAuth Client Credentials Flow** - Automatic authentication
- [x] **Bulk API 2.0** - Efficient querying of large datasets
- [x] **Describe API** - Field metadata and object descriptions
- [x] **SOQL Query API** - Standard Salesforce queries

### 🔄 Planned APIs
- [ ] **SObjects API** - Standard CRUD operations
- [ ] **Tooling API** - Development and deployment tools
- [ ] **Bulk API 1.0** - Legacy bulk operations
- [ ] **Streaming API** - Real-time event streaming

### 🚀 Export Features
- [x] **Parquet Export** - Efficient columnar storage with schema mapping
- [x] **CSV Export** - Simple text format export
- [x] **Resume Support** - Resume interrupted queries using job IDs
- [x] **Streaming Processing** - Memory-efficient processing of large datasets
- [x] **Type Mapping** - Automatic Salesforce to PyArrow type conversion

## Installation

### Core (Connection Only)
```bash
uv add aio-sf
# or: pip install aio-sf
```

### With Export Capabilities
```bash
uv add "aio-sf[exporter]"
# or: pip install "aio-sf[exporter]"
```

## Quick Start

### Authentication & Connection
```python
import asyncio
import os
from aio_salesforce import SalesforceConnection, ClientCredentialsAuth

async def main():
    auth = ClientCredentialsAuth(
        client_id=os.getenv('SF_CLIENT_ID'),
        client_secret=os.getenv('SF_CLIENT_SECRET'),
        instance_url=os.getenv('SF_INSTANCE_URL'),
    )
    
    async with SalesforceConnection(auth_strategy=auth) as sf:
        print(f"✅ Connected to: {sf.instance_url}")

        sobjects = await sf.describe.list_sobjects()
        print(sobjects[0]["name"])

        contact_describe = await sf.describe.sobject("Contact")

        # retrieve first 5 "creatable" fields on contact
        queryable_fields = [
            field.get("name", "")
            for field in contact_describe["fields"]
            if field.get("createable")
        ][:5]

        query = f"SELECT {', '.join(queryable_fields)} FROM Contact LIMIT 5"
        print(query)

        query_result = await sf.query.soql(query)
        # Loop over records using async iteration
        async for record in query_result:
            print(record.get("AccountId"))

asyncio.run(main())
```




## Exporter

The Exporter library contains a streamlined and "opinionated" way to export data from Salesforce to various formats.  

### 2. Query Records
```python
from aio_salesforce.exporter import bulk_query

async def main():
    # ... authentication code from above ...
    
    async with SalesforceConnection(auth_strategy=auth) as sf:
        # Execute bulk query
        query_result = await bulk_query(
            sf=sf,
            soql_query="SELECT Id, Name, Email FROM Contact LIMIT 1000"
        )
        
        # Process records
        count = 0
        async for record in query_result:
            print(f"Contact: {record['Name']} - {record['Email']}")
            count += 1
            
        print(f"Processed {count} records")
```

### 3. Export to Parquet
```python
from aio_salesforce.exporter import bulk_query, write_query_to_parquet

async def main():
    # ... authentication code from above ...
    
    async with SalesforceConnection(auth_strategy=auth) as sf:
        # Query with proper schema
        query_result = await bulk_query(
            sf=sf,
            soql_query="SELECT Id, Name, Email, CreatedDate FROM Contact"
        )
        
        # Export to Parquet
        write_query_to_parquet(
            query_result=query_result,
            file_path="contacts.parquet"
        )
        
        print(f"✅ Exported {len(query_result)} contacts to Parquet")
```


## License

MIT License