jararaca 0.3.12a6__py3-none-any.whl → 0.3.12a7__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.
- jararaca/tools/typescript/decorators.py +16 -5
- jararaca/tools/typescript/interface_parser.py +18 -5
- {jararaca-0.3.12a6.dist-info → jararaca-0.3.12a7.dist-info}/METADATA +1 -1
- {jararaca-0.3.12a6.dist-info → jararaca-0.3.12a7.dist-info}/RECORD +8 -8
- pyproject.toml +1 -1
- {jararaca-0.3.12a6.dist-info → jararaca-0.3.12a7.dist-info}/LICENSE +0 -0
- {jararaca-0.3.12a6.dist-info → jararaca-0.3.12a7.dist-info}/WHEEL +0 -0
- {jararaca-0.3.12a6.dist-info → jararaca-0.3.12a7.dist-info}/entry_points.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, Callable, TypeVar
|
|
1
|
+
from typing import Any, Callable, TypeVar, cast
|
|
2
2
|
|
|
3
3
|
DECORATED_FUNC = TypeVar("DECORATED_FUNC", bound=Callable[..., Any])
|
|
4
4
|
|
|
@@ -10,21 +10,32 @@ class QueryEndpoint:
|
|
|
10
10
|
|
|
11
11
|
METADATA_KEY = "__jararaca_query_endpoint__"
|
|
12
12
|
|
|
13
|
-
def __init__(self) -> None:
|
|
13
|
+
def __init__(self, has_infinite_query: bool = False) -> None:
|
|
14
|
+
"""
|
|
15
|
+
Initialize the QueryEndpoint decorator.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
has_infinite_query: Whether the query endpoint supports infinite queries.
|
|
19
|
+
Important:
|
|
20
|
+
- Make sure a PaginatedQuery child instance is on the first argument
|
|
21
|
+
- Make sure the endpoint is a Patch (recommended) or Put method
|
|
22
|
+
- Make sure the endpoint returns a Paginated[T]
|
|
23
|
+
"""
|
|
24
|
+
self.has_infinite_query = has_infinite_query
|
|
14
25
|
|
|
15
26
|
def __call__(self, func: DECORATED_FUNC) -> DECORATED_FUNC:
|
|
16
27
|
"""
|
|
17
28
|
Decorate the function to mark it as a query endpoint.
|
|
18
29
|
"""
|
|
19
|
-
setattr(func, self.METADATA_KEY,
|
|
30
|
+
setattr(func, self.METADATA_KEY, self)
|
|
20
31
|
return func
|
|
21
32
|
|
|
22
33
|
@staticmethod
|
|
23
|
-
def
|
|
34
|
+
def extract_query_endpoint(func: Any) -> "QueryEndpoint":
|
|
24
35
|
"""
|
|
25
36
|
Check if the function is marked as a query endpoint.
|
|
26
37
|
"""
|
|
27
|
-
return getattr(func, QueryEndpoint.METADATA_KEY,
|
|
38
|
+
return cast(QueryEndpoint, getattr(func, QueryEndpoint.METADATA_KEY, None))
|
|
28
39
|
|
|
29
40
|
|
|
30
41
|
class MutationEndpoint:
|
|
@@ -389,7 +389,7 @@ def write_microservice_to_typescript_interface(
|
|
|
389
389
|
|
|
390
390
|
final_buffer.write(
|
|
391
391
|
"""
|
|
392
|
-
import { createClassQueryHooks , createClassMutationHooks, createClassInfiniteQueryHooks } from "@jararaca/core";
|
|
392
|
+
import { createClassQueryHooks , createClassMutationHooks, createClassInfiniteQueryHooks, paginationModelByFirstArgPaginationFilter } from "@jararaca/core";
|
|
393
393
|
export type WebSocketMessageMap = {
|
|
394
394
|
%s
|
|
395
395
|
}
|
|
@@ -512,7 +512,7 @@ def write_rest_controller_to_typescript_interface(
|
|
|
512
512
|
|
|
513
513
|
class_name = controller.__name__
|
|
514
514
|
|
|
515
|
-
decorated_queries: list[tuple[str, FunctionType]] = []
|
|
515
|
+
decorated_queries: list[tuple[str, FunctionType, QueryEndpoint]] = []
|
|
516
516
|
decorated_mutations: list[tuple[str, FunctionType]] = []
|
|
517
517
|
|
|
518
518
|
class_buffer = StringIO()
|
|
@@ -533,8 +533,8 @@ def write_rest_controller_to_typescript_interface(
|
|
|
533
533
|
if return_type is None:
|
|
534
534
|
return_type = NoneType
|
|
535
535
|
|
|
536
|
-
if QueryEndpoint.
|
|
537
|
-
decorated_queries.append((name, member))
|
|
536
|
+
if query_endpoint := QueryEndpoint.extract_query_endpoint(member):
|
|
537
|
+
decorated_queries.append((name, member, query_endpoint))
|
|
538
538
|
if MutationEndpoint.is_mutation(member):
|
|
539
539
|
decorated_mutations.append((name, member))
|
|
540
540
|
|
|
@@ -624,9 +624,22 @@ def write_rest_controller_to_typescript_interface(
|
|
|
624
624
|
controller_hooks_builder.write(
|
|
625
625
|
f"\t...createClassQueryHooks({class_name},\n"
|
|
626
626
|
)
|
|
627
|
-
for name, member in decorated_queries:
|
|
627
|
+
for name, member, _ in decorated_queries:
|
|
628
628
|
controller_hooks_builder.write(f'\t\t"{snake_to_camel(name)}",\n')
|
|
629
629
|
controller_hooks_builder.write("\t),\n")
|
|
630
|
+
|
|
631
|
+
if decorated_queries and any(
|
|
632
|
+
query.has_infinite_query for _, _, query in decorated_queries
|
|
633
|
+
):
|
|
634
|
+
controller_hooks_builder.write(
|
|
635
|
+
f"\t...createClassInfiniteQueryHooks({class_name}, {{\n"
|
|
636
|
+
)
|
|
637
|
+
for name, member, query in decorated_queries:
|
|
638
|
+
if query.has_infinite_query:
|
|
639
|
+
controller_hooks_builder.write(
|
|
640
|
+
f'\t\t"{snake_to_camel(name)}": paginationModelByFirstArgPaginationFilter(),\n'
|
|
641
|
+
)
|
|
642
|
+
controller_hooks_builder.write("\t}),\n")
|
|
630
643
|
if decorated_mutations:
|
|
631
644
|
controller_hooks_builder.write(
|
|
632
645
|
f"\t...createClassMutationHooks({class_name},\n"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
2
2
|
README.md,sha256=2qMM__t_MoLKZr4IY9tXjo-Jn6LKjuHMb1qbyXpgL08,3401
|
|
3
|
-
pyproject.toml,sha256=
|
|
3
|
+
pyproject.toml,sha256=rfAelC2k9MV3eq2dge_J4UxWLHNXNRSyQy8_1W-YXos,2040
|
|
4
4
|
jararaca/__init__.py,sha256=jN3paW2ujI97485DNZTcRe_8ORwO-OQbJUG5mmSI9LI,21226
|
|
5
5
|
jararaca/__main__.py,sha256=-O3vsB5lHdqNFjUtoELDF81IYFtR-DSiiFMzRaiSsv4,67
|
|
6
6
|
jararaca/broker_backend/__init__.py,sha256=GzEIuHR1xzgCJD4FE3harNjoaYzxHMHoEL0_clUaC-k,3528
|
|
@@ -67,13 +67,13 @@ jararaca/tools/app_config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
|
67
67
|
jararaca/tools/app_config/decorators.py,sha256=-ckkMZ1dswOmECdo1rFrZ15UAku--txaNXMp8fd1Ndk,941
|
|
68
68
|
jararaca/tools/app_config/interceptor.py,sha256=HV8h4AxqUc_ACs5do4BSVlyxlRXzx7HqJtoVO9tfRnQ,2611
|
|
69
69
|
jararaca/tools/typescript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
70
|
-
jararaca/tools/typescript/decorators.py,sha256=
|
|
71
|
-
jararaca/tools/typescript/interface_parser.py,sha256=
|
|
70
|
+
jararaca/tools/typescript/decorators.py,sha256=DbwZADDzzo3cbMfNcY6ldILy_80N4x25ChyQoX1q56s,1956
|
|
71
|
+
jararaca/tools/typescript/interface_parser.py,sha256=jgkIDtM5ifGGLSSSqR2D41CC9Xrz4kvKKcN5321JAVo,34161
|
|
72
72
|
jararaca/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
73
73
|
jararaca/utils/rabbitmq_utils.py,sha256=ytdAFUyv-OBkaVnxezuJaJoLrmN7giZgtKeet_IsMBs,10918
|
|
74
74
|
jararaca/utils/retry.py,sha256=DzPX_fXUvTqej6BQ8Mt2dvLo9nNlTBm7Kx2pFZ26P2Q,4668
|
|
75
|
-
jararaca-0.3.
|
|
76
|
-
jararaca-0.3.
|
|
77
|
-
jararaca-0.3.
|
|
78
|
-
jararaca-0.3.
|
|
79
|
-
jararaca-0.3.
|
|
75
|
+
jararaca-0.3.12a7.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
76
|
+
jararaca-0.3.12a7.dist-info/METADATA,sha256=By0PdO0rXhXnTyH6feXx33JyvjpnzBqh9HqOFe3Ab70,4995
|
|
77
|
+
jararaca-0.3.12a7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
78
|
+
jararaca-0.3.12a7.dist-info/entry_points.txt,sha256=WIh3aIvz8LwUJZIDfs4EeH3VoFyCGEk7cWJurW38q0I,45
|
|
79
|
+
jararaca-0.3.12a7.dist-info/RECORD,,
|
pyproject.toml
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|