jararaca 0.3.11a16__py3-none-any.whl → 0.3.12__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.
Potentially problematic release.
This version of jararaca might be problematic. Click here for more details.
- README.md +120 -0
- jararaca/__init__.py +106 -8
- jararaca/cli.py +216 -31
- jararaca/messagebus/worker.py +749 -272
- jararaca/microservice.py +42 -0
- jararaca/persistence/interceptors/aiosqa_interceptor.py +82 -73
- jararaca/persistence/interceptors/constants.py +1 -0
- jararaca/persistence/interceptors/decorators.py +45 -0
- jararaca/presentation/server.py +57 -11
- jararaca/presentation/websocket/redis.py +113 -7
- jararaca/reflect/metadata.py +1 -1
- jararaca/rpc/http/__init__.py +97 -0
- jararaca/rpc/http/backends/__init__.py +10 -0
- jararaca/rpc/http/backends/httpx.py +39 -9
- jararaca/rpc/http/decorators.py +302 -6
- jararaca/scheduler/beat_worker.py +550 -91
- jararaca/tools/typescript/__init__.py +0 -0
- jararaca/tools/typescript/decorators.py +95 -0
- jararaca/tools/typescript/interface_parser.py +699 -156
- jararaca-0.3.12.dist-info/LICENSE +674 -0
- {jararaca-0.3.11a16.dist-info → jararaca-0.3.12.dist-info}/METADATA +4 -3
- {jararaca-0.3.11a16.dist-info → jararaca-0.3.12.dist-info}/RECORD +26 -19
- {jararaca-0.3.11a16.dist-info → jararaca-0.3.12.dist-info}/WHEEL +1 -1
- pyproject.toml +86 -0
- /jararaca-0.3.11a16.dist-info/LICENSE → /LICENSE +0 -0
- {jararaca-0.3.11a16.dist-info → jararaca-0.3.12.dist-info}/entry_points.txt +0 -0
|
File without changes
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from typing import Any, Callable, TypeVar, cast
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
DECORATED_FUNC = TypeVar("DECORATED_FUNC", bound=Callable[..., Any])
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class QueryEndpoint:
|
|
9
|
+
"""
|
|
10
|
+
Decorator to mark a endpoint function as a query endpoint for Typescript generation.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
METADATA_KEY = "__jararaca_query_endpoint__"
|
|
14
|
+
|
|
15
|
+
def __init__(self, has_infinite_query: bool = False) -> None:
|
|
16
|
+
"""
|
|
17
|
+
Initialize the QueryEndpoint decorator.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
has_infinite_query: Whether the query endpoint supports infinite queries.
|
|
21
|
+
Important:
|
|
22
|
+
- Make sure a PaginatedQuery child instance is on the first argument
|
|
23
|
+
- Make sure the endpoint is a Patch (recommended) or Put method
|
|
24
|
+
- Make sure the endpoint returns a Paginated[T]
|
|
25
|
+
"""
|
|
26
|
+
self.has_infinite_query = has_infinite_query
|
|
27
|
+
|
|
28
|
+
def __call__(self, func: DECORATED_FUNC) -> DECORATED_FUNC:
|
|
29
|
+
"""
|
|
30
|
+
Decorate the function to mark it as a query endpoint.
|
|
31
|
+
"""
|
|
32
|
+
setattr(func, self.METADATA_KEY, self)
|
|
33
|
+
return func
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def extract_query_endpoint(func: Any) -> "QueryEndpoint":
|
|
37
|
+
"""
|
|
38
|
+
Check if the function is marked as a query endpoint.
|
|
39
|
+
"""
|
|
40
|
+
return cast(QueryEndpoint, getattr(func, QueryEndpoint.METADATA_KEY, None))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class MutationEndpoint:
|
|
44
|
+
"""
|
|
45
|
+
Decorator to mark a endpoint function as a mutation endpoint for Typescript generation.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
METADATA_KEY = "__jararaca_mutation_endpoint__"
|
|
49
|
+
|
|
50
|
+
def __init__(self) -> None: ...
|
|
51
|
+
|
|
52
|
+
def __call__(self, func: DECORATED_FUNC) -> DECORATED_FUNC:
|
|
53
|
+
"""
|
|
54
|
+
Decorate the function to mark it as a mutation endpoint.
|
|
55
|
+
"""
|
|
56
|
+
setattr(func, self.METADATA_KEY, True)
|
|
57
|
+
return func
|
|
58
|
+
|
|
59
|
+
@staticmethod
|
|
60
|
+
def is_mutation(func: Any) -> bool:
|
|
61
|
+
"""
|
|
62
|
+
Check if the function is marked as a mutation endpoint.
|
|
63
|
+
"""
|
|
64
|
+
return getattr(func, MutationEndpoint.METADATA_KEY, False)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
BASEMODEL_T = TypeVar("BASEMODEL_T", bound=BaseModel)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class SplitInputOutput:
|
|
71
|
+
"""
|
|
72
|
+
Decorator to mark a Pydantic model to generate separate Input and Output TypeScript interfaces.
|
|
73
|
+
|
|
74
|
+
Input interface: Used for API inputs (mutations/queries), handles optional fields with defaults
|
|
75
|
+
Output interface: Used for API outputs, represents the complete object structure
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
METADATA_KEY = "__jararaca_split_input_output__"
|
|
79
|
+
|
|
80
|
+
def __init__(self) -> None:
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
def __call__(self, cls: type[BASEMODEL_T]) -> type[BASEMODEL_T]:
|
|
84
|
+
"""
|
|
85
|
+
Decorate the Pydantic model class to mark it for split interface generation.
|
|
86
|
+
"""
|
|
87
|
+
setattr(cls, self.METADATA_KEY, True)
|
|
88
|
+
return cls
|
|
89
|
+
|
|
90
|
+
@staticmethod
|
|
91
|
+
def is_split_model(cls: type) -> bool:
|
|
92
|
+
"""
|
|
93
|
+
Check if the Pydantic model is marked for split interface generation.
|
|
94
|
+
"""
|
|
95
|
+
return getattr(cls, SplitInputOutput.METADATA_KEY, False)
|