Help us shape the future of Go! Take the 2026 Go Developer Survey

types

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheTypeRerunAll                          = 1
	CacheTypeReuseExistingNode                 = 2
	CacheTypeReuseWhenScriptUnchanged          = 3
	CacheTypeReuseWhenScriptAndParamsUnchanged = 4
)
View Source
const (
	// AnalysisStatusRunning 表示分析已被某个调度器接管并正在推进,是恢复扫描的入口状态。
	AnalysisStatusRunning = "running"
	// AnalysisStatusStopping 表示已收到停止请求,等待所属调度器收敛到终态。
	AnalysisStatusStopping = "stopping"
	// AnalysisStatusStopped 是用户停止后的终态。
	AnalysisStatusStopped = "stopped"
	// AnalysisStatusFinished 是正常跑完的终态。
	AnalysisStatusFinished = "finished"
	// AnalysisStatusFailed 是异常终止的终态。
	AnalysisStatusFailed = "failed"
)

analysis.job_status 取值。所有调度器(legacy dag_v1 / node_v1 / dynamic_v2 / dataflow_v3)共用同一套状态字符串,避免各 orchestrator 各自维护一份常量, 导致统一恢复入口在判断 running / stopping 时出现不一致。

View Source
const (
	// SchedulerModeDag 是静态图调度器(internal/dag/scheduler/dag)。
	// 历史空值 / dag_v1 / node_v1 都归一到此。
	SchedulerModeDag = "dag"
	// SchedulerModeDynamic 是动态物化调度器(internal/dag/scheduler/dynamic)。
	SchedulerModeDynamic = "dynamic"
	// SchedulerModeDataflow 是数据流调度器(internal/dag/scheduler/dataflow)。
	SchedulerModeDataflow = "dataflow"
)

analysis.scheduler_mode 取值,标识推进该分析的调度器,同时是 dag/scheduler.Registry 的查找键。名称直接对应具体实现,不再带 V1/V2/V3 后缀。

View Source
const (
	PullPolicyAlways       = "Always"
	PullPolicyIfNotPresent = "IfNotPresent"
	PullPolicyNever        = "Never"
)
View Source
const (
	LiteratureContentSourceFile     = "file"
	LiteratureContentSourceDatabase = "database"
)

Literature content source values.

View Source
const DefaultLiteratureFilename = "fulltext.md"

DefaultLiteratureFilename is the default full-text file name stored under the project literature directory.

View Source
const DefaultProjectReportFilename = "output.md"

DefaultProjectReportFilename 是项目报告工作目录下约定的输出文件名。 它仍然被 LLM 运行时(projectReport 环境)用来定位报告输出文件。

Variables

View Source
var (
	// Container 已经停止
	ErrContainerAlreadyStopped = errors.New("container already stopped")
)

Functions

func EncodeArticleCursor

func EncodeArticleCursor(c ArticleCursor) string

EncodeArticleCursor encodes an article cursor to an opaque string.

func NormalizeSchedulerMode added in v0.1.4

func NormalizeSchedulerMode(mode string) string

NormalizeSchedulerMode 把持久化的 scheduler_mode 归一化为当前规范名。

历史值(空值 / dag_v1 / dynamic_v2 / dataflow_v3 / node_v1)会被折叠到当前 名称,保证旧数据仍能解析到正确的调度器;未知值一律回退到默认的静态图调度器。

Types

type AISummary added in v0.1.2

type AISummary struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	// OwnerID 摘要所属对象的 ID,主要为 Analysis.ID 或 AnalysisNode.ID。
	OwnerID int64 `json:"owner_id,string" gorm:"column:owner_id;type:bigint;index:idx_ai_summaries_owner"`
	// OwnerType 摘要所属对象的类型:analysis 或 analysis_node。
	OwnerType SummaryOwnerType `json:"owner_type" gorm:"column:owner_type;type:varchar(32);index:idx_ai_summaries_owner"`
	// ProjectID 摘要所属项目 ID(t_project.id),创建时由创建者的激活项目推导。
	ProjectID int64  `json:"project_id,string" gorm:"column:project_id;type:bigint;index:idx_ai_summaries_project"`
	Title     string `json:"title" gorm:"column:title;type:varchar(255)"`
	// Content AI 生成的摘要内容。
	Content string `json:"content" gorm:"column:content;type:longtext"`
	// Status 生成状态:生成中 / 生成成功 / 生成失败。
	Status SummaryStatus `json:"status" gorm:"column:status;type:varchar(32);default:generating"`
	// ProfileID 生成该摘要使用的 Agent Profile ID(agent_profiles.id),用于按 ID 解析 Profile。
	// 为 0 时由 AISummaryWorker 回退到内置 summary Profile。
	ProfileID int64 `json:"profile_id,string" gorm:"column:profile_id;type:bigint;index"`
	// Profile 生成该摘要使用的 Agent Profile 展示名(仅用于展示,不参与查询;
	// 为空表示使用内置 summary Profile)。
	Profile string `json:"profile" gorm:"column:profile;type:varchar(64)"`
	// TaskID 生成该摘要的 Agent 任务 ID(agent_tasks 表)。
	TaskID int64 `json:"task_id,string" gorm:"column:task_id;type:bigint;index"`

	CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"`

	// Prefix 是摘要所属对象输出目录对应的 /data-analysis URL 前缀,便于前端拼接
	// 该输出目录下结果文件的访问地址。非持久化字段,查询时按需填充
	// (见 aiSummaryService.ListAISummariesByOwner)。
	Prefix string `json:"prefix" gorm:"-"`
}

AISummary 存储 AI 为 Analysis 或 AnalysisNode 的 output 内容生成的摘要。

func (*AISummary) BeforeCreate added in v0.1.2

func (t *AISummary) BeforeCreate(_ *gorm.DB) error

func (AISummary) TableName added in v0.1.2

func (AISummary) TableName() string

type AISummaryGeneratePayload added in v0.1.2

type AISummaryGeneratePayload struct {
	SummaryID int64 `json:"summary_id,string"`
}

AISummaryGeneratePayload 是 AISummary 生成请求的 outbox 事件载荷。

type AISummaryInput added in v0.1.2

type AISummaryInput struct {
	// Title 是摘要标题的候选值。
	Title string `json:"title"`
	// ProfileName 是生成该摘要使用的 AgentProfile 展示名(取自摘要记录,为空回退内置 summary Profile)。
	ProfileName string `json:"profile,omitempty"`
	ProfileID   int64  `json:"profile_id,omitempty,string"`
	// SystemPrompt 是用 Profile 模板 + Vars 渲染后的真实系统提示词。
	SystemPrompt string `json:"system_prompt,omitempty"`
	// Vars 是渲染系统提示词模板所用的变量(业务上下文)。
	Vars map[string]any `json:"vars,omitempty"`
	// WorkingDir 是 Agent 执行任务时的工作目录。
	WorkingDir string `json:"working_dir"`
}

AISummaryInput 是生成摘要时交给 LLM 的输入信息,用于前端展示。

type AISummaryStatusEvent added in v0.1.2

type AISummaryStatusEvent struct {
	SummaryID int64            `json:"summary_id,string"`
	OwnerType SummaryOwnerType `json:"owner_type"`
	OwnerID   int64            `json:"owner_id,string"`
	Status    SummaryStatus    `json:"status"`
}

AISummaryStatusEvent 在 AI 摘要状态发生变更时发布到事件总线。

type AddFileToDatasetRequest

type AddFileToDatasetRequest struct {
	DatasetID      int64  `json:"dataset_id,string" binding:"required"`
	ProjectID      string `json:"-"`
	AnalysisNodeID int64  `json:"analysis_node_id,string,omitempty"` // optional, if provided, the file will be linked to the analysis node
	Path           string `json:"path" binding:"required"`
	Role           string `json:"role"`
	FileName       string `json:"file_name" gorm:"type:varchar(255)"`
	IsCopy         bool   `json:"is_copy"`   // if true, copy the file to the dataset, otherwise just link it
	IsPrefix       bool   `json:"is_prefix"` // if true, the path is a prefix, and all files under the prefix will be added to the dataset
	// data analysis external
	Source string `json:"source"`
}

type AddFileToDatasetResponse

type AddFileToDatasetResponse struct {
	File        *File        `json:"file"`
	DatasetFile *DatasetFile `json:"dataset_file"`
}

type AgentProfileInfo added in v0.1.5

type AgentProfileInfo struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Model       string `json:"model,omitempty"`
	Provider    string `json:"provider,omitempty"`
	IsDefault   bool   `json:"is_default"`
	IsBuiltin   bool   `json:"is_builtin"`
}

AgentProfileInfo 是随用户信息返回的 Agent Profile 摘要(DTO)。

只暴露前端展示 / 选择所需的字段;Profile 的完整内容(系统提示词、技能等) 仍通过 /agent/profile 接口按 ID 获取。

func NewAgentProfileInfo added in v0.1.5

func NewAgentProfileInfo(p *agent.Profile) *AgentProfileInfo

NewAgentProfileInfo 由 agent.Profile 构造展示用 DTO;p 为空时返回 nil。

type Analysis

type Analysis struct {
	// ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`
	// ProjectID   string `json:"project" gorm:"column:project;type:varchar(255)"`
	ProjectID   int64  `json:"project_id,string" gorm:"column:project_id;type:bigint"`
	AnalysisID  string `json:"analysis_id" gorm:"column:analysis_id;type:varchar(255)"`
	ComponentID string `json:"component_id" gorm:"column:component_id;type:varchar(255)"`
	// WorkflowID 是工作流主键(pipeline_components_relation.id),不再是 relation_id UUID。
	// 列名 workflow_id(历史列名为 relation_id,迁移见 migrations/2026-09-21-analysis-workflow-id)。
	WorkflowID int64 `json:"workflow_id,string" gorm:"column:workflow_id;type:bigint;index:idx_nextflow_workflow_id"`
	// AnalysisType        string    `json:"analysis_type" gorm:"column:analysis_type;type:varchar(255)"`
	AnalysisName   string `json:"analysis_name" gorm:"column:analysis_name;type:varchar(255)"`
	InputFile      string `json:"input_file" gorm:"column:input_file;type:varchar(255)"`
	AnalysisMethod string `json:"analysis_method" gorm:"column:analysis_method;type:varchar(255)"`
	// WorkspaceDir 是本次分析的根目录。落库时相对 storage.base_dir 存储,
	// 读取时由 repository 还原成绝对路径,因此 base_dir 变更只需拷贝目录,
	// 无需回写数据库。其余路径全部由它派生(见下方 gorm:"-" 字段)。
	WorkspaceDir        string `json:"workspace_dir" gorm:"column:workspace_dir;type:varchar(255)"`
	RequestParam        string `json:"request_param" gorm:"column:request_param;type:longtext"`
	OutputFormat        string `json:"output_format" gorm:"column:output_format;type:longtext"`
	PipelineScript      string `json:"pipeline_script" gorm:"column:pipeline_script;type:varchar(255)"`
	ParseAnalysisModule string `json:"parse_analysis_module" gorm:"column:parse_analysis_module;type:varchar(255)"`
	ProcessID           string `json:"process_id" gorm:"column:process_id;type:varchar(255)"`
	ScriptConfigFile    string `json:"script_config_file" gorm:"column:script_config_file;type:varchar(255)"`
	JobID               string `json:"job_id" gorm:"column:job_id;type:varchar(255)"`
	Ports               string `json:"ports" gorm:"column:ports;type:varchar(255)"`
	URL                 string `json:"url" gorm:"column:url;type:varchar(255)"`
	JobStatus           string `json:"job_status" gorm:"column:job_status;type:varchar(255)"`
	// ServerStatus        string `json:"server_status" gorm:"column:server_status;type:varchar(255)"`
	// SchedulerMode 记录推进本次分析的调度器,用于进程重启后把分析交回正确的调度器恢复。
	// 历史数据该列为空,按 legacy DAG 调度器处理(见 NormalizeSchedulerMode)。
	SchedulerMode    string    `json:"scheduler_mode" gorm:"column:scheduler_mode;type:varchar(64);default:''"`
	IsReport         bool      `json:"is_report" gorm:"column:is_report;default:false"`
	CacheType        int       `json:"cache_type" gorm:"column:cache_type;default:1"`
	Used             bool      `json:"used" gorm:"column:used;default:true"`
	DataComponentIDs string    `json:"data_component_ids" gorm:"column:data_component_ids;type:text"`
	ExtraProjectIDs  string    `json:"extra_project_ids" gorm:"column:extra_project_ids;type:longtext"`
	CreatedAt        time.Time `json:"created_at" gorm:"column:created_at"`
	UpdatedAt        time.Time `json:"updated_at" gorm:"column:updated_at"`

	// 以下是 WorkspaceDir 的派生路径,一律不落库(gorm:"-")。
	// repository 在读取时通过 HydrateDerivedPaths 填充,保证磁盘布局只有一处定义。
	ParamsPath      string `json:"params_path" gorm:"-"`
	CommandPath     string `json:"command_path" gorm:"-"`
	CommandLogPath  string `json:"command_log_path" gorm:"-"`
	TraceFile       string `json:"trace_file" gorm:"-"`
	WorkflowLogFile string `json:"workflow_log_file" gorm:"-"`
	ExecutorLogFile string `json:"executor_log_file" gorm:"-"`
}

Analysis maps to Python brave's nextflow table.

func (*Analysis) BeforeCreate

func (t *Analysis) BeforeCreate(_ *gorm.DB) error

func (*Analysis) HydrateDerivedPaths added in v0.1.4

func (t *Analysis) HydrateDerivedPaths()

HydrateDerivedPaths 从 WorkspaceDir 推导出全部派生路径。 WorkspaceDir 为空时派生路径全部为空,避免产生悬空的文件名。

func (Analysis) TableName

func (Analysis) TableName() string

type AnalysisControllerSaveInput

type AnalysisControllerSaveInput struct {
	RequestParam        map[string]any
	ParseAnalysisResult map[string]any
	DagRuntime          map[string]any
	Project             *Project
	IsRunNode           bool
	IsReport            bool
	// SchedulerMode 由各控制入口显式声明,标识谁来推进这次分析。
	// 为空时保持库中原值不变(更新路径)或按 legacy 处理(新建路径)。
	SchedulerMode string
}

type AnalysisEdge

type AnalysisEdge struct {
	ID             uint   `json:"id" gorm:"primaryKey;autoIncrement"`
	AnalysisEdgeID string `json:"analysis_edge_id" gorm:"column:analysis_edge_id;type:varchar(255)"`
	// AnalysisID     string `json:"analysis_id" gorm:"column:analysis_id;type:varchar(255);index:idx_analysis_edges_analysis_id"`
	AnalysisID int64 `json:"analysis_id,string" gorm:"column:analysis_id;type:bigint"`

	SourceNode   string    `json:"source_node" gorm:"column:source_node;type:varchar(255)"`
	TargetNode   string    `json:"target_node" gorm:"column:target_node;type:varchar(255)"`
	SourceHandle string    `json:"source_handle" gorm:"column:source_handle;type:varchar(255)"`
	TargetHandle string    `json:"target_handle" gorm:"column:target_handle;type:varchar(255)"`
	CreatedAt    time.Time `json:"created_at" gorm:"column:created_at"`
	UpdatedAt    time.Time `json:"updated_at" gorm:"column:updated_at"`
}

AnalysisEdge maps to Python brave's analysis_edges table.

func (AnalysisEdge) TableName

func (AnalysisEdge) TableName() string

type AnalysisNode

type AnalysisNode struct {
	// ID                     uint       `json:"id" gorm:"primaryKey;autoIncrement"`
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	AnalysisNodeID string `json:"analysis_node_id" gorm:"column:analysis_node_id;type:varchar(255)"`
	// ProjectID      string `json:"project_id" gorm:"column:project_id;type:varchar(255);index:idx_analysis_nodes_project_id"`
	ProjectID int64 `json:"project_id,string" gorm:"column:project_id;type:bigint"`
	// AnalysisID string `json:"analysis_id" gorm:"column:analysis_id;type:varchar(255);index:idx_analysis_nodes_analysis_id;index:idx_analysis_nodes_analysis_id_status,priority:1;index:idx_analysis_nodes_analysis_id_node_id,priority:1"`
	AnalysisID int64  `json:"analysis_id,string" gorm:"column:analysis_id;type:bigint"`
	NodeID     string `json:"node_id" gorm:"column:node_id;type:varchar(255);index:idx_analysis_nodes_analysis_id_node_id,priority:2"`
	NodeName   string `json:"node_name" gorm:"column:node_name;type:varchar(255)"`
	SampleID   string `json:"sample_id" gorm:"column:sample_id;type:varchar(255)"`
	// ScriptID       string `json:"script_id" gorm:"column:script_id;type:varchar(255)"`
	ScriptID               int64     `json:"script_id,string" gorm:"column:script_id;type:bigint"`
	InputsPatterns         JSONMap   `json:"inputs_patterns" gorm:"column:inputs_patterns;type:json"`
	ResolvedInputs         JSONMap   `json:"resolved_inputs" gorm:"column:resolved_inputs;type:json"`
	OutputPatterns         JSONMap   `json:"output_patterns" gorm:"column:output_patterns;type:json"`
	ResolvedOutputs        JSONMap   `json:"resolved_outputs" gorm:"column:resolved_outputs;type:json"`
	OutputFileIDs          JSONMap   `json:"output_file_ids" gorm:"column:output_file_ids;type:json"` // 输出句柄 -> go_file id,供下游 SelectAssay 输入还原为 {"files": "<id>"}
	RequestParam           string    `json:"request_param" gorm:"column:request_param;type:longtext"`
	CPU                    int       `json:"cpu" gorm:"column:cpu"`
	Memory                 string    `json:"memory" gorm:"column:memory;type:varchar(64)"`
	Disk                   string    `json:"disk" gorm:"column:disk;type:varchar(64)"`
	GPU                    int       `json:"gpu" gorm:"column:gpu"`
	Status                 string    `json:"status" gorm:"column:status;type:varchar(64);index:idx_analysis_nodes_analysis_id_status,priority:2"`
	ServerStatus           string    `json:"server_status" gorm:"column:server_status;type:varchar(64)"`
	PID                    int       `json:"pid" gorm:"column:pid"`
	JobID                  string    `json:"job_id" gorm:"column:job_id;type:varchar(255)"`
	Executor               string    `json:"executor" gorm:"column:executor;type:varchar(64)"`
	Retry                  int       `json:"retry" gorm:"column:retry;default:0"`
	MaxRetry               int       `json:"max_retry" gorm:"column:max_retry;default:3"`
	ExitCode               int       `json:"exit_code" gorm:"column:exit_code"`
	ErrorMessage           string    `json:"error_message" gorm:"column:error_message;type:text"`
	RerunReason            string    `json:"rerun_reason" gorm:"column:rerun_reason;type:text"`
	InputHash              string    `json:"input_hash" gorm:"column:input_hash;type:varchar(255)"`
	CacheHit               bool      `json:"cache_hit" gorm:"column:cache_hit"`
	UpstreamIDs            JSONSlice `json:"upstream_ids" gorm:"column:upstream_ids;type:json"`
	DownstreamIDs          JSONSlice `json:"downstream_ids" gorm:"column:downstream_ids;type:json"`
	InputValidationErrors  JSONSlice `json:"input_validation_errors" gorm:"column:input_validation_errors;type:json"`
	OutputValidationErrors JSONSlice `json:"output_validation_errors" gorm:"column:output_validation_errors;type:json"`
	// WorkspaceDir 是节点根目录。落库时相对 storage.base_dir 存储,
	// 读取时由 repository 还原成绝对路径。其余路径全部由它派生。
	WorkspaceDir   string     `json:"workspace_dir" gorm:"column:workspace_dir;type:varchar(255)"`
	CommandMD5     string     `json:"command_md5" gorm:"column:command_md5;type:varchar(64)"`
	ParamsMD5      string     `json:"params_md5" gorm:"column:params_md5;type:varchar(64)"`
	CreationSource string     `json:"creation_source" gorm:"column:creation_source;type:varchar(32)"`
	StartedAt      *time.Time `json:"started_at" gorm:"column:started_at"`
	FinishedAt     *time.Time `json:"finished_at" gorm:"column:finished_at"`
	CreatedAt      time.Time  `json:"created_at" gorm:"column:created_at"`
	UpdatedAt      time.Time  `json:"updated_at" gorm:"column:updated_at"`

	// 以下是 WorkspaceDir 的派生路径,一律不落库(gorm:"-")。
	// repository 在读取时通过 HydrateDerivedPaths 填充。
	LogPath     string `json:"log_path" gorm:"-"`
	OutputDir   string `json:"output_dir" gorm:"-"`
	CacheDir    string `json:"cache_dir" gorm:"-"`
	CommandPath string `json:"command_path" gorm:"-"`
	ParamsPath  string `json:"params_path" gorm:"-"`
}

AnalysisNode maps to Python brave's analysis_nodes table.

func (*AnalysisNode) BeforeCreate

func (t *AnalysisNode) BeforeCreate(_ *gorm.DB) error

func (*AnalysisNode) HydrateDerivedPaths added in v0.1.4

func (t *AnalysisNode) HydrateDerivedPaths()

HydrateDerivedPaths 从 WorkspaceDir 推导出全部派生路径。 WorkspaceDir 为空时派生路径全部为空,避免产生悬空的文件名。

func (AnalysisNode) TableName

func (AnalysisNode) TableName() string

type AnalysisQuery

type AnalysisQuery = AnalysisQuey

AnalysisQuery is an alias of AnalysisQuey for clearer naming in new code.

type AnalysisQuey

type AnalysisQuey struct {
	IDs []int64 `json:"ids,omitempty"`

	ID *int64 `json:"id,string,omitempty"`

	ProjectID int64 `json:"project_id,string,omitempty"`

	AnalysisID string `json:"analysis_id,omitempty"`

	AnalysisName string `json:"analysis_name,omitempty"`

	// WorkflowID 过滤条件,取值是工作流主键(pipeline_components_relation.id)。
	WorkflowID int64 `json:"workflow_id,string,omitempty"`

	JobStatus string `json:"job_status,omitempty"`

	ServerStatus string `json:"server_status,omitempty"`

	IsReport *bool `json:"is_report,omitempty"`

	CacheType *int `json:"cache_type,omitempty"`

	SortBy string `json:"sort_by,omitempty"`

	SortOrder string `json:"sort_order,omitempty"`
}

AnalysisQuey defines optional filters and sorting for analysis pagination. Keep the type name for compatibility with existing callers.

func (*AnalysisQuey) GetAnalysisID

func (q *AnalysisQuey) GetAnalysisID() string

func (*AnalysisQuey) GetAnalysisName

func (q *AnalysisQuey) GetAnalysisName() string

func (*AnalysisQuey) GetJobStatus

func (q *AnalysisQuey) GetJobStatus() string

