@danhachuel/thunderbolt 0.7.50 → 0.7.51

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.
@@ -60,6 +60,37 @@ def _country_key(value: Any) -> str:
60
60
  return "".join(char for char in normalized if not unicodedata.combining(char)).casefold()
61
61
 
62
62
 
63
+ COUNTRY_CODE_NAMES = {
64
+ "BR": "Brasil",
65
+ "CH": "Suíça",
66
+ "ES": "Espanha",
67
+ "RS": "Sérvia",
68
+ }
69
+
70
+
71
+ COUNTRY_NAME_CODES = {name: code for code, name in COUNTRY_CODE_NAMES.items()}
72
+
73
+
74
+ def _country_flag(value: Any) -> str:
75
+ """Render a two-letter country code as a Unicode regional-indicator flag."""
76
+ clean_value = _clean(value).upper()
77
+ if len(clean_value) != 2 or not clean_value.isascii() or not clean_value.isalpha():
78
+ return ""
79
+ return "".join(chr(0x1F1E6 + ord(char) - ord("A")) for char in clean_value)
80
+
81
+
82
+ def _country_display(value: Any) -> str:
83
+ clean_value = _clean(value)
84
+ if not clean_value:
85
+ return "Não definido"
86
+ code = clean_value.upper()
87
+ flag = _country_flag(code)
88
+ if flag:
89
+ return f"{flag} {COUNTRY_CODE_NAMES.get(code, code)}"
90
+ mapped_code = COUNTRY_NAME_CODES.get(clean_value)
91
+ return f"{_country_flag(mapped_code)} {clean_value}" if mapped_code else clean_value
92
+
93
+
63
94
  COUNTRY_ALIASES = {
64
95
  "brazil": "Brasil",
65
96
  "brasil": "Brasil",
@@ -75,6 +106,12 @@ def _normalise_country(value: Any) -> str:
75
106
  clean_value = _clean(value)
76
107
  if not clean_value:
77
108
  return ""
109
+ code = clean_value.upper()
110
+ if code in COUNTRY_CODE_NAMES:
111
+ return COUNTRY_CODE_NAMES[code]
112
+ if len(code) == 2 and code.isascii() and code.isalpha():
113
+ # Keep unknown legacy ISO codes usable and renderable rather than dropping them.
114
+ return code
78
115
  if clean_value in COUNTRY_OPTIONS:
79
116
  return clean_value
80
117
  key = _country_key(clean_value)
@@ -108,7 +145,7 @@ def _country_index(value: Any) -> int:
108
145
 
109
146
 
110
147
  def _country_label(value: str) -> str:
111
- return value or "Não definido"
148
+ return _country_display(value)
112
149
 
113
150
 
114
151
  def _instagram_posts_key(profile_id: str) -> str:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.7.50",
3
+ "version": "0.7.51",
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",