Files
dify/api/models/api_based_extension.py
JyongandClaude Fable 5.2 be340e569c refactor(file-scan): let the custom endpoint scanner hold its own address and key
The Custom Endpoint scanner no longer goes through API-based extensions.
A workspace enters the endpoint URL and an API key in the scanner dialog,
and the endpoint receives the file content directly instead of a signed
download link.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 15:04:19 +08:00

37 lines
1.3 KiB
Python

import enum
from datetime import datetime
from uuid import uuid4
import sqlalchemy as sa
from sqlalchemy import DateTime, String, func
from sqlalchemy.orm import Mapped, mapped_column
from .base import TypeBase
from .types import LongText, StringUUID
class APIBasedExtensionPoint(enum.StrEnum):
APP_EXTERNAL_DATA_TOOL_QUERY = "app.external_data_tool.query"
PING = "ping"
APP_MODERATION_INPUT = "app.moderation.input"
APP_MODERATION_OUTPUT = "app.moderation.output"
class APIBasedExtension(TypeBase):
__tablename__ = "api_based_extensions"
__table_args__ = (
sa.PrimaryKeyConstraint("id", name="api_based_extension_pkey"),
sa.Index("api_based_extension_tenant_idx", "tenant_id"),
)
id: Mapped[str] = mapped_column(
StringUUID, insert_default=lambda: str(uuid4()), default_factory=lambda: str(uuid4()), init=False
)
tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
name: Mapped[str] = mapped_column(String(255), nullable=False)
api_endpoint: Mapped[str] = mapped_column(String(255), nullable=False)
api_key: Mapped[str] = mapped_column(LongText, nullable=False)
created_at: Mapped[datetime] = mapped_column(
DateTime, nullable=False, server_default=func.current_timestamp(), init=False
)