package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/edge"
	"entgo.io/ent/schema/field"
)

type AgentBase struct {
	ent.Schema
}

func (AgentBase) Fields() []ent.Field {
	return []ent.Field{
		field.String("id").Comment("id"),
		field.String("q").Optional().Default("").Comment("q"),
		field.String("a").Optional().Default("").Comment("a"),
		field.Uint64("chunk_index").Positive().Comment("chunk_index"),
		field.JSON("indexes", []string{}).Optional().
			Annotations(entsql.WithComments(true)).
			Comment("indexes"),
		field.String("dataset_id").Optional().Default("").Comment("dataset_id"),
		field.String("collection_id").Optional().Default("").Comment("collection_id"),
		field.String("source_name").Optional().Default("").Comment("source_name"),
		field.JSON("can_write", []bool{}).Optional().
			Annotations(entsql.WithComments(true)).
			Comment("can_write"),
		field.JSON("is_owner", []bool{}).Optional().
			Annotations(entsql.WithComments(true)).
			Comment("is_owner"),
	}
}

func (AgentBase) Mixin() []ent.Mixin {
	return []ent.Mixin{}
}

func (AgentBase) Edges() []ent.Edge {
	return []ent.Edge{
		edge.To("wx_agent", Wx.Type),
	}
}

func (AgentBase) Indexes() []ent.Index {
	return []ent.Index{}
}

func (AgentBase) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		entsql.Annotation{Table: "agent_base"},
	}
}
