belgie-proto 0.1.0a4__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.
@@ -0,0 +1,17 @@
1
+ """Shared protocol interfaces for Belgie packages."""
2
+
3
+ from belgie_proto.account import AccountProtocol
4
+ from belgie_proto.adapter import AdapterProtocol
5
+ from belgie_proto.connection import DBConnection
6
+ from belgie_proto.oauth_state import OAuthStateProtocol
7
+ from belgie_proto.session import SessionProtocol
8
+ from belgie_proto.user import UserProtocol
9
+
10
+ __all__ = [
11
+ "AccountProtocol",
12
+ "AdapterProtocol",
13
+ "DBConnection",
14
+ "OAuthStateProtocol",
15
+ "SessionProtocol",
16
+ "UserProtocol",
17
+ ]
@@ -0,0 +1,23 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Protocol, runtime_checkable
4
+
5
+ if TYPE_CHECKING:
6
+ from datetime import datetime
7
+ from uuid import UUID
8
+
9
+
10
+ @runtime_checkable
11
+ class AccountProtocol(Protocol):
12
+ id: UUID
13
+ user_id: UUID
14
+ provider: str
15
+ provider_account_id: str
16
+ access_token: str | None
17
+ refresh_token: str | None
18
+ expires_at: datetime | None
19
+ token_type: str | None
20
+ scope: str | None
21
+ id_token: str | None
22
+ created_at: datetime
23
+ updated_at: datetime
@@ -0,0 +1,121 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable
4
+
5
+ from belgie_proto.account import AccountProtocol
6
+ from belgie_proto.oauth_state import OAuthStateProtocol
7
+ from belgie_proto.session import SessionProtocol
8
+ from belgie_proto.user import UserProtocol
9
+
10
+ if TYPE_CHECKING:
11
+ from datetime import datetime
12
+ from uuid import UUID
13
+
14
+ from belgie_proto.connection import DBConnection
15
+
16
+
17
+ @runtime_checkable
18
+ class AdapterProtocol[
19
+ UserT: UserProtocol,
20
+ AccountT: AccountProtocol,
21
+ SessionT: SessionProtocol,
22
+ OAuthStateT: OAuthStateProtocol,
23
+ ](Protocol):
24
+ """Protocol for database adapters."""
25
+
26
+ async def create_user(
27
+ self,
28
+ session: DBConnection,
29
+ email: str,
30
+ name: str | None = None,
31
+ image: str | None = None,
32
+ *,
33
+ email_verified: bool = False,
34
+ ) -> UserT: ...
35
+
36
+ async def get_user_by_id(self, session: DBConnection, user_id: UUID) -> UserT | None: ...
37
+
38
+ async def get_user_by_email(self, session: DBConnection, email: str) -> UserT | None: ...
39
+
40
+ async def update_user(
41
+ self,
42
+ session: DBConnection,
43
+ user_id: UUID,
44
+ **updates: Any, # noqa: ANN401
45
+ ) -> UserT | None: ...
46
+
47
+ async def create_account(
48
+ self,
49
+ session: DBConnection,
50
+ user_id: UUID,
51
+ provider: str,
52
+ provider_account_id: str,
53
+ **tokens: Any, # noqa: ANN401
54
+ ) -> AccountT: ...
55
+
56
+ async def get_account(
57
+ self,
58
+ session: DBConnection,
59
+ provider: str,
60
+ provider_account_id: str,
61
+ ) -> AccountT | None: ...
62
+
63
+ async def get_account_by_user_and_provider(
64
+ self,
65
+ session: DBConnection,
66
+ user_id: UUID,
67
+ provider: str,
68
+ ) -> AccountT | None: ...
69
+
70
+ async def update_account(
71
+ self,
72
+ session: DBConnection,
73
+ user_id: UUID,
74
+ provider: str,
75
+ **tokens: Any, # noqa: ANN401
76
+ ) -> AccountT | None: ...
77
+
78
+ async def create_session(
79
+ self,
80
+ session: DBConnection,
81
+ user_id: UUID,
82
+ expires_at: datetime,
83
+ ip_address: str | None = None,
84
+ user_agent: str | None = None,
85
+ ) -> SessionT: ...
86
+
87
+ async def get_session(
88
+ self,
89
+ session: DBConnection,
90
+ session_id: UUID,
91
+ ) -> SessionT | None: ...
92
+
93
+ async def update_session(
94
+ self,
95
+ session: DBConnection,
96
+ session_id: UUID,
97
+ **updates: Any, # noqa: ANN401
98
+ ) -> SessionT | None: ...
99
+
100
+ async def delete_session(self, session: DBConnection, session_id: UUID) -> bool: ...
101
+
102
+ async def delete_expired_sessions(self, session: DBConnection) -> int: ...
103
+
104
+ async def create_oauth_state(
105
+ self,
106
+ session: DBConnection,
107
+ state: str,
108
+ expires_at: datetime,
109
+ code_verifier: str | None = None,
110
+ redirect_url: str | None = None,
111
+ ) -> OAuthStateT: ...
112
+
113
+ async def get_oauth_state(
114
+ self,
115
+ session: DBConnection,
116
+ state: str,
117
+ ) -> OAuthStateT | None: ...
118
+
119
+ async def delete_oauth_state(self, session: DBConnection, state: str) -> bool: ...
120
+
121
+ async def delete_user(self, session: DBConnection, user_id: UUID) -> bool: ...
@@ -0,0 +1,12 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Protocol, runtime_checkable
4
+
5
+
6
+ @runtime_checkable
7
+ class DBConnection(Protocol):
8
+ async def commit(self) -> None: ...
9
+
10
+ async def rollback(self) -> None: ...
11
+
12
+ async def close(self) -> None: ...
@@ -0,0 +1,17 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Protocol, runtime_checkable
4
+
5
+ if TYPE_CHECKING:
6
+ from datetime import datetime
7
+ from uuid import UUID
8
+
9
+
10
+ @runtime_checkable
11
+ class OAuthStateProtocol(Protocol):
12
+ id: UUID
13
+ state: str
14
+ code_verifier: str | None
15
+ redirect_url: str | None
16
+ created_at: datetime
17
+ expires_at: datetime
belgie_proto/py.typed ADDED
File without changes
@@ -0,0 +1,18 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Protocol, runtime_checkable
4
+
5
+ if TYPE_CHECKING:
6
+ from datetime import datetime
7
+ from uuid import UUID
8
+
9
+
10
+ @runtime_checkable
11
+ class SessionProtocol(Protocol):
12
+ id: UUID
13
+ user_id: UUID
14
+ expires_at: datetime
15
+ ip_address: str | None
16
+ user_agent: str | None
17
+ created_at: datetime
18
+ updated_at: datetime
belgie_proto/user.py ADDED
@@ -0,0 +1,20 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Protocol, runtime_checkable
4
+
5
+ if TYPE_CHECKING:
6
+ from datetime import datetime
7
+ from uuid import UUID
8
+
9
+
10
+ @runtime_checkable
11
+ class UserProtocol[S: str](Protocol):
12
+ # Generic over scope type S (must be str or subclass like StrEnum)
13
+ id: UUID
14
+ email: str
15
+ email_verified: bool
16
+ name: str | None
17
+ image: str | None
18
+ created_at: datetime
19
+ updated_at: datetime
20
+ scopes: list[S] | None # User's application-level scopes (None means no scopes)
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.3
2
+ Name: belgie-proto
3
+ Version: 0.1.0a4
4
+ Summary: Shared protocol interfaces for Belgie
5
+ Author: Matt LeMay
6
+ Author-email: Matt LeMay <mplemay@users.noreply.github.com>
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+
10
+ # belgie-proto
11
+
12
+ Shared protocol interfaces for Belgie packages. Import from `belgie_proto`.
@@ -0,0 +1,11 @@
1
+ belgie_proto/__init__.py,sha256=ABjW1baApcplegVDWN4g44my3wpTGCwObOP9H6wlbXo,500
2
+ belgie_proto/account.py,sha256=DImHp_ywOIQQtswxumZ35X9fmSf-XL_ihF9y_BR4Drs,524
3
+ belgie_proto/adapter.py,sha256=RTIAGJlCQCFnsV_Dh3L-yYB_3d6evbfHoz0VluOtMIY,3220
4
+ belgie_proto/connection.py,sha256=cHrErcD5vL5gfWOE4klzOeYvnsnLBJL7CSoSYKwtfi0,257
5
+ belgie_proto/oauth_state.py,sha256=vznJ24sScY5kDEd2pEwNy4vkQX17gStdFyZKGb5l6oU,371
6
+ belgie_proto/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ belgie_proto/session.py,sha256=oQ7XfzWUDgny2WpRrC4DjbiessVt83fERjQiCPCoJls,391
8
+ belgie_proto/user.py,sha256=8_mMbVKOJzwJotmgP1rosg3xBCuLa3IkScnkU2zZCIw,538
9
+ belgie_proto-0.1.0a4.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
10
+ belgie_proto-0.1.0a4.dist-info/METADATA,sha256=LpnmBZE_QUNDfQ3Y2tqqgZwGDhHmKPfzecMqquRO_Xc,341
11
+ belgie_proto-0.1.0a4.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.9.28
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any