@danhachuel/thunderbolt 0.7.18 → 0.7.19
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.
- package/app/main.py +41 -3
- package/package.json +1 -1
package/app/main.py
CHANGED
|
@@ -697,6 +697,46 @@ def blueprint_for_channel(channel: dict) -> dict[str, Any]:
|
|
|
697
697
|
return {"id": blueprint_id, "name": blueprint_id}
|
|
698
698
|
|
|
699
699
|
|
|
700
|
+
def _resolve_saved_script_blueprint(record: dict[str, Any], channel: dict[str, Any]) -> tuple[str, str]:
|
|
701
|
+
"""Resolve legacy script Blueprint metadata from channel fields or its saved name."""
|
|
702
|
+
blueprint_id = str(
|
|
703
|
+
channel.get("default_blueprint_id")
|
|
704
|
+
or channel.get("blueprint_id")
|
|
705
|
+
or record.get("blueprint_id")
|
|
706
|
+
or ""
|
|
707
|
+
).strip()
|
|
708
|
+
blueprint_name = str(
|
|
709
|
+
channel.get("default_blueprint_name")
|
|
710
|
+
or channel.get("blueprint_name")
|
|
711
|
+
or channel.get("blueprint")
|
|
712
|
+
or record.get("blueprint_name")
|
|
713
|
+
or record.get("blueprint")
|
|
714
|
+
or ""
|
|
715
|
+
).strip()
|
|
716
|
+
resolved = blueprint_for_channel(channel) if blueprint_id else {}
|
|
717
|
+
resolved_name = str(resolved.get("name") or "").strip()
|
|
718
|
+
if resolved_name and (resolved_name.casefold() != blueprint_id.casefold() or not blueprint_name):
|
|
719
|
+
blueprint_name = resolved_name
|
|
720
|
+
wanted = {value.casefold() for value in (blueprint_id, blueprint_name) if value}
|
|
721
|
+
if wanted:
|
|
722
|
+
for path in list_blueprint_files():
|
|
723
|
+
try:
|
|
724
|
+
data = load_blueprint_file(path)
|
|
725
|
+
except (OSError, ValueError, json.JSONDecodeError):
|
|
726
|
+
continue
|
|
727
|
+
display_name = get_display_name("blueprints", path, str(data.get("name") or data.get("title") or path.stem)).strip()
|
|
728
|
+
identifiers = {
|
|
729
|
+
str(data.get("id") or "").strip(),
|
|
730
|
+
path.stem.strip(),
|
|
731
|
+
str(data.get("name") or "").strip(),
|
|
732
|
+
str(data.get("title") or "").strip(),
|
|
733
|
+
display_name,
|
|
734
|
+
}
|
|
735
|
+
if wanted.intersection({value.casefold() for value in identifiers if value}):
|
|
736
|
+
return str(data.get("id") or path.stem).strip(), display_name
|
|
737
|
+
return blueprint_id, blueprint_name or (blueprint_id if blueprint_id else "SEM BLUEPRINT CONFIGURADO")
|
|
738
|
+
|
|
739
|
+
|
|
700
740
|
def _script_channel(record: dict[str, Any], channels: list[dict[str, Any]]) -> dict[str, Any]:
|
|
701
741
|
channel_id = str(record.get("channel_id") or "").strip()
|
|
702
742
|
channel_name = str(record.get("channel_name") or record.get("channel") or "").strip().casefold()
|
|
@@ -724,9 +764,7 @@ def _backfill_saved_script_blueprints(records: list[dict[str, Any]] | None = Non
|
|
|
724
764
|
channel = _script_channel(record, channels)
|
|
725
765
|
if not channel:
|
|
726
766
|
continue
|
|
727
|
-
blueprint_id =
|
|
728
|
-
blueprint = blueprint_for_channel(channel)
|
|
729
|
-
blueprint_name = str(blueprint.get("name") or blueprint_id or "SEM BLUEPRINT CONFIGURADO").strip()
|
|
767
|
+
blueprint_id, blueprint_name = _resolve_saved_script_blueprint(record, channel)
|
|
730
768
|
current_id = str(record.get("blueprint_id") or "").strip()
|
|
731
769
|
current_name = str(record.get("blueprint_name") or record.get("blueprint") or "").strip()
|
|
732
770
|
if current_id == blueprint_id and current_name == blueprint_name:
|
package/package.json
CHANGED