feat: Oracle Canvas Component Schema and Qwen 3.6 integration (#31)
Co-authored-by: Sagnik <sagnik7896@gmail.com> Reviewed-on: #31
This commit was merged in pull request #31.
This commit is contained in:
@@ -57,13 +57,37 @@ def _stringify(value: Any) -> str:
|
||||
return str(value) if value is not None else ""
|
||||
|
||||
|
||||
def _json_object(value: Any) -> dict[str, Any]:
|
||||
if isinstance(value, dict):
|
||||
return value
|
||||
if isinstance(value, str) and value.strip():
|
||||
try:
|
||||
parsed = json.loads(value)
|
||||
if isinstance(parsed, dict):
|
||||
return parsed
|
||||
except Exception:
|
||||
logger.warning("canvas_service: failed to parse JSON object field; using empty object")
|
||||
return {}
|
||||
|
||||
|
||||
def _normalize_component(component: dict[str, Any]) -> dict[str, Any]:
|
||||
normalized = deepcopy(component)
|
||||
normalized["componentId"] = _stringify(normalized.get("componentId"))
|
||||
descriptor = normalized.get("dataSourceDescriptor") or {}
|
||||
descriptor = _json_object(normalized.get("dataSourceDescriptor"))
|
||||
if descriptor.get("descriptorId") is not None:
|
||||
descriptor["descriptorId"] = _stringify(descriptor["descriptorId"])
|
||||
normalized["dataSourceDescriptor"] = descriptor
|
||||
for field in (
|
||||
"visualizationParameters",
|
||||
"dataBindings",
|
||||
"provenance",
|
||||
"renderingHints",
|
||||
"layout",
|
||||
"accessControls",
|
||||
"styleSignature",
|
||||
"validationState",
|
||||
):
|
||||
normalized[field] = _json_object(normalized.get(field))
|
||||
return normalized
|
||||
|
||||
|
||||
@@ -105,7 +129,7 @@ def _deserialize_page_row(row: Any, components: list[dict[str, Any]]) -> dict[st
|
||||
"isShared": bool(row["is_shared"]),
|
||||
"headRevision": head_revision,
|
||||
"baseRevision": int(row["base_revision"]),
|
||||
"sharingPolicy": row["sharing_policy"] or {
|
||||
"sharingPolicy": _json_object(row["sharing_policy"]) or {
|
||||
"shareMode": "direct_fork_only",
|
||||
"allowReshare": False,
|
||||
"defaultForkVisibility": "private",
|
||||
|
||||
Reference in New Issue
Block a user