dataceen-client 0.0.2__tar.gz → 0.0.4__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.
Files changed (78) hide show
  1. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/CHANGELOG.md +71 -58
  2. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/PKG-INFO +1 -1
  3. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/pyproject.toml +67 -67
  4. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/dataceen_client.py +4 -0
  5. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/runtime/__init__.py +59 -48
  6. dataceen_client-0.0.4/src/dataceen_client/runtime/aggregations.py +112 -0
  7. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/runtime/filter.py +134 -130
  8. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/runtime/operations.py +17 -2
  9. dataceen_client-0.0.4/src/dataceen_client/runtime/order_by.py +99 -0
  10. dataceen_client-0.0.4/src/dataceen_client/runtime/saved_searches.py +74 -0
  11. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/subscriptions/__init__.py +4 -0
  12. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/subscriptions/_pb/dataceenevent_pb2.py +12 -12
  13. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/subscriptions/_pb/dataceenevent_pb2.pyi +2 -0
  14. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/subscriptions/subscription.py +19 -0
  15. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/subscriptions/types.py +38 -0
  16. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/types.py +1 -0
  17. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client.egg-info/PKG-INFO +1 -1
  18. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client.egg-info/SOURCES.txt +2 -0
  19. dataceen_client-0.0.4/tests/test_order_by.py +57 -0
  20. dataceen_client-0.0.4/tests/test_saved_searches.py +81 -0
  21. dataceen_client-0.0.2/src/dataceen_client/runtime/aggregations.py +0 -54
  22. dataceen_client-0.0.2/src/dataceen_client/runtime/order_by.py +0 -29
  23. dataceen_client-0.0.2/tests/test_order_by.py +0 -27
  24. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/.env.example +0 -0
  25. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/LICENSE +0 -0
  26. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/MANIFEST.in +0 -0
  27. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/README.md +0 -0
  28. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/docs/decisions.md +0 -0
  29. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/docs/dsl-comparison.md +0 -0
  30. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/docs/plan.md +0 -0
  31. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/docs/porting-guide.md +0 -0
  32. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/docs/progress.md +0 -0
  33. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/docs/release.md +0 -0
  34. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/protos/dataceenevent.proto +0 -0
  35. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/setup.cfg +0 -0
  36. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/__init__.py +0 -0
  37. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/config.py +0 -0
  38. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/errors.py +0 -0
  39. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/http_transport.py +0 -0
  40. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/py.typed +0 -0
  41. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/runtime/fields.py +0 -0
  42. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/subscriptions/_pb/__init__.py +0 -0
  43. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/subscriptions/_pb/dataceenevent_pb2_grpc.py +0 -0
  44. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/subscriptions/grpc_client.py +0 -0
  45. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/subscriptions/subscription_manager.py +0 -0
  46. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client/token_provider.py +0 -0
  47. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client.egg-info/dependency_links.txt +0 -0
  48. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client.egg-info/requires.txt +0 -0
  49. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/src/dataceen_client.egg-info/top_level.txt +0 -0
  50. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/__init__.py +0 -0
  51. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_aggregations.py +0 -0
  52. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_codegen_aggregation.py +0 -0
  53. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_codegen_emit.py +0 -0
  54. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_codegen_parse.py +0 -0
  55. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_dataceen_client.py +0 -0
  56. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_examples_smoke.py +0 -0
  57. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_fields.py +0 -0
  58. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_filter.py +0 -0
  59. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_http_transport.py +0 -0
  60. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_operations.py +0 -0
  61. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tests/test_subscriptions.py +0 -0
  62. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/__init__.py +0 -0
  63. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/__init__.py +0 -0
  64. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/__init__.py +0 -0
  65. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/cli.py +0 -0
  66. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/emit_aggregation.py +0 -0
  67. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/emit_all_client.py +0 -0
  68. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/emit_client.py +0 -0
  69. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/emit_create.py +0 -0
  70. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/emit_fields.py +0 -0
  71. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/emit_filter.py +0 -0
  72. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/emit_model.py +0 -0
  73. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/emit_plan.py +0 -0
  74. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/emit_update.py +0 -0
  75. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/emit_util.py +0 -0
  76. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/fetch_schema.py +0 -0
  77. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/introspection_query.py +0 -0
  78. {dataceen_client-0.0.2 → dataceen_client-0.0.4}/tools/codegen/src/parse_schema.py +0 -0