func (*AnalysisQuey) GetServerStatus

func (q *AnalysisQuey) GetServerStatus() string

func (*AnalysisQuey) GetSortColumn

func (q *AnalysisQuey) GetSortColumn() string

func (*AnalysisQuey) GetSortOrder

func (q *AnalysisQuey) GetSortOrder() string

func (*AnalysisQuey) GetWorkflowID

func (q *AnalysisQuey) GetWorkflowID() int64

type AppSession

type AppSession struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	UserID    string `json:"user_id" gorm:"type:varchar(36);index;not null"`
	ProjectID int64  `json:"project_id,string" gorm:"column:project_id;type:bigint"`

	AnalysisNodeID int64 `json:"analysis_node_id,string" gorm:"index"`

	ContainerTemplateID int64 `json:"container_template_id,string" gorm:"index;not null"`

	Name string `json:"name" gorm:"type:varchar(255);not null"`

	Status string `json:"status" gorm:"type:varchar(32);index;not null;default:PENDING"`

	WorkspacePath string `json:"workspace_path" gorm:"type:varchar(1024)"`

	LastAccessAt *time.Time `json:"last_access_at"`

	StartedAt *time.Time `json:"started_at"`

	StoppedAt *time.Time `json:"stopped_at"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

AppSession 的状态机 PENDING

↓

CREATING

↓

RUNNING

↓

STOPPED

↓

RESUMING

↓

FAILED

func (*AppSession) BeforeCreate

func (t *AppSession) BeforeCreate(_ *gorm.DB) error

func (AppSession) TableName

func (AppSession) TableName() string

type AppSessionPageQuery

type AppSessionPageQuery struct {
	AnalysisNodeID *int64 `json:"analysis_node_id,string,omitempty"`
	ProjectID      *int64 `json:"project_id,omitempty"`
}

type ArticleCursor

type ArticleCursor struct {
	SortBy string `json:"sort_by"`
	// Value stores the current sort field's value as string.
	Value string `json:"value"`
	// ID is the tiebreaker for stable ordering.
	ID int64 `json:"id"`
}

ArticleCursor is the cursor payload for article pagination. It uses sort_by + value + id to build a stable ordering cursor.

func DecodeArticleCursor

func DecodeArticleCursor(cursor string) (ArticleCursor, error)

DecodeArticleCursor decodes an opaque cursor string.

type Assay added in v0.1.5

type Assay struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	// SampleName 是样本的业务编号兼展示名(列 go_assay.sample_name),例如
	// S-001 / 脾脏-6。无需全局唯一,只在同一个 dataset 下唯一(经
	// go_dataset_assay 绑定判定);同一个名字可以出现在不同 dataset。
	SampleName string `json:"sample_name" gorm:"type:varchar(255);index;not null"`

	AssayType string `json:"assay_type" gorm:"type:varchar(64);index"`

	Platform string `json:"platform" gorm:"type:varchar(128)"`

	LibraryID string `json:"library_id" gorm:"type:varchar(255)"`

	// Role 是该 assay 的角色(列 go_assay.role),例如 DEFAULT / TABLE;
	// input_type=assay 的表单输入用 resolver.accept_formats 与之匹配(与
	// go_file.role 对文件的口径一致)。空表示不参与角色过滤。
	Role string `json:"role" gorm:"type:varchar(64);index"`

	Metadata string `json:"metadata" gorm:"type:text"`

	Description string `json:"description" gorm:"type:text"`

	CreatedAt time.Time `json:"created_at"`

	UpdatedAt time.Time `json:"updated_at"`
}

Assay 是一次实验/测序建库记录,直接隶属于某个 Dataset(Dataset -> DatasetAssay -> Assay -> File)。其下文件(go_file.assay_id)是 assay 私有的,不跨 assay 复用。

func (*Assay) BeforeCreate added in v0.1.5

func (t *Assay) BeforeCreate(_ *gorm.DB) error

func (Assay) TableName added in v0.1.5

func (Assay) TableName() string

type AssayWithDatasetInfo added in v0.1.5

type AssayWithDatasetInfo struct {
	ID int64 `json:"id,string"`

	SampleName string `json:"sample_name"`

	AssayType string `json:"assay_type"`

	Platform string `json:"platform"`

	LibraryID string `json:"library_id"`

	// Role 是该 assay 的角色(go_assay.role),例如 DEFAULT / TABLE;
	// input_type=assay 的表单输入用 resolver.accept_formats 与之匹配,
	// resolveFormAnalysisResult 据此把 assay 分组挂到 analysis_result[role]。
	Role string `json:"role"`

	Metadata string `json:"metadata"`

	Description string `json:"description"`

	CreatedAt time.Time `json:"created_at"`

	UpdatedAt time.Time `json:"updated_at"`

	DatasetID string `json:"dataset_id"`

	DatasetName string `json:"dataset_name"`
}

AssayWithDatasetInfo is the read model of an Assay joined with the dataset it is bound to through go_dataset_assay, used by the project-wide assay queries. The assay itself carries its SampleName, so no sample join is needed.

type AuthToken

type AuthToken struct {
	// Unique identifier of the token
	ID string `json:"id"         gorm:"type:varchar(36);primaryKey"`
	// User ID that owns this token
	UserID string `json:"user_id"    gorm:"type:varchar(36);index;not null"`
	// Token value (JWT or other format)
	Token string `json:"token"      gorm:"type:text;not null"`
	// Token type (access_token, refresh_token)
	TokenType string `json:"token_type" gorm:"type:varchar(50);not null"`
	// Token expiration time
	ExpiresAt time.Time `json:"expires_at"`
	// Whether the token is revoked
	IsRevoked bool `json:"is_revoked" gorm:"default:false"`
	// Creation time of the token
	CreatedAt time.Time `json:"created_at"`
	// Last updated time of the token
	UpdatedAt time.Time `json:"updated_at"`

	// Association relationship
	User *User `json:"user,omitempty" gorm:"foreignKey:UserID"`
}

AuthToken represents an authentication token

type ContainerEvent

type ContainerEvent struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	ContainerInstanceID int64 `json:"container_instance_id,string" gorm:"index;not null"`

	Event string `json:"event" gorm:"type:varchar(64);index;not null"`

	Message string `json:"message" gorm:"type:text"`

	CreatedAt time.Time `json:"created_at"`
}

func (*ContainerEvent) BeforeCreate

func (t *ContainerEvent) BeforeCreate(_ *gorm.DB) error

func (ContainerEvent) TableName

func (ContainerEvent) TableName() string

type ContainerImage

type ContainerImage struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	Name string `json:"name" gorm:"type:varchar(255);not null;index"`

	FullName string `json:"full_name" gorm:"type:varchar(512);not null"`

	Description string `json:"description" gorm:"type:text"`

	Size int64 `json:"size"`

	PullPolicy string `json:"pull_policy" gorm:"type:varchar(32);index;not null;default:IfNotPresent"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*ContainerImage) BeforeCreate

func (t *ContainerImage) BeforeCreate(_ *gorm.DB) error

func (ContainerImage) TableName

func (ContainerImage) TableName() string

func (*ContainerImage) ToExport added in v0.1.4

func (t *ContainerImage) ToExport() *ContainerImageExport

type ContainerImageExport added in v0.1.4

type ContainerImageExport struct {
	ID          int64  `json:"id,string"`
	Name        string `json:"name"`
	FullName    string `json:"full_name"`
	Description string `json:"description"`
	Size        int64  `json:"size"`
	PullPolicy  string `json:"pull_policy"`
}

ContainerImageExport 是 ContainerImage 的导出结构,包含 ID,不含时间字段。

type ContainerImageItem added in v0.1.4

type ContainerImageItem struct {
	*ContainerImage
	Usage *ContainerImageUsage `json:"usage,omitempty"`
}

ContainerImageItem 是镜像目录的对外读模型:嵌入镜像本体(JSON 平铺,字段不变)+ 绑定引用信息。

type ContainerImageRef added in v0.1.4

type ContainerImageRef struct {
	DefinitionID int64  `json:"definition_id,string"`
	SpecID       int64  `json:"spec_id,string"`
	TemplateName string `json:"template_name"`
}

ContainerImageRef 描述一个镜像被哪一个可运行模板(配置 × 镜像 绑定行)引用。

type ContainerImageUsage added in v0.1.4

type ContainerImageUsage struct {
	ImageID   int64               `json:"image_id,string"`
	RefCount  int                 `json:"ref_count"`
	Templates []ContainerImageRef `json:"templates"`
}

ContainerImageUsage 是镜像的绑定引用情况。镜像目录仍可增删改, 但只要还被绑定行引用就不允许删除,避免模板的 image_id 变成空引用。

type ContainerInstance

type ContainerInstance struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	TemplateID int64 `json:"template_id,string" gorm:"index;not null"`

	OwnerType ContainerOwnerType `json:"owner_type" gorm:"type:varchar(30);index;not null"`

	OwnerID int64 `json:"owner_id,string" gorm:"index;not null"`

	RuntimeName string `json:"runtime_name" gorm:"type:varchar(255);index;not null"`

	RuntimeID string `json:"runtime_id" gorm:"type:varchar(255);index"`

	Name string `json:"name" gorm:"type:varchar(255);not null;index"`

	Status ContainerStatus `json:"status" gorm:"type:varchar(30);index;not null;default:pending"`

	IPAddress       string `json:"ip_address" gorm:"type:varchar(128)"`
	RuntimeNodeName string `json:"runtime_node_name" gorm:"type:varchar(255);index"`

	ExitCode *int `json:"exit_code"`

	StartedAt *time.Time `json:"started_at"`

	FinishedAt *time.Time `json:"finished_at"`

	CreatedAt time.Time `json:"created_at"`

	UpdatedAt time.Time `json:"updated_at"`
}

func (*ContainerInstance) BeforeCreate

func (t *ContainerInstance) BeforeCreate(_ *gorm.DB) error

func (ContainerInstance) TableName

func (ContainerInstance) TableName() string

type ContainerOwnerType

type ContainerOwnerType string
const (
	ContainerOwnerDagNode    ContainerOwnerType = "dag_node"
	ContainerOwnerAppSession ContainerOwnerType = "app_session"
	ContainerOwnerService    ContainerOwnerType = "service"
)

type ContainerSchedulingConstraint

type ContainerSchedulingConstraint struct {
	Type     string   `json:"type"`
	Key      string   `json:"key"`
	Operator string   `json:"operator"`
	Values   []string `json:"values,omitempty"`
}

type ContainerSchedulingSelector

type ContainerSchedulingSelector struct {
	Constraints []ContainerSchedulingConstraint `json:"constraints"`
}

type ContainerSpec

type ContainerSpec struct {
	Image                string
	Entrypoint           []string
	Command              []string
	Env                  map[string]string
	Volumes              []ContainerVolume
	SupplementalGroups   []int64
	SchedulingConstraint *ContainerSchedulingSelector
	User                 string
	Labels               map[string]string

	// PullPolicy 来自镜像目录(ContainerImage.PullPolicy),取值 Always / IfNotPresent / Never,
	// 空值按 IfNotPresent 处理。落地方式由 runtime 决定:
	// docker 没有 imagePullPolicy 概念,在 create 前按策略决定是否 pull;
	// kubernetes 直接映射为 container.imagePullPolicy。
	PullPolicy string

	CPU    float64
	Memory int64

	WorkDir          string
	RuntimeName      string
	RuntimeNamespace string
	WorkloadKind     string
	ExposedPort      int
	ExposeService    bool
}

type ContainerStatus

