konecty_sdk_python 2.1.1__py3-none-any.whl

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 (35) hide show
  1. KonectySdkPython/__init__.py +41 -0
  2. KonectySdkPython/cli/__init__.py +38 -0
  3. KonectySdkPython/cli/apply.py +555 -0
  4. KonectySdkPython/cli/backup.py +161 -0
  5. KonectySdkPython/cli/pull.py +309 -0
  6. KonectySdkPython/lib/__init__.py +43 -0
  7. KonectySdkPython/lib/client.py +950 -0
  8. KonectySdkPython/lib/exceptions.py +26 -0
  9. KonectySdkPython/lib/feature_types/__init__.py +46 -0
  10. KonectySdkPython/lib/feature_types/cross_module_query.py +78 -0
  11. KonectySdkPython/lib/feature_types/kpi.py +21 -0
  12. KonectySdkPython/lib/feature_types/query_json.py +242 -0
  13. KonectySdkPython/lib/file_manager.py +248 -0
  14. KonectySdkPython/lib/filters.py +155 -0
  15. KonectySdkPython/lib/http.py +95 -0
  16. KonectySdkPython/lib/model.py +88 -0
  17. KonectySdkPython/lib/serialization.py +13 -0
  18. KonectySdkPython/lib/services/__init__.py +5 -0
  19. KonectySdkPython/lib/services/aggregation.py +142 -0
  20. KonectySdkPython/lib/services/auth.py +105 -0
  21. KonectySdkPython/lib/services/base.py +63 -0
  22. KonectySdkPython/lib/services/change_user.py +64 -0
  23. KonectySdkPython/lib/services/comments.py +89 -0
  24. KonectySdkPython/lib/services/export.py +54 -0
  25. KonectySdkPython/lib/services/files.py +59 -0
  26. KonectySdkPython/lib/services/notifications.py +41 -0
  27. KonectySdkPython/lib/services/query.py +192 -0
  28. KonectySdkPython/lib/services/stream.py +133 -0
  29. KonectySdkPython/lib/services/subscriptions.py +26 -0
  30. KonectySdkPython/lib/settings.py +152 -0
  31. KonectySdkPython/lib/types.py +418 -0
  32. konecty_sdk_python-2.1.1.dist-info/METADATA +155 -0
  33. konecty_sdk_python-2.1.1.dist-info/RECORD +35 -0
  34. konecty_sdk_python-2.1.1.dist-info/WHEEL +4 -0
  35. konecty_sdk_python-2.1.1.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,155 @@
