matrx-api 0.1.4__tar.gz → 0.1.6__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.
- {matrx_api-0.1.4 → matrx_api-0.1.6}/PKG-INFO +1 -1
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/__init__.py +2 -1
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/client.py +38 -9
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/credentials.py +3 -8
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/deployments.py +1 -1
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/account.py +1554 -1440
- matrx_api-0.1.6/matrx_api/generated/agents.py +3839 -0
- matrx_api-0.1.6/matrx_api/generated/ai.py +589 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/apps.py +382 -314
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/architecture.py +2450 -2029
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/audio.py +302 -262
- matrx_api-0.1.6/matrx_api/generated/chat.py +2661 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/code.py +1435 -1333
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/commerce.py +11 -5
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/communications.py +591 -540
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/computer.py +335 -261
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/content.py +766 -682
- matrx_api-0.1.6/matrx_api/generated/crm.py +1481 -0
- matrx_api-0.1.6/matrx_api/generated/data.py +2080 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/education.py +33 -27
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/files.py +2341 -2112
- matrx_api-0.1.6/matrx_api/generated/human_resources.py +1013 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/integrations.py +10921 -9807
- matrx_api-0.1.6/matrx_api/generated/intelligence.py +3572 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/knowledge.py +2527 -2333
- matrx_api-0.1.6/matrx_api/generated/legal.py +973 -0
- matrx_api-0.1.6/matrx_api/generated/marketing.py +7988 -0
- matrx_api-0.1.6/matrx_api/generated/masterwork.py +1591 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/media.py +1005 -900
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/platform.py +307 -279
- matrx_api-0.1.6/matrx_api/generated/publish.py +1283 -0
- matrx_api-0.1.6/matrx_api/generated/web.py +4573 -0
- matrx_api-0.1.6/matrx_api/generated/workflows.py +3935 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/pyproject.toml +7 -1
- {matrx_api-0.1.4 → matrx_api-0.1.6}/scripts/generate.py +42 -18
- {matrx_api-0.1.4 → matrx_api-0.1.6}/tests/test_client.py +32 -0
- matrx_api-0.1.4/matrx_api/generated/agents.py +0 -3728
- matrx_api-0.1.4/matrx_api/generated/ai.py +0 -479
- matrx_api-0.1.4/matrx_api/generated/chat.py +0 -2524
- matrx_api-0.1.4/matrx_api/generated/crm.py +0 -1434
- matrx_api-0.1.4/matrx_api/generated/data.py +0 -1784
- matrx_api-0.1.4/matrx_api/generated/human_resources.py +0 -981
- matrx_api-0.1.4/matrx_api/generated/intelligence.py +0 -3464
- matrx_api-0.1.4/matrx_api/generated/legal.py +0 -933
- matrx_api-0.1.4/matrx_api/generated/marketing.py +0 -7432
- matrx_api-0.1.4/matrx_api/generated/masterwork.py +0 -1537
- matrx_api-0.1.4/matrx_api/generated/publish.py +0 -1239
- matrx_api-0.1.4/matrx_api/generated/web.py +0 -4389
- matrx_api-0.1.4/matrx_api/generated/workflows.py +0 -3695
- {matrx_api-0.1.4 → matrx_api-0.1.6}/.gitignore +0 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/README.md +0 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/errors.py +0 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/generated/__init__.py +0 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/matrx_api/streams.py +0 -0
- {matrx_api-0.1.4 → matrx_api-0.1.6}/tests/conftest.py +0 -0
|
@@ -7,6 +7,7 @@ from .client import (
|
|
|
7
7
|
MatrxApi,
|
|
8
8
|
Multipart,
|
|
9
9
|
OperationDescriptor,
|
|
10
|
+
RawPath,
|
|
10
11
|
RequestInfo,
|
|
11
12
|
)
|
|
12
13
|
from .credentials import (
|
|
@@ -25,7 +26,7 @@ from .streams import NdjsonFramer, SseFrame, SseFramer
|
|
|
25
26
|
__all__ = [
|
|
26
27
|
"ApiKeyCredential", "ApiStream", "CONTRACT_SHA256", "CallOptions", "DEPLOYMENTS", "DOMAINS",
|
|
27
28
|
"GuestCredential", "JsonOrStream", "MATRX_HEADERS", "MatrxApi", "MatrxApiError", "Multipart",
|
|
28
|
-
"NdjsonFramer", "OperationDescriptor", "OrganizationContextError", "RequestInfo",
|
|
29
|
+
"NdjsonFramer", "OperationDescriptor", "OrganizationContextError", "RawPath", "RequestInfo",
|
|
29
30
|
"ScopedCredential", "ServiceCredential", "SseFrame", "SseFramer", "UserCredential",
|
|
30
31
|
"credential_to_headers",
|
|
31
32
|
]
|
|
@@ -19,7 +19,7 @@ import asyncio
|
|
|
19
19
|
import json
|
|
20
20
|
import uuid
|
|
21
21
|
from collections.abc import AsyncIterator, Callable, Mapping
|
|
22
|
-
from dataclasses import dataclass
|
|
22
|
+
from dataclasses import dataclass
|
|
23
23
|
from typing import Any, Generic, Literal, TypeVar
|
|
24
24
|
|
|
25
25
|
import httpx
|
|
@@ -27,14 +27,15 @@ import httpx
|
|
|
27
27
|
from .credentials import MATRX_HEADERS, CredentialsSetting, credential_to_headers, resolve_credential
|
|
28
28
|
from .deployments import DEPLOYMENTS
|
|
29
29
|
from .errors import MatrxApiError, OrganizationContextError
|
|
30
|
-
from .streams import NdjsonFramer, SseFramer
|
|
30
|
+
from .streams import NdjsonFramer, SseFramer
|
|
31
|
+
|
|
32
|
+
E = TypeVar("E")
|
|
33
|
+
J = TypeVar("J")
|
|
31
34
|
|
|
32
35
|
Environment = Literal["production", "localhost"]
|
|
33
36
|
StreamKind = Literal["none", "ndjson", "sse", "bytes", "ndjson_or_json", "sse_or_json", "bytes_or_json"]
|
|
34
37
|
|
|
35
38
|
DEFAULT_CONNECT_TIMEOUT = 15.0
|
|
36
|
-
E = TypeVar("E")
|
|
37
|
-
J = TypeVar("J")
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
@dataclass(frozen=True, slots=True)
|
|
@@ -54,6 +55,21 @@ class CallOptions:
|
|
|
54
55
|
headers: Mapping[str, str] | None = None
|
|
55
56
|
connect_timeout: float | None = None
|
|
56
57
|
total_timeout: float | None = None
|
|
58
|
+
#: Hand back a non-2xx response as-is (status, headers, body untouched) instead of raising
|
|
59
|
+
#: :class:`MatrxApiError`. For gateways that relay the upstream answer verbatim; use with
|
|
60
|
+
#: ``MatrxApi.send`` / ``raw`` / ``open_stream`` (``call`` still parses the body it gets).
|
|
61
|
+
raw_errors: bool = False
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class RawPath(str):
|
|
65
|
+
"""A path-parameter value whose ``/`` separators are kept (a catch-all ``{path}`` parameter).
|
|
66
|
+
|
|
67
|
+
Every other path value is percent-encoded whole, so ``a/b`` becomes ``a%2Fb``. Wrap the value
|
|
68
|
+
in ``RawPath`` for a parameter the server declares as a ``path`` converter; each segment is
|
|
69
|
+
still encoded, only the separators survive.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
__slots__ = ()
|
|
57
73
|
|
|
58
74
|
|
|
59
75
|
@dataclass(frozen=True, slots=True)
|
|
@@ -77,12 +93,12 @@ def _interpolate(template: str, params: Mapping[str, Any] | None) -> str:
|
|
|
77
93
|
import re
|
|
78
94
|
from urllib.parse import quote
|
|
79
95
|
|
|
80
|
-
def sub(m:
|
|
96
|
+
def sub(m: re.Match[str]) -> str:
|
|
81
97
|
name = m.group(1)
|
|
82
98
|
value = (params or {}).get(name)
|
|
83
99
|
if value is None or str(value) == "":
|
|
84
100
|
raise TypeError(f'Missing path parameter "{name}" for {template}')
|
|
85
|
-
return quote(str(value), safe="")
|
|
101
|
+
return quote(str(value), safe="/" if isinstance(value, RawPath) else "")
|
|
86
102
|
|
|
87
103
|
return re.sub(r"\{([^}]+)\}", sub, template)
|
|
88
104
|
|
|
@@ -154,10 +170,23 @@ class ApiStream(Generic[E]):
|
|
|
154
170
|
self._started = True
|
|
155
171
|
return self._iterate()
|
|
156
172
|
|
|
173
|
+
async def aiter_raw(self) -> AsyncIterator[bytes]:
|
|
174
|
+
"""The response body exactly as received (no decoding, no framing), for byte-for-byte relays."""
|
|
175
|
+
if self._started:
|
|
176
|
+
raise RuntimeError("an ApiStream can only be iterated once")
|
|
177
|
+
self._started = True
|
|
178
|
+
try:
|
|
179
|
+
async for chunk in self.response.aiter_raw():
|
|
180
|
+
yield chunk
|
|
181
|
+
except httpx.TransportError as exc:
|
|
182
|
+
raise MatrxApiError(status=0, path=str(self.response.url), message=f"stream interrupted: {exc}", code="network_error") from exc
|
|
183
|
+
finally:
|
|
184
|
+
await self.response.aclose()
|
|
185
|
+
|
|
157
186
|
async def aclose(self) -> None:
|
|
158
187
|
await self.response.aclose()
|
|
159
188
|
|
|
160
|
-
async def __aenter__(self) ->
|
|
189
|
+
async def __aenter__(self) -> ApiStream[E]:
|
|
161
190
|
return self
|
|
162
191
|
|
|
163
192
|
async def __aexit__(self, *exc: object) -> None:
|
|
@@ -215,7 +244,7 @@ class MatrxApi:
|
|
|
215
244
|
if self._owns_client:
|
|
216
245
|
await self._client.aclose()
|
|
217
246
|
|
|
218
|
-
async def __aenter__(self) ->
|
|
247
|
+
async def __aenter__(self) -> MatrxApi:
|
|
219
248
|
return self
|
|
220
249
|
|
|
221
250
|
async def __aexit__(self, *exc: object) -> None:
|
|
@@ -371,7 +400,7 @@ class MatrxApi:
|
|
|
371
400
|
message=f"{type(exc).__name__}: {exc}" if str(exc) else type(exc).__name__,
|
|
372
401
|
code="network_error",
|
|
373
402
|
) from exc
|
|
374
|
-
if response.status_code >= 400:
|
|
403
|
+
if response.status_code >= 400 and not (options and options.raw_errors):
|
|
375
404
|
raise await self._error(response, op, path)
|
|
376
405
|
return response, request_id
|
|
377
406
|
raise AssertionError(last) # pragma: no cover
|
|
@@ -5,8 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import inspect
|
|
6
6
|
from collections.abc import Awaitable, Callable
|
|
7
7
|
from dataclasses import dataclass
|
|
8
|
-
from typing import
|
|
9
|
-
|
|
8
|
+
from typing import TypeAlias
|
|
10
9
|
MATRX_HEADERS = {
|
|
11
10
|
"authorization": "Authorization",
|
|
12
11
|
"fingerprint": "X-Fingerprint-ID",
|
|
@@ -55,12 +54,8 @@ class ScopedCredential:
|
|
|
55
54
|
token: str
|
|
56
55
|
|
|
57
56
|
|
|
58
|
-
Credential =
|
|
59
|
-
CredentialsSetting =
|
|
60
|
-
Credential,
|
|
61
|
-
None,
|
|
62
|
-
Callable[[], Union[Credential, None, Awaitable[Union[Credential, None]]]],
|
|
63
|
-
]
|
|
57
|
+
Credential: TypeAlias = UserCredential | GuestCredential | ApiKeyCredential | ServiceCredential | ScopedCredential
|
|
58
|
+
CredentialsSetting: TypeAlias = Credential | None | Callable[[], Credential | None | Awaitable[Credential | None]]
|
|
64
59
|
|
|
65
60
|
|
|
66
61
|
def credential_to_headers(credential: Credential | None) -> dict[str, str]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""GENERATED by matrx-api scripts/generate.py from aidream/api-contract - never edit by hand."""
|
|
2
2
|
|
|
3
|
-
CONTRACT_SHA256 = '
|
|
3
|
+
CONTRACT_SHA256 = '2e22230d01e754f5ae210e0932290279956cc04757022cfee77b6d128f1c667c'
|
|
4
4
|
|
|
5
5
|
# Which deployment answers (api-deployments.json): default base URLs and the env names that override them.
|
|
6
6
|
DEPLOYMENTS: dict[str, dict] = {
|