type ContainerStatus string
const (
	ContainerCreatePending   ContainerStatus = "create_pending"
	ContainerReCreatePending ContainerStatus = "recreate_pending"
	ContainerReCreating      ContainerStatus = "recreating"
	ContainerCreating        ContainerStatus = "creating"
	ContainerRunning         ContainerStatus = "running"
	ContainerPaused          ContainerStatus = "paused"
	ContainerStopPending     ContainerStatus = "stop_pending"
	ContainerStopping        ContainerStatus = "stopping"
	ContainerStartPending    ContainerStatus = "start_pending"
	ContainerStarting        ContainerStatus = "starting"
	ContainerStopped         ContainerStatus = "stopped"
	ContainerDeleted         ContainerStatus = "deleted"
	ContainerFailed          ContainerStatus = "failed"
	ContainerExited          ContainerStatus = "exited"
	ContainerDeletePending   ContainerStatus = "delete_pending"
	ContainerDeleting        ContainerStatus = "deleting"
)

type ContainerTemplate

type ContainerTemplate struct {
	ID      int64 `json:"id,string"`
	SpecID  int64 `json:"spec_id,string"`
	ImageID int64 `json:"image_id,string"`

	Name        string          `json:"name"`
	Description string          `json:"description"`
	Image       *ContainerImage `json:"image,omitempty"`

	Command string  `json:"command"`
	CPU     float64 `json:"cpu"`
	Memory  int64   `json:"memory"`

	WorkDir string `json:"work_dir"`
	Port    int    `json:"port"`
	AppType string `json:"app_type"`

	Env                  datatypes.JSON `json:"env"`
	Mounts               datatypes.JSON `json:"mounts"`
	SchedulingConstraint datatypes.JSON `json:"scheduling_constraint"`
	Labels               datatypes.JSON `json:"labels"`
	ChangeUID            bool           `json:"change_uid"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

ContainerTemplate 不是持久化对象,由 repo 层 JOIN go_container_template_definition + go_container_template_spec + go_container_image 组装返回。 ID == ContainerTemplateDefinition.ID:引用方(script.container_template_id / app_session.container_template_id / container_instance.template_id)语义不变, 同时天然锁定了该模板要使用的镜像。

func NewContainerTemplate added in v0.1.4

func NewContainerTemplate(spec *ContainerTemplateSpec, binding *ContainerTemplateDefinition, image *ContainerImage) *ContainerTemplate

NewContainerTemplate 把共享配置、绑定行与镜像组装成对外读模型。spec/image 允许为 nil: 分别表示只取绑定行字段 / 未加载镜像详情。binding 为 nil 时返回 nil。

func (*ContainerTemplate) ToExport added in v0.1.4

type ContainerTemplateDefinition added in v0.1.4

type ContainerTemplateDefinition struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	SpecID  int64 `json:"spec_id,string" gorm:"uniqueIndex:uk_template_spec_image,priority:1;not null"`
	ImageID int64 `json:"image_id,string" gorm:"uniqueIndex:uk_template_spec_image,priority:2;not null"`

	// DisplayName 为空时,对外名称回退到 ContainerTemplateConfig.Name。
	DisplayName string `json:"display_name" gorm:"type:varchar(255)"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

ContainerTemplateDefinition 一行即"一个可直接运行的容器模板":共享配置 + 一个具体镜像。 由于每行本身就唯一确定了一个可运行配置,不需要 is_default / sort_order 之类的标记: 同一 SpecID 可绑定多个镜像,同一 ImageID 也可被多个配置绑定(多对多), 且同一 (SpecID, ImageID) 组合唯一。 注意:该表主键 ID 就是对外暴露的 ContainerTemplate.ID。

func (*ContainerTemplateDefinition) BeforeCreate added in v0.1.4

func (t *ContainerTemplateDefinition) BeforeCreate(_ *gorm.DB) error

func (ContainerTemplateDefinition) TableName added in v0.1.4

func (ContainerTemplateDefinition) TableName() string

type ContainerTemplateExport added in v0.1.4

type ContainerTemplateExport struct {
	ID                   int64                 `json:"id,string"`
	Name                 string                `json:"name"`
	Description          string                `json:"description"`
	Image                *ContainerImageExport `json:"image"`
	Command              string                `json:"command"`
	CPU                  float64               `json:"cpu"`
	Memory               int64                 `json:"memory"`
	WorkDir              string                `json:"work_dir"`
	Port                 int                   `json:"port"`
	AppType              string                `json:"app_type"`
	Env                  datatypes.JSON        `json:"env"`
	Mounts               datatypes.JSON        `json:"mounts"`
	Volumes              datatypes.JSON        `json:"volumes"`
	SchedulingConstraint datatypes.JSON        `json:"scheduling_constraint"`
	Labels               datatypes.JSON        `json:"labels"`
	ChangeUID            bool                  `json:"change_uid"`
}

ContainerTemplateExport 是 ContainerTemplate 的导出结构,包含 ID,不含时间字段; ImageID 被转换为内嵌的 ContainerImageExport 对象。

type ContainerTemplateSpec added in v0.1.4

type ContainerTemplateSpec struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	Name        string `json:"name" gorm:"type:varchar(255);not null;index"`
	Description string `json:"description" gorm:"type:text"`

	Command string `json:"command" gorm:"type:text"`

	CPU    float64 `json:"cpu"`
	Memory int64   `json:"memory"`

	WorkDir string `json:"work_dir" gorm:"type:varchar(512)"`
	Port    int    `json:"port" gorm:"not null;default:8787"`
	AppType string `json:"app_type" gorm:"type:varchar(32);index"`

	Env                  datatypes.JSON `json:"env" gorm:"type:json"`
	Mounts               datatypes.JSON `json:"mounts" gorm:"type:json"`
	SchedulingConstraint datatypes.JSON `json:"scheduling_constraint" gorm:"type:json"`
	Labels               datatypes.JSON `json:"labels" gorm:"type:json"`
	ChangeUID            bool           `json:"change_uid" gorm:"default:false"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

ContainerTemplateSpec 只描述"怎么跑":命令、资源、端口、环境变量、挂载、标签等, 不包含镜像。镜像由 ContainerTemplateDefinition 关联,因此同一套运行配置可被多个镜像复用。

func (*ContainerTemplateSpec) BeforeCreate added in v0.1.4

func (t *ContainerTemplateSpec) BeforeCreate(_ *gorm.DB) error

func (ContainerTemplateSpec) TableName added in v0.1.4

func (ContainerTemplateSpec) TableName() string

type ContainerVolume

type ContainerVolume struct {
	Source string
	Target string
	Mode   string
	// Type 可选:值为 "file" 时源路径按文件创建,否则按目录创建。
	Type  string
	Owner string
}

type ContextKey

type ContextKey string

ContextKey defines a type for context keys to avoid string collision

const (
	// TenantIDContextKey is the context key for tenant ID
	TenantIDContextKey ContextKey = "TenantID"
	// TenantInfoContextKey is the context key for tenant information
	TenantInfoContextKey ContextKey = "TenantInfo"
	ReqContextKey        ContextKey = "RequestContext"
	// RequestIDContextKey is the context key for request ID
	RequestIDContextKey ContextKey = "RequestID"
	// LoggerContextKey is the context key for logger
	LoggerContextKey ContextKey = "Logger"
	// UserContextKey is the context key for user information
	UserContextKey ContextKey = "User"
	// UserIDContextKey is the context key for user ID
	UserIDContextKey ContextKey = "UserID"
	// SessionTenantIDContextKey is the context key for session owner's tenant ID.
	// When set (e.g. in pipeline with shared agent), session/message lookups use this instead of TenantIDContextKey.
	SessionTenantIDContextKey ContextKey = "SessionTenantID"
	// EmbedQueryContextKey is the context key for embedding query text
	EmbedQueryContextKey ContextKey = "EmbedQuery"
	// LanguageContextKey is the context key for user language preference (e.g. "zh-CN", "en-US")
	LanguageContextKey ContextKey = "Language"
	// LangfuseTraceContextKey carries the active Langfuse *Trace across the
	// request lifecycle. Defined here (not inside the langfuse package) so
	// that logger.CloneContext can preserve it without importing langfuse.
	LangfuseTraceContextKey ContextKey = "LangfuseTrace"
)

func (ContextKey) String

func (c ContextKey) String() string

String returns the string representation of the context key

type CreateDatasetRequest added in v0.1.4

type CreateDatasetRequest struct {
	DatasetName string `json:"dataset_name" binding:"required"`
	Description string `json:"description"`
	Metadata    string `json:"metadata"`
}

CreateDatasetRequest is the payload for creating a dataset. The primary key is generated by the application, callers only provide business fields.

func (*CreateDatasetRequest) ToDataset added in v0.1.4

func (r *CreateDatasetRequest) ToDataset() *Dataset

ToDataset converts the request into a Dataset entity. ID and audit fields are intentionally left zero so that BeforeCreate generates them.

type CursorPageResult

type CursorPageResult struct {
	Data       interface{} `json:"data"`
	PageSize   int         `json:"page_size"`
	NextCursor string      `json:"next_cursor,omitempty"`
	HasMore    bool        `json:"has_more"`
	SortBy     string      `json:"sort_by,omitempty"`
}

CursorPageResult represents cursor pagination result.

func NewCursorPageResult

func NewCursorPageResult(page *CursorPagination, data interface{}, nextCursor string, hasMore bool) *CursorPageResult

NewCursorPageResult creates a new cursor pagination result.

type CursorPagination

type CursorPagination struct {
	// Cursor for next page, empty means first page.
	Cursor string `form:"cursor" json:"cursor" binding:"omitempty"`
	// Sort field, for example: published_at, created_at, updated_at.
	SortBy string `form:"sort_by" json:"sort_by" binding:"omitempty"`
	// Page size.
	PageSize int `form:"page_size" json:"page_size" binding:"omitempty,min=1,max=1000"`
}

CursorPagination represents lazy-loading cursor pagination parameters.

func (*CursorPagination) GetPageSize

func (p *CursorPagination) GetPageSize() int

GetPageSize gets the page size, default is 20.

func (*CursorPagination) GetSortBy

func (p *CursorPagination) GetSortBy() string

GetSortBy gets the sort field, default is published_at.

type Dataset

type Dataset struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	DatasetName string `json:"dataset_name" gorm:"type:varchar(255)"`

	Description string `json:"description" gorm:"type:text"`

	Metadata string `json:"metadata" gorm:"type:text"`

	CreatedAt time.Time `json:"created_at"`

	UpdatedAt time.Time `json:"updated_at"`
}

func (*Dataset) BeforeCreate

func (t *Dataset) BeforeCreate(_ *gorm.DB) error

func (Dataset) TableName

func (Dataset) TableName() string

type DatasetAssay added in v0.1.5

type DatasetAssay struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	DatasetID int64 `json:"dataset_id,string" gorm:"index;not null"`

	AssayID int64 `json:"assay_id,string" gorm:"index;not null"`

	CreatedAt time.Time `json:"created_at"`
}

DatasetAssay is the join table binding an Assay into a Dataset (go_dataset_assay). A dataset binds directly to the Assay; the assay's files follow it (go_file.assay_id), so every project-scoped query joins go_dataset_assay -> go_assay to filter on dataset_id. The same assay can be bound to multiple datasets.

func (*DatasetAssay) BeforeCreate added in v0.1.5

func (t *DatasetAssay) BeforeCreate(_ *gorm.DB) error

func (DatasetAssay) TableName added in v0.1.5

func (DatasetAssay) TableName() string

type DatasetFile

type DatasetFile struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	DatasetID int64 `json:"dataset_id,string" gorm:"index;not null"`

	FileID int64 `json:"file_id,string" gorm:"index;not null"`

	CreatedAt time.Time `json:"created_at"`
}

DatasetFile is the pure join row binding a File to a Dataset. The file's role lives on the file itself (go_file.role), not here, so this row only carries the two foreign keys and the creation timestamp.

func (*DatasetFile) BeforeCreate

func (t *DatasetFile) BeforeCreate(_ *gorm.DB) error

func (DatasetFile) TableName

func (DatasetFile) TableName() string

type File

type File struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	FileName string `json:"file_name" gorm:"type:varchar(255)"`

	Path string `json:"path" gorm:"type:text;not null"`

	Format string `json:"format" gorm:"type:varchar(64)"`

	// AssayID owns the file (int64 PK of go_assay). 0 means the file is not
	// owned by any assay.
	AssayID int64 `json:"assay_id,string" gorm:"type:bigint;index"`

	// FileKey is the file's key inside its owning assay, e.g. FASTQ_R1 or BAM.
	// Analysis form inputs use it to map the file onto the matching key of
	// their resolver.accept_formats (see buildParseAnalysisResult).
	FileKey string `json:"file_key" gorm:"type:varchar(64)"`
	// Role is the role the file is published under in the workflow form's
	// analysis_result map, e.g. BAM / VCF / DEFAULT. A node output file takes it
	// from its output_patterns entry (see NodeCompletionCoordinator.recordNodeOutputFiles),
	// defaulting to dag.DefaultNodeOutputRole ("DEFAULT") when the pattern declares
	// none; resolveFormAnalysisResult groups the node output files by it so the
	// frontend reads them as dataMap[role] just like dataset files.
	Role           string `json:"role" gorm:"type:varchar(64);index"`
	AnalysisNodeID int64  `json:"analysis_node_id" gorm:"type:bigint;index"`

	Size int64 `json:"size"`

	MD5 string `json:"md5" gorm:"type:varchar(64);index"`

	Storage string `json:"storage" gorm:"type:varchar(32);default:LOCAL"`

	Description string `json:"description" gorm:"type:text"`

	CreatedAt time.Time `json:"created_at"`

	UpdatedAt time.Time `json:"updated_at"`
}

File is a physical file. A file belongs to at most one Assay (Assay -> File is 1:N), so the binding lives directly on this row instead of a join table:

Project -> DatasetAssay -> Assay -> File

Files that are only attached to a dataset (never produced by an assay) keep AssayID == 0, which is why the column stays nullable.

func (*File) BeforeCreate

func (t *File) BeforeCreate(_ *gorm.DB) error

func (File) TableName

func (File) TableName() string

type FileByProjectRoleGroup

type FileByProjectRoleGroup struct {
	Role string `json:"role"`

	Items []*FileWithDatasetInfo `json:"items"`
}

type FileWithDatasetInfo

type FileWithDatasetInfo struct {
	ID int64 `json:"id,string"`

	// FileID mirrors the file's own primary key (go_file.id). It is kept so list
	// responses still carry a "file_id" the frontend can pass straight to the
	// by-id sheet endpoints; the entity no longer has a separate business id.
	FileID int64 `json:"file_id,string"`

	FileName string `json:"file_name"`

	Path string `json:"path"`

	Format string `json:"format"`

	AnalysisNodeID int64 `json:"analysis_node_id,string,omitempty"`

	Size int64 `json:"size"`

	MD5 string `json:"md5"`

	Storage string `json:"storage"`

	Description string `json:"description"`

	CreatedAt time.Time `json:"created_at"`

	UpdatedAt time.Time `json:"updated_at"`

	DatasetID string `json:"dataset_id"`

	DatasetName string `json:"dataset_name"`

	Role string `json:"role"`
}

type GatewayRoute

type GatewayRoute struct {
	RouteKey string `json:"route_key" gorm:"primaryKey;type:varchar(255)"`

	ContainerInstanceID int64 `json:"container_instance_id,string" gorm:"index"`

	PathPrefix   string `json:"path_prefix" gorm:"type:varchar(512);not null;uniqueIndex"`
	IsTrimPrefix *bool  `json:"is_trim_prefix" gorm:"not null;default:true"`
	BackendHost  string `json:"backend_host" gorm:"type:varchar(255);not null"`
	BackendPort  int    `json:"backend_port" gorm:"not null"`

	Metadata datatypes.JSON `json:"metadata" gorm:"type:json"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (GatewayRoute) TableName

func (GatewayRoute) TableName() string

type ImageStatus

type ImageStatus string
const (
	ImageStatusPending  ImageStatus = "pending"
	ImageStatusPulling  ImageStatus = "pulling"
	ImageStatusReady    ImageStatus = "ready"
	ImageStatusFailed   ImageStatus = "failed"
	ImageStatusDeleted  ImageStatus = "deleted"
	ImageStatusDisabled ImageStatus = "disabled"
)

type ImportAssayTSVRequest added in v0.1.5

type ImportAssayTSVRequest struct {
	DatasetID int64  `json:"dataset_id,string" binding:"required"`
	Content   string `json:"content" binding:"required"`
	ProjectID string `json:"-"`
}

ImportAssayTSVRequest is the payload of the assay TSV import: a target dataset plus the raw TSV text (an uploaded file or pasted content).

The header row names the columns. Columns that map onto an Assay field configure that entity (see the column map in the data service), e.g. sample_name / assay_type / assay_role / assay_desc; every other column is treated as a File whose FileKey is the column name and whose Path is the cell value — so new file columns (FASTQ_R3, BAM, ...) need no code change. All columns except sample_name are optional. ProjectID is filled in by the handler from the active project and is never sent by the client.

type ImportAssayTSVResult added in v0.1.5

type ImportAssayTSVResult struct {
	Rows          int `json:"rows"`
	AssaysCreated int `json:"assays_created"`
	AssaysUpdated int `json:"assays_updated"`
	FilesCreated  int `json:"files_created"`
	FilesUpdated  int `json:"files_updated"`
}

ImportAssayTSVResult summarises one import run: how many rows were processed and how many records were created versus updated.

type JSONMap

type JSONMap map[string]any

func (JSONMap) MarshalJSON

func (m JSONMap) MarshalJSON() ([]byte, error)

func (*JSONMap) Scan

func (m *JSONMap) Scan(value any) error

func (JSONMap) Value

func (m JSONMap) Value() (driver.Value, error)

type JSONSlice

type JSONSlice []any

func (JSONSlice) MarshalJSON

func (s JSONSlice) MarshalJSON() ([]byte, error)

func (*JSONSlice) Scan

func (s *JSONSlice) Scan(value any) error

func (JSONSlice) Value

func (s JSONSlice) Value() (driver.Value, error)

type LLMConversation

type LLMConversation struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	ConversationID string `json:"conversation_id" gorm:"type:varchar(64);uniqueIndex;not null"`

	LLMSessionID int64 `json:"llm_session_id,string" gorm:"index;not null"`

	Role string `json:"role" gorm:"type:varchar(32);index;not null"`

	Content string `json:"content" gorm:"type:longtext"`

	Model string `json:"model" gorm:"type:varchar(255)"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

LLMConversation stores a single conversation entry under a session. We intentionally use LLMSessionID instead of GORM associations.

func (*LLMConversation) BeforeCreate

func (t *LLMConversation) BeforeCreate(_ *gorm.DB) error

func (LLMConversation) TableName

func (LLMConversation) TableName() string

type LLMSession

type LLMSession struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	ProjectID int64 `json:"project_id" gorm:"type:bigint;index;not null"`

	Title string `json:"title" gorm:"type:varchar(255)"`

	Status string `json:"status" gorm:"type:varchar(32);index;not null;default:ACTIVE"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

LLMSession stores a chat session and owner scope. Relation with conversation is maintained manually via LLMConversation.LLMSessionID.

func (*LLMSession) BeforeCreate

func (t *LLMSession) BeforeCreate(_ *gorm.DB) error

func (LLMSession) TableName

func (LLMSession) TableName() string

type Literature added in v0.1.2

type Literature struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	Title string `json:"title" gorm:"type:varchar(255)"`
	// Content is only authoritative when ContentSource == "database". For
	// file-backed literature this column stays empty and the real content lives
	// in the file referenced by Filename under the project literature directory.
	Content string `json:"content" gorm:"type:longtext"`
	// ContentSource indicates where the full text is stored: "file" or "database".
	ContentSource string `json:"content_source" gorm:"type:varchar(16);default:file"`
	// Filename is the full-text file name under the project literature directory.
	Filename string `json:"filename" gorm:"type:varchar(255);default:fulltext.md"`
	// OwnerProjectID is the project whose literature directory owns the full-text
	// file. It is set when the literature is first created.
	OwnerProjectID string    `json:"owner_project_id" gorm:"type:varchar(255);index"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

Literature maps to the t_literature table. It represents a reference paper / literature entry whose full text is (by default) stored as a file on disk.

The relationship between literature and projects is maintained manually via the project_literature mapping table; we intentionally do NOT use GORM association tags/relations here.

func (*Literature) BeforeCreate added in v0.1.2

func (t *Literature) BeforeCreate(_ *gorm.DB) error

func (Literature) TableName added in v0.1.2

func (Literature) TableName() string

type LiteraturePoolItem added in v0.1.2

type LiteraturePoolItem struct {
	Literature
	Bound bool `json:"bound"`
}

LiteraturePoolItem carries a Literature together with whether it is already bound to the queried project. Used by the bind-literature picker.

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"    binding:"required,email"`
	Password string `json:"password" binding:"required,min=6"`
}

