alpha-python 0.1.0__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.
- alpha/__init__.py +0 -0
- alpha/adapters/__init__.py +0 -0
- alpha/adapters/sqla_unit_of_work.py +120 -0
- alpha/domain/__init__.py +0 -0
- alpha/domain/models/__init__.py +0 -0
- alpha/domain/models/base_model.py +25 -0
- alpha/encoder.py +62 -0
- alpha/exceptions.py +99 -0
- alpha/factories/__init__.py +0 -0
- alpha/factories/_type_conversion_matrix.py +233 -0
- alpha/factories/_type_mapping.py +29 -0
- alpha/factories/class_factories.py +496 -0
- alpha/factories/default_field_factory.py +50 -0
- alpha/factories/field_iterator.py +188 -0
- alpha/factories/logging_handler_factory.py +86 -0
- alpha/factories/model_class_factory.py +176 -0
- alpha/factories/models/__init__.py +0 -0
- alpha/factories/models/factory_classes.py +20 -0
- alpha/factories/request_factory.py +211 -0
- alpha/factories/response_factory.py +186 -0
- alpha/factories/type_factories.py +204 -0
- alpha/infra/__init__.py +0 -0
- alpha/infra/database/__init__.py +0 -0
- alpha/infra/database/sql_alchemy_database.py +159 -0
- alpha/infra/database/sql_alchemy_view.py +48 -0
- alpha/infra/models/__init__.py +0 -0
- alpha/infra/models/filter_operators.py +98 -0
- alpha/infra/models/json_patch.py +21 -0
- alpha/infra/models/order_by.py +69 -0
- alpha/infra/models/query_clause.py +45 -0
- alpha/infra/models/search_filter.py +586 -0
- alpha/interfaces/__init__.py +0 -0
- alpha/interfaces/attrs_instance.py +10 -0
- alpha/interfaces/dataclass_instance.py +11 -0
- alpha/interfaces/factories.py +102 -0
- alpha/interfaces/openapi_model.py +21 -0
- alpha/interfaces/patchable.py +8 -0
- alpha/interfaces/sql_database.py +36 -0
- alpha/interfaces/sql_mapper.py +23 -0
- alpha/interfaces/sql_repository.py +380 -0
- alpha/interfaces/token_factory.py +56 -0
- alpha/interfaces/unit_of_work.py +53 -0
- alpha/interfaces/updateable.py +7 -0
- alpha/py.typed +0 -0
- alpha/repositories/__init__.py +0 -0
- alpha/repositories/default_sql_repository.py +679 -0
- alpha/repositories/models/__init__.py +0 -0
- alpha/repositories/models/repository_model.py +16 -0
- alpha/services/__init__.py +0 -0
- alpha/services/authentication_service.py +71 -0
- alpha/utils/__init__.py +0 -0
- alpha/utils/_http_codes.py +148 -0
- alpha/utils/is_attrs.py +18 -0
- alpha/utils/logging_configurator.py +133 -0
- alpha/utils/logging_level_checker.py +26 -0
- alpha/utils/response_object.py +26 -0
- alpha/utils/version_check.py +17 -0
- alpha_python-0.1.0.dist-info/METADATA +22 -0
- alpha_python-0.1.0.dist-info/RECORD +62 -0
- alpha_python-0.1.0.dist-info/WHEEL +5 -0
- alpha_python-0.1.0.dist-info/licenses/LICENSE +21 -0
- alpha_python-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from typing import Any, ClassVar, Protocol, runtime_checkable
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@runtime_checkable
|
|
5
|
+
class OpenAPIModel(Protocol):
|
|
6
|
+
"""OpenAPIModel interface"""
|
|
7
|
+
|
|
8
|
+
openapi_types: ClassVar[dict[str, type]]
|
|
9
|
+
attribute_map: ClassVar[dict[str, str]]
|
|
10
|
+
|
|
11
|
+
def __init__(self) -> None: ...
|
|
12
|
+
|
|
13
|
+
def to_dict(self) -> dict[str, Any]: ...
|
|
14
|
+
|
|
15
|
+
def to_str(self): ...
|
|
16
|
+
|
|
17
|
+
def __repr__(self): ...
|
|
18
|
+
|
|
19
|
+
def __eq__(self, other): ...
|
|
20
|
+
|
|
21
|
+
def __ne__(self, other): ...
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from typing import Protocol
|
|
2
|
+
|
|
3
|
+
from alpha.domain.models.base_model import DomainModelCovariant
|
|
4
|
+
from alpha.infra.models.json_patch import JsonPatch
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Patchable(Protocol[DomainModelCovariant]):
|
|
8
|
+
def patch(self, patches: JsonPatch) -> DomainModelCovariant: ...
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from typing import Protocol, runtime_checkable, ClassVar
|
|
2
|
+
|
|
3
|
+
import sqlalchemy as sa
|
|
4
|
+
from sqlalchemy.engine import Engine
|
|
5
|
+
from sqlalchemy.orm.session import Session
|
|
6
|
+
|
|
7
|
+
from alpha.interfaces.sql_mapper import SqlMapper
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@runtime_checkable
|
|
11
|
+
class SqlDatabase(Protocol):
|
|
12
|
+
_host: ClassVar[str]
|
|
13
|
+
_port: ClassVar[int]
|
|
14
|
+
_username: ClassVar[str]
|
|
15
|
+
_password: ClassVar[str]
|
|
16
|
+
_db_name: ClassVar[str]
|
|
17
|
+
_db_type: ClassVar[str]
|
|
18
|
+
_schema_name: ClassVar[str]
|
|
19
|
+
_mapper: ClassVar[SqlMapper | None]
|
|
20
|
+
_connection_string: ClassVar[str]
|
|
21
|
+
_engine: ClassVar[Engine]
|
|
22
|
+
_session_factory: ClassVar[Session]
|
|
23
|
+
|
|
24
|
+
def get_session(self) -> Session: ...
|
|
25
|
+
|
|
26
|
+
def engine(self) -> Engine: ...
|
|
27
|
+
|
|
28
|
+
def create_tables(
|
|
29
|
+
self, metadata: sa.MetaData, tables: list[sa.Table] | None = None
|
|
30
|
+
) -> None: ...
|
|
31
|
+
|
|
32
|
+
def drop_tables(
|
|
33
|
+
self, metadata: sa.MetaData, tables: list[sa.Table] | None = None
|
|
34
|
+
) -> None: ...
|
|
35
|
+
|
|
36
|
+
def _create_schema(self, engine: Engine, schema_name: str) -> None: ...
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""_summary_
|
|
2
|
+
"""
|
|
3
|
+
from typing import Any, ClassVar, Protocol, runtime_checkable
|
|
4
|
+
|
|
5
|
+
import sqlalchemy as sa
|
|
6
|
+
from sqlalchemy.orm import registry
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@runtime_checkable
|
|
10
|
+
class SqlMapper(Protocol):
|
|
11
|
+
"""_summary_"""
|
|
12
|
+
|
|
13
|
+
convention: ClassVar[dict[str, Any]]
|
|
14
|
+
started: ClassVar[bool]
|
|
15
|
+
schema_name: ClassVar[str]
|
|
16
|
+
|
|
17
|
+
metadata: ClassVar[sa.MetaData]
|
|
18
|
+
|
|
19
|
+
mapper_registry: ClassVar[registry]
|
|
20
|
+
|
|
21
|
+
@classmethod
|
|
22
|
+
def start_mapping(cls) -> None:
|
|
23
|
+
"""_summary_"""
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"""_summary_"""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any, Literal, Protocol, overload, runtime_checkable
|
|
5
|
+
from uuid import UUID
|
|
6
|
+
|
|
7
|
+
from sqlalchemy.orm import (
|
|
8
|
+
Query,
|
|
9
|
+
Session,
|
|
10
|
+
)
|
|
11
|
+
from sqlalchemy.orm.attributes import InstrumentedAttribute
|
|
12
|
+
|
|
13
|
+
from alpha.domain.models.base_model import BaseDomainModel, DomainModel
|
|
14
|
+
from alpha.infra.models.search_filter import SearchFilter
|
|
15
|
+
from alpha.infra.models.query_clause import QueryClause
|
|
16
|
+
from alpha.interfaces.patchable import Patchable
|
|
17
|
+
from alpha.interfaces.updateable import Updateable
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@runtime_checkable
|
|
21
|
+
class SqlRepository(Protocol[DomainModel]):
|
|
22
|
+
"""_summary_
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
Protocol : _type_
|
|
27
|
+
_description_
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
session: Session
|
|
31
|
+
_default_model: DomainModel
|
|
32
|
+
|
|
33
|
+
def __init__(self, session: Session, default_model: DomainModel) -> None:
|
|
34
|
+
"""_summary_
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
session : Session
|
|
39
|
+
_description_
|
|
40
|
+
default_model : DomainModel
|
|
41
|
+
_description_
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
@overload
|
|
45
|
+
def add(
|
|
46
|
+
self,
|
|
47
|
+
obj: DomainModel,
|
|
48
|
+
return_obj: Literal[True] = True,
|
|
49
|
+
raise_if_exists: bool = False,
|
|
50
|
+
) -> DomainModel: ...
|
|
51
|
+
|
|
52
|
+
@overload
|
|
53
|
+
def add(
|
|
54
|
+
self,
|
|
55
|
+
obj: DomainModel,
|
|
56
|
+
return_obj: Literal[False],
|
|
57
|
+
raise_if_exists: bool = False,
|
|
58
|
+
) -> None: ...
|
|
59
|
+
|
|
60
|
+
def add(
|
|
61
|
+
self,
|
|
62
|
+
obj: DomainModel,
|
|
63
|
+
return_obj: bool = True,
|
|
64
|
+
raise_if_exists: bool = False,
|
|
65
|
+
) -> DomainModel | None:
|
|
66
|
+
"""_summary_
|
|
67
|
+
|
|
68
|
+
Parameters
|
|
69
|
+
----------
|
|
70
|
+
obj : DomainModel
|
|
71
|
+
_description_
|
|
72
|
+
raise_if_exists : bool, optional
|
|
73
|
+
_description_, by default False
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
def add_all(
|
|
77
|
+
self,
|
|
78
|
+
objs: list[DomainModel],
|
|
79
|
+
return_obj: bool = False,
|
|
80
|
+
raise_if_exists: bool = False,
|
|
81
|
+
) -> list[DomainModel] | None:
|
|
82
|
+
"""_summary_
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
objs : list[DomainModel]
|
|
87
|
+
_description_
|
|
88
|
+
raise_if_exists : bool, optional
|
|
89
|
+
_description_, by default False
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
def count(
|
|
93
|
+
self,
|
|
94
|
+
model: DomainModel | None = None,
|
|
95
|
+
**kwargs: Any,
|
|
96
|
+
) -> int:
|
|
97
|
+
"""_summary_
|
|
98
|
+
|
|
99
|
+
Parameters
|
|
100
|
+
----------
|
|
101
|
+
model : DomainModel | None, optional
|
|
102
|
+
_description_, by default None
|
|
103
|
+
|
|
104
|
+
Returns
|
|
105
|
+
-------
|
|
106
|
+
int
|
|
107
|
+
_description_
|
|
108
|
+
"""
|
|
109
|
+
...
|
|
110
|
+
|
|
111
|
+
def get(
|
|
112
|
+
self,
|
|
113
|
+
attr: str | InstrumentedAttribute[Any],
|
|
114
|
+
value: str | int | float | Enum | UUID | BaseDomainModel,
|
|
115
|
+
cursor_result: str = "first",
|
|
116
|
+
model: DomainModel | None = None,
|
|
117
|
+
**kwargs: Any,
|
|
118
|
+
) -> DomainModel:
|
|
119
|
+
"""_summary_
|
|
120
|
+
|
|
121
|
+
Parameters
|
|
122
|
+
----------
|
|
123
|
+
attr : str | InstrumentedAttribute
|
|
124
|
+
_description_
|
|
125
|
+
value : str | int | float | Enum | UUID
|
|
126
|
+
_description_
|
|
127
|
+
cursor_result : str, optional
|
|
128
|
+
_description_, by default "first"
|
|
129
|
+
model : DomainModel | None, optional
|
|
130
|
+
_description_, by default None
|
|
131
|
+
|
|
132
|
+
Returns
|
|
133
|
+
-------
|
|
134
|
+
DomainModel
|
|
135
|
+
_description_
|
|
136
|
+
"""
|
|
137
|
+
...
|
|
138
|
+
|
|
139
|
+
def get_all(
|
|
140
|
+
self,
|
|
141
|
+
attr: str | InstrumentedAttribute[Any],
|
|
142
|
+
value: str | int | float | Enum | UUID | BaseDomainModel,
|
|
143
|
+
cursor_result: str = "all",
|
|
144
|
+
model: DomainModel | None = None,
|
|
145
|
+
**kwargs: Any,
|
|
146
|
+
) -> list[DomainModel]:
|
|
147
|
+
"""_summary_
|
|
148
|
+
|
|
149
|
+
Parameters
|
|
150
|
+
----------
|
|
151
|
+
attr : str | InstrumentedAttribute
|
|
152
|
+
_description_
|
|
153
|
+
value : str | int | float | Enum | UUID
|
|
154
|
+
_description_
|
|
155
|
+
cursor_result : str, optional
|
|
156
|
+
_description_, by default "all"
|
|
157
|
+
model : DomainModel | None, optional
|
|
158
|
+
_description_, by default None
|
|
159
|
+
|
|
160
|
+
Returns
|
|
161
|
+
-------
|
|
162
|
+
list[DomainModel]
|
|
163
|
+
_description_
|
|
164
|
+
"""
|
|
165
|
+
...
|
|
166
|
+
|
|
167
|
+
def get_one(
|
|
168
|
+
self,
|
|
169
|
+
attr: str | InstrumentedAttribute[Any],
|
|
170
|
+
value: str | int | float | Enum | UUID,
|
|
171
|
+
cursor_result: str = "one",
|
|
172
|
+
model: DomainModel | None = None,
|
|
173
|
+
**kwargs: Any,
|
|
174
|
+
) -> DomainModel:
|
|
175
|
+
"""_summary_
|
|
176
|
+
|
|
177
|
+
Parameters
|
|
178
|
+
----------
|
|
179
|
+
attr : str | InstrumentedAttribute
|
|
180
|
+
_description_
|
|
181
|
+
value : str | int | float | Enum | UUID
|
|
182
|
+
_description_
|
|
183
|
+
cursor_result : str, optional
|
|
184
|
+
_description_, by default "one"
|
|
185
|
+
model : DomainModel | None, optional
|
|
186
|
+
_description_, by default None
|
|
187
|
+
|
|
188
|
+
Returns
|
|
189
|
+
-------
|
|
190
|
+
DomainModel
|
|
191
|
+
_description_
|
|
192
|
+
"""
|
|
193
|
+
...
|
|
194
|
+
|
|
195
|
+
def get_one_or_none(
|
|
196
|
+
self,
|
|
197
|
+
attr: str | InstrumentedAttribute[Any],
|
|
198
|
+
value: str | int | float | Enum | UUID,
|
|
199
|
+
cursor_result: str = "one_or_none",
|
|
200
|
+
model: DomainModel | None = None,
|
|
201
|
+
**kwargs: Any,
|
|
202
|
+
) -> DomainModel | None:
|
|
203
|
+
"""_summary_
|
|
204
|
+
|
|
205
|
+
Parameters
|
|
206
|
+
----------
|
|
207
|
+
attr : str | InstrumentedAttribute
|
|
208
|
+
_description_
|
|
209
|
+
value : str | int | float | Enum | UUID
|
|
210
|
+
_description_
|
|
211
|
+
cursor_result : str, optional
|
|
212
|
+
_description_, by default "one_or_none"
|
|
213
|
+
model : DomainModel | None, optional
|
|
214
|
+
_description_, by default None
|
|
215
|
+
|
|
216
|
+
Returns
|
|
217
|
+
-------
|
|
218
|
+
DomainModel | None
|
|
219
|
+
_description_
|
|
220
|
+
"""
|
|
221
|
+
...
|
|
222
|
+
|
|
223
|
+
def get_by_id(
|
|
224
|
+
self,
|
|
225
|
+
value: str | int | UUID,
|
|
226
|
+
attr: str | InstrumentedAttribute[Any] = "id",
|
|
227
|
+
cursor_result: str = "one_or_none",
|
|
228
|
+
model: DomainModel | None = None,
|
|
229
|
+
**kwargs: Any,
|
|
230
|
+
) -> DomainModel | None:
|
|
231
|
+
"""_summary_
|
|
232
|
+
|
|
233
|
+
Parameters
|
|
234
|
+
----------
|
|
235
|
+
value : str | int | UUID
|
|
236
|
+
_description_
|
|
237
|
+
attr : str | InstrumentedAttribute, optional
|
|
238
|
+
_description_, by default "id"
|
|
239
|
+
cursor_result : str, optional
|
|
240
|
+
_description_, by default "one_or_none"
|
|
241
|
+
model : DomainModel | None, optional
|
|
242
|
+
_description_, by default None
|
|
243
|
+
|
|
244
|
+
Returns
|
|
245
|
+
-------
|
|
246
|
+
DomainModel | None
|
|
247
|
+
_description_
|
|
248
|
+
"""
|
|
249
|
+
...
|
|
250
|
+
|
|
251
|
+
def patch(self, obj: Patchable, patches: dict[str, Any]) -> DomainModel:
|
|
252
|
+
"""_summary_
|
|
253
|
+
|
|
254
|
+
Parameters
|
|
255
|
+
----------
|
|
256
|
+
obj : Patchable
|
|
257
|
+
_description_
|
|
258
|
+
patches : dict[str, Any]
|
|
259
|
+
_description_
|
|
260
|
+
|
|
261
|
+
Returns
|
|
262
|
+
-------
|
|
263
|
+
DomainModel
|
|
264
|
+
_description_
|
|
265
|
+
"""
|
|
266
|
+
|
|
267
|
+
def remove(self, obj: DomainModel) -> None:
|
|
268
|
+
"""_summary_
|
|
269
|
+
|
|
270
|
+
Parameters
|
|
271
|
+
----------
|
|
272
|
+
obj : DomainModel
|
|
273
|
+
_description_
|
|
274
|
+
"""
|
|
275
|
+
|
|
276
|
+
def remove_all(
|
|
277
|
+
self,
|
|
278
|
+
objs: list[DomainModel] | None,
|
|
279
|
+
**kwargs: Any,
|
|
280
|
+
) -> None:
|
|
281
|
+
"""_summary_
|
|
282
|
+
|
|
283
|
+
Parameters
|
|
284
|
+
----------
|
|
285
|
+
objs : list[DomainModel] | None
|
|
286
|
+
_description_
|
|
287
|
+
"""
|
|
288
|
+
|
|
289
|
+
def select(
|
|
290
|
+
self,
|
|
291
|
+
model: DomainModel | None = None,
|
|
292
|
+
cursor_result: str = "all",
|
|
293
|
+
**kwargs: Any,
|
|
294
|
+
) -> list[DomainModel]:
|
|
295
|
+
"""_summary_
|
|
296
|
+
|
|
297
|
+
Parameters
|
|
298
|
+
----------
|
|
299
|
+
model : DomainModel | None, optional
|
|
300
|
+
_description_, by default None
|
|
301
|
+
cursor_result : str, optional
|
|
302
|
+
_description_, by default "all"
|
|
303
|
+
|
|
304
|
+
Returns
|
|
305
|
+
-------
|
|
306
|
+
list[DomainModel]
|
|
307
|
+
_description_
|
|
308
|
+
"""
|
|
309
|
+
...
|
|
310
|
+
|
|
311
|
+
def update(self, obj: Updateable, other: DomainModel) -> DomainModel:
|
|
312
|
+
"""_summary_
|
|
313
|
+
|
|
314
|
+
Parameters
|
|
315
|
+
----------
|
|
316
|
+
obj : DomainModel
|
|
317
|
+
_description_
|
|
318
|
+
other : DomainModel
|
|
319
|
+
_description_
|
|
320
|
+
|
|
321
|
+
Returns
|
|
322
|
+
-------
|
|
323
|
+
DomainModel
|
|
324
|
+
_description_
|
|
325
|
+
"""
|
|
326
|
+
...
|
|
327
|
+
|
|
328
|
+
def view(
|
|
329
|
+
self,
|
|
330
|
+
model: DomainModel,
|
|
331
|
+
cursor_result: str = "all",
|
|
332
|
+
**kwargs: Any,
|
|
333
|
+
) -> list[DomainModel]:
|
|
334
|
+
"""_summary_
|
|
335
|
+
|
|
336
|
+
Parameters
|
|
337
|
+
----------
|
|
338
|
+
model : DomainModel
|
|
339
|
+
_description_
|
|
340
|
+
cursor_result : str, optional
|
|
341
|
+
_description_, by default "all"
|
|
342
|
+
|
|
343
|
+
Returns
|
|
344
|
+
-------
|
|
345
|
+
list[DomainModel]
|
|
346
|
+
_description_
|
|
347
|
+
"""
|
|
348
|
+
...
|
|
349
|
+
|
|
350
|
+
def _query(
|
|
351
|
+
self,
|
|
352
|
+
cursor_result: str | None = None,
|
|
353
|
+
model: DomainModel | None = None,
|
|
354
|
+
filters: list[SearchFilter] = [],
|
|
355
|
+
**kwargs: Any,
|
|
356
|
+
) -> Any:
|
|
357
|
+
"""_summary_
|
|
358
|
+
|
|
359
|
+
Parameters
|
|
360
|
+
----------
|
|
361
|
+
cursor_result : str | None, optional
|
|
362
|
+
_description_, by default None
|
|
363
|
+
model : DomainModel | None, optional
|
|
364
|
+
_description_, by default None
|
|
365
|
+
filters : list[SearchFilter], optional
|
|
366
|
+
_description_, by default []
|
|
367
|
+
|
|
368
|
+
Returns
|
|
369
|
+
-------
|
|
370
|
+
Any
|
|
371
|
+
_description_
|
|
372
|
+
"""
|
|
373
|
+
...
|
|
374
|
+
|
|
375
|
+
def _query_clause(
|
|
376
|
+
self,
|
|
377
|
+
clause: QueryClause,
|
|
378
|
+
query: Query[Any],
|
|
379
|
+
model: DomainModel,
|
|
380
|
+
) -> Query[Any]: ...
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from typing import Protocol
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class TokenFactory(Protocol):
|
|
5
|
+
"""Token Factory interface for creating and validating authentication
|
|
6
|
+
tokens.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
def create(self, user_id: str, payload: dict[str, str]) -> str:
|
|
10
|
+
"""Create an authentication token for a user.
|
|
11
|
+
|
|
12
|
+
Parameters
|
|
13
|
+
----------
|
|
14
|
+
user_id
|
|
15
|
+
The unique identifier for the user.
|
|
16
|
+
payload
|
|
17
|
+
A dictionary containing payload data, such as an object containing
|
|
18
|
+
user information.
|
|
19
|
+
|
|
20
|
+
Returns
|
|
21
|
+
-------
|
|
22
|
+
str
|
|
23
|
+
The generated authentication token as a string.
|
|
24
|
+
"""
|
|
25
|
+
...
|
|
26
|
+
|
|
27
|
+
def validate(self, token: str) -> bool:
|
|
28
|
+
"""Validate an authentication token.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
token
|
|
33
|
+
The authentication token to be validated.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
bool
|
|
38
|
+
True if the token is valid, False otherwise.
|
|
39
|
+
"""
|
|
40
|
+
...
|
|
41
|
+
|
|
42
|
+
def get_payload(self, token: str) -> dict[str, str]:
|
|
43
|
+
"""Retrieve the payload from an authentication token.
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
token
|
|
48
|
+
The authentication token from which to extract the payload.
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
dict[str, str]
|
|
53
|
+
A dictionary containing the payload data extracted from the
|
|
54
|
+
token.
|
|
55
|
+
"""
|
|
56
|
+
...
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""_summary_
|
|
2
|
+
"""
|
|
3
|
+
|
|
4
|
+
from typing import (
|
|
5
|
+
Any,
|
|
6
|
+
Protocol,
|
|
7
|
+
TypeVar,
|
|
8
|
+
runtime_checkable,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
from sqlalchemy.orm.session import Session
|
|
12
|
+
|
|
13
|
+
UOW = TypeVar("UOW", bound="UnitOfWork")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@runtime_checkable
|
|
17
|
+
class UnitOfWork(Protocol):
|
|
18
|
+
"""_summary_
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
Protocol : _type_
|
|
23
|
+
_description_
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __enter__(self: UOW) -> UOW:
|
|
27
|
+
"""_summary_"""
|
|
28
|
+
...
|
|
29
|
+
|
|
30
|
+
def __exit__(self, *args: Any) -> None:
|
|
31
|
+
"""_summary_"""
|
|
32
|
+
|
|
33
|
+
def commit(self) -> None:
|
|
34
|
+
"""_summary_"""
|
|
35
|
+
|
|
36
|
+
def flush(self) -> None:
|
|
37
|
+
"""_summary_"""
|
|
38
|
+
|
|
39
|
+
def rollback(self) -> None:
|
|
40
|
+
"""_summary_"""
|
|
41
|
+
|
|
42
|
+
def refresh(self, obj: object) -> None:
|
|
43
|
+
"""_summary_"""
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def session(self) -> Session:
|
|
47
|
+
"""_summary_
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
Session
|
|
52
|
+
_description_
|
|
53
|
+
"""
|
alpha/py.typed
ADDED
|
File without changes
|
|
File without changes
|