feat: funciones Python infra y tipos Python (core, datascience, infra)

Infra: cache_to_file, cache_to_sqlite, http_download_file, http_get_json,
http_post_json, read_file_with_encoding, safe_extract_zip, scan_directory,
setup_logger, normalize_zip_filenames.
Tipos: 30+ tipos core (agent_action, context, task, message, parse_result...),
6 tipos datascience (entity_candidate, extraction_result...), 2 tipos infra.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-05 17:11:43 +02:00
parent 63a9cb5273
commit 9fd0ca9cac
110 changed files with 5714 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
---
name: http_get_json
kind: function
lang: py
domain: infra
version: "1.0.0"
purity: impure
signature: "http_get_json(url: str, headers: dict[str, str] | None = None, params: dict[str, str] | None = None, timeout: float = 30.0) -> dict"
description: "GET request que espera JSON. Agrega Accept: application/json automaticamente. Lanza RuntimeError si status >= 400 con status code, url truncada y primeros 200 chars del body."
tags: [http, json, get, client, network, stdlib, infra]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: ["json", "urllib.error", "urllib.parse", "urllib.request"]
tested: true
tests:
- "mock de respuesta 200 con JSON"
- "mock de respuesta 404 → error con status code"
- "mock de respuesta con JSON invalido → error descriptivo"
- "params serializados como query string"
- "headers custom enviados"
test_file_path: "python/functions/infra/http_get_json_test.py"
file_path: "python/functions/infra/http_get_json.py"
---
## Ejemplo
```python
data = http_get_json(
"https://api.example.com/users",
params={"page": "1", "limit": "50"},
headers={"X-Api-Key": "secret"},
)
print(data["total"])
```
## Notas
Solo usa stdlib (urllib). Sin dependencias externas. El error incluye los primeros 200 chars del body para facilitar debugging en produccion. Params se serializa con urlencode antes de concatenar a la URL.