LoginRequest represents a login request

type LoginResponse

type LoginResponse struct {
	Success      bool   `json:"success"`
	Message      string `json:"message,omitempty"`
	User         *User  `json:"user,omitempty"`
	Token        string `json:"token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
}

LoginResponse represents a login response

type OIDCAuthURLResponse

type OIDCAuthURLResponse struct {
	Success             bool   `json:"success"`
	ProviderDisplayName string `json:"provider_display_name,omitempty"`
	AuthorizationURL    string `json:"authorization_url,omitempty"`
	State               string `json:"state,omitempty"`
}

type OIDCCallbackResponse

type OIDCCallbackResponse struct {
	Success      bool   `json:"success"`
	Message      string `json:"message,omitempty"`
	User         *User  `json:"user,omitempty"`
	Token        string `json:"token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	IsNewUser    bool   `json:"is_new_user,omitempty"`
}

type OIDCConfigResponse

type OIDCConfigResponse struct {
	Success             bool   `json:"success"`
	Enabled             bool   `json:"enabled"`
	ProviderDisplayName string `json:"provider_display_name,omitempty"`
}

type OIDCUserInfo

type OIDCUserInfo struct {
	Subject  string                 `json:"subject,omitempty"`
	Username string                 `json:"username,omitempty"`
	Email    string                 `json:"email,omitempty"`
	Claims   map[string]interface{} `json:"claims,omitempty"`
}

type OutboxEvent

