backd 0.0.1__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.
- backd-0.0.1/.gitignore +9 -0
- backd-0.0.1/CHANGELOG.md +14 -0
- backd-0.0.1/LICENSE +21 -0
- backd-0.0.1/PKG-INFO +58 -0
- backd-0.0.1/README.md +25 -0
- backd-0.0.1/examples/shelf/README.md +16 -0
- backd-0.0.1/pyproject.toml +70 -0
- backd-0.0.1/src/backd/__init__.py +284 -0
- backd-0.0.1/src/backd/_aio.py +29 -0
- backd-0.0.1/src/backd/_async/__init__.py +1 -0
- backd-0.0.1/src/backd/_async/account.py +153 -0
- backd-0.0.1/src/backd/_async/auth.py +791 -0
- backd-0.0.1/src/backd/_async/client.py +489 -0
- backd-0.0.1/src/backd/_async/config.py +365 -0
- backd-0.0.1/src/backd/_async/consents.py +48 -0
- backd-0.0.1/src/backd/_async/data.py +500 -0
- backd-0.0.1/src/backd/_async/files.py +448 -0
- backd-0.0.1/src/backd/_async/functions.py +159 -0
- backd-0.0.1/src/backd/_async/orgs.py +418 -0
- backd-0.0.1/src/backd/_async/push.py +101 -0
- backd-0.0.1/src/backd/_async/realtime.py +268 -0
- backd-0.0.1/src/backd/_core.py +99 -0
- backd-0.0.1/src/backd/_live.py +777 -0
- backd-0.0.1/src/backd/_retry.py +23 -0
- backd-0.0.1/src/backd/_sio.py +23 -0
- backd-0.0.1/src/backd/_sync/__init__.py +1 -0
- backd-0.0.1/src/backd/_sync/account.py +154 -0
- backd-0.0.1/src/backd/_sync/auth.py +792 -0
- backd-0.0.1/src/backd/_sync/client.py +490 -0
- backd-0.0.1/src/backd/_sync/config.py +366 -0
- backd-0.0.1/src/backd/_sync/consents.py +49 -0
- backd-0.0.1/src/backd/_sync/data.py +501 -0
- backd-0.0.1/src/backd/_sync/files.py +449 -0
- backd-0.0.1/src/backd/_sync/functions.py +160 -0
- backd-0.0.1/src/backd/_sync/orgs.py +419 -0
- backd-0.0.1/src/backd/_sync/push.py +102 -0
- backd-0.0.1/src/backd/_sync/realtime.py +316 -0
- backd-0.0.1/src/backd/cache.py +137 -0
- backd-0.0.1/src/backd/config_storage.py +90 -0
- backd-0.0.1/src/backd/errors.py +388 -0
- backd-0.0.1/src/backd/files.py +37 -0
- backd-0.0.1/src/backd/models.py +716 -0
- backd-0.0.1/src/backd/oauth.py +163 -0
- backd-0.0.1/src/backd/py.typed +0 -0
- backd-0.0.1/src/backd/query.py +303 -0
- backd-0.0.1/src/backd/size.py +87 -0
- backd-0.0.1/src/backd/storage.py +97 -0
- backd-0.0.1/src/backd/upload.py +136 -0
- backd-0.0.1/tests/__init__.py +0 -0
- backd-0.0.1/tests/conftest.py +6 -0
- backd-0.0.1/tests/helpers.py +151 -0
- backd-0.0.1/tests/integration/__init__.py +0 -0
- backd-0.0.1/tests/integration/conftest.py +85 -0
- backd-0.0.1/tests/integration/run.sh +54 -0
- backd-0.0.1/tests/integration/test_account.py +31 -0
- backd-0.0.1/tests/integration/test_data.py +100 -0
- backd-0.0.1/tests/integration/test_files.py +63 -0
- backd-0.0.1/tests/integration/test_functions.py +27 -0
- backd-0.0.1/tests/integration/test_realtime.py +46 -0
- backd-0.0.1/tests/test_account.py +225 -0
- backd-0.0.1/tests/test_auth.py +574 -0
- backd-0.0.1/tests/test_cache.py +213 -0
- backd-0.0.1/tests/test_client.py +259 -0
- backd-0.0.1/tests/test_config.py +217 -0
- backd-0.0.1/tests/test_data.py +251 -0
- backd-0.0.1/tests/test_errors.py +90 -0
- backd-0.0.1/tests/test_files.py +420 -0
- backd-0.0.1/tests/test_functions.py +215 -0
- backd-0.0.1/tests/test_generated_types.py +71 -0
- backd-0.0.1/tests/test_oauth.py +42 -0
- backd-0.0.1/tests/test_orgs.py +241 -0
- backd-0.0.1/tests/test_query.py +128 -0
- backd-0.0.1/tests/test_realtime.py +623 -0
- backd-0.0.1/tests/test_realtime_socket.py +97 -0
- backd-0.0.1/tests/test_size.py +30 -0
- backd-0.0.1/tests/test_storage.py +36 -0
- backd-0.0.1/tests/test_unasync.py +14 -0
- backd-0.0.1/tests/test_upload.py +77 -0
backd-0.0.1/.gitignore
ADDED
backd-0.0.1/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
- First version: `Client` and `AsyncClient` with the request pipeline, errors, retries, token storage and the size helpers.
|
|
6
|
+
- `client.auth`: sign-up, login and the sign-in steps, MFA, magic links, providers (redirect and ID token), `reauth`/`with_proof`, sessions, the email flows, `client.org` and `on_auth_change`.
|
|
7
|
+
- Collections: `list`, `iterate`, `search`, `aggregate`, `get`, `create`, `replace`, `patch`, `delete`, `restore`, `db.batch`, `in_team`/`in_org`, the query-language helpers, `expand` and `fill_buckets`.
|
|
8
|
+
- The revalidation cache (`If-None-Match`/`304`, LRU by entries and bytes, per credential; `cache_stats`, `clear_cache`, `cache=False` per read) and `client.config` (`load`, `get`, `get_sync`, `view`, `on`, persisted copies through `config_storage`).
|
|
9
|
+
- Files: `files(id, field)` (`list`, `get`, `put`, `delete`, `link`, `version`), `upload_file` (through backd, direct to the bucket, in parts), `prepare_upload`, `download_file` (streams to a path or file, checks the SHA-256), `file_url`, `public_url`, `version_status`, `Upload` and progress callbacks.
|
|
10
|
+
- Functions and jobs: `db.fn`, `collection.fn`, `client.functions.call` / `run`, `Job` with `status`, `wait` (polling, timeout, progress) and `steps`, and `JobTimeoutError`.
|
|
11
|
+
- `client.orgs` (organizations, members, teams and team-role windows, email templates, invitations, sign-in connections), `client.consents`, `client.push` (`register`, `devices`, `unregister`, `register_on_launch`) and `client.account` (data export: request, wait, download).
|
|
12
|
+
- Realtime: `client.realtime.subscribe` and `collection.subscribe` over one multiplexed SSE stream, `LiveView` (threads) and `AsyncLiveView` (tasks) with `LiveState`, resume tokens, reset with jitter, reconnect with backoff, references, `access_lost`, and `client.config.live` (the configuration follows the stream). Closing the client leaves no thread or task running.
|
|
13
|
+
- Generated types: `backd types --lang python` writes `types.py` (`TypedDict`s, `Literal`s, field constants, `Realm` and `AsyncRealm` wrappers); the Shelf example's types are checked with `mypy --strict` and for drift.
|
|
14
|
+
- Release tooling: `scripts/check-python-package.sh` (`make python-package`) builds the sdist and the wheel, checks their metadata and contents and uses the wheel from a fresh virtualenv; `publish-python.yml` publishes to PyPI on `py-v*` tags with trusted publishing.
|
backd-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Antonio Fdez.
|
|
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.
|
backd-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: backd
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Python client for backd: auth, sessions and data for services, scripts and notebooks.
|
|
5
|
+
Project-URL: Homepage, https://fernandezvara.github.io/backd/docs/build/clients/python/
|
|
6
|
+
Project-URL: Issues, https://github.com/fernandezvara/backd/issues
|
|
7
|
+
Project-URL: Source, https://github.com/fernandezvara/backd/tree/main/clients/python
|
|
8
|
+
Author: Antonio Fdez.
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: auth,backd,client,httpx,mongodb,rest,sdk
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: httpx<1,>=0.27
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: build; extra == 'dev'
|
|
26
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-timeout>=2.3; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
31
|
+
Requires-Dist: twine; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# backd (Python)
|
|
35
|
+
|
|
36
|
+
Python client for [backd](https://github.com/fernandezvara/backd): auth, sessions and data for services, scripts and notebooks.
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from backd import Client
|
|
40
|
+
|
|
41
|
+
with Client(url="http://localhost:8080", realm="shelf", api_key=key) as backd:
|
|
42
|
+
...
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`AsyncClient` has the same calls with `async with` and `await`. One runtime dependency: [`httpx`](https://www.python-httpx.org/).
|
|
46
|
+
`pip install backd` (PyPI, from the first release; until then `pip install "backd @ git+https://github.com/fernandezvara/backd#subdirectory=clients/python"`). Python 3.10 or later. The client is under construction (milestone 38); the [docs page](https://fernandezvara.github.io/backd/docs/build/clients/python/) lists what exists. `backd types --lang python` generates `TypedDict`s and typed wrappers for a realm.
|
|
47
|
+
|
|
48
|
+
The admin API is not part of the client, for the same reason it isn't in the JavaScript, Dart and Go clients.
|
|
49
|
+
|
|
50
|
+
## Development
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
python -m venv .venv && .venv/bin/pip install -e '.[dev]'
|
|
54
|
+
.venv/bin/python scripts/unasync.py # writes src/backd/_sync from src/backd/_async
|
|
55
|
+
.venv/bin/ruff check . && .venv/bin/ruff format --check . && .venv/bin/mypy && .venv/bin/pytest
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The async client is the source: `src/backd/_sync` is generated from `src/backd/_async` and checked in, and a test fails when it is out of date. Edit the async file, then run `scripts/unasync.py`. Files with no twin (the realtime stream, where a thread and a task differ in more than syntax) are written by hand.
|
backd-0.0.1/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# backd (Python)
|
|
2
|
+
|
|
3
|
+
Python client for [backd](https://github.com/fernandezvara/backd): auth, sessions and data for services, scripts and notebooks.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from backd import Client
|
|
7
|
+
|
|
8
|
+
with Client(url="http://localhost:8080", realm="shelf", api_key=key) as backd:
|
|
9
|
+
...
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`AsyncClient` has the same calls with `async with` and `await`. One runtime dependency: [`httpx`](https://www.python-httpx.org/).
|
|
13
|
+
`pip install backd` (PyPI, from the first release; until then `pip install "backd @ git+https://github.com/fernandezvara/backd#subdirectory=clients/python"`). Python 3.10 or later. The client is under construction (milestone 38); the [docs page](https://fernandezvara.github.io/backd/docs/build/clients/python/) lists what exists. `backd types --lang python` generates `TypedDict`s and typed wrappers for a realm.
|
|
14
|
+
|
|
15
|
+
The admin API is not part of the client, for the same reason it isn't in the JavaScript, Dart and Go clients.
|
|
16
|
+
|
|
17
|
+
## Development
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
python -m venv .venv && .venv/bin/pip install -e '.[dev]'
|
|
21
|
+
.venv/bin/python scripts/unasync.py # writes src/backd/_sync from src/backd/_async
|
|
22
|
+
.venv/bin/ruff check . && .venv/bin/ruff format --check . && .venv/bin/mypy && .venv/bin/pytest
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The async client is the source: `src/backd/_sync` is generated from `src/backd/_async` and checked in, and a test fails when it is out of date. Edit the async file, then run `scripts/unasync.py`. Files with no twin (the realtime stream, where a thread and a task differ in more than syntax) are written by hand.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# The Python client against the Shelf tutorial stack
|
|
2
|
+
|
|
3
|
+
`main.py` signs in to the tutorial's `shelf` realm, lists the published assets with the generated types, saves a note
|
|
4
|
+
and follows the assets live for ten seconds.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
pip install -e clients/python
|
|
8
|
+
SHELF_EMAIL=ada@example.com SHELF_PASSWORD='dev-p4ssw0rd!' python clients/python/examples/shelf/main.py
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`BACKD_URL` is the address of the stack (`http://localhost:8080` by default). The session is kept in
|
|
12
|
+
`~/.backd-shelf-python.session`: only the first run signs in.
|
|
13
|
+
|
|
14
|
+
`shelf_types/types.py` is generated and checked by CI (`make shelf-types`); after a change to the Shelf's schema,
|
|
15
|
+
`make shelf-types-update` rewrites it. The guide is
|
|
16
|
+
[Python client](https://fernandezvara.github.io/backd/docs/build/clients/python/).
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "backd"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Python client for backd: auth, sessions and data for services, scripts and notebooks."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
authors = [{ name = "Antonio Fdez." }]
|
|
14
|
+
keywords = ["backd", "client", "sdk", "rest", "mongodb", "auth", "httpx"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
25
|
+
"Typing :: Typed",
|
|
26
|
+
]
|
|
27
|
+
dependencies = ["httpx>=0.27,<1"]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://fernandezvara.github.io/backd/docs/build/clients/python/"
|
|
31
|
+
Issues = "https://github.com/fernandezvara/backd/issues"
|
|
32
|
+
Source = "https://github.com/fernandezvara/backd/tree/main/clients/python"
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
dev = ["pytest>=8", "pytest-asyncio>=0.24", "pytest-timeout>=2.3", "ruff>=0.6", "mypy>=1.11", "build", "twine"]
|
|
36
|
+
|
|
37
|
+
[tool.hatch.version]
|
|
38
|
+
path = "src/backd/__init__.py"
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.wheel]
|
|
41
|
+
packages = ["src/backd"]
|
|
42
|
+
|
|
43
|
+
[tool.hatch.build.targets.sdist]
|
|
44
|
+
include = ["src", "tests", "README.md", "LICENSE", "CHANGELOG.md", "pyproject.toml"]
|
|
45
|
+
|
|
46
|
+
[tool.pytest.ini_options]
|
|
47
|
+
testpaths = ["tests"]
|
|
48
|
+
asyncio_mode = "auto"
|
|
49
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
50
|
+
pythonpath = ["src", "examples/shelf"]
|
|
51
|
+
addopts = "-ra"
|
|
52
|
+
timeout = 60 # a hang in the realtime tests fails the test instead of the whole run
|
|
53
|
+
|
|
54
|
+
[tool.ruff]
|
|
55
|
+
line-length = 120
|
|
56
|
+
src = ["src", "tests"]
|
|
57
|
+
extend-exclude = ["src/backd/_sync", "examples/shelf/shelf_types"]
|
|
58
|
+
|
|
59
|
+
[tool.ruff.lint]
|
|
60
|
+
select = ["E", "F", "I", "UP", "B", "SIM", "RUF"]
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint.per-file-ignores]
|
|
63
|
+
"tests/*" = ["RUF059"] # a fixture's unused parts are fine in a test
|
|
64
|
+
|
|
65
|
+
[tool.mypy]
|
|
66
|
+
strict = true
|
|
67
|
+
python_version = "3.10"
|
|
68
|
+
files = ["src", "tests", "scripts", "examples"]
|
|
69
|
+
mypy_path = "src:examples/shelf"
|
|
70
|
+
explicit_package_bases = true
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"""Python client for backd: auth, sessions and data for services, scripts and notebooks.
|
|
2
|
+
|
|
3
|
+
``Client`` is the sync client and ``AsyncClient`` the async one; both have the same calls.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from ._async.client import AsyncClient
|
|
7
|
+
from ._async.data import AsyncCollection, AsyncDatabase
|
|
8
|
+
from ._async.functions import AsyncJob
|
|
9
|
+
from ._async.realtime import AsyncLiveView
|
|
10
|
+
from ._live import LiveState, LiveStatus, LiveSubscriptionState, ReferenceSpec, SubscribeOptions, SubscriptionSpec
|
|
11
|
+
from ._retry import Retry
|
|
12
|
+
from ._sync.client import Client
|
|
13
|
+
from ._sync.data import Collection, Database
|
|
14
|
+
from ._sync.functions import Job
|
|
15
|
+
from ._sync.realtime import LiveView
|
|
16
|
+
from .cache import CacheOptions, CacheStats
|
|
17
|
+
from .config_storage import ConfigStorage, FileConfigStorage, MemoryConfigStorage
|
|
18
|
+
from .errors import (
|
|
19
|
+
AggregateNotEnabledError,
|
|
20
|
+
AggregateTooExpensiveError,
|
|
21
|
+
AuthenticationError,
|
|
22
|
+
BackdError,
|
|
23
|
+
ConflictError,
|
|
24
|
+
ConsentRequiredError,
|
|
25
|
+
ErrorDetail,
|
|
26
|
+
ExpandTooLargeError,
|
|
27
|
+
FieldEncryptedError,
|
|
28
|
+
ForbiddenError,
|
|
29
|
+
IdTakenError,
|
|
30
|
+
IndexBuildingError,
|
|
31
|
+
InvalidAggregateError,
|
|
32
|
+
InvalidExpandError,
|
|
33
|
+
InvalidIdError,
|
|
34
|
+
InvalidResumeTokenError,
|
|
35
|
+
JobTimeoutError,
|
|
36
|
+
LastOrgManagerError,
|
|
37
|
+
NetworkError,
|
|
38
|
+
NotAllowedError,
|
|
39
|
+
NotFoundError,
|
|
40
|
+
NotOrgMemberError,
|
|
41
|
+
NotTeamMemberError,
|
|
42
|
+
OrgRequiresMFAError,
|
|
43
|
+
OrgRoleRequiresMFAError,
|
|
44
|
+
PasswordExpiredError,
|
|
45
|
+
RealtimeNotEnabledError,
|
|
46
|
+
RetryableError,
|
|
47
|
+
SearchNotEnabledError,
|
|
48
|
+
SearchTooExpensiveError,
|
|
49
|
+
SecondStepRequiredError,
|
|
50
|
+
SessionEndedError,
|
|
51
|
+
SsoRequiredError,
|
|
52
|
+
SsoSessionError,
|
|
53
|
+
TeamError,
|
|
54
|
+
TooManySubscriptionsError,
|
|
55
|
+
ValidationError,
|
|
56
|
+
VerificationRequiredError,
|
|
57
|
+
VersionMismatchError,
|
|
58
|
+
)
|
|
59
|
+
from .files import public_url, version_status
|
|
60
|
+
from .models import (
|
|
61
|
+
AggregateGroup,
|
|
62
|
+
AggregateResult,
|
|
63
|
+
BatchOperation,
|
|
64
|
+
ConsentChallenge,
|
|
65
|
+
ConsentInfo,
|
|
66
|
+
ConsentState,
|
|
67
|
+
ConsentText,
|
|
68
|
+
DataExport,
|
|
69
|
+
Device,
|
|
70
|
+
DeviceInput,
|
|
71
|
+
Doc,
|
|
72
|
+
EnrollmentChallenge,
|
|
73
|
+
FileDetails,
|
|
74
|
+
FileField,
|
|
75
|
+
FileLink,
|
|
76
|
+
Identity,
|
|
77
|
+
JobData,
|
|
78
|
+
JobResult,
|
|
79
|
+
JobStep,
|
|
80
|
+
Me,
|
|
81
|
+
Meta,
|
|
82
|
+
MfaChallenge,
|
|
83
|
+
Org,
|
|
84
|
+
OrgConnection,
|
|
85
|
+
OrgInvitation,
|
|
86
|
+
OrgMember,
|
|
87
|
+
OrgTeam,
|
|
88
|
+
OrgTeamMember,
|
|
89
|
+
OrgTeamRoleGrant,
|
|
90
|
+
OrgTemplate,
|
|
91
|
+
OrgTemplateText,
|
|
92
|
+
Page,
|
|
93
|
+
PreparedUpload,
|
|
94
|
+
Profile,
|
|
95
|
+
ProviderSession,
|
|
96
|
+
RoleOrigin,
|
|
97
|
+
Session,
|
|
98
|
+
SessionInfo,
|
|
99
|
+
SignInResult,
|
|
100
|
+
User,
|
|
101
|
+
VersionState,
|
|
102
|
+
)
|
|
103
|
+
from .oauth import MemoryOAuthStorage, OAuthReturn, OAuthStorage
|
|
104
|
+
from .query import (
|
|
105
|
+
Where,
|
|
106
|
+
and_,
|
|
107
|
+
between,
|
|
108
|
+
bucket_key,
|
|
109
|
+
contains,
|
|
110
|
+
ends_with,
|
|
111
|
+
eq,
|
|
112
|
+
expand,
|
|
113
|
+
fill_buckets,
|
|
114
|
+
gt,
|
|
115
|
+
gte,
|
|
116
|
+
icontains,
|
|
117
|
+
iends_with,
|
|
118
|
+
ilike,
|
|
119
|
+
in_,
|
|
120
|
+
is_null,
|
|
121
|
+
istarts_with,
|
|
122
|
+
like,
|
|
123
|
+
lt,
|
|
124
|
+
lte,
|
|
125
|
+
ne,
|
|
126
|
+
nin,
|
|
127
|
+
not_null,
|
|
128
|
+
or_,
|
|
129
|
+
search,
|
|
130
|
+
starts_with,
|
|
131
|
+
)
|
|
132
|
+
from .size import SizeFamily, format_bytes, parse_size
|
|
133
|
+
from .storage import FileStorage, MemoryStorage, SlotStorage, TokenStorage
|
|
134
|
+
from .upload import Progress, Upload, UploadSource, part_size_for
|
|
135
|
+
|
|
136
|
+
__version__ = "0.0.1"
|
|
137
|
+
|
|
138
|
+
__all__ = [
|
|
139
|
+
"AggregateGroup",
|
|
140
|
+
"AggregateNotEnabledError",
|
|
141
|
+
"AggregateResult",
|
|
142
|
+
"AggregateTooExpensiveError",
|
|
143
|
+
"AsyncClient",
|
|
144
|
+
"AsyncCollection",
|
|
145
|
+
"AsyncDatabase",
|
|
146
|
+
"AsyncJob",
|
|
147
|
+
"AsyncLiveView",
|
|
148
|
+
"AuthenticationError",
|
|
149
|
+
"BackdError",
|
|
150
|
+
"BatchOperation",
|
|
151
|
+
"CacheOptions",
|
|
152
|
+
"CacheStats",
|
|
153
|
+
"Client",
|
|
154
|
+
"Collection",
|
|
155
|
+
"ConfigStorage",
|
|
156
|
+
"ConflictError",
|
|
157
|
+
"ConsentChallenge",
|
|
158
|
+
"ConsentInfo",
|
|
159
|
+
"ConsentRequiredError",
|
|
160
|
+
"ConsentState",
|
|
161
|
+
"ConsentText",
|
|
162
|
+
"DataExport",
|
|
163
|
+
"Database",
|
|
164
|
+
"Device",
|
|
165
|
+
"DeviceInput",
|
|
166
|
+
"Doc",
|
|
167
|
+
"EnrollmentChallenge",
|
|
168
|
+
"ErrorDetail",
|
|
169
|
+
"ExpandTooLargeError",
|
|
170
|
+
"FieldEncryptedError",
|
|
171
|
+
"FileConfigStorage",
|
|
172
|
+
"FileDetails",
|
|
173
|
+
"FileField",
|
|
174
|
+
"FileLink",
|
|
175
|
+
"FileStorage",
|
|
176
|
+
"ForbiddenError",
|
|
177
|
+
"IdTakenError",
|
|
178
|
+
"Identity",
|
|
179
|
+
"IndexBuildingError",
|
|
180
|
+
"InvalidAggregateError",
|
|
181
|
+
"InvalidExpandError",
|
|
182
|
+
"InvalidIdError",
|
|
183
|
+
"InvalidResumeTokenError",
|
|
184
|
+
"Job",
|
|
185
|
+
"JobData",
|
|
186
|
+
"JobResult",
|
|
187
|
+
"JobStep",
|
|
188
|
+
"JobTimeoutError",
|
|
189
|
+
"LastOrgManagerError",
|
|
190
|
+
"LiveState",
|
|
191
|
+
"LiveStatus",
|
|
192
|
+
"LiveSubscriptionState",
|
|
193
|
+
"LiveView",
|
|
194
|
+
"Me",
|
|
195
|
+
"MemoryConfigStorage",
|
|
196
|
+
"MemoryOAuthStorage",
|
|
197
|
+
"MemoryStorage",
|
|
198
|
+
"Meta",
|
|
199
|
+
"MfaChallenge",
|
|
200
|
+
"NetworkError",
|
|
201
|
+
"NotAllowedError",
|
|
202
|
+
"NotFoundError",
|
|
203
|
+
"NotOrgMemberError",
|
|
204
|
+
"NotTeamMemberError",
|
|
205
|
+
"OAuthReturn",
|
|
206
|
+
"OAuthStorage",
|
|
207
|
+
"Org",
|
|
208
|
+
"OrgConnection",
|
|
209
|
+
"OrgInvitation",
|
|
210
|
+
"OrgMember",
|
|
211
|
+
"OrgRequiresMFAError",
|
|
212
|
+
"OrgRoleRequiresMFAError",
|
|
213
|
+
"OrgTeam",
|
|
214
|
+
"OrgTeamMember",
|
|
215
|
+
"OrgTeamRoleGrant",
|
|
216
|
+
"OrgTemplate",
|
|
217
|
+
"OrgTemplateText",
|
|
218
|
+
"Page",
|
|
219
|
+
"PasswordExpiredError",
|
|
220
|
+
"PreparedUpload",
|
|
221
|
+
"Profile",
|
|
222
|
+
"Progress",
|
|
223
|
+
"ProviderSession",
|
|
224
|
+
"RealtimeNotEnabledError",
|
|
225
|
+
"ReferenceSpec",
|
|
226
|
+
"Retry",
|
|
227
|
+
"RetryableError",
|
|
228
|
+
"RoleOrigin",
|
|
229
|
+
"SearchNotEnabledError",
|
|
230
|
+
"SearchTooExpensiveError",
|
|
231
|
+
"SecondStepRequiredError",
|
|
232
|
+
"Session",
|
|
233
|
+
"SessionEndedError",
|
|
234
|
+
"SessionInfo",
|
|
235
|
+
"SignInResult",
|
|
236
|
+
"SizeFamily",
|
|
237
|
+
"SlotStorage",
|
|
238
|
+
"SsoRequiredError",
|
|
239
|
+
"SsoSessionError",
|
|
240
|
+
"SubscribeOptions",
|
|
241
|
+
"SubscriptionSpec",
|
|
242
|
+
"TeamError",
|
|
243
|
+
"TokenStorage",
|
|
244
|
+
"TooManySubscriptionsError",
|
|
245
|
+
"Upload",
|
|
246
|
+
"UploadSource",
|
|
247
|
+
"User",
|
|
248
|
+
"ValidationError",
|
|
249
|
+
"VerificationRequiredError",
|
|
250
|
+
"VersionMismatchError",
|
|
251
|
+
"VersionState",
|
|
252
|
+
"Where",
|
|
253
|
+
"__version__",
|
|
254
|
+
"and_",
|
|
255
|
+
"between",
|
|
256
|
+
"bucket_key",
|
|
257
|
+
"contains",
|
|
258
|
+
"ends_with",
|
|
259
|
+
"eq",
|
|
260
|
+
"expand",
|
|
261
|
+
"fill_buckets",
|
|
262
|
+
"format_bytes",
|
|
263
|
+
"gt",
|
|
264
|
+
"gte",
|
|
265
|
+
"icontains",
|
|
266
|
+
"iends_with",
|
|
267
|
+
"ilike",
|
|
268
|
+
"in_",
|
|
269
|
+
"is_null",
|
|
270
|
+
"istarts_with",
|
|
271
|
+
"like",
|
|
272
|
+
"lt",
|
|
273
|
+
"lte",
|
|
274
|
+
"ne",
|
|
275
|
+
"nin",
|
|
276
|
+
"not_null",
|
|
277
|
+
"or_",
|
|
278
|
+
"parse_size",
|
|
279
|
+
"part_size_for",
|
|
280
|
+
"public_url",
|
|
281
|
+
"search",
|
|
282
|
+
"starts_with",
|
|
283
|
+
"version_status",
|
|
284
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""The few places where the async client needs a different function from the sync one.
|
|
2
|
+
``scripts/unasync.py`` swaps this module for ``_sio`` when it writes ``_sync``."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import asyncio
|
|
7
|
+
from collections.abc import Awaitable, Callable, Coroutine
|
|
8
|
+
from typing import Any, TypeVar, cast
|
|
9
|
+
|
|
10
|
+
T = TypeVar("T")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
async def sleep(seconds: float) -> None:
|
|
14
|
+
await asyncio.sleep(seconds)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
_tasks: set[asyncio.Task[None]] = set()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def spawn(fn: Callable[..., Awaitable[None]], *args: Any) -> None:
|
|
21
|
+
"""Runs ``fn(*args)`` in the background: a task here, a thread in the sync client."""
|
|
22
|
+
task: asyncio.Task[None] = asyncio.get_running_loop().create_task(cast("Coroutine[Any, Any, None]", fn(*args)))
|
|
23
|
+
_tasks.add(task) # a task nothing refers to may be collected before it ends
|
|
24
|
+
task.add_done_callback(_tasks.discard)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
async def run_blocking(fn: Callable[..., T], *args: Any) -> T:
|
|
28
|
+
"""Runs a blocking function (hashing a big file) without stopping the event loop; the sync client just calls it."""
|
|
29
|
+
return await asyncio.to_thread(fn, *args)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""The async client. These files are the source of ``_sync``; run ``python scripts/unasync.py``."""
|