@@ -1,58 +1,71 @@
1
- # Changelog
2
-
3
- All notable changes to `dataceen-client` (Python) are documented here. Format
4
- follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the
5
- project loosely follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
-
7
- ## [Unreleased]
8
-
9
- ## [0.0.1] — 2026-05-01
10
-
11
- Initial alpha — feature-parity with C# `DataceenClient` and TypeScript
12
- `@dataceen/client`, verified against the same model fixtures.
13
-
14
- ### Added
15
-
16
- - **Core runtime** (`dataceen_client.*`)
17
- - `DataceenConfig`, `DataceenClientOptions`, `load_config_from_env()`
18
- - `DataceenError` — single error type for HTTP, GraphQL, parse, and server-side `ResponseCode != 0`
19
- - `DataceenClient.execute_query()` (default retry on transient) and `execute_mutation()` (no retry by default)
20
- - `TokenProvider` — Azure AD client-credentials via `msal`, with `force_refresh` simulated by `remove_tokens_for_client()`
21
- - `HttpTransport` — `httpx.AsyncClient` POST with 401-refresh + transient retry (408/429/5xx, exponential backoff)
22
- - Result `TypedDict`s: `FindResult[T]`, `SearchResult[T]`, `MutationResult`, …
23
-
24
- - **Runtime DSL helpers** (`dataceen_client.runtime.*`)
25
- - Pure-dict DSL — `filter_to_graphql`, `order_by_to_graphql`, `collect_fields`
26
- - `StringOps`, `NumberOps`, `BooleanOps`, `DateOps` — typed comparison-operator dicts
27
- - `aggregation_fragment(depth)` — recursive Aggregations result expansion
28
- - `do_find` / `do_search` / `do_create` / `do_create_bulk` / `do_update` / `do_update_bulk` / `do_delete` / `do_create_relation` / `do_create_relation_bulk`
29
-
30
- - **Codegen** (`tools/codegen/`)
31
- - GraphQL introspection fetch + cache (`fetch_schema.py`, `parse_schema.py`)
32
- - Per-entity emitters: read TypedDict, Create TypedDict, Update class with `__setattr__` change-tracking, Filter / SearchFilter, Fields, per-entity Client, AllClient
33
- - Aggregation emitter — typed `Search<Entity>_aggregation` + `<Entity>AggregationDetails`
34
- - CLI: `python -m tools.codegen.src.cli {fetch,emit ROOT,emit-all}` (also installable as `dataceen-codegen`)
35
-
36
- - **gRPC subscriptions** (`dataceen_client.subscriptions.*`)
37
- - `Subscription` class with typed + low-level handlers, `asyncio.Event`-based cancel
38
- - `grpc.aio` async stream open + Bearer-metadata auth
39
- - Subscription manager with baseload semantics, exponential reconnect (max 10), synthetic CONNECTION_LOST/RECONNECTED events, slow-handler timing, central exception catch
40
- - Pre-compiled proto stubs in `_pb/` (regenerable via `scripts/regenerate_proto.py`)
41
-
42
- - **Example app** — `examples/candy_shop/` ports the TS port's `examples/candy-shop/`. Read-only flows always run; create/update/delete gated by `RUN_DESTRUCTIVE=1`.
43
-
44
- - **Docs** — `docs/{plan,decisions,progress,dsl-comparison,porting-guide,release}.md`.
45
-
46
- ### Test coverage
47
-
48
- 88 unit tests, hermetic (~1.7s). Live-backend integration is opt-in via
49
- `RUN_INTEGRATION=1` once `.env` is configured.
50
-
51
- ### Known gaps for v0.1
52
-
53
- - No live-backend smoke run yet (needs valid `.env`).
54
- - No published wheel — `python -m build` produces it locally.
55
- - Sphinx/MkDocs site not built; docstrings + `docs/*.md` are the source of truth.
56
-
57
- [Unreleased]: https://github.com/dataceen/dataceen-client-python/compare/v0.0.1...HEAD
58
- [0.0.1]: https://github.com/dataceen/dataceen-client-python/releases/tag/v0.0.1
1
+ # Changelog
2
+
3
+ All notable changes to `dataceen-client` (Python) are documented here. Format
4
+ follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the
5
+ project loosely follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.0.4] — not yet released
10
+
11
+ ### Added
12
+
13
+ - `distance_from(lat, lon, *, descending=False, path=())` — an order-by entry
14
+ that sorts a search by distance from a point; each item's `_distance` is its
15
+ distance in km.
16
+
17
+ ### Fixed
18
+
19
+ - `order_by_to_graphql` writes nested entries (a sub-group, a related entity)
20
+ as GraphQL input. It printed them as a Python dict before.
21
+
22
+ ## [0.0.1] — 2026-05-01
23
+
24
+ Initial alpha — feature-parity with C# `DataceenClient` and TypeScript
25
+ `@dataceen/client`, verified against the same model fixtures.
26
+
27
+ ### Added
28
+
29
+ - **Core runtime** (`dataceen_client.*`)
30
+ - `DataceenConfig`, `DataceenClientOptions`, `load_config_from_env()`
31
+ - `DataceenError` — single error type for HTTP, GraphQL, parse, and server-side `ResponseCode != 0`
32
+ - `DataceenClient.execute_query()` (default retry on transient) and `execute_mutation()` (no retry by default)
33
+ - `TokenProvider` — Azure AD client-credentials via `msal`, with `force_refresh` simulated by `remove_tokens_for_client()`
34
+ - `HttpTransport` — `httpx.AsyncClient` POST with 401-refresh + transient retry (408/429/5xx, exponential backoff)
35
+ - Result `TypedDict`s: `FindResult[T]`, `SearchResult[T]`, `MutationResult`, …
36
+
37
+ - **Runtime DSL helpers** (`dataceen_client.runtime.*`)
38
+ - Pure-dict DSL — `filter_to_graphql`, `order_by_to_graphql`, `collect_fields`
39
+ - `StringOps`, `NumberOps`, `BooleanOps`, `DateOps` — typed comparison-operator dicts
40
+ - `aggregation_fragment(depth)` — recursive Aggregations result expansion
41
+ - `do_find` / `do_search` / `do_create` / `do_create_bulk` / `do_update` / `do_update_bulk` / `do_delete` / `do_create_relation` / `do_create_relation_bulk`
42
+
43
+ - **Codegen** (`tools/codegen/`)
44
+ - GraphQL introspection fetch + cache (`fetch_schema.py`, `parse_schema.py`)
45
+ - Per-entity emitters: read TypedDict, Create TypedDict, Update class with `__setattr__` change-tracking, Filter / SearchFilter, Fields, per-entity Client, AllClient
46
+ - Aggregation emitter — typed `Search<Entity>_aggregation` + `<Entity>AggregationDetails`
47
+ - CLI: `python -m tools.codegen.src.cli {fetch,emit ROOT,emit-all}` (also installable as `dataceen-codegen`)
48
+
49
+ - **gRPC subscriptions** (`dataceen_client.subscriptions.*`)
50
+ - `Subscription` class with typed + low-level handlers, `asyncio.Event`-based cancel
51
+ - `grpc.aio` async stream open + Bearer-metadata auth
52
+ - Subscription manager with baseload semantics, exponential reconnect (max 10), synthetic CONNECTION_LOST/RECONNECTED events, slow-handler timing, central exception catch
53
+ - Pre-compiled proto stubs in `_pb/` (regenerable via `scripts/regenerate_proto.py`)
54
+
55
+ - **Example app** — `examples/candy_shop/` ports the TS port's `examples/candy-shop/`. Read-only flows always run; create/update/delete gated by `RUN_DESTRUCTIVE=1`.
56
+
57
+ - **Docs** — `docs/{plan,decisions,progress,dsl-comparison,porting-guide,release}.md`.
58
+
59
+ ### Test coverage
60
+
61
+ 88 unit tests, hermetic (~1.7s). Live-backend integration is opt-in via
62
+ `RUN_INTEGRATION=1` once `.env` is configured.
63
+
64
+ ### Known gaps for v0.1
65
+
66
+ - No live-backend smoke run yet (needs valid `.env`).
67
+ - No published wheel — `python -m build` produces it locally.
68
+ - Sphinx/MkDocs site not built; docstrings + `docs/*.md` are the source of truth.
69
+
70
+ [Unreleased]: https://github.com/dataceen/dataceen-client-python/compare/v0.0.1...HEAD
71
+ [0.0.1]: https://github.com/dataceen/dataceen-client-python/releases/tag/v0.0.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dataceen-client
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Python client for Dataceen GraphQL + gRPC subscription APIs
5
5
  Author: Dataceen
