Format
This commit is contained in:
parent
e07eae6a8d
commit
cff2563ee1
2 changed files with 94 additions and 116 deletions
|
|
@ -77,17 +77,13 @@ class CustomComponent(Component):
|
||||||
|
|
||||||
def update_state(self, name: str, value: Any):
|
def update_state(self, name: str, value: Any):
|
||||||
try:
|
try:
|
||||||
self.vertex.graph.update_state(
|
self.vertex.graph.update_state(name=name, record=value, caller=self.vertex.id)
|
||||||
name=name, record=value, caller=self.vertex.id
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(f"Error updating state: {e}")
|
raise ValueError(f"Error updating state: {e}")
|
||||||
|
|
||||||
def append_state(self, name: str, value: Any):
|
def append_state(self, name: str, value: Any):
|
||||||
try:
|
try:
|
||||||
self.vertex.graph.append_state(
|
self.vertex.graph.append_state(name=name, record=value, caller=self.vertex.id)
|
||||||
name=name, record=value, caller=self.vertex.id
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(f"Error appending state: {e}")
|
raise ValueError(f"Error appending state: {e}")
|
||||||
|
|
||||||
|
|
@ -138,9 +134,7 @@ class CustomComponent(Component):
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return self.field_config
|
return self.field_config
|
||||||
|
|
||||||
def update_build_config(
|
def update_build_config(self, build_config: dict, field_name: str, field_value: Any):
|
||||||
self, build_config: dict, field_name: str, field_value: Any
|
|
||||||
):
|
|
||||||
build_config[field_name] = field_value
|
build_config[field_name] = field_value
|
||||||
return build_config
|
return build_config
|
||||||
|
|
||||||
|
|
@ -148,9 +142,7 @@ class CustomComponent(Component):
|
||||||
def tree(self):
|
def tree(self):
|
||||||
return self.get_code_tree(self.code or "")
|
return self.get_code_tree(self.code or "")
|
||||||
|
|
||||||
def to_records(
|
def to_records(self, data: Any, keys: Optional[List[str]] = None, silent_errors: bool = False) -> List[Record]:
|
||||||
self, data: Any, keys: Optional[List[str]] = None, silent_errors: bool = False
|
|
||||||
) -> List[Record]:
|
|
||||||
"""
|
"""
|
||||||
Converts input data into a list of Record objects.
|
Converts input data into a list of Record objects.
|
||||||
|
|
||||||
|
|
@ -199,9 +191,7 @@ class CustomComponent(Component):
|
||||||
|
|
||||||
return records
|
return records
|
||||||
|
|
||||||
def create_references_from_records(
|
def create_references_from_records(self, records: List[Record], include_data: bool = False) -> str:
|
||||||
self, records: List[Record], include_data: bool = False
|
|
||||||
) -> str:
|
|
||||||
"""
|
"""
|
||||||
Create references from a list of records.
|
Create references from a list of records.
|
||||||
|
|
||||||
|
|
@ -240,20 +230,14 @@ class CustomComponent(Component):
|
||||||
if not self.code:
|
if not self.code:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
component_classes = [
|
component_classes = [cls for cls in self.tree["classes"] if self.code_class_base_inheritance in cls["bases"]]
|
||||||
cls
|
|
||||||
for cls in self.tree["classes"]
|
|
||||||
if self.code_class_base_inheritance in cls["bases"]
|
|
||||||
]
|
|
||||||
if not component_classes:
|
if not component_classes:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
# Assume the first Component class is the one we're interested in
|
# Assume the first Component class is the one we're interested in
|
||||||
component_class = component_classes[0]
|
component_class = component_classes[0]
|
||||||
build_methods = [
|
build_methods = [
|
||||||
method
|
method for method in component_class["methods"] if method["name"] == self.function_entrypoint_name
|
||||||
for method in component_class["methods"]
|
|
||||||
if method["name"] == self.function_entrypoint_name
|
|
||||||
]
|
]
|
||||||
|
|
||||||
return build_methods[0] if build_methods else {}
|
return build_methods[0] if build_methods else {}
|
||||||
|
|
@ -310,9 +294,7 @@ class CustomComponent(Component):
|
||||||
# Retrieve and decrypt the credential by name for the current user
|
# Retrieve and decrypt the credential by name for the current user
|
||||||
db_service = get_db_service()
|
db_service = get_db_service()
|
||||||
with session_getter(db_service) as session:
|
with session_getter(db_service) as session:
|
||||||
return credential_service.get_credential(
|
return credential_service.get_credential(user_id=self._user_id or "", name=name, session=session)
|
||||||
user_id=self._user_id or "", name=name, session=session
|
|
||||||
)
|
|
||||||
|
|
||||||
return get_credential
|
return get_credential
|
||||||
|
|
||||||
|
|
@ -322,9 +304,7 @@ class CustomComponent(Component):
|
||||||
credential_service = get_credential_service()
|
credential_service = get_credential_service()
|
||||||
db_service = get_db_service()
|
db_service = get_db_service()
|
||||||
with session_getter(db_service) as session:
|
with session_getter(db_service) as session:
|
||||||
return credential_service.list_credentials(
|
return credential_service.list_credentials(user_id=self._user_id, session=session)
|
||||||
user_id=self._user_id, session=session
|
|
||||||
)
|
|
||||||
|
|
||||||
def index(self, value: int = 0):
|
def index(self, value: int = 0):
|
||||||
"""Returns a function that returns the value at the given index in the iterable."""
|
"""Returns a function that returns the value at the given index in the iterable."""
|
||||||
|
|
@ -363,11 +343,7 @@ class CustomComponent(Component):
|
||||||
if not self._flows_records:
|
if not self._flows_records:
|
||||||
self.list_flows()
|
self.list_flows()
|
||||||
if not flow_id and self._flows_records:
|
if not flow_id and self._flows_records:
|
||||||
flow_ids = [
|
flow_ids = [flow.data["id"] for flow in self._flows_records if flow.data["name"] == flow_name]
|
||||||
flow.data["id"]
|
|
||||||
for flow in self._flows_records
|
|
||||||
if flow.data["name"] == flow_name
|
|
||||||
]
|
|
||||||
if not flow_ids:
|
if not flow_ids:
|
||||||
raise ValueError(f"Flow {flow_name} not found")
|
raise ValueError(f"Flow {flow_name} not found")
|
||||||
elif len(flow_ids) > 1:
|
elif len(flow_ids) > 1:
|
||||||
|
|
@ -389,9 +365,7 @@ class CustomComponent(Component):
|
||||||
db_service = get_db_service()
|
db_service = get_db_service()
|
||||||
with get_session(db_service) as session:
|
with get_session(db_service) as session:
|
||||||
flows = session.exec(
|
flows = session.exec(
|
||||||
select(Flow)
|
select(Flow).where(Flow.user_id == self._user_id).where(Flow.is_component == False) # noqa
|
||||||
.where(Flow.user_id == self._user_id)
|
|
||||||
.where(Flow.is_component == False) # noqa
|
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
flows_records = [flow.to_record() for flow in flows]
|
flows_records = [flow.to_record() for flow in flows]
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ export default function CollectionCardComponent({
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
className={cn(
|
className={cn(
|
||||||
"group relative h-48 w-2/6 flex flex-col justify-between overflow-hidden transition-all hover:shadow-md",
|
"group relative flex h-48 w-2/6 flex-col justify-between overflow-hidden transition-all hover:shadow-md"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -36,31 +36,35 @@ export default function CollectionCardComponent({
|
||||||
<div>
|
<div>
|
||||||
<CardTitle className="flex w-full items-center justify-between gap-3 text-xl">
|
<CardTitle className="flex w-full items-center justify-between gap-3 text-xl">
|
||||||
{flow.icon && isEmoji(flow.icon) && (
|
{flow.icon && isEmoji(flow.icon) && (
|
||||||
<div className="p-2 rounded-md flex align-middle items-center justify-center" style={{ backgroundColor: flow.icon_bg_color }}>
|
<div
|
||||||
|
className="flex items-center justify-center rounded-md p-2 align-middle"
|
||||||
<div className="pl-0.5 h-7 w-7">
|
style={{ backgroundColor: flow.icon_bg_color }}
|
||||||
{flow.icon}
|
>
|
||||||
|
<div className="h-7 w-7 pl-0.5">{flow.icon}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
)}
|
)}
|
||||||
{(!flow.icon || !isEmoji(flow.icon)) &&
|
{(!flow.icon || !isEmoji(flow.icon)) && (
|
||||||
<div className="p-2 rounded-md flex align-middle items-center justify-center" style={{ backgroundColor: flow.icon_bg_color }}>
|
<div
|
||||||
|
className="flex items-center justify-center rounded-md p-2 align-middle"
|
||||||
|
style={{ backgroundColor: flow.icon_bg_color }}
|
||||||
|
>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
className={cn(
|
className={cn("h-7 w-7 flex-shrink-0 text-flow-icon")}
|
||||||
"flex-shrink-0 h-7 w-7 text-flow-icon",
|
|
||||||
)}
|
|
||||||
name={flow.icon || "Group"}
|
name={flow.icon || "Group"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
)}
|
||||||
<ShadTooltip content={flow.name}>
|
<ShadTooltip content={flow.name}>
|
||||||
<div className="w-full truncate">{flow.name}</div>
|
<div className="w-full truncate">{flow.name}</div>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
</div>
|
</div>
|
||||||
<CardDescription className="pb-2 pt-2">
|
<CardDescription className="pb-2 pt-2">
|
||||||
<ShadTooltip side="bottom" styleClasses="z-50" content={flow.description}>
|
<ShadTooltip
|
||||||
|
side="bottom"
|
||||||
|
styleClasses="z-50"
|
||||||
|
content={flow.description}
|
||||||
|
>
|
||||||
<div className="truncate-doubleline">{flow.description}</div>
|
<div className="truncate-doubleline">{flow.description}</div>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue