jararaca 0.3.12a13__py3-none-any.whl → 0.3.12a15__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.

@@ -1,5 +1,7 @@
1
1
  from typing import Any, Callable, TypeVar, cast
2
2
 
3
+ from pydantic import BaseModel
4
+
3
5
  DECORATED_FUNC = TypeVar("DECORATED_FUNC", bound=Callable[..., Any])
4
6
 
5
7
 
@@ -60,3 +62,34 @@ class MutationEndpoint:
60
62
  Check if the function is marked as a mutation endpoint.
61
63
  """
62
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)