6
6
  License: Apache-2.0
@@ -1,67 +1,67 @@
1
- [build-system]
2
- requires = ["setuptools>=68", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "dataceen-client"
7
- version = "0.0.2"
8
- description = "Python client for Dataceen GraphQL + gRPC subscription APIs"
9
- readme = "README.md"
10
- # `typing.NotRequired` and generic `TypedDict` (Generic[T]) require 3.11+.
11
- requires-python = ">=3.11"
12
- license = { text = "Apache-2.0" }
13
- authors = [{ name = "Dataceen" }]
14
- keywords = ["dataceen", "graphql", "grpc", "client", "azure-ad"]
15
- classifiers = [
16
- "Development Status :: 3 - Alpha",
17
- "Intended Audience :: Developers",
18
- "License :: OSI Approved :: Apache Software License",
19
- "Operating System :: OS Independent",
20
- "Programming Language :: Python :: 3",
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
- "Topic :: Software Development :: Libraries",
26
- "Typing :: Typed",
27
- ]
28
- dependencies = [
29
- "httpx>=0.27",
30
- "msal>=1.28",
31
- "grpcio>=1.60",
32
- "protobuf>=4.25",
33
- ]
34
-
35
- [project.optional-dependencies]
36
- dev = [
37
- "pytest>=8",
38
- "pytest-asyncio>=0.23",
39
- "respx>=0.21",
40
- "python-dotenv>=1.0",
41
- "grpcio-tools>=1.60",
42
- "build>=1.2",
43
- ]
44
-
45
- [project.urls]
46
- Source = "https://github.com/dataceen/dataceen-client-python"
47
- Issues = "https://github.com/dataceen/dataceen-client-python/issues"
48
-
49
- # Codegen (under tools/) is a dev-time tool run from a source checkout via
50
- # `python -m tools.codegen.src.cli`; it is intentionally NOT exposed as an
51
- # installed console script because it is not shipped in the wheel — only the
52
- # runtime `dataceen_client` package is installed for end users.
53
-
54
- [tool.setuptools]
55
- include-package-data = true
56
-
57
- [tool.setuptools.packages.find]
58
- where = ["src"]
59
-
60
- [tool.setuptools.package-data]
61
- # PEP 561 marker + the proto stub `.pyi` types live next to the runtime code.
62
- "dataceen_client" = ["py.typed"]
63
- "dataceen_client.subscriptions._pb" = ["*.pyi"]
64
-
65
- [tool.pytest.ini_options]
66
- asyncio_mode = "auto"
67
- testpaths = ["tests"]
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "dataceen-client"
7
+ version = "0.0.4"
8
+ description = "Python client for Dataceen GraphQL + gRPC subscription APIs"
9
+ readme = "README.md"
10
+ # `typing.NotRequired` and generic `TypedDict` (Generic[T]) require 3.11+.
11
+ requires-python = ">=3.11"
12
+ license = { text = "Apache-2.0" }
13
+ authors = [{ name = "Dataceen" }]
14
+ keywords = ["dataceen", "graphql", "grpc", "client", "azure-ad"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: Apache Software License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
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
+ "Topic :: Software Development :: Libraries",
26
+ "Typing :: Typed",
27
+ ]
28
+ dependencies = [
29
+ "httpx>=0.27",
30
+ "msal>=1.28",
31
+ "grpcio>=1.60",
32
+ "protobuf>=4.25",
33
+ ]
34
+
35
+ [project.optional-dependencies]
36
+ dev = [
37
+ "pytest>=8",
38
+ "pytest-asyncio>=0.23",
39
+ "respx>=0.21",
40
+ "python-dotenv>=1.0",
41
+ "grpcio-tools>=1.60",
42
+ "build>=1.2",
43
+ ]
44
+
45
+ [project.urls]
46
+ Source = "https://github.com/dataceen/dataceen-client-python"
47
+ Issues = "https://github.com/dataceen/dataceen-client-python/issues"
48
+
49
+ # Codegen (under tools/) is a dev-time tool run from a source checkout via
50
+ # `python -m tools.codegen.src.cli`; it is intentionally NOT exposed as an
51
+ # installed console script because it is not shipped in the wheel — only the
52
+ # runtime `dataceen_client` package is installed for end users.
53
+
54
+ [tool.setuptools]
55
+ include-package-data = true
56
+
57
+ [tool.setuptools.packages.find]
58
+ where = ["src"]
59
+
60
+ [tool.setuptools.package-data]
61
+ # PEP 561 marker + the proto stub `.pyi` types live next to the runtime code.
62
+ "dataceen_client" = ["py.typed"]
63
+ "dataceen_client.subscriptions._pb" = ["*.pyi"]
64
+
65
+ [tool.pytest.ini_options]
66
+ asyncio_mode = "auto"
67
+ testpaths = ["tests"]
@@ -214,6 +214,10 @@ def _parse_graphql_response(text: str, req: GqlRequest) -> Any:
214
214
  )
215
215
 
216
216
  payload = data.get(req.operation_name)
217
+ # A refusal of the whole call comes as data.ResponseCode / data.Message (e.g. a saved search the server will not keep).
218
+ top_code = data.get("ResponseCode")
219
+ if payload is None and top_code is not None and top_code != 0:
220
+ raise DataceenError(data.get("Message") or f"ResponseCode={top_code}", top_code, req.query)
217
221
  if payload is None:
218
222
  raise DataceenError(
219
223
  f"Response does not contain data.{req.operation_name}. Raw: {text[:500]}",
@@ -1,48 +1,59 @@
1
- """Runtime helpers shared by all generated entity clients."""
2
- from .aggregations import (
3
- DEFAULT_AGGREGATION_DEPTH,
4
- aggregation_fragment,
5
- )
6
- from .fields import collect_fields
7
- from .filter import (
8
- BooleanOps,
9
- DateOps,
10
- NumberOps,
11
- StringOps,
12
- filter_to_graphql,
13
- )
14
- from .operations import (
15
- RelationRef,
16
- do_create,
17
- do_create_bulk,
18
- do_create_relation,
19
- do_create_relation_bulk,
20
- do_delete,
21
- do_find,
22
- do_search,
23
- do_update,
24
- do_update_bulk,
25
- )
26
- from .order_by import order_by_to_graphql
27
-
28
- __all__ = [
29
- "BooleanOps",
30
- "DEFAULT_AGGREGATION_DEPTH",
31
- "DateOps",
32
- "NumberOps",
33
- "StringOps",
34
- "aggregation_fragment",
35
- "collect_fields",
36
- "filter_to_graphql",
37
- "order_by_to_graphql",
38
- "RelationRef",
39
- "do_create",
40
- "do_create_bulk",
41
- "do_create_relation",
42
- "do_create_relation_bulk",
43
- "do_delete",
44
- "do_find",
45
- "do_search",
46
- "do_update",
47
- "do_update_bulk",
48
- ]
1
+ """Runtime helpers shared by all generated entity clients."""
2
+ from .aggregations import (
3
+ DEFAULT_AGGREGATION_DEPTH,
4
+ aggregation_fragment,
5
+ )
6
+ from .fields import collect_fields
7
+ from .filter import (
8
+ BooleanOps,
9
+ DateOps,
10
+ NumberOps,
11
+ StringOps,
12
+ filter_to_graphql,
13
+ )
14
+ from .operations import (
15
+ RelationRef,
16
+ do_create,
17
+ do_create_bulk,
18
+ do_create_relation,
19
+ do_create_relation_bulk,
20
+ do_delete,
21
+ do_find,
22
+ do_search,
23
+ do_update,
24
+ do_update_bulk,
25
+ )
26
+ from .order_by import distance_from, order_by_to_graphql
27
+ from .saved_searches import (
28
+ delete_saved_search,
29
+ do_save_search,
30
+ get_saved_searches,
31
+ saved_search_arguments,
32
+ )
33
+
34
+ __all__ = [
35
+ "BooleanOps",
36
+ "DEFAULT_AGGREGATION_DEPTH",
37
+ "DateOps",
38
+ "NumberOps",
39
+ "StringOps",
40
+ "aggregation_fragment",
41
+ "collect_fields",
42
+ "filter_to_graphql",
43
+ "order_by_to_graphql",
44
+ "distance_from",
45
+ "RelationRef",
46
+ "do_create",
47
+ "do_create_bulk",
48
+ "do_create_relation",
49
+ "do_create_relation_bulk",
50
+ "do_delete",
51
+ "do_find",
52
+ "do_search",
53
+ "do_update",
54
+ "do_update_bulk",
55
+ "do_save_search",
56
+ "get_saved_searches",
57
+ "delete_saved_search",
58
+ "saved_search_arguments",
59
+ ]
@@ -0,0 +1,112 @@
1
+ """Aggregation types and result-fragment expansion.
2
+
3
+ Mirrors `DataceenClientTs/src/runtime/aggregations.ts`. The server's
4
+ introspection does not advertise the Aggregations field on
5
+ `<Entity>SearchResult`, but it returns it when the selection asks for it.
6
+ We expand the fragment at a fixed depth so callers can nest up to N levels.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ from typing import Any, Literal, NotRequired, TypedDict
11
+
12
+
13
+ # Metrics_Avg, _Stats and _Percentiles and Bucket_Histogram take a number property; Metrics_Min, _Max and
14
+ # Bucket_Range a number or a date; Bucket_DateHistogram a date; Bucket_Filters does not use its property;
15
+ # Top_Hits sorts the enclosing bucket's records by it. The Geo_ kinds go on _location itself: Geo_Grid counts per
16
+ # map cell at precision, Geo_Distance per ring of km from origin, Geo_Bounds and Geo_Centroid the box and the centre.
17
+ AggregationType = Literal[
18
+ "Bucket_Terms", "Metrics_Sum",
19
+ "Metrics_Min", "Metrics_Max", "Metrics_Avg", "Metrics_Stats", "Metrics_Distinct", "Metrics_Percentiles",
20
+ "Bucket_Range", "Bucket_Histogram", "Bucket_DateHistogram", "Bucket_Filters", "Top_Hits",
21
+ "Geo_Grid", "Geo_Distance", "Geo_Bounds", "Geo_Centroid",
22
+ ]
23
+
24
+ CalendarInterval = Literal["minute", "hour", "day", "week", "month", "quarter", "year"]
25
+
26
+
27
+ class AggregationRange(TypedDict, total=False):
28
+ """A range of a Bucket_Range aggregation: from inclusive, to exclusive,
29
+ either left out; a number or a date as text."""
30
+
31
+ key: str
32
+ to: str
33
+
34
+
35
+ # "from" is a Python keyword: the functional form carries it.
36
+ AggregationRangeFrom = TypedDict("AggregationRangeFrom", {"from": str}, total=False)
37
+
38
+
39
+ class AggregationFilter(TypedDict, total=False):
40
+ key: str
41
+ where: dict[str, Any]
42
+
43
+
44
+ class AggregationDetails(TypedDict, total=False):
45
+ """Per-field aggregation request shape. Matches server's
46
+ `Search<Entity>AggregationDetails`."""
47
+
48
+ name: str
49
+ size: int
50
+ type: AggregationType
51
+ aggregations: list[Any]
52
+ ranges: list[dict[str, str]]
53
+ interval: float
54
+ calendarInterval: CalendarInterval
55
+ timeZone: str
56
+ minDocCount: int
57
+ percents: list[float]
58
+ filters: list[AggregationFilter]
59
+ sortDirection: Literal["Ascending", "Descending"]
60
+ # Geo_Grid: the map zoom of the cells, 0 to 29 (6 when left out).
61
+ precision: int
62
+ # Geo_Distance: {"lat": ..., "lon": ...}, the point the rings (ranges, in km) are measured from.
63
+ origin: dict[str, float]
64
+
65
+
66
+ class Bucket(TypedDict):
67
+ Key: Any
68
+ Count: int
69
+ Aggregations: NotRequired[list["Aggregation"]]
70
+ From: NotRequired[Any]
71
+ To: NotRequired[Any]
72
+
73
+
74
+ class AggregationStats(TypedDict):
75
+ Count: int
76
+ Min: float | None
77
+ Max: float | None
78
+ Avg: float | None
79
+ Sum: float
80
+
81
+
82
+ class Aggregation(TypedDict):
83
+ Name: str
84
+ SumOtherDocCount: NotRequired[int]
85
+ DocCountErrorUpperBound: NotRequired[int]
86
+ Buckets: list[Bucket]
87
+ Value: NotRequired[float]
88
+ ValueAsString: NotRequired[str]
89
+ Stats: NotRequired[AggregationStats]
90
+ Percentiles: NotRequired[list[dict[str, Any]]]
91
+ Hits: NotRequired[list[dict[str, Any]]]
92
+ # Geo_Bounds: {"TopLeft": {"Lat", "Lon"}, "BottomRight": {...}}; Geo_Centroid: {"Lat", "Lon"} and Count.
93
+ Bounds: NotRequired[dict[str, dict[str, float]]]
94
+ Centroid: NotRequired[dict[str, float]]
95
+ Count: NotRequired[int]
96
+
97
+
98
+ DEFAULT_AGGREGATION_DEPTH = 3
99
+
100
+
101
+ def aggregation_fragment(depth: int) -> str:
102
+ """Build a GraphQL selection fragment for the Aggregations result, expanded
103
+ to the given nesting depth. Deeper buckets are returned by the server but
104
+ silently dropped by the selection."""
105
+ scalar_fields = "Name SumOtherDocCount DocCountErrorUpperBound Value"
106
+ fragment = f"Aggregations {{ {scalar_fields} Buckets {{ Key Count }} }}"
107
+ for _ in range(depth - 1):
108
+ fragment = (
109
+ f"Aggregations {{ {scalar_fields} "
110
+ f"Buckets {{ Key Count {fragment} }} }}"
111
+ )
112
+ return fragment