jararaca 0.3.7__py3-none-any.whl → 0.3.9__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/cli.py +72 -4
- jararaca/tools/typescript/interface_parser.py +14 -4
- {jararaca-0.3.7.dist-info → jararaca-0.3.9.dist-info}/METADATA +1 -1
- {jararaca-0.3.7.dist-info → jararaca-0.3.9.dist-info}/RECORD +7 -7
- {jararaca-0.3.7.dist-info → jararaca-0.3.9.dist-info}/LICENSE +0 -0
- {jararaca-0.3.7.dist-info → jararaca-0.3.9.dist-info}/WHEEL +0 -0
- {jararaca-0.3.7.dist-info → jararaca-0.3.9.dist-info}/entry_points.txt +0 -0
jararaca/cli.py
CHANGED
|
@@ -275,11 +275,22 @@ def scheduler_v2(
|
|
|
275
275
|
scheduler.run()
|
|
276
276
|
|
|
277
277
|
|
|
278
|
-
def generate_interfaces(
|
|
278
|
+
def generate_interfaces(
|
|
279
|
+
app_path: str,
|
|
280
|
+
file_path: str | None = None,
|
|
281
|
+
stdout: bool = False,
|
|
282
|
+
post_process_cmd: str | None = None,
|
|
283
|
+
) -> str:
|
|
279
284
|
try:
|
|
280
285
|
app = find_microservice_by_module_path(app_path)
|
|
281
286
|
content = write_microservice_to_typescript_interface(app)
|
|
282
287
|
|
|
288
|
+
if stdout:
|
|
289
|
+
return content
|
|
290
|
+
|
|
291
|
+
if not file_path:
|
|
292
|
+
return content
|
|
293
|
+
|
|
283
294
|
with open(file_path, "w", encoding="utf-8") as file:
|
|
284
295
|
# Save current position
|
|
285
296
|
file.tell()
|
|
@@ -295,8 +306,25 @@ def generate_interfaces(app_path: str, file_path: str) -> None:
|
|
|
295
306
|
print(
|
|
296
307
|
f"Generated TypeScript interfaces at {time.strftime('%H:%M:%S')} at {str(Path(file_path).absolute())}"
|
|
297
308
|
)
|
|
309
|
+
|
|
310
|
+
if post_process_cmd and file_path:
|
|
311
|
+
import subprocess
|
|
312
|
+
|
|
313
|
+
try:
|
|
314
|
+
print(f"Running post-process command: {post_process_cmd}")
|
|
315
|
+
subprocess.run(
|
|
316
|
+
post_process_cmd.replace("{file}", file_path),
|
|
317
|
+
shell=True,
|
|
318
|
+
check=True,
|
|
319
|
+
)
|
|
320
|
+
print(f"Post-processing completed successfully")
|
|
321
|
+
except subprocess.CalledProcessError as e:
|
|
322
|
+
print(f"Post-processing command failed: {e}", file=sys.stderr)
|
|
323
|
+
|
|
324
|
+
return content
|
|
298
325
|
except Exception as e:
|
|
299
326
|
print(f"Error generating TypeScript interfaces: {e}", file=sys.stderr)
|
|
327
|
+
return ""
|
|
300
328
|
|
|
301
329
|
|
|
302
330
|
@cli.command()
|
|
@@ -307,6 +335,7 @@ def generate_interfaces(app_path: str, file_path: str) -> None:
|
|
|
307
335
|
@click.argument(
|
|
308
336
|
"file_path",
|
|
309
337
|
type=click.Path(file_okay=True, dir_okay=False),
|
|
338
|
+
required=False,
|
|
310
339
|
)
|
|
311
340
|
@click.option(
|
|
312
341
|
"--watch",
|
|
@@ -317,11 +346,50 @@ def generate_interfaces(app_path: str, file_path: str) -> None:
|
|
|
317
346
|
type=click.Path(exists=True, file_okay=False, dir_okay=True),
|
|
318
347
|
default="src",
|
|
319
348
|
)
|
|
320
|
-
|
|
349
|
+
@click.option(
|
|
350
|
+
"--stdout",
|
|
351
|
+
is_flag=True,
|
|
352
|
+
help="Print generated interfaces to stdout instead of writing to a file",
|
|
353
|
+
)
|
|
354
|
+
@click.option(
|
|
355
|
+
"--post-process",
|
|
356
|
+
type=str,
|
|
357
|
+
help="Command to run after generating the interfaces, {file} will be replaced with the output file path",
|
|
358
|
+
)
|
|
359
|
+
def gen_tsi(
|
|
360
|
+
app_path: str,
|
|
361
|
+
file_path: str | None,
|
|
362
|
+
watch: bool,
|
|
363
|
+
src_dir: str,
|
|
364
|
+
stdout: bool,
|
|
365
|
+
post_process: str | None,
|
|
366
|
+
) -> None:
|
|
321
367
|
"""Generate TypeScript interfaces from a Python microservice."""
|
|
322
368
|
|
|
369
|
+
if stdout and watch:
|
|
370
|
+
print(
|
|
371
|
+
"Error: --watch and --stdout options cannot be used together",
|
|
372
|
+
file=sys.stderr,
|
|
373
|
+
)
|
|
374
|
+
return
|
|
375
|
+
|
|
376
|
+
if not file_path and not stdout:
|
|
377
|
+
print("Error: either file_path or --stdout must be provided", file=sys.stderr)
|
|
378
|
+
return
|
|
379
|
+
|
|
380
|
+
if post_process and stdout:
|
|
381
|
+
print(
|
|
382
|
+
"Error: --post-process and --stdout options cannot be used together",
|
|
383
|
+
file=sys.stderr,
|
|
384
|
+
)
|
|
385
|
+
return
|
|
386
|
+
|
|
323
387
|
# Initial generation
|
|
324
|
-
generate_interfaces(app_path, file_path)
|
|
388
|
+
content = generate_interfaces(app_path, file_path, stdout, post_process)
|
|
389
|
+
|
|
390
|
+
if stdout:
|
|
391
|
+
print(content)
|
|
392
|
+
return
|
|
325
393
|
|
|
326
394
|
# If watch mode is not enabled, exit
|
|
327
395
|
if not watch:
|
|
@@ -350,7 +418,7 @@ def gen_tsi(app_path: str, file_path: str, watch: bool, src_dir: str) -> None:
|
|
|
350
418
|
# Create a completely detached process to ensure classes are reloaded
|
|
351
419
|
process = multiprocessing.get_context("spawn").Process(
|
|
352
420
|
target=generate_interfaces,
|
|
353
|
-
args=(app_path, file_path),
|
|
421
|
+
args=(app_path, file_path, False, post_process),
|
|
354
422
|
daemon=False, # Non-daemon to ensure it completes
|
|
355
423
|
)
|
|
356
424
|
process.start()
|
|
@@ -74,13 +74,23 @@ def parse_literal_value(value: Any) -> str:
|
|
|
74
74
|
use_parse_context().mapped_types.add(value.__class__)
|
|
75
75
|
return f"{value.__class__.__name__}.{value.name}"
|
|
76
76
|
if isinstance(value, str):
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return
|
|
77
|
+
# Properly escape quotes for TypeScript string literals
|
|
78
|
+
escaped_value = value.replace("\\", "\\\\").replace('"', '\\"')
|
|
79
|
+
return f'"{escaped_value}"'
|
|
80
80
|
if isinstance(value, float):
|
|
81
81
|
return str(value)
|
|
82
82
|
if isinstance(value, bool):
|
|
83
|
-
|
|
83
|
+
# Ensure Python's True/False are properly converted to JavaScript's true/false
|
|
84
|
+
return "true" if value else "false"
|
|
85
|
+
# Special handling for Python symbols that might appear in literal types
|
|
86
|
+
if value is True:
|
|
87
|
+
return "true"
|
|
88
|
+
if value is False:
|
|
89
|
+
return "false"
|
|
90
|
+
if value is None:
|
|
91
|
+
return "null"
|
|
92
|
+
if isinstance(value, int):
|
|
93
|
+
return str(value)
|
|
84
94
|
return "unknown"
|
|
85
95
|
|
|
86
96
|
|
|
@@ -3,7 +3,7 @@ jararaca/__main__.py,sha256=-O3vsB5lHdqNFjUtoELDF81IYFtR-DSiiFMzRaiSsv4,67
|
|
|
3
3
|
jararaca/broker_backend/__init__.py,sha256=GzEIuHR1xzgCJD4FE3harNjoaYzxHMHoEL0_clUaC-k,3528
|
|
4
4
|
jararaca/broker_backend/mapper.py,sha256=vTsi7sWpNvlga1PWPFg0rCJ5joJ0cdzykkIc2Tuvenc,696
|
|
5
5
|
jararaca/broker_backend/redis_broker_backend.py,sha256=a7DHchy3NAiD71Ix8SwmQOUnniu7uup-Woa4ON_4J7I,5786
|
|
6
|
-
jararaca/cli.py,sha256=
|
|
6
|
+
jararaca/cli.py,sha256=sbWqviMH0JF65763fBzwUTQWHsuPmTWkup87kqTtZWo,12164
|
|
7
7
|
jararaca/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
jararaca/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
jararaca/core/providers.py,sha256=wktH84FK7c1s2wNq-fudf1uMfi3CQBR0neU2czJ_L0U,434
|
|
@@ -63,11 +63,11 @@ jararaca/tools/app_config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
|
63
63
|
jararaca/tools/app_config/decorators.py,sha256=-ckkMZ1dswOmECdo1rFrZ15UAku--txaNXMp8fd1Ndk,941
|
|
64
64
|
jararaca/tools/app_config/interceptor.py,sha256=nfFZiS80hrbnL7-XEYrwmp2rwaVYBqxvqu3Y-6o_ov4,2575
|
|
65
65
|
jararaca/tools/metadata.py,sha256=7nlCDYgItNybentPSSCc2MLqN7IpBd0VyQzfjfQycVI,1402
|
|
66
|
-
jararaca/tools/typescript/interface_parser.py,sha256=
|
|
66
|
+
jararaca/tools/typescript/interface_parser.py,sha256=35xbOrZDQDyTXdMrVZQ8nnFw79f28lJuLYNHAspIqi8,30492
|
|
67
67
|
jararaca/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
68
68
|
jararaca/utils/rabbitmq_utils.py,sha256=FPDP8ZVgvitZXV-oK73D7EIANsqUzXTW7HdpEKsIsyI,2811
|
|
69
|
-
jararaca-0.3.
|
|
70
|
-
jararaca-0.3.
|
|
71
|
-
jararaca-0.3.
|
|
72
|
-
jararaca-0.3.
|
|
73
|
-
jararaca-0.3.
|
|
69
|
+
jararaca-0.3.9.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
70
|
+
jararaca-0.3.9.dist-info/METADATA,sha256=QUd0KvFdDWQNVvIzaVfGRWXzttqzP_AqAo7HbjzZ0pc,4951
|
|
71
|
+
jararaca-0.3.9.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
72
|
+
jararaca-0.3.9.dist-info/entry_points.txt,sha256=WIh3aIvz8LwUJZIDfs4EeH3VoFyCGEk7cWJurW38q0I,45
|
|
73
|
+
jararaca-0.3.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|