konecty_sdk_python 2.1.1__tar.gz → 2.1.3__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 (36) hide show
  1. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/client.py +4 -1
  2. konecty_sdk_python-2.1.3/KonectySdkPython/lib/exceptions.py +42 -0
  3. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/auth.py +34 -5
  4. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/PKG-INFO +2 -2
  5. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/pyproject.toml +1 -1
  6. konecty_sdk_python-2.1.1/KonectySdkPython/lib/exceptions.py +0 -26
  7. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/.gitignore +0 -0
  8. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/__init__.py +0 -0
  9. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/cli/__init__.py +0 -0
  10. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/cli/apply.py +0 -0
  11. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/cli/backup.py +0 -0
  12. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/cli/pull.py +0 -0
  13. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/__init__.py +0 -0
  14. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/feature_types/__init__.py +0 -0
  15. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/feature_types/cross_module_query.py +0 -0
  16. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/feature_types/kpi.py +0 -0
  17. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/feature_types/query_json.py +0 -0
  18. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/file_manager.py +0 -0
  19. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/filters.py +0 -0
  20. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/http.py +0 -0
  21. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/model.py +0 -0
  22. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/serialization.py +0 -0
  23. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/__init__.py +0 -0
  24. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/aggregation.py +0 -0
  25. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/base.py +0 -0
  26. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/change_user.py +0 -0
  27. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/comments.py +0 -0
  28. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/export.py +0 -0
  29. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/files.py +0 -0
  30. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/notifications.py +0 -0
  31. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/query.py +0 -0
  32. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/stream.py +0 -0
  33. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/services/subscriptions.py +0 -0
  34. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/settings.py +0 -0
  35. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/KonectySdkPython/lib/types.py +0 -0
  36. {konecty_sdk_python-2.1.1 → konecty_sdk_python-2.1.3}/README.md +0 -0
@@ -31,12 +31,15 @@ logging.getLogger("urllib3.connectionpool").setLevel(logging.ERROR)
31
31
 
32
32
  logger = logging.getLogger(__name__)
33
33
 
34
+ # `_updatedBy` is NOT stripped: the backend accepts it on update as an explicit
35
+ # authorship override for admin callers (automations crediting a write to the user
36
+ # it acted on behalf of). Non-admin callers have it ignored server-side, so letting
37
+ # it through costs nothing. See "Autoria da escrita" in docs/pt-BR/api.md (konecty/Konecty).
34
38
  KONECTY_UPDATE_IGNORE_FIELDS = [
35
39
  "_id",
36
40
  "code",
37
41
  "_updatedAt",
38
42
  "_createdAt",
39
- "_updatedBy",
40
43
  "_createdBy",
41
44
  ]
42
45
  KONECTY_CREATE_IGNORE_FIELDS = ["_updatedAt", "_createdAt", "_updatedBy", "_createdBy"]
@@ -0,0 +1,42 @@
1
+ """Exceptions for the Konecty SDK."""
2
+
3
+
4
+ class KonectyError(Exception):
5
+ """Base exception for Konecty errors."""
6
+
7
+ pass
8
+
9
+
10
+ class KonectyAPIError(KonectyError):
11
+ """Raised when the API returns success=false or a non-2xx status."""
12
+
13
+ pass
14
+
15
+
16
+ class KonectyGoogleSessionError(KonectyAPIError):
17
+ """
18
+ Raised by exchange_google_code. Carries the machine-readable ``code`` from
19
+ ``errors[0].code`` so callers can branch or translate without parsing the
20
+ message; ``failed`` covers unreadable or unrecognised bodies.
21
+
22
+ Subclasses KonectyAPIError so existing ``except KonectyAPIError`` keeps working.
23
+
24
+ Mirrors KonectyGoogleSessionError in the TypeScript SDK — keep both in sync.
25
+ """
26
+
27
+ def __init__(self, code: str, message: str) -> None:
28
+ super().__init__(message)
29
+ self.code = code
30
+
31
+
32
+ class KonectyValidationError(KonectyError):
33
+ """Raised for validation errors."""
34
+
35
+ pass
36
+
37
+
38
+ class KonectySerializationError(KonectyError):
39
+ """Raised when a value is not serializable."""
40
+
41
+ def __init__(self) -> None:
42
+ super().__init__("Tipo não serializável")
@@ -3,7 +3,7 @@
3
3
  from typing import Any, Dict, Optional, Union