1
+ Metadata-Version: 2.4
2
+ Name: konecty_sdk_python
3
+ Version: 2.1.1
4
+ Summary: Konecty SDK Python
5
+ Author-email: Leonardo Leal <leonardo.leal@konecty.com>, Derotino Silveira <derotino.silveira@konecty.com>
6
+ License: MIT
7
+ Keywords: api,konecty,sdk
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Requires-Python: >=3.11
16
+ Requires-Dist: aiohttp>=3.11.11
17
+ Requires-Dist: asyncio>=3.4.3
18
+ Requires-Dist: black>=24.10.0
19
+ Requires-Dist: email-validator>=2.2.0
20
+ Requires-Dist: inquirer>=3.4.0
21
+ Requires-Dist: pydantic>=2.11.4
22
+ Requires-Dist: pymongo>=4.10.1
23
+ Requires-Dist: requests>=2.32.3
24
+ Requires-Dist: rich>=13.9.4
25
+ Requires-Dist: typing-extensions>=4.12.2
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ ## Konecty Python SDK
32
+
33
+ > 🛠️ Work in progress
34
+
35
+ This project exposes both:
36
+
37
+ - a cli for interacting with the database
38
+ - the Konecty client sdk for interacting with Konecty's api
39
+
40
+ #### Usage
41
+
42
+ ##### Installing on a project
43
+
44
+ ```sh
45
+ uv pip install konecty-sdk-python
46
+ konecty-cli apply --mongo-url="..." --database my-db
47
+ ```
48
+
49
+ ##### Running on uvx
50
+
51
+ ```sh
52
+ uvx --from konecty-sdk-python konecty-cli pull --all --mongo-url="..." --database my-db
53
+ ```
54
+
55
+ #### Google login
56
+
57
+ The Konecty core hosts the whole authorization code flow: your app never talks to Google
58
+ and never sees `client_secret`. The `authId` never travels in a URL — the callback returns
59
+ a single-use code (TTL 60s) and the `authId` only exists in the body of `POST /api/auth/google/session`.
60
+
61
+ Three steps, three methods:
62
+
63
+ 1. `client.google_login_url(...)` — build the URL to send the browser to (no request is made).
64
+ 2. the browser comes back to your `redirect_uri` with `?code=...&state=...` (or `?error=...&state=...`).
65
+ 3. `await client.exchange_google_code(code)` — turn the code into a session; the returned
66
+ `authId` is adopted by the client, so the next calls are authenticated.
67
+
68
+ ```python
69
+ import asyncio
70
+ import os
71
+ import secrets
72
+
73
+ from KonectySdkPython import KonectyClient
74
+ from KonectySdkPython.lib.exceptions import KonectyAPIError
75
+
76
+ KONECTY_URL = os.environ["KONECTY_URL"]
77
+ CLIENT_ID = os.environ["KONECTY_CLIENT_ID"]
78
+ REDIRECT_URI = os.environ["KONECTY_REDIRECT_URI"]
79
+
80
+
81
+ async def main() -> None:
82
+ client = KonectyClient(KONECTY_URL)
83
+
84
+ # Is Google login enabled for this namespace?
85
+ options = await client.get_login_options()
86
+ if not options["googleEnabled"]:
87
+ raise SystemExit("Google login is disabled for this namespace")
88
+
89
+ # Step 1 — send the browser here (state is opaque to Konecty; use it against CSRF).
90
+ state = secrets.token_urlsafe(16)
91
+ print(client.google_login_url(client_id=CLIENT_ID, redirect_uri=REDIRECT_URI, state=state))
92
+
93
+ # Step 2 — Konecty redirects the browser back to REDIRECT_URI with code + state.
94
+ # On refusal it comes back as ?error=<access_denied|provider_error|
95
+ # email_not_verified|user_not_found|user_inactive|ambiguous_user>&state=...
96
+ returned_code = input("code from the callback: ")
97
+
98
+ # Step 3 — exchange the single-use code for a session.
99
+ try:
100
+ session = await client.exchange_google_code(
101
+ returned_code,
102
+ source="my-app", # optional telemetry: geolocation, resolution, source, fingerprint
103
+ )
104
+ except KonectyAPIError as error:
105
+ raise SystemExit(f"Google login failed: {error}")
106
+
107
+ print("logged as", session["user"]["login"], "authId:", client.auth_id)
108
+
109
+ # The client is now authenticated: no token needed on the constructor.
110
+ contacts = await client.find_by_id("User", session["user"]["_id"])
111
+ print(contacts)
112
+
113
+
114
+ asyncio.run(main())
115
+ ```
116
+
117
+ `exchange_google_code` raises `KonectyAPIError` with the message of `errors[0]`
118
+ (`invalid_code`, `expired_code`, `user_not_found`, `user_inactive`) and leaves the client's
119
+ authentication state untouched.
120
+
121
+ #### Tests
122
+
123
+ ```sh
124
+ uv pip install -e ".[dev]"
125
+ .venv/bin/python -m pytest
126
+ ```
127
+
128
+ #### Build & Publish
129
+
130
+ Publishing runs from the **Publish** workflow, triggered by hand from the Actions tab
131
+ (`Run workflow`) — no merge publishes on its own. Pick the increment (`patch`, `minor` or
132
+ `major`) and run it; **the version bump is part of publishing**, so there is nothing to edit
133
+ beforehand.
134
+
135
+ The workflow runs the tests, bumps `version` in [pyproject.toml](./pyproject.toml), builds into
136
+ `dist-build/` and uploads with `uv publish` (secret `PYPI_API_TOKEN`). Only after the upload
137
+ succeeds does it commit `chore(release): <version>` and tag it — a failed upload leaves no bump
138
+ behind claiming a release that does not exist on PyPI.
139
+
140
+ <details>
141
+ <summary>Publishing manually</summary>
142
+
143
+ Same PyPI endpoint (`upload.pypi.org/legacy/`) and the same kind of API token. Credentials
144
+ come from `.pypirc`, which is gitignored and therefore local-only — this is why CI
145
+ authenticates through a secret instead.
146
+
147
+ ```sh
148
+ uv build
149
+ uvx twine upload --config-file .pypirc --skip-existing dist/*
150
+ ```
151
+
152
+ Note `--skip-existing`: unlike the workflow, this silently skips versions already published,
153
+ and it is what keeps a stale local `dist/` from re-uploading old artifacts.
154
+
155
+ </details>
@@ -0,0 +1,35 @@
1
+ KonectySdkPython/__init__.py,sha256=E8bSSpoh-XogtSp4oDAhhID0J0UtctOlGS9LhI5F5d0,1022
2
+ KonectySdkPython/cli/__init__.py,sha256=Ap83UThRejLC44VaM-l31NhKcpkzx0Y4CgT042OJCBE,761
3
+ KonectySdkPython/cli/apply.py,sha256=LyPoNcsU3oz9P_eTAi4BdtJHWkbp-sNK_SP9W8Xua04,17923
4
+ KonectySdkPython/cli/backup.py,sha256=rcla3EWfPsy-vWgmDK844EaM5u3h7JF-u7-b2HUBMgA,4785
5
+ KonectySdkPython/cli/pull.py,sha256=n4gIkKtuEpPKULb3zcYu5tZlBLbt_4oNQDeu2l6tHxU,9529
6
+ KonectySdkPython/lib/__init__.py,sha256=Du8jLNfFG1bQuHX5u7pAhbyV9TjC7Ie9K1Xo1KSUqqc,995
7
+ KonectySdkPython/lib/client.py,sha256=i-7goKqsH-jvwxZfGeipTRFByOBAOhMHkuhjjdEN3kE,34034
8
+ KonectySdkPython/lib/exceptions.py,sha256=HR48cd-cptFPoObr37NcvDrdkb-RtxKRteQoG-tuPkk,529
9
+ KonectySdkPython/lib/file_manager.py,sha256=CLpOJWdA1tb2iq0qOIeRyEEIuACRq9tIo7Rls1YT2ig,9986
10
+ KonectySdkPython/lib/filters.py,sha256=PsFaUFCEyKgxgzD566LdTLvuMJevoF_i9U1WnpJZzPQ,4482
11
+ KonectySdkPython/lib/http.py,sha256=atwyuKSFniulvAspi_VhinUhtPJGNyZYkIkaEgqfIqo,3377
12
+ KonectySdkPython/lib/model.py,sha256=8ok1VzPGpXQklz2fJwjP8HT0aKOzhtE93BzcgfVw4zY,2846
13
+ KonectySdkPython/lib/serialization.py,sha256=HxA2t7uPv-4aqkGHMUF8WgP1RcTg6RXsFmr-nUhtx7E,401
14
+ KonectySdkPython/lib/settings.py,sha256=Xbv-KTVM-oxvj-hJQFv2-vbsv4R5aV4D3XWOSdpw6as,5245
15
+ KonectySdkPython/lib/types.py,sha256=Gh8BgoMFug2ixXGs99d3MMFl_JlfRCUdGBLjLAtF_aE,12766
16
+ KonectySdkPython/lib/feature_types/__init__.py,sha256=IooLjxKUkp-uuB8M295FCiKwwrvn7ijp180Q4Lv0Ees,1010
17
+ KonectySdkPython/lib/feature_types/cross_module_query.py,sha256=kG21qBMgCWd2gE1MGRYMvIAQb9ocB-epiKtNJH5t-eQ,2439
18
+ KonectySdkPython/lib/feature_types/kpi.py,sha256=67RpwwwnzU8piIPRyFb6Kn0hqSRpT9RFbYqiRnvYkFk,626
19
+ KonectySdkPython/lib/feature_types/query_json.py,sha256=yZgMPmkMdiBLm-dIrmU1AeZe5G9zQLwLtKUPMb7IOhU,8139
20
+ KonectySdkPython/lib/services/__init__.py,sha256=fluQuxs6LnIZwcjYTuKNeXCFTKuNF3At3X19fIB68p8,121
21
+ KonectySdkPython/lib/services/aggregation.py,sha256=igK1mleMFU2_rDQCAU1yKyvDoOjhTO1SO0Nn4T_DokA,5610
22
+ KonectySdkPython/lib/services/auth.py,sha256=JFiOvk0cqwRucvDQCN93jmKvSITxGtFYW1ME0gdEkMk,4226
23
+ KonectySdkPython/lib/services/base.py,sha256=tdVyWb7Y77cBhVc8Mz2BQMN6kAyZIohoxBxdwDnRsYs,1820
24
+ KonectySdkPython/lib/services/change_user.py,sha256=ce6mcDYMP6eWxW0bEtzlVf7wbppGHCkGwdgo2jJFJOQ,2548
25
+ KonectySdkPython/lib/services/comments.py,sha256=RNevCg4de2FWNk7mD60-pk3r8f2sJ1NLoolD2iNMidg,3033
26
+ KonectySdkPython/lib/services/export.py,sha256=WAtSOUYx4uK1ujGHmITP77B1_l69UykhxvUBXEOG_wE,2074
27
+ KonectySdkPython/lib/services/files.py,sha256=YvaN2yyh48pcPfv0t4PtZLxaDxQlQrGnzIAwnEYN5Ag,1843
28
+ KonectySdkPython/lib/services/notifications.py,sha256=7AtCBbBl-YAz_RBIW6bzoKvuwsYqAUVnLBnS4uAlMWQ,1446
29
+ KonectySdkPython/lib/services/query.py,sha256=vCqbf0QdV8Blh8Hfsvq6Ne1-YFuC5siw1gVa7ZBGs_k,6605
30
+ KonectySdkPython/lib/services/stream.py,sha256=1DMVxcg9Ymk2NgX0Qfvpjrr6vZJo5iFovPFT1NA3_CY,4737
31
+ KonectySdkPython/lib/services/subscriptions.py,sha256=_Jq8jW7YkL_hwLNte1bWgrr4D2EMZUUSOXUgnRoGGK4,1022
32
+ konecty_sdk_python-2.1.1.dist-info/METADATA,sha256=zK3rmKw6vnfQNOLXQWJSjqj5pKmGxOOfmlABHsMeDcs,5442
33
+ konecty_sdk_python-2.1.1.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
34
+ konecty_sdk_python-2.1.1.dist-info/entry_points.txt,sha256=awf962DamFgy791G3PsJ354edBMLJg16Dqi-2Y1tb9s,58
35
+ konecty_sdk_python-2.1.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ konecty-cli = KonectySdkPython.cli:main