jararaca 0.2.37a9__py3-none-any.whl → 0.2.37a10__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,5 @@
1
1
  import inspect
2
- from typing import Any, Callable, Protocol, TypeVar, cast
2
+ from typing import Any, Callable, Literal, Protocol, TypeVar, cast
3
3
 
4
4
  from fastapi import APIRouter
5
5
  from fastapi import Depends as DependsF
@@ -147,6 +147,16 @@ class RestController:
147
147
 
148
148
  Options = dict[str, Any]
149
149
 
150
+ ResponseType = Literal[
151
+ "arraybuffer",
152
+ "blob",
153
+ "document",
154
+ "json",
155
+ "text",
156
+ "stream",
157
+ "formdata",
158
+ ]
159
+
150
160
 
151
161
  class HttpMapping:
152
162
 
@@ -154,11 +164,16 @@ class HttpMapping:
154
164
  ORDER_COUNTER = 0
155
165
 
156
166
  def __init__(
157
- self, method: str, path: str = "/", options: Options | None = None
167
+ self,
168
+ method: str,
169
+ path: str = "/",
170
+ adapter_options: Options | None = None,
171
+ response_type: ResponseType | None = None,
158
172
  ) -> None:
159
173
  self.method = method
160
174
  self.path = path
161
- self.options = options
175
+ self.options = adapter_options
176
+ self.response_type = response_type
162
177
 
163
178
  HttpMapping.ORDER_COUNTER += 1
164
179
  self.order = HttpMapping.ORDER_COUNTER
@@ -185,32 +200,57 @@ class HttpMapping:
185
200
 
186
201
  class Post(HttpMapping):
187
202
 
188
- def __init__(self, path: str = "/", options: Options | None = None) -> None:
189
- super().__init__("POST", path, options)
203
+ def __init__(
204
+ self,
205
+ path: str = "/",
206
+ options: Options | None = None,
207
+ response_type: ResponseType | None = None,
208
+ ) -> None:
209
+ super().__init__("POST", path, options, response_type)
190
210
 
191
211
 
192
212
  class Get(HttpMapping):
193
213
 
194
- def __init__(self, path: str = "/", options: Options | None = None) -> None:
195
- super().__init__("GET", path, options)
214
+ def __init__(
215
+ self,
216
+ path: str = "/",
217
+ options: Options | None = None,
218
+ response_type: ResponseType | None = None,
219
+ ) -> None:
220
+ super().__init__("GET", path, options, response_type)
196
221
 
197
222
 
198
223
  class Put(HttpMapping):
199
224
 
200
- def __init__(self, path: str = "/", options: Options | None = None) -> None:
201
- super().__init__("PUT", path, options)
225
+ def __init__(
226
+ self,
227
+ path: str = "/",
228
+ options: Options | None = None,
229
+ response_type: ResponseType | None = None,
230
+ ) -> None:
231
+ super().__init__("PUT", path, options, response_type)
202
232
 
203
233
 
204
234
  class Delete(HttpMapping):
205
235
 
206
- def __init__(self, path: str = "/", options: Options | None = None) -> None:
207
- super().__init__("DELETE", path, options)
236
+ def __init__(
237
+ self,
238
+ path: str = "/",
239
+ options: Options | None = None,
240
+ response_type: ResponseType | None = None,
241
+ ) -> None:
242
+ super().__init__("DELETE", path, options, response_type)
208
243
 
209
244
 
210
245
  class Patch(HttpMapping):
211
246
 
212
- def __init__(self, path: str = "/", options: Options | None = None) -> None:
213
- super().__init__("PATCH", path, options)
247
+ def __init__(
248
+ self,
249
+ path: str = "/",
250
+ options: Options | None = None,
251
+ response_type: ResponseType | None = None,
252
+ ) -> None:
253
+ super().__init__("PATCH", path, options, response_type)
214
254
 
215
255
 
216
256
  class UseMiddleware:
@@ -85,6 +85,8 @@ def parse_literal_value(value: Any) -> str:
85
85
 
86
86
 
87
87
  def get_field_type_for_ts(field_type: Any) -> Any:
88
+ if field_type is Response:
89
+ return "unknown"
88
90
  if field_type is Any:
89
91
  return "any"
90
92
  if field_type == UploadFile:
@@ -367,12 +369,23 @@ export type WebSocketMessageMap = {
367
369
 
368
370
  final_buffer.write(
369
371
  """
372
+ export type ResponseType =
373
+ | "arraybuffer"
374
+ | "blob"
375
+ | "document"
376
+ | "json"
377
+ | "text"
378
+ | "stream"
379
+ | "formdata";
380
+
381
+
370
382
  export interface HttpBackendRequest {
371
383
  method: string;
372
384
  path: string;
373
385
  headers: { [key: string]: string };
374
386
  query: { [key: string]: unknown };
375
387
  body: unknown;
388
+ responseType?: ResponseType;
376
389
  }
377
390
 
378
391
  export interface HttpBackend {
@@ -491,6 +504,8 @@ def write_rest_controller_to_typescript_interface(
491
504
  "const response = await this.httpBackend.request<%s>({ \n"
492
505
  % return_value_repr
493
506
  )
507
+ if mapping.response_type is not None:
508
+ class_buffer.write(f'\t\t\tresponseType: "{mapping.response_type}",\n')
494
509
  class_buffer.write(f'\t\t\tmethod: "{mapping.method}",\n')
495
510
 
496
511
  endpoint_path = parse_path_with_params(mapping.path, arg_params_spec)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jararaca
3
- Version: 0.2.37a9
3
+ Version: 0.2.37a10
4
4
  Summary: A simple and fast API framework for Python
5
5
  Home-page: https://github.com/LuscasLeo/jararaca
6
6
  Author: Lucas S
@@ -1,6 +1,6 @@
1
1
  LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
2
2
  README.md,sha256=mte30I-ZEJJp-Oax-OganNgl6G9GaCZPL6JVFAvZGz4,7034
3
- pyproject.toml,sha256=2UOhWHtsEocbNG2dLDU2dLKDKluERP8cFYHdnh8L990,1839
3
+ pyproject.toml,sha256=Hz6Rk-E8INfd6U7oblRlcW8Qvm_aRmyY_EjWaGj6ukw,1840
4
4
  jararaca/__init__.py,sha256=gDCvrIhIu5_IkKjmZmhWZ2khOi8WGiw2AidFFe-BnWU,15118
5
5
  jararaca/__main__.py,sha256=-O3vsB5lHdqNFjUtoELDF81IYFtR-DSiiFMzRaiSsv4,67
6
6
  jararaca/cli.py,sha256=JKk4xrRbtX2fM8yYw794lbxvJFH73bWw3GGIvrpAkeE,5706
@@ -32,7 +32,7 @@ jararaca/persistence/session.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
32
32
  jararaca/persistence/sort_filter.py,sha256=agggpN0YvNjUr6wJjy69NkaqxoDDW13ys9B3r85OujA,9226
33
33
  jararaca/persistence/utilities.py,sha256=0v1YrK-toTCgtw8aROtrDMNfjo3qWWNAb5qQcCOdSUU,13681
34
34
  jararaca/presentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- jararaca/presentation/decorators.py,sha256=eL2YCgMSr19m4YCri5PQU46NRxf0QxsqDnz6MqKu0YQ,8389
35
+ jararaca/presentation/decorators.py,sha256=EErRZtLZDoZZj1ZVlDkGQbvqpoQkBaoU70KAUwWIufs,9146
36
36
  jararaca/presentation/hooks.py,sha256=WBbU5DG3-MAm2Ro2YraQyYG_HENfizYfyShL2ktHi6k,1980
37
37
  jararaca/presentation/http_microservice.py,sha256=g771JosV6jTY3hQtG-HkLOo-T0e-r3b3rp1ddt99Qf0,533
38
38
  jararaca/presentation/server.py,sha256=JuEatLFhD_NFnszwXDSgtcCXNOwvQYyxoxxQ33hnAEc,3731
@@ -58,9 +58,9 @@ jararaca/tools/app_config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
58
58
  jararaca/tools/app_config/decorators.py,sha256=-ckkMZ1dswOmECdo1rFrZ15UAku--txaNXMp8fd1Ndk,941
59
59
  jararaca/tools/app_config/interceptor.py,sha256=nfFZiS80hrbnL7-XEYrwmp2rwaVYBqxvqu3Y-6o_ov4,2575
60
60
  jararaca/tools/metadata.py,sha256=7nlCDYgItNybentPSSCc2MLqN7IpBd0VyQzfjfQycVI,1402
61
- jararaca/tools/typescript/interface_parser.py,sha256=l-QyPVntATcbL4JYm48xq2gNWfV1y2iArvOuIueFi8w,28829
62
- jararaca-0.2.37a9.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
63
- jararaca-0.2.37a9.dist-info/METADATA,sha256=RkVCVzBHDnAGBl11qdhtmRoYnQcE4AOEKrF6I0Oip3U,8554
64
- jararaca-0.2.37a9.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
65
- jararaca-0.2.37a9.dist-info/entry_points.txt,sha256=WIh3aIvz8LwUJZIDfs4EeH3VoFyCGEk7cWJurW38q0I,45
66
- jararaca-0.2.37a9.dist-info/RECORD,,
61
+ jararaca/tools/typescript/interface_parser.py,sha256=4SHt094P-QawMFHSyMCiujQf8Niw7xACIO1RHBM8-w4,29192
62
+ jararaca-0.2.37a10.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
63
+ jararaca-0.2.37a10.dist-info/METADATA,sha256=d0angF0OwLZKGkRL3wKp8GkP79k0HTXlfRIUXRAoZOA,8555
64
+ jararaca-0.2.37a10.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
65
+ jararaca-0.2.37a10.dist-info/entry_points.txt,sha256=WIh3aIvz8LwUJZIDfs4EeH3VoFyCGEk7cWJurW38q0I,45
66
+ jararaca-0.2.37a10.dist-info/RECORD,,
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "jararaca"
3
- version = "0.2.37a9"
3
+ version = "0.2.37a10"
4
4
  description = "A simple and fast API framework for Python"
5
5
  authors = ["Lucas S <me@luscasleo.dev>"]
6
6
  readme = "README.md"