type OutboxEvent struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	Type string `json:"type" gorm:"type:varchar(128);index;not null"`

	Payload datatypes.JSON `json:"payload" gorm:"type:json;not null"`

	Status string `json:"status" gorm:"type:varchar(32);index;not null;default:pending"` // pending / sent

	SentAt *time.Time `json:"sent_at"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*OutboxEvent) BeforeCreate

func (t *OutboxEvent) BeforeCreate(_ *gorm.DB) error

func (OutboxEvent) TableName

func (OutboxEvent) TableName() string

type PageResult

type PageResult struct {
	Total    int64       `json:"total"`     // Total number of records
	Page     int         `json:"page"`      // Current page number
	PageSize int         `json:"page_size"` // Page size
	Data     interface{} `json:"data"`      // Data
}

PageResult represents the pagination query result

func NewPageResult

func NewPageResult(total int64, page *Pagination, data interface{}) *PageResult

NewPageResult creates a new pagination result

type Pagination

type Pagination struct {
	// Page
	Page int `form:"page"      json:"page"      binding:"omitempty,min=1"`
	// Page size
	PageSize int `form:"page_size" json:"page_size" binding:"omitempty,min=1,max=1000"`
}

Pagination represents the pagination parameters

func (*Pagination) GetPage

func (p *Pagination) GetPage() int

GetPage gets the page number, default is 1

func (*Pagination) GetPageSize

func (p *Pagination) GetPageSize() int

GetPageSize gets the page size, default is 20

func (*Pagination) Limit

func (p *Pagination) Limit() int

Limit gets the limit for database query

func (*Pagination) Offset

func (p *Pagination) Offset() int

Offset gets the offset for database query

type Project

type Project struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`
	// ID           uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	ProjectID    string         `json:"project_id" gorm:"type:varchar(255);uniqueIndex;not null"`
	ProjectName  string         `json:"project_name" gorm:"type:varchar(255)"`
	MetadataForm string         `json:"metadata_form" gorm:"type:text"`
	Research     string         `json:"research" gorm:"type:text"`
	Parameter    string         `json:"parameter" gorm:"type:text"`
	Mounts       datatypes.JSON `json:"mounts" gorm:"type:json"`
	Env          datatypes.JSON `json:"env" gorm:"type:json"`

	Description string    `json:"description" gorm:"type:text"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

Project maps to Python brave's t_project table.

func (*Project) BeforeCreate

func (t *Project) BeforeCreate(_ *gorm.DB) error

func (Project) TableName

func (Project) TableName() string

type ProjectDataset

type ProjectDataset struct {
	ID int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`

	ProjectID string `json:"project_id" gorm:"index;not null"`

	DatasetID int64 `json:"dataset_id,string" gorm:"index;not null"`

	CreatedAt time.Time `json:"created_at"`
}

func (*ProjectDataset) BeforeCreate

func (t *ProjectDataset) BeforeCreate(_ *gorm.DB) error

func (ProjectDataset) TableName

func (ProjectDataset) TableName() string

type ProjectListItem

type ProjectListItem struct {
	Project
	ShareCode    string `json:"share_code"`
	ShareEnabled bool   `json:"share_enabled"`
}

ProjectListItem carries a Project together with the sharing settings of the current user, taken from the user_project mapping table.

type ProjectLiterature added in v0.1.2

type ProjectLiterature struct {
	ID           uint      `json:"id" gorm:"primaryKey;autoIncrement"`
	ProjectID    string    `` /* 141-byte string literal not displayed */
	LiteratureID int64     `` /* 148-byte string literal not displayed */
	CreatedAt    time.Time `json:"created_at"`
}

ProjectLiterature is a manual many-to-many mapping table between projects and literatures. We intentionally do not use GORM association tags/relations.

func (ProjectLiterature) TableName added in v0.1.2

func (ProjectLiterature) TableName() string

type ProjectReport

type ProjectReport struct {
	ID        int64     `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`
	ProjectID string    `json:"project_id" gorm:"type:varchar(255);not null;index"`
	Title     string    `json:"title" gorm:"type:varchar(255)"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

ProjectReport 是一个报告容器,只保存标题等元信息,不再承载文件内容。 报告的内容由 ProjectReportItem 列表按顺序拼接而成。

func (*ProjectReport) BeforeCreate

func (t *ProjectReport) BeforeCreate(_ *gorm.DB) error

func (ProjectReport) TableName

func (ProjectReport) TableName() string

type ProjectReportItem added in v0.1.5

type ProjectReportItem struct {
	ID              int64 `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`
	ProjectReportID int64 `json:"project_report_id,string" gorm:"column:project_report_id;type:bigint;index:idx_project_report_items_report"`
	// ParentID 指向同一报告下的父条目 ID,0 表示根节点。用于组织树形结构。
	ParentID  int64                      `json:"parent_id,string" gorm:"column:parent_id;type:bigint;index:idx_project_report_items_parent"`
	OwnerType ProjectReportItemOwnerType `json:"owner_type" gorm:"column:owner_type;type:varchar(32);index:idx_project_report_items_owner"`
	// OwnerID 指向 OwnerType 对应的主键。
	OwnerID   int64     `json:"owner_id,string" gorm:"column:owner_id;type:bigint;index:idx_project_report_items_owner"`
	SortOrder int       `json:"sort_order" gorm:"column:sort_order;default:0"`
	CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"`

	// Title 是展示用标题。仅 OwnerType=custom 时由用户编辑并持久化;
	// 其他引用类型的标题由 owner 推导(读取时派生),写入时会清空,不落库。
	Title string `json:"title" gorm:"type:varchar(255)"`
	// Content 是自定义 markdown 正文,仅 OwnerType=custom 时持久化;
	// 其他引用类型不存储内容。
	Content string `json:"content" gorm:"type:longtext"`
}

ProjectReportItem 是 ProjectReport 下的一个内容条目,按 SortOrder 排序后拼接成报告正文。

func (*ProjectReportItem) BeforeCreate added in v0.1.5

func (t *ProjectReportItem) BeforeCreate(_ *gorm.DB) error

func (ProjectReportItem) TableName added in v0.1.5

func (ProjectReportItem) TableName() string

type ProjectReportItemContent added in v0.1.5

type ProjectReportItemContent struct {
	Title     string                     `json:"title"`
	Prefix    string                     `json:"prefix"`
	Content   string                     `json:"content"`
	OwnerType ProjectReportItemOwnerType `json:"owner_type"`
}

ProjectReportItemContent 是 ProjectReportItem 渲染后的内容片段。 Title 为展示标题,Content 为正文,Prefix 为正文中相对资源(图片/链接)的 /data-analysis URL 前缀,渲染时拼接到相对图片路径前。

func (ProjectReportItemContent) Render added in v0.1.5

func (c ProjectReportItemContent) Render() string

Render 将片段渲染为 markdown 小节;正文为空时返回空串。 Prefix 作为正文中相对图片资源的 URL 前缀,会拼接到每个 img 的相对路径前。

type ProjectReportItemOrder added in v0.1.5

type ProjectReportItemOrder struct {
	ID        int64
	ParentID  int64
	SortOrder int
}

ProjectReportItemOrder 描述拖拽重排后单个条目的目标位置(父节点与同级顺序)。

type ProjectReportItemOwnerType added in v0.1.5

type ProjectReportItemOwnerType string

ProjectReportItemOwnerType 标识 ProjectReportItem 指向的内容来源类型。

const (
	// ProjectReportItemOwnerAnalysis 指向 Analysis(nextflow 表)的 ID。
	ProjectReportItemOwnerAnalysis ProjectReportItemOwnerType = "analysis"
	// ProjectReportItemOwnerAnalysisNode 指向 AnalysisNode(analysis_nodes 表)的 ID。
	ProjectReportItemOwnerAnalysisNode ProjectReportItemOwnerType = "analysis_node"
	// ProjectReportItemOwnerAISummary 指向 AISummary 的 ID。
	ProjectReportItemOwnerAISummary ProjectReportItemOwnerType = "ai_summary"
	// ProjectReportItemOwnerCustom 是自定义内容条目,用于章节占位/自定义 markdown 段落。
	// 它不引用外部 owner,标题与正文由用户直接编辑并持久化在本表。
	ProjectReportItemOwnerCustom ProjectReportItemOwnerType = "custom"
)

func NormalizeProjectReportItemOwnerType added in v0.1.5

func NormalizeProjectReportItemOwnerType(t string) (ProjectReportItemOwnerType, bool)

NormalizeProjectReportItemOwnerType 校验并归一化 OwnerType。

type QueryDataset

type QueryDataset struct {
	ID *int64 `json:"id,string,omitempty"`

	DatasetName string `json:"dataset_name,omitempty"`

	Description string `json:"description,omitempty"`

	Metadata string `json:"metadata,omitempty"`
}

QueryDataset defines optional dataset filters for list/page APIs.

func (*QueryDataset) GetDatasetName

func (q *QueryDataset) GetDatasetName() string

func (*QueryDataset) GetDescription

func (q *QueryDataset) GetDescription() string

func (*QueryDataset) GetMetadata

func (q *QueryDataset) GetMetadata() string

type RegisterRequest

type RegisterRequest struct {
	Username string `json:"username" binding:"required,min=2,max=50"`
	Email    string `json:"email"    binding:"required,email"`
	Password string `json:"password" binding:"required,min=6"`
}

RegisterRequest represents a registration request

type RegisterResponse

type RegisterResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
	User    *User  `json:"user,omitempty"`
}

RegisterResponse represents a registration response

type RequestContext

type RequestContext struct {
	User *User
}

type RuntimeVariable added in v0.1.4

type RuntimeVariable struct {
	Name        string                  `json:"name"`
	Value       string                  `json:"value"`
	Category    RuntimeVariableCategory `json:"category"`
	Description string                  `json:"description"`
	Source      RuntimeVariableSource   `json:"source"`
}

RuntimeVariable 是一条已求值的运行时变量,附带展示元数据。

type RuntimeVariableCategory added in v0.1.4

type RuntimeVariableCategory string

RuntimeVariableCategory 对运行时变量按领域分组,用于前端分类展示。

const (
	RuntimeVariableCategorySystem     RuntimeVariableCategory = "system"
	RuntimeVariableCategoryPackage    RuntimeVariableCategory = "package"
	RuntimeVariableCategoryProject    RuntimeVariableCategory = "project"
	RuntimeVariableCategoryWorkspace  RuntimeVariableCategory = "workspace"
	RuntimeVariableCategoryAppSession RuntimeVariableCategory = "app_session"
	RuntimeVariableCategoryDagNode    RuntimeVariableCategory = "dag_node"
)

type RuntimeVariableDefinition added in v0.1.4

type RuntimeVariableDefinition struct {
	Name        string                  `json:"name"`
	Category    RuntimeVariableCategory `json:"category"`
	Description string                  `json:"description"`
	Source      RuntimeVariableSource   `json:"source"`
}

RuntimeVariableDefinition 是某个变量名的声明式元数据(单一事实来源)。

type RuntimeVariableSource added in v0.1.4

type RuntimeVariableSource string

RuntimeVariableSource 表示变量取值的来源。

const (
	RuntimeVariableSourceStatic   RuntimeVariableSource = "static"   // 固定/派生路径
	RuntimeVariableSourceEnv      RuntimeVariableSource = "env"      // 来自进程环境变量
	RuntimeVariableSourceDB       RuntimeVariableSource = "db"       // 来自 session/node/project 记录
	RuntimeVariableSourceComputed RuntimeVariableSource = "computed" // 运行时计算
)

type Script

