Metadata-Version: 2.4
Name: aio-sf
Version: 0.1.0b6
Summary: Async Salesforce library for Python
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.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Requires-Dist: boto3>=1.34.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: pyarrow>=10.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: core
Requires-Dist: httpx>=0.25.0; extra == 'core'
Requires-Dist: pydantic>=2.0.0; extra == 'core'
Requires-Dist: python-dotenv>=1.0.0; extra == 'core'
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-asyncio>=0.21.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.

## Features

### ✅ Supported APIs
- [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
- [x] **SObjects Collections API** - CRUD on collections of SObjects (up to 2000 records at a time)
- [ ] **Tooling API** - Development and deployment tools
- [ ] **Bulk API 1.0** - Legacy bulk operations
- [ ] **Streaming API** - Real-time event streaming

### ✅ Supported Authentication Strategies
- [x] **OAuth Client Credentials** - Automatic authentication
- [x] **Static Token** - Existing access tokens
- [x] **Refresh Token** - Refresh token flow
- [x] **SFDX CLI** - Login by grabbing a token from the SFDX CLI
- [ ] **Password Authentication** - Password + ST authentication (soap login)

### 🚀 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

## Installation

### Full Package (Default - Includes Everything)
```bash
uv add aio-sf
# or: pip install aio-sf
```

### Core Only (Minimal Dependencies)
```bash
uv add "aio-sf[core]"
# or: pip install "aio-sf[core]"
```

## Quick Start

### Authentication & Connection
```python
import asyncio
import os
from aio_sf import SalesforceClient, 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 SalesforceClient(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
        # or: await query_result.collect_all() to collect all records into a list
        async for record in query_result:
            print(record.get("AccountId"))

        # Create a new Account
        await sf.collections.insert(
            sobject_type="Account",
            records=[{"Name": "Test Account"}]
        )

asyncio.run(main())
```



## Exporter

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


### 3. Export to Parquet
```python
# With full installation (default), you can import directly from aio_sf
from aio_sf import SalesforceClient, ClientCredentialsAuth, bulk_query, write_query_to_parquet

# Or import from the exporter module (both work)
# from aio_sf.exporter import bulk_query, write_query_to_parquet

async def main():
    # ... authentication code from above ...
    
    async with SalesforceClient(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