4
4
  from urllib.parse import quote, urlencode
5
5
 
6
- from ..exceptions import KonectyAPIError
6
+ from ..exceptions import KonectyAPIError, KonectyGoogleSessionError
7
7
  from .base import BaseService
8
8
 
9
9
  GOOGLE_START_PATH = "/api/auth/google/start"
@@ -15,6 +15,29 @@ GOOGLE_SESSION_PATH = "/api/auth/google/session"
15
15
  LOGIN_OPTIONS_PATH = "/api/auth/login-options"
16
16
 
17
17
 
18
+ _GOOGLE_SESSION_ERROR_CODES = (
19
+ "invalid_code",
20
+ "expired_code",
21
+ "user_not_found",
22
+ "user_inactive",
23
+ )
24
+
25
+
26
+ def _first_error_code(error: KonectyAPIError) -> str:
27
+ """
28
+ Extract the first recognised ``errors[].code``; ``failed`` when there is none.
29
+
30
+ Same set and same fallback as the TypeScript SDK, so both raise the same code
31
+ for the same response.
32
+ """
33
+ errors = error.args[0] if error.args else None
34
+ if isinstance(errors, list):
35
+ for item in errors:
36
+ if isinstance(item, dict) and item.get("code") in _GOOGLE_SESSION_ERROR_CODES:
37
+ return str(item["code"])
38
+ return "failed"
39
+
40
+
18
41
  def _first_error_message(error: KonectyAPIError) -> str:
19
42
  """Extract errors[0].message from a KonectyAPIError raised by the HTTP layer."""
20
43
  errors = error.args[0] if error.args else None
@@ -74,8 +97,10 @@ class AuthService(BaseService):
74
97
  POST /api/auth/google/session. Exchanges the single-use code (TTL 60s) for a session.
75
98
 
76
99
  On success the returned authId is adopted by the client, so following requests
77
- are authenticated. On error raises KonectyAPIError with errors[0].message and
78
- leaves the client authentication state untouched.
100
+ are authenticated. On error raises KonectyGoogleSessionError — errors[0].message
101
+ as the message plus the machine-readable ``code`` — and leaves the client
102
+ authentication state untouched. The error subclasses KonectyAPIError, so callers
103
+ catching that keep working.
79
104
  """
80
105
  payload: Dict[str, Any] = {"code": code}
81
106
  if geolocation is not None:
@@ -90,11 +115,15 @@ class AuthService(BaseService):
90
115
  try:
91
116
  response = await self._post(GOOGLE_SESSION_PATH, json=payload)
92
117
  except KonectyAPIError as error:
93
- raise KonectyAPIError(_first_error_message(error)) from error
118
+ raise KonectyGoogleSessionError(
119
+ _first_error_code(error), _first_error_message(error)
120
+ ) from error
94
121
 
95
122
  auth_id = response.get("authId") if isinstance(response, dict) else None
96
123
  if not isinstance(auth_id, str) or not auth_id:
97
- raise KonectyAPIError("Google session response has no authId")
124
+ raise KonectyGoogleSessionError(
125
+ "failed", "Google session response has no authId"
126
+ )
98
127
 
99
128
  self._client.set_auth_id(auth_id)
100
129
  return response
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: konecty_sdk_python
3
- Version: 2.1.1
3
+ Version: 2.1.3
4
4
  Summary: Konecty SDK Python
5
5
  Author-email: Leonardo Leal <leonardo.leal@konecty.com>, Derotino Silveira <derotino.silveira@konecty.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "konecty_sdk_python"
3
- version = "2.1.1"
3
+ version = "2.1.3"
4
4
  description = "Konecty SDK Python"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,26 +0,0 @@
1
- """Exceptions for the Konecty SDK."""
2
-
3
-
4
- class KonectyError(Exception):
5
- """Base exception for Konecty errors."""
6
-
7
- pass
8
-
9
-
10
- class KonectyAPIError(KonectyError):
11
- """Raised when the API returns success=false or a non-2xx status."""
12
-
13
- pass
14
-
15
-
16
- class KonectyValidationError(KonectyError):
17
- """Raised for validation errors."""
18
-
19
- pass
20
-
21
-
22
- class KonectySerializationError(KonectyError):
23
- """Raised when a value is not serializable."""
24
-
25
- def __init__(self) -> None:
26
- super().__init__("Tipo não serializável")