type Script struct {
	// ID                  uint      `json:"id" gorm:"primaryKey;autoIncrement"`
	ID                  int64  `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`
	StoreID             int64  `json:"store_id,string" gorm:"column:store_id;type:bigint"`
	ProjectID           int64  `json:"project_id,string" gorm:"column:project_id;type:bigint"`
	ScriptID            string `json:"component_id" gorm:"column:component_id;type:varchar(255)"`
	InstallKey          string `json:"install_key" gorm:"type:varchar(255)"`
	ComponentType       string `json:"component_type" gorm:"type:varchar(255)"`
	ComponentName       string `json:"component_name" gorm:"type:varchar(255)"`
	Description         string `json:"description" gorm:"type:longtext"`
	ComponentIDs        string `json:"component_ids" gorm:"type:longtext"`
	Img                 string `json:"img" gorm:"type:varchar(255)"`
	ContainerTemplateID int64  `json:"container_template_id,string" gorm:"column:container_template_id;type:bigint"`
	ToolsContainerID    string `json:"tools_container_id" gorm:"type:text"`
	Prompt              string `json:"prompt" gorm:"type:longtext"`
	// IOSchema            string `json:"io_schema" gorm:"column:io_schema;type:longtext"`
	SubContainerID string `json:"sub_container_id" gorm:"type:varchar(255)"`
	Tags           string `json:"tags" gorm:"type:varchar(255)"`
	FileType       string `json:"file_type" gorm:"type:varchar(255)"`
	ScriptType     string `json:"script_type" gorm:"type:varchar(255)"`
	Category       string `json:"category" gorm:"type:varchar(255);default:default"`
	// Content        string `json:"content" gorm:"type:text"`
	OrderIndex int    `json:"order_index"`
	Position   string `json:"position" gorm:"type:text"`
	Edges      string `json:"edges" gorm:"type:text"`

	// Version   string    `json:"version" gorm:"type:varchar(255)"`
	// Message   string    `json:"message" gorm:"type:longtext"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*Script) BeforeCreate

func (t *Script) BeforeCreate(_ *gorm.DB) error

func (Script) TableName

func (Script) TableName() string

type ScriptContainerSnapshot

type ScriptContainerSnapshot struct {
	ScriptID       string `json:"script_id" gorm:"column:script_id"`
	ContainerID    int64  `json:"container_id,string" gorm:"column:container_id"`
	ContainerName  string `json:"container_name" gorm:"column:container_name"`
	ImageID        int64  `json:"image_id,string" gorm:"column:image_id"`
	ContainerImage string `json:"container_image" gorm:"column:container_image"`
	ImageName      string `json:"image_name" gorm:"column:image_name"`
}

ScriptContainerSnapshot is a read model for analysis node visualization. It flattens script -> container template definition/spec -> container image fields via SQL join. ContainerID is the go_container_template_definition primary key (the id scripts bind to); the image tag is already part of ContainerImage (go_container_image.full_name), and image status is no longer persisted, so there is no separate tag/status column here.

type ScriptJSONExportResponse

type ScriptJSONExportResponse struct {
	// Version 是导出文件格式版本(取值见 internal/exportcodec,如 exportcodec.VersionV1),
	// 写入 script.json 顶层;安装侧(InstallScript)据此路由到对应版本的 Codec。
	// 历史产物没有该字段,反序列化后为空字符串。
	Version  string         `json:"version"`
	ScriptID string         `json:"script_id"`
	Script   map[string]any `json:"script"`
	// ContainerTemplateSpecs 是去重后的容器运行配置列表(按 ContainerTemplateSpec 主键去重,
	// 结构见 types.ContainerTemplateSpec)。脚本的 container_template_id 引用的是绑定行主键,
	// 绑定行通过 SpecID 引用这里的配置,因此三个列表都按主键去重,不重复出现。
	ContainerTemplateSpecs []map[string]any `json:"container_template_specs,omitempty"`
	// ContainerTemplateDefinitions 是去重后的「运行配置 × 镜像」绑定行列表(按主键去重,
	// 结构见 types.ContainerTemplateDefinition):SpecID 指向 ContainerTemplateSpecs,
	// ImageID 指向 ContainerImages,主键就是脚本 container_template_id 引用的值。
	ContainerTemplateDefinitions []map[string]any `json:"container_template_definitions,omitempty"`
	// ContainerImages 是去重后的容器镜像列表(按镜像主键去重),
	// 结构见 types.ContainerImageExport,与 container_template_definitions 的 image_id 一一对应。
	ContainerImages []map[string]any `json:"container_images,omitempty"`
}

type ScriptPageQuery

type ScriptPageQuery struct {
	IDs []int64 `json:"ids,omitempty"`

	ID *int64 `json:"id,string,omitempty"`

	ProjectID int64 `json:"project_id,string,omitempty"`

	ScriptID string `json:"script_id,omitempty"`

	ComponentName string `json:"component_name,omitempty"`

	ScriptType string `json:"script_type,omitempty"`

	Category string `json:"category,omitempty"`

	InstallKey string `json:"install_key,omitempty"`

	Tags string `json:"tags,omitempty"`

	Keywords string `json:"keywords,omitempty"`

	ContainerTemplateID *int64 `json:"container_template_id,string,omitempty"`

	SortBy string `json:"sort_by,omitempty"`

	SortOrder string `json:"sort_order,omitempty"`
}

ScriptPageQuery defines optional filters and sorting for script pagination. New query fields should be added here and wired in repository applyFilters.

func (*ScriptPageQuery) GetCategory

func (q *ScriptPageQuery) GetCategory() string

func (*ScriptPageQuery) GetComponentName

func (q *ScriptPageQuery) GetComponentName() string

func (*ScriptPageQuery) GetInstallKey

func (q *ScriptPageQuery) GetInstallKey() string

func (*ScriptPageQuery) GetKeywords

func (q *ScriptPageQuery) GetKeywords() string

func (*ScriptPageQuery) GetScriptID

func (q *ScriptPageQuery) GetScriptID() string

func (*ScriptPageQuery) GetScriptType

func (q *ScriptPageQuery) GetScriptType() string

func (*ScriptPageQuery) GetSortColumn

func (q *ScriptPageQuery) GetSortColumn() string

func (*ScriptPageQuery) GetSortOrder

func (q *ScriptPageQuery) GetSortOrder() string

func (*ScriptPageQuery) GetTags

func (q *ScriptPageQuery) GetTags() string

type ScriptVersion

type ScriptVersion struct {
	Script
	// StoreVersion string `json:"store_version"`
	StorePath  string `json:"store_path"`
	ScriptPath string `json:"script_path"`
	// IOSchema 实时读取自脚本目录的 io_schema.json(不再是数据库字段)。
	IOSchema string `json:"io_schema"`
	// StoreURL string `json:"store_url"`
	// StoreMessage string `json:"store_message"`
	// GitState 由磁盘上的 git 元数据实时推导(不落库):
	// has_local_changes=true 表示本地有未发布改动,
	// has_store_changes=true 表示 store 有本地未同步的提交。
	GitState *utils.GitSyncState `json:"git_state,omitempty"`
}

type Store

type Store struct {
	ID int64 `json:"id,string" gorm:"primaryKey;autoIncrement"`

	// StoreID string `json:"store_id" gorm:"type:varchar(255);index"`
	// AppID       string         `json:"app_id" gorm:"type:varchar(255);index"`
	// workflow script
	StoreType string `json:"store_type" gorm:"type:varchar(255);index"`
	Name      string `json:"name" gorm:"type:varchar(255)"`
	Origin    string `json:"origin" gorm:"type:varchar(255)"`
	// URL 字段已删除:store 不再保存「远程仓库地址」。
	// 发布到远程(PublishStoreRemote)只把地址写进 store 裸仓库的 git remote 配置,
	// 下载来源地址同样可以从 clone 生成的 origin remote 读回,因此地址不再落库,
	// 避免数据库与仓库真实配置两份状态漂移。
	// 需要展示时读 Remotes(由磁盘实时推导)。
	// Status    string `json:"status" gorm:"type:varchar(255);index"`
	// PathName 是 store 目录在 storage.base_dir/store 下的相对标识,只在首次创建 store 时
	// 由 utils.GenerateStorePathName 生成随机串并固定下来:既不随 workflow_id / script_id 变化,
	// 也不来自下载源地址(历史数据可能仍是 workflow/script ID 或 "<owner>/<repo>",原样沿用)。
	// 绝对路径一律不落库,需要时用 utils.GetWorkflowOrScriptStoreDir(baseDir, PathName) 解析。
	PathName string `json:"path_name" gorm:"type:varchar(255)"`
	// StorePath 是 PathName 按当前 storage.base_dir 解析出的绝对目录,只在响应里返回。
	// 不落库(gorm:"-"),既避免 base_dir 迁移后库内路径失效,也保证与 PathName 单一来源一致。
	StorePath string `json:"store_path,omitempty" gorm:"-"`
	// Remotes 是 store 裸仓库上配置的远程仓库列表(github / gitee / origin ...),
	// 与 StorePath 一样只在响应里返回、不落库(gorm:"-"):发布到远程时写入的是
	// store 仓库的 git remote 配置,读取侧统一通过 utils.ReadGitRemotes 实时推导。
	Remotes  []utils.GitRemote `json:"remotes,omitempty" gorm:"-"`
	Category string            `json:"category" gorm:"type:varchar(255);index"`
	Tags     datatypes.JSON    `json:"tags" gorm:"type:json"`
	Img      string            `json:"img" gorm:"type:varchar(255)"`
	// PublishURLs datatypes.JSON `json:"publish_urls" gorm:"column:publish_urls;type:json"`
	Log string `json:"log" gorm:"type:longtext"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*Store) BeforeCreate

func (t *Store) BeforeCreate(_ *gorm.DB) error

func (Store) TableName

func (Store) TableName() string

type StoreDTO

type StoreDTO struct {
	Store
	Installed   bool   `json:"installed"`
	InstalledID string `json:"installed_id,omitempty"`
}

type StorePageQuery

type StorePageQuery struct {
	StoreType string `json:"store_type"`
	Keywords  string `json:"keywords,omitempty"`
	SortBy    string `json:"sort_by,omitempty"`
	SortOrder string `json:"sort_order,omitempty"`
}

StorePageQuery defines required filters for store pagination.

func (*StorePageQuery) GetKeywords

func (q *StorePageQuery) GetKeywords() string

func (*StorePageQuery) GetSortColumn

func (q *StorePageQuery) GetSortColumn() string

func (*StorePageQuery) GetSortOrder

func (q *StorePageQuery) GetSortOrder() string

func (*StorePageQuery) GetStoreType

func (q *StorePageQuery) GetStoreType() string

type SummaryOwnerType added in v0.1.2

type SummaryOwnerType string

SummaryOwnerType 摘要所属对象的类型。

const (
	// SummaryOwnerAnalysis 摘要归属于 Analysis(nextflow 表)。
	SummaryOwnerAnalysis SummaryOwnerType = "analysis"
	// SummaryOwnerAnalysisNode 摘要归属于 AnalysisNode(analysis_nodes 表)。
	SummaryOwnerAnalysisNode SummaryOwnerType = "analysis_node"
)

type SummaryStatus added in v0.1.2

type SummaryStatus string

SummaryStatus 摘要生成状态。

const (
	SummaryStatusPending SummaryStatus = "pending"
	// SummaryStatusGenerating 生成中
	SummaryStatusGenerating SummaryStatus = "generating"
	// SummaryStatusSuccess 生成成功
	SummaryStatusSuccess SummaryStatus = "success"
	// SummaryStatusFailed 生成失败
	SummaryStatusFailed SummaryStatus = "failed"
)

type UpdateDatasetRequest added in v0.1.4

type UpdateDatasetRequest struct {
	ID          int64  `json:"id,string" binding:"required"`
	DatasetName string `json:"dataset_name" binding:"required"`
	Description string `json:"description"`
	Metadata    string `json:"metadata"`
}

UpdateDatasetRequest is the payload for updating a dataset. ID identifies the record to update and is always required.

func (*UpdateDatasetRequest) ToDataset added in v0.1.4

func (r *UpdateDatasetRequest) ToDataset() *Dataset

ToDataset converts the request into a Dataset entity for the update path.

type User

type User struct {
	// Unique identifier of the user
	ID string `json:"id"         gorm:"type:varchar(36);primaryKey"`
	// Username of the user
	Username string `json:"username"   gorm:"type:varchar(100);uniqueIndex;not null"`
	// Email address of the user
	Email string `json:"email"      gorm:"type:varchar(255);uniqueIndex;not null"`
	// Hashed password of the user
	PasswordHash string `json:"-"          gorm:"type:varchar(255);not null"`
	// Avatar URL of the user
	Avatar string `json:"avatar"     gorm:"type:varchar(500)"`
	// AgentConfig 用户的 Agent 配置(Profile + 权限策略),以 JSON 形式落库。
	AgentConfig agent.UserAgentConfig `json:"agent_config" gorm:"serializer:json"`
	// Tenant ID that the user belongs to
	// TenantID uint64 `json:"tenant_id"  gorm:"index"`
	// Whether the user is active
	IsActive bool `json:"is_active"  gorm:"default:true"`
	// Whether the user can access all tenants (cross-tenant access)
	CanAccessAllTenants bool `json:"can_access_all_tenants" gorm:"default:false"`
	// Creation time of the user
	CreatedAt time.Time `json:"created_at"`
	// Last updated time of the user
	UpdatedAt time.Time `json:"updated_at"`
	// Deletion time of the user
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

User represents a user in the system

func (*User) ToUserInfo

func (u *User) ToUserInfo() *UserInfo

ToUserInfo converts User to UserInfo (without sensitive data)

type UserInfo

type UserInfo struct {
	ID          string                `json:"id"`
	Username    string                `json:"username"`
	Email       string                `json:"email"`
	Avatar      string                `json:"avatar"`
	AgentConfig agent.UserAgentConfig `json:"agent_config"`
	// AgentProfile 是 agent_config.ProfileID 对应的 Profile 摘要(DTO,按需填充,可能为空)。
	AgentProfile        *AgentProfileInfo `json:"agent_profile,omitempty"`
	TenantID            uint64            `json:"tenant_id"`
	IsActive            bool              `json:"is_active"`
	CanAccessAllTenants bool              `json:"can_access_all_tenants"`
	CreatedAt           time.Time         `json:"created_at"`
	UpdatedAt           time.Time         `json:"updated_at"`
}

UserInfo represents user information for API responses

type UserProject

type UserProject struct {
	ID     uint   `json:"id" gorm:"primaryKey;autoIncrement"`
	UserID string `json:"user_id" gorm:"type:varchar(36);not null;index:idx_user_project_user;uniqueIndex:idx_user_project_unique,priority:1"`
	// ProjectID int64  `json:"project_id,string" gorm:"column:project_id;type:bigint"`
	ProjectID string `` /* 129-byte string literal not displayed */
	IsActive  bool   `json:"is_active" gorm:"default:false"`

	// ShareCode is generated when the owner enables project sharing. Other users
	// can use it to look up the project and gain access.
	ShareCode string `json:"share_code" gorm:"type:varchar(64);index"`
	// ShareEnabled toggles whether the project can be shared via ShareCode.
	ShareEnabled bool      `json:"share_enabled" gorm:"default:false"`
	CreatedAt    time.Time `json:"created_at"`
}

UserProject is a manual many-to-many mapping table between users and projects. We intentionally do not use GORM association tags/relations.

func (UserProject) TableName

func (UserProject) TableName() string

type Workflow

type Workflow struct {
	// ID                 uint           `json:"id" gorm:"primaryKey;autoIncrement"`
	ID        int64          `json:"id,string" gorm:"primaryKey;type:bigint;autoIncrement:false"`
	ProjectID int64          `json:"project_id,string" gorm:"column:project_id;type:bigint"`
	StoreID   int64          `json:"store_id,string" gorm:"column:store_id;type:bigint"`
	Name      string         `json:"name" gorm:"type:varchar(255)"`
	Img       string         `json:"img" gorm:"type:varchar(255)"`
	Tags      datatypes.JSON `json:"tags" gorm:"type:json"`
	// URL                string         `json:"url" gorm:"column:url;type:varchar(255)"`
	Category    string `json:"category" gorm:"type:varchar(255);default:default"`
	Description string `json:"description" gorm:"type:longtext"`
	Prompt      string `json:"prompt" gorm:"type:longtext"`
	// DagDefinition      string         `json:"dag_definition" gorm:"column:dag_definition;type:longtext"`
	WorkflowID         string         `json:"workflow_id" gorm:"column:relation_id;type:varchar(255)"`
	RelationType       string         `json:"relation_type" gorm:"type:varchar(255)"`
	InstallKey         string         `json:"install_key" gorm:"type:varchar(255)"`
	ModuleID           string         `json:"component_id" gorm:"column:component_id;type:varchar(255)"`
	ContainerID        string         `json:"container_id" gorm:"type:varchar(255)"`
	ParentComponentID  string         `json:"parent_component_id" gorm:"type:varchar(255)"`
	InputComponentIDs  datatypes.JSON `json:"input_component_ids" gorm:"type:json"`
	OutputComponentIDs datatypes.JSON `json:"output_component_ids" gorm:"type:json"`
	OrderIndex         int            `json:"order_index"`
	// Version            string         `json:"version" gorm:"type:varchar(255)"`
	// Message   string    `json:"message" gorm:"type:longtext"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*Workflow) BeforeCreate

func (t *Workflow) BeforeCreate(_ *gorm.DB) error

func (Workflow) TableName

func (Workflow) TableName() string

type WorkflowJSONExportResponse

type WorkflowJSONExportResponse struct {
	// Version 是导出文件格式版本(取值见 internal/exportcodec,如 exportcodec.VersionV1),
	// 写入 workflow.json 顶层;安装侧(InstallWorkflow)据此路由到对应版本的 Codec。
	// 历史产物没有该字段,反序列化后为空字符串。
	Version string `json:"version"`
	// Path               string           `json:"path"`
	WorkflowID string           `json:"workflow_id"`
	Workflow   map[string]any   `json:"workflow"`
	Scripts    []map[string]any `json:"scripts"`
	// ContainerTemplateSpecs 是去重后的容器运行配置列表(按 ContainerTemplateSpec 主键去重,
	// 结构见 types.ContainerTemplateSpec)。脚本的 container_template_id 引用的是绑定行主键,
	// 绑定行通过 SpecID 引用这里的配置,因此三个列表都按主键去重,不重复出现。
	ContainerTemplateSpecs []map[string]any `json:"container_template_specs"`
	// ContainerTemplateDefinitions 是去重后的「运行配置 × 镜像」绑定行列表(按主键去重,
	// 结构见 types.ContainerTemplateDefinition):SpecID 指向 ContainerTemplateSpecs,
	// ImageID 指向 ContainerImages,主键就是脚本 container_template_id 引用的值。
	ContainerTemplateDefinitions []map[string]any `json:"container_template_definitions"`
	// ContainerImages 是去重后的容器镜像列表(按镜像主键去重),
	// 结构见 types.ContainerImageExport,与 container_template_definitions 的 image_id 一一对应。
	ContainerImages []map[string]any `json:"container_images"`
}

type WorkflowPageQuery

type WorkflowPageQuery struct {
	IDs []uint `json:"ids,omitempty"`

	ID *uint `json:"id,omitempty"`

	ProjectID int64 `json:"project_id,string,omitempty"`

	WorkflowID string `json:"workflow_id,omitempty"`

	Name string `json:"name,omitempty"`

	Category string `json:"category,omitempty"`

	InstallKey string `json:"install_key,omitempty"`

	ModuleID string `json:"module_id,omitempty"`

	RelationType string `json:"relation_type,omitempty"`

	Tags string `json:"tags,omitempty"`

	Keywords string `json:"keywords,omitempty"`

	SortBy string `json:"sort_by,omitempty"`

	SortOrder string `json:"sort_order,omitempty"`
}

WorkflowPageQuery defines optional filters and sorting for workflow pagination.

func (*WorkflowPageQuery) GetCategory

func (q *WorkflowPageQuery) GetCategory() string

func (*WorkflowPageQuery) GetInstallKey

func (q *WorkflowPageQuery) GetInstallKey() string

func (*WorkflowPageQuery) GetKeywords

func (q *WorkflowPageQuery) GetKeywords() string

func (*WorkflowPageQuery) GetModuleID

func (q *WorkflowPageQuery) GetModuleID() string

func (*WorkflowPageQuery) GetName

func (q *WorkflowPageQuery) GetName() string

func (*WorkflowPageQuery) GetRelationType

func (q *WorkflowPageQuery) GetRelationType() string

func (*WorkflowPageQuery) GetSortColumn

func (q *WorkflowPageQuery) GetSortColumn() string

func (*WorkflowPageQuery) GetSortOrder

func (q *WorkflowPageQuery) GetSortOrder() string

func (*WorkflowPageQuery) GetTags

func (q *WorkflowPageQuery) GetTags() string

func (*WorkflowPageQuery) GetWorkflowID

func (q *WorkflowPageQuery) GetWorkflowID() string

type WorkflowVersion

type WorkflowVersion struct {
	// ID                 int64          `json:"id,string"`
	// ProjectID          int64          `json:"project_id,string"`
	// StoreID            int64          `json:"store_id,string"`
	// Name               string         `json:"name"`
	// Img                string         `json:"img"`
	// Tags               datatypes.JSON `json:"tags"`
	// URL                string         `json:"url"`
	// Category           string         `json:"category"`
	// Description        string         `json:"description"`
	// Prompt             string         `json:"prompt"`
	// DagDefinition      string         `json:"dag_definition"`
	// WorkflowID         string         `json:"relation_id"`
	// RelationType       string         `json:"relation_type"`
	// InstallKey         string         `json:"install_key"`
	// ModuleID           string         `json:"component_id"`
	// ContainerID        string         `json:"container_id"`
	// ParentComponentID  string         `json:"parent_component_id"`
	// InputComponentIDs  datatypes.JSON `json:"input_component_ids"`
	// OutputComponentIDs datatypes.JSON `json:"output_component_ids"`
	// OrderIndex         int            `json:"order_index"`
	// Version            string         `json:"version"`
	// UpdateInfo         string         `json:"update_info"`
	// CreatedAt          time.Time      `json:"created_at"`
	// UpdatedAt          time.Time      `json:"updated_at"`
	Workflow
	StorePath    string `json:"store_path"`
	WorkflowPath string `json:"workflow_path"`
	// DagDefinition 实时读取自工作流目录的 dag_definition.json(不再是数据库字段)。
	// 用于工作流可视化编辑与 DAG 运行时编译(见 GetWorkflowVisByWorkflowID / SaveWorkflow)。
	DagDefinition string `json:"dag_definition"`
	// IOSchema 实时读取自工作流目录的 io_schema.json(不再是数据库字段)。
	// 工作流级 inputs 用于运行工作流时生成 formJson(见 GetFormJSONByWorkflowID)。
	IOSchema string `json:"io_schema"`
	// StoreURL     string `json:"store_url"`
	// StoreMessage string `json:"store_message"`
	// StoreVersion string `json:"store_version"`
	// GitState 由磁盘上的 git 元数据实时推导(不落库):
	// has_local_changes=true 表示本地有未发布改动,
	// has_store_changes=true 表示 store 有本地未同步的提交。
	GitState *utils.GitSyncState `json:"git_state,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL