atlascompiler 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atlascompiler-1.0.0/.gitignore +4 -0
- atlascompiler-1.0.0/LICENSE +21 -0
- atlascompiler-1.0.0/PKG-INFO +128 -0
- atlascompiler-1.0.0/README.md +109 -0
- atlascompiler-1.0.0/pyproject.toml +39 -0
- atlascompiler-1.0.0/src/atlascompiler/__init__.py +1235 -0
- atlascompiler-1.0.0/src/atlascompiler/py.typed +1 -0
- atlascompiler-1.0.0/src/atlascompiler/webhooks.py +257 -0
- atlascompiler-1.0.0/tests/test_conformance.py +223 -0
- atlascompiler-1.0.0/tests/test_webhooks.py +323 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Atlas Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: atlascompiler
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Atlas Python SDK
|
|
5
|
+
Project-URL: Homepage, https://github.com/Atlas-Compiler/Atlas
|
|
6
|
+
Project-URL: Repository, https://github.com/Atlas-Compiler/Atlas
|
|
7
|
+
Project-URL: Issues, https://github.com/Atlas-Compiler/Atlas/issues
|
|
8
|
+
Project-URL: Discord, https://discord.gg/z9ktRhuudq
|
|
9
|
+
Project-URL: Documentation, https://docs.atlas-compiler.com/sdk/python
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Requires-Dist: httpx==0.28.1
|
|
14
|
+
Requires-Dist: typing-extensions==4.15.0
|
|
15
|
+
Provides-Extra: test
|
|
16
|
+
Requires-Dist: build==1.2.2.post1; extra == 'test'
|
|
17
|
+
Requires-Dist: pytest==8.3.5; extra == 'test'
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# Atlas Python SDK
|
|
21
|
+
|
|
22
|
+
The official Python client library for the [Atlas](https://atlas-compiler.com) API.
|
|
23
|
+
|
|
24
|
+
Supports both synchronous and asynchronous workflows with full type annotations, automatic idempotency protection, polling helpers, and constant-time webhook signature verification.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install atlascompiler
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### Synchronous Client (`AtlasClient`)
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import os
|
|
38
|
+
from atlascompiler import AtlasClient, CompileUrlRequest
|
|
39
|
+
|
|
40
|
+
# Initializes using explicit args or ambient environment (ATLAS_API_KEY, ATLAS_WORKSPACE_ID)
|
|
41
|
+
with AtlasClient(os.getenv("ATLAS_API_KEY"), workspace_id=os.getenv("ATLAS_WORKSPACE_ID")) as client:
|
|
42
|
+
# Compile: Automatically generates UUIDv4 idempotency key when omitted
|
|
43
|
+
response = client.compile({"url": "https://example.com/article"})
|
|
44
|
+
|
|
45
|
+
if response.status == 200:
|
|
46
|
+
print("Compiled Markdown:", response.value["markdown"])
|
|
47
|
+
else:
|
|
48
|
+
# 202 Accepted: Asynchronous compilation job
|
|
49
|
+
job_id = response.value["id"]
|
|
50
|
+
job = client.wait_for_job(job_id, interval_seconds=1.0, max_wait_seconds=60.0)
|
|
51
|
+
results = client.list_job_results(job_id)
|
|
52
|
+
print("Results:", results.value["data"][0]["markdown"])
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Asynchronous Client (`AsyncAtlasClient`)
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
import asyncio
|
|
59
|
+
import os
|
|
60
|
+
from atlascompiler import AsyncAtlasClient
|
|
61
|
+
|
|
62
|
+
async def main():
|
|
63
|
+
async with AsyncAtlasClient(os.getenv("ATLAS_API_KEY")) as client:
|
|
64
|
+
response = await client.compile({"url": "https://example.com/article"})
|
|
65
|
+
if response.status == 200:
|
|
66
|
+
print("Markdown:", response.value["markdown"])
|
|
67
|
+
else:
|
|
68
|
+
job = await client.wait_for_job(response.value["id"])
|
|
69
|
+
results = await client.list_job_results(job["id"])
|
|
70
|
+
print("Results:", results.value["data"][0]["markdown"])
|
|
71
|
+
|
|
72
|
+
asyncio.run(main())
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Idempotency Semantics
|
|
76
|
+
|
|
77
|
+
- **Implicit Execution Safety**: For mutation endpoints (`compile`, `cancel_job`, `bulk_cancel_jobs`), an RFC 4122 UUIDv4 is automatically generated when `idempotency_key` is omitted.
|
|
78
|
+
- **Explicit Deterministic Deduplication**: When deduplication across distinct attempts is required, pass your custom string:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
client.compile({"url": "https://example.com"}, idempotency_key="my-deterministic-key-123")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Error Handling (RFC 9457)
|
|
85
|
+
|
|
86
|
+
All non-2xx API errors raise `AtlasApiError` containing the parsed RFC 9457 Problem Details object:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from atlascompiler import AtlasApiError
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
client.get_job("job_invalid_id")
|
|
93
|
+
except AtlasApiError as e:
|
|
94
|
+
print(f"Error [{e.status}] {e.code}: {e.detail}")
|
|
95
|
+
print(f"Request ID: {e.problem.get('requestId')}")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Webhook Signature Verification
|
|
99
|
+
|
|
100
|
+
Verify webhook payloads, guard against replay attacks with configurable clock drift tolerance, and support zero-downtime secret rotation:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from atlascompiler import verify_webhook_signature
|
|
104
|
+
|
|
105
|
+
result = verify_webhook_signature(
|
|
106
|
+
payload=raw_body, # bytes or str
|
|
107
|
+
headers=request.headers,
|
|
108
|
+
secret=os.getenv("ATLAS_WEBHOOK_SECRET"),
|
|
109
|
+
previous_secret=os.getenv("ATLAS_WEBHOOK_PREVIOUS_SECRET"), # optional rotation grace
|
|
110
|
+
tolerance_seconds=300, # 5 minutes
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
if not result.valid:
|
|
114
|
+
print(f"Webhook verification failed: {result.error}")
|
|
115
|
+
else:
|
|
116
|
+
event = result.event
|
|
117
|
+
print(f"Received event: {event['type']}")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Configuration Precedence
|
|
121
|
+
|
|
122
|
+
1. Explicit constructor arguments (`api_key`, `workspace_id`, `base_url`, `timeout`)
|
|
123
|
+
2. Ambient environment variables (`ATLAS_API_KEY`, `ATLAS_WORKSPACE_ID`, `ATLAS_BASE_URL`)
|
|
124
|
+
3. Defaults (`https://api.atlas-compiler.com`, 30.0s timeout)
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Atlas Python SDK
|
|
2
|
+
|
|
3
|
+
The official Python client library for the [Atlas](https://atlas-compiler.com) API.
|
|
4
|
+
|
|
5
|
+
Supports both synchronous and asynchronous workflows with full type annotations, automatic idempotency protection, polling helpers, and constant-time webhook signature verification.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install atlascompiler
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### Synchronous Client (`AtlasClient`)
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
import os
|
|
19
|
+
from atlascompiler import AtlasClient, CompileUrlRequest
|
|
20
|
+
|
|
21
|
+
# Initializes using explicit args or ambient environment (ATLAS_API_KEY, ATLAS_WORKSPACE_ID)
|
|
22
|
+
with AtlasClient(os.getenv("ATLAS_API_KEY"), workspace_id=os.getenv("ATLAS_WORKSPACE_ID")) as client:
|
|
23
|
+
# Compile: Automatically generates UUIDv4 idempotency key when omitted
|
|
24
|
+
response = client.compile({"url": "https://example.com/article"})
|
|
25
|
+
|
|
26
|
+
if response.status == 200:
|
|
27
|
+
print("Compiled Markdown:", response.value["markdown"])
|
|
28
|
+
else:
|
|
29
|
+
# 202 Accepted: Asynchronous compilation job
|
|
30
|
+
job_id = response.value["id"]
|
|
31
|
+
job = client.wait_for_job(job_id, interval_seconds=1.0, max_wait_seconds=60.0)
|
|
32
|
+
results = client.list_job_results(job_id)
|
|
33
|
+
print("Results:", results.value["data"][0]["markdown"])
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Asynchronous Client (`AsyncAtlasClient`)
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import asyncio
|
|
40
|
+
import os
|
|
41
|
+
from atlascompiler import AsyncAtlasClient
|
|
42
|
+
|
|
43
|
+
async def main():
|
|
44
|
+
async with AsyncAtlasClient(os.getenv("ATLAS_API_KEY")) as client:
|
|
45
|
+
response = await client.compile({"url": "https://example.com/article"})
|
|
46
|
+
if response.status == 200:
|
|
47
|
+
print("Markdown:", response.value["markdown"])
|
|
48
|
+
else:
|
|
49
|
+
job = await client.wait_for_job(response.value["id"])
|
|
50
|
+
results = await client.list_job_results(job["id"])
|
|
51
|
+
print("Results:", results.value["data"][0]["markdown"])
|
|
52
|
+
|
|
53
|
+
asyncio.run(main())
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Idempotency Semantics
|
|
57
|
+
|
|
58
|
+
- **Implicit Execution Safety**: For mutation endpoints (`compile`, `cancel_job`, `bulk_cancel_jobs`), an RFC 4122 UUIDv4 is automatically generated when `idempotency_key` is omitted.
|
|
59
|
+
- **Explicit Deterministic Deduplication**: When deduplication across distinct attempts is required, pass your custom string:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
client.compile({"url": "https://example.com"}, idempotency_key="my-deterministic-key-123")
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Error Handling (RFC 9457)
|
|
66
|
+
|
|
67
|
+
All non-2xx API errors raise `AtlasApiError` containing the parsed RFC 9457 Problem Details object:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from atlascompiler import AtlasApiError
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
client.get_job("job_invalid_id")
|
|
74
|
+
except AtlasApiError as e:
|
|
75
|
+
print(f"Error [{e.status}] {e.code}: {e.detail}")
|
|
76
|
+
print(f"Request ID: {e.problem.get('requestId')}")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Webhook Signature Verification
|
|
80
|
+
|
|
81
|
+
Verify webhook payloads, guard against replay attacks with configurable clock drift tolerance, and support zero-downtime secret rotation:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from atlascompiler import verify_webhook_signature
|
|
85
|
+
|
|
86
|
+
result = verify_webhook_signature(
|
|
87
|
+
payload=raw_body, # bytes or str
|
|
88
|
+
headers=request.headers,
|
|
89
|
+
secret=os.getenv("ATLAS_WEBHOOK_SECRET"),
|
|
90
|
+
previous_secret=os.getenv("ATLAS_WEBHOOK_PREVIOUS_SECRET"), # optional rotation grace
|
|
91
|
+
tolerance_seconds=300, # 5 minutes
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
if not result.valid:
|
|
95
|
+
print(f"Webhook verification failed: {result.error}")
|
|
96
|
+
else:
|
|
97
|
+
event = result.event
|
|
98
|
+
print(f"Received event: {event['type']}")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Configuration Precedence
|
|
102
|
+
|
|
103
|
+
1. Explicit constructor arguments (`api_key`, `workspace_id`, `base_url`, `timeout`)
|
|
104
|
+
2. Ambient environment variables (`ATLAS_API_KEY`, `ATLAS_WORKSPACE_ID`, `ATLAS_BASE_URL`)
|
|
105
|
+
3. Defaults (`https://api.atlas-compiler.com`, 30.0s timeout)
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
MIT
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "atlascompiler"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Official Atlas Python SDK"
|
|
5
|
+
requires-python = ">=3.10"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"httpx==0.28.1",
|
|
10
|
+
"typing-extensions==4.15.0",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[project.optional-dependencies]
|
|
14
|
+
test = ["build==1.2.2.post1", "pytest==8.3.5"]
|
|
15
|
+
|
|
16
|
+
[project.urls]
|
|
17
|
+
Homepage = "https://github.com/Atlas-Compiler/Atlas"
|
|
18
|
+
Repository = "https://github.com/Atlas-Compiler/Atlas"
|
|
19
|
+
Issues = "https://github.com/Atlas-Compiler/Atlas/issues"
|
|
20
|
+
Discord = "https://discord.gg/z9ktRhuudq"
|
|
21
|
+
Documentation = "https://docs.atlas-compiler.com/sdk/python"
|
|
22
|
+
|
|
23
|
+
[build-system]
|
|
24
|
+
requires = ["hatchling==1.27.0"]
|
|
25
|
+
build-backend = "hatchling.build"
|
|
26
|
+
|
|
27
|
+
[tool.hatch.build.targets.wheel]
|
|
28
|
+
packages = ["src/atlascompiler"]
|
|
29
|
+
|
|
30
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
31
|
+
"src/atlascompiler/py.typed" = "atlascompiler/py.typed"
|
|
32
|
+
|
|
33
|
+
[tool.pytest.ini_options]
|
|
34
|
+
testpaths = ["tests"]
|
|
35
|
+
pythonpath = ["src"]
|
|
36
|
+
|
|
37
|
+
[tool.ruff]
|
|
38
|
+
line-length = 100
|
|
39
|
+
target-version = "py310"
|