@danhachuel/thunderbolt 0.5.12 → 0.5.13

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.
@@ -30,9 +30,29 @@ def _items(value: Any) -> list[dict[str, Any]]:
30
30
  for key in ("items", "designs", "results"):
31
31
  if isinstance(value.get(key), list):
32
32
  return [dict(item) for item in value[key] if isinstance(item, Mapping)]
33
+ for key in ("data", "result", "response"):
34
+ if isinstance(value.get(key), (Mapping, list)):
35
+ nested = _items(value[key])
36
+ if nested:
37
+ return nested
33
38
  return []
34
39
 
35
40
 
41
+ def _design_id(value: Any) -> str:
42
+ """Extract a Canva design identifier from REST/MCP result variants."""
43
+ if isinstance(value, Mapping):
44
+ for key in ("design_id", "designId", "id"):
45
+ candidate = str(value.get(key) or "").strip()
46
+ if candidate:
47
+ return candidate
48
+ for key in ("design", "resource", "data"):
49
+ if isinstance(value.get(key), Mapping):
50
+ found = _design_id(value[key])
51
+ if found:
52
+ return found
53
+ return ""
54
+
55
+
36
56
  def _first_id(value: Any, keys: tuple[str, ...]) -> str:
37
57
  if isinstance(value, Mapping):
38
58
  for key in keys:
@@ -102,8 +122,8 @@ def run_direct_canva_thumbnail(
102
122
  candidates = _items(result)
103
123
  if not candidates:
104
124
  raise CanvaMCPError("Canva não encontrou designs para as palavras-chave da thumbnail.")
105
- selected = candidates[0]
106
- design_id = str(selected.get("id") or "").strip()
125
+ selected = next((candidate for candidate in candidates if _design_id(candidate)), candidates[0])
126
+ design_id = _design_id(selected)
107
127
  if not design_id:
108
128
  raise CanvaMCPError("A pesquisa Canva devolveu um design sem ID.")
109
129
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",