mirror of
https://github.com/reconurge/flowsint.git
synced 2026-07-16 17:13:47 -05:00
feat(api): update models
This commit is contained in:
@@ -337,3 +337,32 @@ class InvestigationUserRole(Base):
|
||||
Index("idx_investigation_roles_user_id", "user_id"),
|
||||
Index("idx_investigation_roles_investigation_id", "investigation_id"),
|
||||
)
|
||||
|
||||
|
||||
class CustomType(Base):
|
||||
__tablename__ = "custom_types"
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(
|
||||
PGUUID(as_uuid=True), primary_key=True, default=uuid.uuid4
|
||||
)
|
||||
name: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
owner_id: Mapped[uuid.UUID] = mapped_column(
|
||||
PGUUID(as_uuid=True),
|
||||
ForeignKey("profiles.id", onupdate="CASCADE", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
schema: Mapped[dict] = mapped_column(JSONB, nullable=False)
|
||||
status: Mapped[str] = mapped_column(String, server_default="draft", nullable=False)
|
||||
checksum: Mapped[str] = mapped_column(String, nullable=True)
|
||||
description: Mapped[str] = mapped_column(Text, nullable=True)
|
||||
created_at = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = mapped_column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||
|
||||
# Relationships
|
||||
owner = relationship("Profile", foreign_keys=[owner_id])
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_custom_types_owner_id", "owner_id"),
|
||||
Index("idx_custom_types_name", "name"),
|
||||
Index("idx_custom_types_status", "status"),
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import inspect
|
||||
from typing import Dict, Optional, Type, List
|
||||
from typing import Dict, Optional, Type, List, Any
|
||||
from flowsint_core.core.transform_base import Transform
|
||||
|
||||
# Domain-related transforms
|
||||
@@ -72,7 +72,9 @@ class TransformRegistry:
|
||||
return name in cls._transforms
|
||||
|
||||
@classmethod
|
||||
def get_transform(cls, name: str, sketch_id: str, scan_id: str, **kwargs) -> Transform:
|
||||
def get_transform(
|
||||
cls, name: str, sketch_id: str, scan_id: str, **kwargs
|
||||
) -> Transform:
|
||||
if name not in cls._transforms:
|
||||
raise Exception(f"Transform '{name}' not found")
|
||||
return cls._transforms[name](sketch_id=sketch_id, scan_id=scan_id, **kwargs)
|
||||
@@ -96,12 +98,19 @@ class TransformRegistry:
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def list(cls, exclude: Optional[List[str]] = []) -> Dict[str, Dict[str, str]]:
|
||||
return {
|
||||
name: cls._create_transform_metadata(transform)
|
||||
for name, transform in cls._transforms.items()
|
||||
if name not in exclude
|
||||
}
|
||||
def list(
|
||||
cls, exclude: Optional[List[str]] = None, wobbly_type: Optional[bool] = False
|
||||
) -> List[Dict[str, Any]]:
|
||||
if exclude is None:
|
||||
exclude = []
|
||||
return [
|
||||
{
|
||||
**cls._create_transform_metadata(transform),
|
||||
"wobblyType": wobbly_type,
|
||||
}
|
||||
for transform in cls._transforms.values()
|
||||
if transform.name() not in exclude
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def list_by_categories(cls) -> Dict[str, List[Dict[str, str]]]:
|
||||
@@ -110,7 +119,9 @@ class TransformRegistry:
|
||||
category = transform.category()
|
||||
if category not in transforms_by_category:
|
||||
transforms_by_category[category] = []
|
||||
transforms_by_category[category].append(cls._create_transform_metadata(transform))
|
||||
transforms_by_category[category].append(
|
||||
cls._create_transform_metadata(transform)
|
||||
)
|
||||
return transforms_by_category
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user