diff --git a/backend/biz/agentresource/bare_repo_ensurer.go b/backend/biz/agentresource/bare_repo_ensurer.go new file mode 100644 index 00000000..797122af --- /dev/null +++ b/backend/biz/agentresource/bare_repo_ensurer.go @@ -0,0 +1,93 @@ +package agentresource + +import ( + "context" + "fmt" + + "github.com/google/uuid" + + "github.com/chaitin/MonkeyCode/backend/db" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" +) + +// BareRepoSourceType / BareRepoScopeType 与 ent enum 字符串严格保持一致。 +const ( + BareRepoSourceType = "bare" + BareRepoScopeTypeTeam = "team" + BareRepoScopeTypeGlobal = "global" +) + +// teamBareRepoName 生成 bare repo 的展示名,与 docs/skill-architecture.md §3 +// 锁定的命名一致(`team-`)。 +func teamBareRepoName(teamID uuid.UUID) string { + return fmt.Sprintf("team-%s", teamID.String()) +} + +// EnsureTeamBareReposTx 保证给定 team 存在恰好一个 bare skill_repo 与一个 bare +// plugin_repo(对应 docs/skill-architecture.md §3 中的 provision 钩子)。 +// 幂等:已存在则原样返回(不重复创建,不更新);不存在则插入。 +// 必须在事务内调用,事务由调用方持有(典型场景是 InitTeam 的事务尾部)。 +func EnsureTeamBareReposTx(ctx context.Context, tx *db.Tx, teamID, createdBy uuid.UUID) (*db.AgentSkillRepo, *db.AgentPluginRepo, error) { + scopeID := teamID.String() + + skillRepo, err := ensureTeamBareSkillRepo(ctx, tx, teamID, scopeID, createdBy) + if err != nil { + return nil, nil, fmt.Errorf("ensure bare skill repo: %w", err) + } + pluginRepo, err := ensureTeamBarePluginRepo(ctx, tx, teamID, scopeID, createdBy) + if err != nil { + return nil, nil, fmt.Errorf("ensure bare plugin repo: %w", err) + } + return skillRepo, pluginRepo, nil +} + +func ensureTeamBareSkillRepo(ctx context.Context, tx *db.Tx, teamID uuid.UUID, scopeID string, createdBy uuid.UUID) (*db.AgentSkillRepo, error) { + existing, err := tx.AgentSkillRepo.Query(). + Where( + agentskillrepo.ScopeTypeEQ(agentskillrepo.ScopeTypeTeam), + agentskillrepo.ScopeIDEQ(scopeID), + agentskillrepo.SourceTypeEQ(agentskillrepo.SourceTypeBare), + agentskillrepo.IsDeletedEQ(false), + ). + First(ctx) + if err == nil { + return existing, nil + } + if !db.IsNotFound(err) { + return nil, err + } + return tx.AgentSkillRepo.Create(). + SetID(uuid.New()). + SetName(teamBareRepoName(teamID)). + SetScopeType(agentskillrepo.ScopeTypeTeam). + SetScopeID(scopeID). + SetCreatedBy(createdBy). + SetSourceType(agentskillrepo.SourceTypeBare). + Save(ctx) +} + +func ensureTeamBarePluginRepo(ctx context.Context, tx *db.Tx, teamID uuid.UUID, scopeID string, createdBy uuid.UUID) (*db.AgentPluginRepo, error) { + existing, err := tx.AgentPluginRepo.Query(). + Where( + agentpluginrepo.ScopeTypeEQ(agentpluginrepo.ScopeTypeTeam), + agentpluginrepo.ScopeIDEQ(scopeID), + agentpluginrepo.SourceTypeEQ(agentpluginrepo.SourceTypeBare), + agentpluginrepo.IsDeletedEQ(false), + ). + First(ctx) + if err == nil { + return existing, nil + } + if !db.IsNotFound(err) { + return nil, err + } + return tx.AgentPluginRepo.Create(). + SetID(uuid.New()). + SetName(teamBareRepoName(teamID)). + SetScopeType(agentpluginrepo.ScopeTypeTeam). + SetScopeID(scopeID). + SetCreatedBy(createdBy). + SetSourceType(agentpluginrepo.SourceTypeBare). + Save(ctx) +} diff --git a/backend/biz/agentresource/noop_objectstore.go b/backend/biz/agentresource/noop_objectstore.go new file mode 100644 index 00000000..ae7d018d --- /dev/null +++ b/backend/biz/agentresource/noop_objectstore.go @@ -0,0 +1,27 @@ +package agentresource + +import ( + "context" + "errors" + "fmt" + "io" + "time" +) + +// noopObjectStore is used when ObjectStorage is disabled in config. Every +// fetch fails with a stable sentinel-ish error so resolver-level warn logs +// stay informative ("skill skipped: object storage disabled") rather than +// crashing with a nil deref. +type noopObjectStore struct{} + +func (noopObjectStore) GetObject(_ context.Context, _ string) (io.ReadCloser, error) { + return nil, fmt.Errorf("object storage disabled") +} + +func (noopObjectStore) PresignGet(_ context.Context, _ string, _ time.Duration) (string, error) { + return "", errors.New("object storage disabled") +} + +func (noopObjectStore) PutFile(_ context.Context, _, _ string, _ io.Reader) error { + return errors.New("object storage disabled") +} diff --git a/backend/biz/agentresource/register.go b/backend/biz/agentresource/register.go new file mode 100644 index 00000000..aa0b056a --- /dev/null +++ b/backend/biz/agentresource/register.go @@ -0,0 +1,77 @@ +// Package agentresource — DI wiring for the agent-resource read-only stack. +// +// The Repo / Resolver pair is consumed by: +// - biz/task/usecase (rule + skill + plugin injection into ConfigFile slice) +// - biz/skill/handler/v1 (/api/v1/skills picker) +// - biz/plugin/handler/v1 (/api/v1/plugins picker) +package agentresource + +import ( + "context" + "log/slog" + + "github.com/samber/do" + + "github.com/chaitin/MonkeyCode/backend/config" + "github.com/chaitin/MonkeyCode/backend/db" + "github.com/chaitin/MonkeyCode/backend/pkg/oss" +) + +// ProvideAgentResource wires the agent-resource module. The ObjectStore is +// picked from whichever bucket block is configured: +// +// - object_storage.enabled = true → AWS-SDK-v2 client (any S3-compatible +// store: MinIO, RustFS, real AWS). Reuses the same client avatar / repo / +// spec / temp uploads use, so single SDK in the binary. +// - aliyun.public_oss.bucket set → aliyun-oss-go-sdk client. AWS SDK's +// SigV4 signer is incompatible with Aliyun OSS (SignatureDoesNotMatch + +// bucket double-prefix in path-style URLs), so we wire a native client +// just for this code path. Existing pkg/oss.Client is untouched; avatar +// etc. still go through the AWS SDK path when object_storage is on. +// - neither configured → nil ObjectStore. Resolver downgrades +// to noopObjectStore; fetch/presign each fail and the per-asset skip +// pipeline keeps the task creating without rule/skill/plugin assets. +func ProvideAgentResource(i *do.Injector) { + do.Provide(i, func(i *do.Injector) (Repo, error) { + return NewRepo(do.MustInvoke[*db.Client](i)), nil + }) + + do.Provide(i, func(i *do.Injector) (ObjectStore, error) { + cfg := do.MustInvoke[*config.Config](i) + logger := do.MustInvoke[*slog.Logger](i) + + // Primary: ObjectStorage block — AWS-SDK-v2 client. + if cfg.ObjectStorage.Enabled { + opt := oss.S3Option{ + ForcePathStyle: cfg.ObjectStorage.ForcePathStyle, + InitBucket: cfg.ObjectStorage.InitBucket, + } + client, err := oss.NewS3Compatible(context.Background(), cfg.ObjectStorage, opt) + if err != nil { + return nil, err + } + return client, nil + } + + // Fallback: aliyun.public_oss — native aliyun-oss-go-sdk client. + if pub := cfg.Aliyun.PublicOSS; pub.Bucket != "" && pub.Endpoint != "" { + logger.Info("agentresource: using aliyun.public_oss (native SDK)", + "endpoint", pub.Endpoint, "bucket", pub.Bucket) + client, err := oss.NewAliyunOSS(pub) + if err != nil { + return nil, err + } + return client, nil + } + + // Neither block configured — Resolver downgrades to noopObjectStore. + return noopObjectStore{}, nil + }) + + do.Provide(i, func(i *do.Injector) (ResolverInterface, error) { + repo := do.MustInvoke[Repo](i) + store := do.MustInvoke[ObjectStore](i) + logger := do.MustInvoke[*slog.Logger](i) + return NewResolver(repo, store, logger), nil + }) +} diff --git a/backend/biz/agentresource/repo.go b/backend/biz/agentresource/repo.go new file mode 100644 index 00000000..0e6b61e5 --- /dev/null +++ b/backend/biz/agentresource/repo.go @@ -0,0 +1,803 @@ +package agentresource + +import ( + "context" + "fmt" + "sort" + + "github.com/google/uuid" + + "github.com/chaitin/MonkeyCode/backend/db" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/chaitin/MonkeyCode/backend/db/teamgroup" +) + +// Repo is the read-only surface used by the task dispatch path and by the +// public listing endpoints. All methods are safe to call concurrently. +type Repo interface { + // ListActiveRules returns every non-deleted rule whose active version + // row exists. Used by getCodingConfigs. Rule content comes straight from + // the DB; there is no S3 indirection for rules. + ListActiveRules(ctx context.Context) ([]*RuleWithVersion, error) + + // ListActiveSkills returns the union of {userSelectedIDs} and + // {is_force_delivery=true} skills. Orphan skills are kept so the agent + // keeps shipping whatever was previously active. Deleted skills and + // skills without an active_version_id are skipped. + ListActiveSkills(ctx context.Context, userSelectedIDs []uuid.UUID) ([]*SkillWithVersion, error) + + // ListActivePlugins mirrors ListActiveSkills for plugins. + ListActivePlugins(ctx context.Context, userSelectedIDs []uuid.UUID) ([]*PluginWithVersion, error) + + // ListSkillsForListing powers the /api/v1/skills picker. Orphans are + // hidden because users should not pick a resource that is no longer + // in the upstream repo. + ListSkillsForListing(ctx context.Context) ([]*ResourceListItem, error) + + // ListPluginsForListing powers the /api/v1/plugins picker. + ListPluginsForListing(ctx context.Context) ([]*ResourceListItem, error) + + // ---- ScopeFilter variants (three-tier picker / dispatch) ---- + + // ListSkillsForListingScoped returns the picker view filtered by scope. + // Unlike the legacy variant, this does NOT filter by enabled — the + // disabled rows are returned with Enabled=false so the picker can render + // a greyed-out chip. Name-based override is applied (user > team > global) + // using the rule: same name across scopes → the higher-priority one wins. + // Groups are populated for scope=team skills only. + ListSkillsForListingScoped(ctx context.Context, f ScopeFilter) ([]*ResourceListItem, error) + + // ListPluginsForListingScoped is the plugin counterpart. Groups are + // always empty (no team-admin plugin upload UX). + ListPluginsForListingScoped(ctx context.Context, f ScopeFilter) ([]*ResourceListItem, error) + + // ListActiveSkillsScoped is the dispatch-time query. It applies the + // SAME scope filter + name-override semantics as the listing path, but + // also filters out enabled=false rows entirely (because we won't dispatch + // a disabled skill even if the user explicitly picked it). Returns the + // union of {SkillSelection.UserSelectedIDs} ∪ {is_force_delivery=true} + // within scope. + ListActiveSkillsScoped(ctx context.Context, sel SkillSelection) ([]*SkillWithVersion, error) + + // ListActivePluginsScoped is the plugin counterpart. + ListActivePluginsScoped(ctx context.Context, sel SkillSelection) ([]*PluginWithVersion, error) +} + +type repoImpl struct { + db *db.Client +} + +// NewRepo wires a Repo backed by the given ent client. +func NewRepo(client *db.Client) Repo { + return &repoImpl{db: client} +} + +// ---- rules ---- + +func (r *repoImpl) ListActiveRules(ctx context.Context) ([]*RuleWithVersion, error) { + rules, err := r.db.AgentRule.Query(). + Where( + agentrule.IsDeletedEQ(false), + agentrule.ActiveVersionIDNotNil(), + ). + Order(db.Asc(agentrule.FieldName)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list rules: %w", err) + } + if len(rules) == 0 { + return nil, nil + } + + versionIDs := make([]uuid.UUID, 0, len(rules)) + for _, ru := range rules { + if ru.ActiveVersionID != nil { + versionIDs = append(versionIDs, *ru.ActiveVersionID) + } + } + + versions, err := r.db.AgentRuleVersion.Query(). + Where(agentruleversion.IDIn(versionIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list rule versions: %w", err) + } + + versionByID := make(map[uuid.UUID]*db.AgentRuleVersion, len(versions)) + for _, v := range versions { + versionByID[v.ID] = v + } + + out := make([]*RuleWithVersion, 0, len(rules)) + for _, ru := range rules { + if ru.ActiveVersionID == nil { + continue + } + v, ok := versionByID[*ru.ActiveVersionID] + if !ok { + // Active version dangling — should not happen in practice but + // skip rather than crash task creation. + continue + } + out = append(out, &RuleWithVersion{ + ID: ru.ID, + Name: ru.Name, + Version: v.Version, + Content: v.Content, + UpdatedAt: ru.UpdatedAt, + }) + } + return out, nil +} + +// ---- skills ---- + +func (r *repoImpl) ListActiveSkills(ctx context.Context, userSelectedIDs []uuid.UUID) ([]*SkillWithVersion, error) { + // Base filter: not deleted + has an active version. We then OR together + // (id in user-selected) and (is_force_delivery = true). + q := r.db.AgentSkill.Query(). + Where( + agentskill.IsDeletedEQ(false), + agentskill.ActiveVersionIDNotNil(), + ) + + if len(userSelectedIDs) == 0 { + // Only force-delivery skills matter when the caller selected none. + q = q.Where(agentskill.IsForceDeliveryEQ(true)) + } else { + q = q.Where(agentskill.Or( + agentskill.IDIn(userSelectedIDs...), + agentskill.IsForceDeliveryEQ(true), + )) + } + + skills, err := q.Order(db.Asc(agentskill.FieldName)).All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list skills: %w", err) + } + if len(skills) == 0 { + return nil, nil + } + + versionIDs := make([]uuid.UUID, 0, len(skills)) + for _, s := range skills { + if s.ActiveVersionID != nil { + versionIDs = append(versionIDs, *s.ActiveVersionID) + } + } + + versions, err := r.db.AgentSkillVersion.Query(). + Where(agentskillversion.IDIn(versionIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list skill versions: %w", err) + } + + versionByID := make(map[uuid.UUID]*db.AgentSkillVersion, len(versions)) + for _, v := range versions { + versionByID[v.ID] = v + } + + out := make([]*SkillWithVersion, 0, len(skills)) + for _, s := range skills { + if s.ActiveVersionID == nil { + continue + } + v, ok := versionByID[*s.ActiveVersionID] + if !ok { + continue + } + out = append(out, &SkillWithVersion{ + ID: s.ID, + Name: s.Name, + Description: s.Description, + Version: v.Version, + S3Key: v.S3Key, + IsForceDelivery: s.IsForceDelivery, + IsOrphan: s.IsOrphan, + ParsedMeta: v.ParsedMeta, + UpdatedAt: s.UpdatedAt, + }) + } + return out, nil +} + +// ---- plugins ---- + +func (r *repoImpl) ListActivePlugins(ctx context.Context, userSelectedIDs []uuid.UUID) ([]*PluginWithVersion, error) { + q := r.db.AgentPlugin.Query(). + Where( + agentplugin.IsDeletedEQ(false), + agentplugin.ActiveVersionIDNotNil(), + ) + + if len(userSelectedIDs) == 0 { + q = q.Where(agentplugin.IsForceDeliveryEQ(true)) + } else { + q = q.Where(agentplugin.Or( + agentplugin.IDIn(userSelectedIDs...), + agentplugin.IsForceDeliveryEQ(true), + )) + } + + plugins, err := q.Order(db.Asc(agentplugin.FieldName)).All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list plugins: %w", err) + } + if len(plugins) == 0 { + return nil, nil + } + + versionIDs := make([]uuid.UUID, 0, len(plugins)) + for _, p := range plugins { + if p.ActiveVersionID != nil { + versionIDs = append(versionIDs, *p.ActiveVersionID) + } + } + + versions, err := r.db.AgentPluginVersion.Query(). + Where(agentpluginversion.IDIn(versionIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list plugin versions: %w", err) + } + + versionByID := make(map[uuid.UUID]*db.AgentPluginVersion, len(versions)) + for _, v := range versions { + versionByID[v.ID] = v + } + + out := make([]*PluginWithVersion, 0, len(plugins)) + for _, p := range plugins { + if p.ActiveVersionID == nil { + continue + } + v, ok := versionByID[*p.ActiveVersionID] + if !ok { + continue + } + out = append(out, &PluginWithVersion{ + ID: p.ID, + Name: p.Name, + Description: p.Description, + Version: v.Version, + S3Key: v.S3Key, + IsForceDelivery: p.IsForceDelivery, + IsOrphan: p.IsOrphan, + Entry: v.ParsedMeta.Entry, + UpdatedAt: p.UpdatedAt, + }) + } + return out, nil +} + +// ---- listing endpoints ---- + +func (r *repoImpl) ListSkillsForListing(ctx context.Context) ([]*ResourceListItem, error) { + skills, err := r.db.AgentSkill.Query(). + Where( + agentskill.IsDeletedEQ(false), + agentskill.IsOrphanEQ(false), + agentskill.ActiveVersionIDNotNil(), + ). + Order(db.Asc(agentskill.FieldName)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list skills for listing: %w", err) + } + if len(skills) == 0 { + return nil, nil + } + + versionIDs := make([]uuid.UUID, 0, len(skills)) + for _, s := range skills { + if s.ActiveVersionID != nil { + versionIDs = append(versionIDs, *s.ActiveVersionID) + } + } + + versions, err := r.db.AgentSkillVersion.Query(). + Where(agentskillversion.IDIn(versionIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list skill versions for listing: %w", err) + } + + versionByID := make(map[uuid.UUID]*db.AgentSkillVersion, len(versions)) + for _, v := range versions { + versionByID[v.ID] = v + } + + out := make([]*ResourceListItem, 0, len(skills)) + for _, s := range skills { + if s.ActiveVersionID == nil { + continue + } + v, ok := versionByID[*s.ActiveVersionID] + if !ok { + continue + } + out = append(out, &ResourceListItem{ + ID: s.ID, + Name: s.Name, + Description: s.Description, + Version: v.Version, + IsForceDelivery: s.IsForceDelivery, + }) + } + return out, nil +} + +// ---- ScopeFilter variants ---- + +// pickSkillByName 实现 user > team > global 的名字覆盖规则。同名行只保留 +// 优先级最高的 scope 那一条。 +func pickSkillByName(items []*db.AgentSkill) []*db.AgentSkill { + priority := map[string]int{"global": 0, "team": 1, "user": 2} + best := map[string]*db.AgentSkill{} + for _, s := range items { + cur, ok := best[s.Name] + if !ok || priority[string(s.ScopeType)] > priority[string(cur.ScopeType)] { + best[s.Name] = s + } + } + out := make([]*db.AgentSkill, 0, len(best)) + for _, s := range best { + out = append(out, s) + } + sort.Slice(out, func(i, j int) bool { return out[i].Name < out[j].Name }) + return out +} + +func pickPluginByName(items []*db.AgentPlugin) []*db.AgentPlugin { + priority := map[string]int{"global": 0, "team": 1, "user": 2} + best := map[string]*db.AgentPlugin{} + for _, p := range items { + cur, ok := best[p.Name] + if !ok || priority[string(p.ScopeType)] > priority[string(cur.ScopeType)] { + best[p.Name] = p + } + } + out := make([]*db.AgentPlugin, 0, len(best)) + for _, p := range best { + out = append(out, p) + } + sort.Slice(out, func(i, j int) bool { return out[i].Name < out[j].Name }) + return out +} + +// applyScopeSkill builds an OR predicate matching the requested scopes. +// If no scope is selected (all false/nil), returns a never-match predicate +// so the query short-circuits to empty rather than returning all rows. +func applyScopeSkill(q *db.AgentSkillQuery, f ScopeFilter) *db.AgentSkillQuery { + var preds []predicate.AgentSkill + if f.IncludeGlobal { + preds = append(preds, agentskill.ScopeTypeEQ(agentskill.ScopeTypeGlobal)) + } + if f.TeamID != nil { + preds = append(preds, agentskill.And( + agentskill.ScopeTypeEQ(agentskill.ScopeTypeTeam), + agentskill.ScopeIDEQ(f.TeamID.String()), + )) + } + if f.UserID != nil { + preds = append(preds, agentskill.And( + agentskill.ScopeTypeEQ(agentskill.ScopeTypeUser), + agentskill.ScopeIDEQ(f.UserID.String()), + )) + } + if len(preds) == 0 { + return q.Where(agentskill.IDEQ(uuid.Nil)) + } + return q.Where(agentskill.Or(preds...)) +} + +func applyScopePlugin(q *db.AgentPluginQuery, f ScopeFilter) *db.AgentPluginQuery { + var preds []predicate.AgentPlugin + if f.IncludeGlobal { + preds = append(preds, agentplugin.ScopeTypeEQ(agentplugin.ScopeTypeGlobal)) + } + if f.TeamID != nil { + preds = append(preds, agentplugin.And( + agentplugin.ScopeTypeEQ(agentplugin.ScopeTypeTeam), + agentplugin.ScopeIDEQ(f.TeamID.String()), + )) + } + if f.UserID != nil { + preds = append(preds, agentplugin.And( + agentplugin.ScopeTypeEQ(agentplugin.ScopeTypeUser), + agentplugin.ScopeIDEQ(f.UserID.String()), + )) + } + if len(preds) == 0 { + return q.Where(agentplugin.IDEQ(uuid.Nil)) + } + return q.Where(agentplugin.Or(preds...)) +} + +func (r *repoImpl) ListSkillsForListingScoped(ctx context.Context, f ScopeFilter) ([]*ResourceListItem, error) { + q := r.db.AgentSkill.Query(). + Where( + agentskill.IsDeletedEQ(false), + agentskill.IsOrphanEQ(false), + agentskill.ActiveVersionIDNotNil(), + ). + Order(db.Asc(agentskill.FieldName)) + q = applyScopeSkill(q, f) + + skills, err := q.All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list skills scoped: %w", err) + } + if len(skills) == 0 { + return nil, nil + } + + // name-based override: user > team > global + skills = pickSkillByName(skills) + + versionIDs := make([]uuid.UUID, 0, len(skills)) + skillIDs := make([]uuid.UUID, 0, len(skills)) + for _, s := range skills { + if s.ActiveVersionID != nil { + versionIDs = append(versionIDs, *s.ActiveVersionID) + } + skillIDs = append(skillIDs, s.ID) + } + + versions, err := r.db.AgentSkillVersion.Query(). + Where(agentskillversion.IDIn(versionIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list skill versions scoped: %w", err) + } + versionByID := make(map[uuid.UUID]*db.AgentSkillVersion, len(versions)) + for _, v := range versions { + versionByID[v.ID] = v + } + + // groups: load all bindings for the selected skills, join team_groups + groupsBySkill, err := r.loadSkillGroups(ctx, skillIDs) + if err != nil { + return nil, err + } + + out := make([]*ResourceListItem, 0, len(skills)) + for _, s := range skills { + if s.ActiveVersionID == nil { + continue + } + v, ok := versionByID[*s.ActiveVersionID] + if !ok { + continue + } + desc := v.ParsedMeta.Description + if s.Description != "" { + desc = s.Description + } + if s.AdminDescription != nil && *s.AdminDescription != "" { + desc = *s.AdminDescription + } + tags := v.ParsedMeta.Tags + if s.AdminTags != nil { + tags = s.AdminTags + } + out = append(out, &ResourceListItem{ + ID: s.ID, + Name: s.Name, + Description: desc, + Version: v.Version, + IsForceDelivery: s.IsForceDelivery, + Tags: tags, + Categories: v.ParsedMeta.Categories, + Enabled: s.Enabled, + ScopeType: string(s.ScopeType), + ScopeID: s.ScopeID, + Groups: groupsBySkill[s.ID], + }) + } + return out, nil +} + +func (r *repoImpl) ListPluginsForListingScoped(ctx context.Context, f ScopeFilter) ([]*ResourceListItem, error) { + q := r.db.AgentPlugin.Query(). + Where( + agentplugin.IsDeletedEQ(false), + agentplugin.IsOrphanEQ(false), + agentplugin.ActiveVersionIDNotNil(), + ). + Order(db.Asc(agentplugin.FieldName)) + q = applyScopePlugin(q, f) + + plugins, err := q.All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list plugins scoped: %w", err) + } + if len(plugins) == 0 { + return nil, nil + } + plugins = pickPluginByName(plugins) + + versionIDs := make([]uuid.UUID, 0, len(plugins)) + for _, p := range plugins { + if p.ActiveVersionID != nil { + versionIDs = append(versionIDs, *p.ActiveVersionID) + } + } + versions, err := r.db.AgentPluginVersion.Query(). + Where(agentpluginversion.IDIn(versionIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list plugin versions scoped: %w", err) + } + versionByID := make(map[uuid.UUID]*db.AgentPluginVersion, len(versions)) + for _, v := range versions { + versionByID[v.ID] = v + } + + out := make([]*ResourceListItem, 0, len(plugins)) + for _, p := range plugins { + if p.ActiveVersionID == nil { + continue + } + v, ok := versionByID[*p.ActiveVersionID] + if !ok { + continue + } + out = append(out, &ResourceListItem{ + ID: p.ID, + Name: p.Name, + Description: p.Description, + Version: v.Version, + IsForceDelivery: p.IsForceDelivery, + Entry: v.ParsedMeta.Entry, + Enabled: p.Enabled, + ScopeType: string(p.ScopeType), + ScopeID: p.ScopeID, + }) + } + return out, nil +} + +func (r *repoImpl) ListActiveSkillsScoped(ctx context.Context, sel SkillSelection) ([]*SkillWithVersion, error) { + q := r.db.AgentSkill.Query(). + Where( + agentskill.IsDeletedEQ(false), + agentskill.EnabledEQ(true), + agentskill.ActiveVersionIDNotNil(), + ) + q = applyScopeSkill(q, sel.Scope) + + if len(sel.UserSelectedIDs) == 0 { + q = q.Where(agentskill.IsForceDeliveryEQ(true)) + } else { + q = q.Where(agentskill.Or( + agentskill.IDIn(sel.UserSelectedIDs...), + agentskill.IsForceDeliveryEQ(true), + )) + } + + skills, err := q.Order(db.Asc(agentskill.FieldName)).All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list active skills scoped: %w", err) + } + if len(skills) == 0 { + return nil, nil + } + skills = pickSkillByName(skills) + + versionIDs := make([]uuid.UUID, 0, len(skills)) + for _, s := range skills { + if s.ActiveVersionID != nil { + versionIDs = append(versionIDs, *s.ActiveVersionID) + } + } + versions, err := r.db.AgentSkillVersion.Query(). + Where(agentskillversion.IDIn(versionIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list active skill versions scoped: %w", err) + } + versionByID := make(map[uuid.UUID]*db.AgentSkillVersion, len(versions)) + for _, v := range versions { + versionByID[v.ID] = v + } + + out := make([]*SkillWithVersion, 0, len(skills)) + for _, s := range skills { + if s.ActiveVersionID == nil { + continue + } + v, ok := versionByID[*s.ActiveVersionID] + if !ok { + continue + } + out = append(out, &SkillWithVersion{ + ID: s.ID, + Name: s.Name, + Description: s.Description, + Version: v.Version, + S3Key: v.S3Key, + IsForceDelivery: s.IsForceDelivery, + IsOrphan: s.IsOrphan, + ParsedMeta: v.ParsedMeta, + UpdatedAt: s.UpdatedAt, + }) + } + return out, nil +} + +func (r *repoImpl) ListActivePluginsScoped(ctx context.Context, sel SkillSelection) ([]*PluginWithVersion, error) { + q := r.db.AgentPlugin.Query(). + Where( + agentplugin.IsDeletedEQ(false), + agentplugin.EnabledEQ(true), + agentplugin.ActiveVersionIDNotNil(), + ) + q = applyScopePlugin(q, sel.Scope) + + if len(sel.UserSelectedIDs) == 0 { + q = q.Where(agentplugin.IsForceDeliveryEQ(true)) + } else { + q = q.Where(agentplugin.Or( + agentplugin.IDIn(sel.UserSelectedIDs...), + agentplugin.IsForceDeliveryEQ(true), + )) + } + + plugins, err := q.Order(db.Asc(agentplugin.FieldName)).All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list active plugins scoped: %w", err) + } + if len(plugins) == 0 { + return nil, nil + } + plugins = pickPluginByName(plugins) + + versionIDs := make([]uuid.UUID, 0, len(plugins)) + for _, p := range plugins { + if p.ActiveVersionID != nil { + versionIDs = append(versionIDs, *p.ActiveVersionID) + } + } + versions, err := r.db.AgentPluginVersion.Query(). + Where(agentpluginversion.IDIn(versionIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list active plugin versions scoped: %w", err) + } + versionByID := make(map[uuid.UUID]*db.AgentPluginVersion, len(versions)) + for _, v := range versions { + versionByID[v.ID] = v + } + + out := make([]*PluginWithVersion, 0, len(plugins)) + for _, p := range plugins { + if p.ActiveVersionID == nil { + continue + } + v, ok := versionByID[*p.ActiveVersionID] + if !ok { + continue + } + out = append(out, &PluginWithVersion{ + ID: p.ID, + Name: p.Name, + Description: p.Description, + Version: v.Version, + S3Key: v.S3Key, + IsForceDelivery: p.IsForceDelivery, + IsOrphan: p.IsOrphan, + Entry: v.ParsedMeta.Entry, + UpdatedAt: p.UpdatedAt, + }) + } + return out, nil +} + +// loadSkillGroups joins agent_skill_group_bindings + team_groups to return +// per-skill group refs. Skills without any binding are absent from the map. +func (r *repoImpl) loadSkillGroups(ctx context.Context, skillIDs []uuid.UUID) (map[uuid.UUID][]ResourceGroupRef, error) { + if len(skillIDs) == 0 { + return map[uuid.UUID][]ResourceGroupRef{}, nil + } + bindings, err := r.db.AgentSkillGroupBinding.Query(). + Where(agentskillgroupbinding.SkillIDIn(skillIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: load skill groups: %w", err) + } + if len(bindings) == 0 { + return map[uuid.UUID][]ResourceGroupRef{}, nil + } + groupIDSet := make(map[uuid.UUID]struct{}) + for _, b := range bindings { + groupIDSet[b.GroupID] = struct{}{} + } + groupIDs := make([]uuid.UUID, 0, len(groupIDSet)) + for id := range groupIDSet { + groupIDs = append(groupIDs, id) + } + groups, err := r.db.TeamGroup.Query(). + Where(teamgroup.IDIn(groupIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: load groups: %w", err) + } + groupByID := make(map[uuid.UUID]*db.TeamGroup, len(groups)) + for _, g := range groups { + groupByID[g.ID] = g + } + out := make(map[uuid.UUID][]ResourceGroupRef, len(skillIDs)) + for _, b := range bindings { + g, ok := groupByID[b.GroupID] + if !ok { + continue + } + out[b.SkillID] = append(out[b.SkillID], ResourceGroupRef{ID: g.ID, Name: g.Name}) + } + return out, nil +} + +func (r *repoImpl) ListPluginsForListing(ctx context.Context) ([]*ResourceListItem, error) { + plugins, err := r.db.AgentPlugin.Query(). + Where( + agentplugin.IsDeletedEQ(false), + agentplugin.IsOrphanEQ(false), + agentplugin.ActiveVersionIDNotNil(), + ). + Order(db.Asc(agentplugin.FieldName)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list plugins for listing: %w", err) + } + if len(plugins) == 0 { + return nil, nil + } + + versionIDs := make([]uuid.UUID, 0, len(plugins)) + for _, p := range plugins { + if p.ActiveVersionID != nil { + versionIDs = append(versionIDs, *p.ActiveVersionID) + } + } + + versions, err := r.db.AgentPluginVersion.Query(). + Where(agentpluginversion.IDIn(versionIDs...)). + All(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list plugin versions for listing: %w", err) + } + + versionByID := make(map[uuid.UUID]*db.AgentPluginVersion, len(versions)) + for _, v := range versions { + versionByID[v.ID] = v + } + + out := make([]*ResourceListItem, 0, len(plugins)) + for _, p := range plugins { + if p.ActiveVersionID == nil { + continue + } + v, ok := versionByID[*p.ActiveVersionID] + if !ok { + continue + } + out = append(out, &ResourceListItem{ + ID: p.ID, + Name: p.Name, + Description: p.Description, + Version: v.Version, + IsForceDelivery: p.IsForceDelivery, + Entry: v.ParsedMeta.Entry, + }) + } + return out, nil +} diff --git a/backend/biz/agentresource/repo_test.go b/backend/biz/agentresource/repo_test.go new file mode 100644 index 00000000..95482808 --- /dev/null +++ b/backend/biz/agentresource/repo_test.go @@ -0,0 +1,442 @@ +package agentresource + +import ( + "context" + "testing" + + "github.com/google/uuid" + _ "github.com/mattn/go-sqlite3" + + "github.com/chaitin/MonkeyCode/backend/db" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/enttest" + enttypes "github.com/chaitin/MonkeyCode/backend/ent/types" +) + +func newTestDB(t *testing.T, name string) *db.Client { + t.Helper() + dsn := "file:" + name + "?mode=memory&cache=shared&_fk=1" + client := enttest.Open(t, "sqlite3", dsn) + t.Cleanup(func() { _ = client.Close() }) + return client +} + +// seedRule creates a rule + (optionally) a single version, and points +// active_version_id at it. The content argument is the seed value placed in +// agent_rule_versions.content (rule content lives entirely in the DB; no S3 +// involvement for rules). +func seedRule(t *testing.T, ctx context.Context, client *db.Client, name string, isDeleted bool, content string, withVersion bool) (ruleID, versionID uuid.UUID) { + t.Helper() + creator := uuid.New() + rule, err := client.AgentRule.Create(). + SetName(name). + SetCreatedBy(creator). + SetIsDeleted(isDeleted). + Save(ctx) + if err != nil { + t.Fatalf("seed rule %s: %v", name, err) + } + if !withVersion { + return rule.ID, uuid.Nil + } + v, err := client.AgentRuleVersion.Create(). + SetRuleID(rule.ID). + SetVersion("v1"). + SetContent(content). + Save(ctx) + if err != nil { + t.Fatalf("seed rule version %s: %v", name, err) + } + if _, err := client.AgentRule.UpdateOneID(rule.ID).SetActiveVersionID(v.ID).Save(ctx); err != nil { + t.Fatalf("set active version for rule %s: %v", name, err) + } + return rule.ID, v.ID +} + +type skillSeed struct { + name string + isDeleted bool + isOrphan bool + isForceDelivery bool + withVersion bool // if false, active_version_id stays nil +} + +func seedSkill(t *testing.T, ctx context.Context, client *db.Client, repoID uuid.UUID, s skillSeed) uuid.UUID { + t.Helper() + creator := uuid.New() + sk, err := client.AgentSkill.Create(). + SetRepoID(repoID). + SetName(s.name). + SetCreatedBy(creator). + SetIsDeleted(s.isDeleted). + SetIsOrphan(s.isOrphan). + SetIsForceDelivery(s.isForceDelivery). + Save(ctx) + if err != nil { + t.Fatalf("seed skill %s: %v", s.name, err) + } + if !s.withVersion { + return sk.ID + } + v, err := client.AgentSkillVersion.Create(). + SetResourceID(sk.ID). + SetVersion("v1"). + SetS3Key("skills/" + s.name + ".tgz"). + SetParsedMeta(enttypes.SkillParsedMeta{Description: s.name + " desc"}). + Save(ctx) + if err != nil { + t.Fatalf("seed skill version %s: %v", s.name, err) + } + if _, err := client.AgentSkill.UpdateOneID(sk.ID).SetActiveVersionID(v.ID).Save(ctx); err != nil { + t.Fatalf("set active version for skill %s: %v", s.name, err) + } + return sk.ID +} + +func seedSkillRepo(t *testing.T, ctx context.Context, client *db.Client) uuid.UUID { + t.Helper() + r, err := client.AgentSkillRepo.Create(). + SetName("default"). + SetSourceType(agentskillrepo.SourceTypeGithub). + SetGithubURL("https://example.com/skills.git"). + SetCreatedBy(uuid.New()). + Save(ctx) + if err != nil { + t.Fatalf("seed skill repo: %v", err) + } + return r.ID +} + +func seedPluginRepo(t *testing.T, ctx context.Context, client *db.Client) uuid.UUID { + t.Helper() + r, err := client.AgentPluginRepo.Create(). + SetName("default"). + SetSourceType(agentpluginrepo.SourceTypeGithub). + SetGithubURL("https://example.com/plugins.git"). + SetCreatedBy(uuid.New()). + Save(ctx) + if err != nil { + t.Fatalf("seed plugin repo: %v", err) + } + return r.ID +} + +type pluginSeed struct { + name string + isDeleted bool + isOrphan bool + isForceDelivery bool + withVersion bool + entry string +} + +func seedPlugin(t *testing.T, ctx context.Context, client *db.Client, repoID uuid.UUID, p pluginSeed) uuid.UUID { + t.Helper() + creator := uuid.New() + pl, err := client.AgentPlugin.Create(). + SetRepoID(repoID). + SetName(p.name). + SetCreatedBy(creator). + SetIsDeleted(p.isDeleted). + SetIsOrphan(p.isOrphan). + SetIsForceDelivery(p.isForceDelivery). + Save(ctx) + if err != nil { + t.Fatalf("seed plugin %s: %v", p.name, err) + } + if !p.withVersion { + return pl.ID + } + entry := p.entry + if entry == "" { + entry = "index.js" + } + v, err := client.AgentPluginVersion.Create(). + SetResourceID(pl.ID). + SetVersion("v1"). + SetS3Key("plugins/" + p.name + ".tgz"). + SetParsedMeta(enttypes.PluginParsedMeta{Entry: entry}). + Save(ctx) + if err != nil { + t.Fatalf("seed plugin version %s: %v", p.name, err) + } + if _, err := client.AgentPlugin.UpdateOneID(pl.ID).SetActiveVersionID(v.ID).Save(ctx); err != nil { + t.Fatalf("set active version for plugin %s: %v", p.name, err) + } + return pl.ID +} + +// ---- ListActiveRules ---- + +func TestListActiveRules_ReturnsContent(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-rules-content") + + seedRule(t, ctx, client, "rule-a", false, "hello", true) + + repo := NewRepo(client) + out, err := repo.ListActiveRules(ctx) + if err != nil { + t.Fatalf("ListActiveRules: %v", err) + } + if len(out) != 1 || out[0].Name != "rule-a" { + t.Fatalf("expected rule-a only, got %+v", out) + } + if out[0].Content != "hello" { + t.Fatalf("expected content %q, got %q", "hello", out[0].Content) + } +} + +func TestListActiveRules_SkipsDeleted(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-rules-deleted") + + seedRule(t, ctx, client, "alive", false, "a", true) + seedRule(t, ctx, client, "tombstone", true, "b", true) + + repo := NewRepo(client) + out, err := repo.ListActiveRules(ctx) + if err != nil { + t.Fatalf("ListActiveRules: %v", err) + } + if len(out) != 1 || out[0].Name != "alive" { + t.Fatalf("expected only alive rule, got %+v", out) + } +} + +func TestListActiveRules_SkipsRuleWithoutActiveVersion(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-rules-nover") + + seedRule(t, ctx, client, "no-active", false, "", false) + + repo := NewRepo(client) + out, err := repo.ListActiveRules(ctx) + if err != nil { + t.Fatalf("ListActiveRules: %v", err) + } + if len(out) != 0 { + t.Fatalf("expected no rules, got %+v", out) + } +} + +// ---- ListActiveSkills ---- + +func TestListActiveSkills_UnionWithForceDelivery(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-skills-union") + repoID := seedSkillRepo(t, ctx, client) + + picked := seedSkill(t, ctx, client, repoID, skillSeed{name: "picked", withVersion: true}) + _ = seedSkill(t, ctx, client, repoID, skillSeed{name: "force", isForceDelivery: true, withVersion: true}) + _ = seedSkill(t, ctx, client, repoID, skillSeed{name: "ignored", withVersion: true}) // not selected, not forced + + repo := NewRepo(client) + out, err := repo.ListActiveSkills(ctx, []uuid.UUID{picked}) + if err != nil { + t.Fatalf("ListActiveSkills: %v", err) + } + names := skillNames(out) + if !equalStringSet(names, []string{"force", "picked"}) { + t.Fatalf("expected {force, picked}, got %v", names) + } +} + +func TestListActiveSkills_FilterDeleted(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-skills-deleted") + repoID := seedSkillRepo(t, ctx, client) + + gone := seedSkill(t, ctx, client, repoID, skillSeed{name: "gone", isDeleted: true, withVersion: true}) + _ = seedSkill(t, ctx, client, repoID, skillSeed{name: "force-gone", isDeleted: true, isForceDelivery: true, withVersion: true}) + + repo := NewRepo(client) + out, err := repo.ListActiveSkills(ctx, []uuid.UUID{gone}) + if err != nil { + t.Fatalf("ListActiveSkills: %v", err) + } + if len(out) != 0 { + t.Fatalf("expected no skills (all deleted), got %+v", out) + } +} + +func TestListActiveSkills_KeepsOrphans(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-skills-orphan") + repoID := seedSkillRepo(t, ctx, client) + + orphan := seedSkill(t, ctx, client, repoID, skillSeed{name: "orphan", isOrphan: true, withVersion: true}) + + repo := NewRepo(client) + out, err := repo.ListActiveSkills(ctx, []uuid.UUID{orphan}) + if err != nil { + t.Fatalf("ListActiveSkills: %v", err) + } + if len(out) != 1 || out[0].Name != "orphan" || !out[0].IsOrphan { + t.Fatalf("expected single orphan skill kept, got %+v", out) + } +} + +func TestListActiveSkills_EmptyUserIDs_OnlyForce(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-skills-emptyuser") + repoID := seedSkillRepo(t, ctx, client) + + _ = seedSkill(t, ctx, client, repoID, skillSeed{name: "force-1", isForceDelivery: true, withVersion: true}) + _ = seedSkill(t, ctx, client, repoID, skillSeed{name: "not-force", withVersion: true}) + + repo := NewRepo(client) + out, err := repo.ListActiveSkills(ctx, nil) + if err != nil { + t.Fatalf("ListActiveSkills: %v", err) + } + if len(out) != 1 || out[0].Name != "force-1" { + t.Fatalf("expected only force-1, got %+v", out) + } +} + +func TestListActiveSkills_SkipsNoActiveVersion(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-skills-nover") + repoID := seedSkillRepo(t, ctx, client) + + _ = seedSkill(t, ctx, client, repoID, skillSeed{name: "force-noversion", isForceDelivery: true, withVersion: false}) + + repo := NewRepo(client) + out, err := repo.ListActiveSkills(ctx, nil) + if err != nil { + t.Fatalf("ListActiveSkills: %v", err) + } + if len(out) != 0 { + t.Fatalf("expected no skills, got %+v", out) + } +} + +// ---- ListActivePlugins ---- + +func TestListActivePlugins_UnionAndEntry(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-plugins-union") + repoID := seedPluginRepo(t, ctx, client) + + picked := seedPlugin(t, ctx, client, repoID, pluginSeed{name: "picked", withVersion: true, entry: "main.js"}) + _ = seedPlugin(t, ctx, client, repoID, pluginSeed{name: "force", isForceDelivery: true, withVersion: true, entry: "force.js"}) + _ = seedPlugin(t, ctx, client, repoID, pluginSeed{name: "ignored", withVersion: true}) + + repo := NewRepo(client) + out, err := repo.ListActivePlugins(ctx, []uuid.UUID{picked}) + if err != nil { + t.Fatalf("ListActivePlugins: %v", err) + } + got := map[string]string{} + for _, p := range out { + got[p.Name] = p.Entry + } + if len(got) != 2 || got["picked"] != "main.js" || got["force"] != "force.js" { + t.Fatalf("expected picked/main.js + force/force.js, got %+v", got) + } +} + +// ---- ListSkillsForListing ---- + +func TestListSkillsForListing_ExcludesOrphans(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-skills-listing") + repoID := seedSkillRepo(t, ctx, client) + + _ = seedSkill(t, ctx, client, repoID, skillSeed{name: "active", withVersion: true}) + _ = seedSkill(t, ctx, client, repoID, skillSeed{name: "orphan", isOrphan: true, withVersion: true}) + _ = seedSkill(t, ctx, client, repoID, skillSeed{name: "deleted", isDeleted: true, withVersion: true}) + _ = seedSkill(t, ctx, client, repoID, skillSeed{name: "no-active", withVersion: false}) + + repo := NewRepo(client) + out, err := repo.ListSkillsForListing(ctx) + if err != nil { + t.Fatalf("ListSkillsForListing: %v", err) + } + names := listingNames(out) + if !equalStringSet(names, []string{"active"}) { + t.Fatalf("expected only {active}, got %v", names) + } + if out[0].Version != "v1" { + t.Fatalf("expected version v1, got %q", out[0].Version) + } +} + +// ---- ListPluginsForListing ---- + +func TestListPluginsForListing_ExcludesDeleted(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-plugins-listing") + repoID := seedPluginRepo(t, ctx, client) + + _ = seedPlugin(t, ctx, client, repoID, pluginSeed{name: "active", withVersion: true}) + _ = seedPlugin(t, ctx, client, repoID, pluginSeed{name: "orphan", isOrphan: true, withVersion: true}) + _ = seedPlugin(t, ctx, client, repoID, pluginSeed{name: "deleted", isDeleted: true, withVersion: true}) + + repo := NewRepo(client) + out, err := repo.ListPluginsForListing(ctx) + if err != nil { + t.Fatalf("ListPluginsForListing: %v", err) + } + names := listingNames(out) + if !equalStringSet(names, []string{"active"}) { + t.Fatalf("expected only {active}, got %v", names) + } +} + +func TestListPluginsForListing_CarriesEntry(t *testing.T) { + ctx := context.Background() + client := newTestDB(t, "agentresource-plugins-listing-entry") + repoID := seedPluginRepo(t, ctx, client) + + _ = seedPlugin(t, ctx, client, repoID, pluginSeed{name: "alpha", withVersion: true, entry: "dist/index.js"}) + + repo := NewRepo(client) + out, err := repo.ListPluginsForListing(ctx) + if err != nil { + t.Fatalf("ListPluginsForListing: %v", err) + } + if len(out) != 1 || out[0].Name != "alpha" { + t.Fatalf("expected one plugin alpha, got %+v", out) + } + if out[0].Entry != "dist/index.js" { + t.Fatalf("expected entry dist/index.js, got %q", out[0].Entry) + } +} + +// ---- helpers ---- + +func skillNames(items []*SkillWithVersion) []string { + out := make([]string, 0, len(items)) + for _, it := range items { + out = append(out, it.Name) + } + return out +} + +func listingNames(items []*ResourceListItem) []string { + out := make([]string, 0, len(items)) + for _, it := range items { + out = append(out, it.Name) + } + return out +} + +func equalStringSet(a, b []string) bool { + if len(a) != len(b) { + return false + } + set := map[string]int{} + for _, x := range a { + set[x]++ + } + for _, x := range b { + set[x]-- + if set[x] < 0 { + return false + } + } + return true +} diff --git a/backend/biz/agentresource/resolver.go b/backend/biz/agentresource/resolver.go new file mode 100644 index 00000000..55598c18 --- /dev/null +++ b/backend/biz/agentresource/resolver.go @@ -0,0 +1,306 @@ +package agentresource + +import ( + "context" + "fmt" + "io" + "log/slog" + "time" + + "github.com/google/uuid" +) + +// defaultPresignTTL is the lifetime baked into skill / plugin presigned GET +// URLs we hand off to the codingmatrix agent. 24h is the ceiling on task +// VM lifetime, so any URL minted at task-create time stays usable for the +// entire task run. +const defaultPresignTTL = 24 * time.Hour + +// ObjectStore is the minimal read-only surface the Resolver needs from an +// object store. *pkg/oss.Client implements this implicitly, but the interface +// is declared here so tests can inject in-memory fakes without pulling AWS +// SDK dependencies. +type ObjectStore interface { + GetObject(ctx context.Context, key string) (io.ReadCloser, error) + // PresignGet returns a presigned GET URL for the given full object key. + // Used by SkillRefs / PluginRefs so the dispatch path can hand the URL + // down to the codingmatrix agent (which fetches + unzips in-VM) + // instead of round-tripping the zip through the gRPC PushTasks call. + PresignGet(ctx context.Context, key string, expires time.Duration) (string, error) + // PutFile writes a zip artifact under {prefix}/{basename(filename)}. Used + // by the team-admin bare-repo upload flow (biz/team/usecase) so a single + // abstraction owns all skill/plugin OSS writes,无 oss SDK 直接耦合。 + PutFile(ctx context.Context, prefix, filename string, body io.Reader) error +} + +// ResolverInterface is the abstract surface consumed by the task dispatch +// path. It exists so callers (notably the task usecase) can depend on a +// minimal contract and inject fakes in tests. +type ResolverInterface interface { + Rules(ctx context.Context) ([]MaterializedRule, error) + Skills(ctx context.Context, userSelectedIDs []uuid.UUID) ([]MaterializedAsset, error) + Plugins(ctx context.Context, userSelectedIDs []uuid.UUID) ([]MaterializedAsset, error) + // SkillRefs / PluginRefs are the presigned-URL counterparts used by + // the AgentResources dispatch path. The legacy MaterializedAsset + // methods stay so callers we have not migrated keep compiling. + SkillRefs(ctx context.Context, userSelectedIDs []uuid.UUID) ([]SkillRef, error) + PluginRefs(ctx context.Context, userSelectedIDs []uuid.UUID) ([]PluginRef, error) + + // Scoped variants for the three-tier picker / dispatch path. Apply + // ScopeFilter at the SQL layer and name-based override (user > team > + // global) at the projection step. Enabled=false rows are excluded + // (dispatch should never carry disabled skills/plugins,即使 force_delivery)。 + SkillRefsScoped(ctx context.Context, sel SkillSelection) ([]SkillRef, error) + PluginRefsScoped(ctx context.Context, sel SkillSelection) ([]PluginRef, error) +} + +// Resolver glues the read-only Repo together with the read-only ObjectStore. +// It is the single seam used by the task dispatch path to turn DB rows + S3 +// keys into actual byte payloads. +// +// All methods are safe for concurrent use as long as the underlying Repo and +// ObjectStore implementations are; the resolver itself is stateless. +type Resolver struct { + repo Repo + objstore ObjectStore + logger *slog.Logger +} + +// NewResolver wires a Resolver. A nil logger falls back to slog.Default so +// the resolver is safe to construct without explicit wiring in tests. +func NewResolver(repo Repo, objstore ObjectStore, logger *slog.Logger) *Resolver { + if logger == nil { + logger = slog.Default() + } + return &Resolver{repo: repo, objstore: objstore, logger: logger} +} + +// Rules materializes every active rule by reading content directly from the +// shared DB (the admin BFF writes rule content into agent_rule_versions.content; +// no S3 round-trip is involved for rules). +func (r *Resolver) Rules(ctx context.Context) ([]MaterializedRule, error) { + rules, err := r.repo.ListActiveRules(ctx) + if err != nil { + return nil, fmt.Errorf("agentresource: list rules: %w", err) + } + out := make([]MaterializedRule, 0, len(rules)) + for _, ru := range rules { + out = append(out, MaterializedRule{Name: ru.Name, Content: ru.Content}) + } + return out, nil +} + +// Skills materializes the union of {userSelectedIDs} and force-delivery +// skills. Each skill's S3 object is expected to be a zip; per-skill failures +// (download, unzip, zip-bomb, zip-slip) are logged + skipped so a single bad +// skill never breaks the dispatch path. +func (r *Resolver) Skills(ctx context.Context, userSelectedIDs []uuid.UUID) ([]MaterializedAsset, error) { + skills, err := r.repo.ListActiveSkills(ctx, userSelectedIDs) + if err != nil { + return nil, fmt.Errorf("agentresource: list skills: %w", err) + } + out := make([]MaterializedAsset, 0, len(skills)) + for _, s := range skills { + body, err := r.fetch(ctx, s.S3Key) + if err != nil { + r.logger.WarnContext(ctx, "agentresource: skip skill, fetch failed", + slog.String("skill", s.Name), + slog.String("s3_key", s.S3Key), + slog.Any("err", err), + ) + continue + } + files, err := unzipToMemory(body, DefaultUnzipLimits) + if err != nil { + r.logger.WarnContext(ctx, "agentresource: skip skill, unzip failed", + slog.String("skill", s.Name), + slog.String("s3_key", s.S3Key), + slog.Any("err", err), + ) + continue + } + r.logger.InfoContext(ctx, "agentresource: skill resolved", + slog.String("skill", s.Name), + slog.String("version", s.Version), + slog.String("s3_key", s.S3Key), + slog.Int("files", len(files)), + ) + out = append(out, MaterializedAsset{Name: s.Name, Files: files}) + } + return out, nil +} + +// Plugins mirrors Skills but also carries the plugin entrypoint (already +// hoisted out of parsed_meta by the repo layer). +func (r *Resolver) Plugins(ctx context.Context, userSelectedIDs []uuid.UUID) ([]MaterializedAsset, error) { + plugins, err := r.repo.ListActivePlugins(ctx, userSelectedIDs) + if err != nil { + return nil, fmt.Errorf("agentresource: list plugins: %w", err) + } + out := make([]MaterializedAsset, 0, len(plugins)) + for _, p := range plugins { + body, err := r.fetch(ctx, p.S3Key) + if err != nil { + r.logger.WarnContext(ctx, "agentresource: skip plugin, fetch failed", + slog.String("plugin", p.Name), + slog.String("s3_key", p.S3Key), + slog.Any("err", err), + ) + continue + } + files, err := unzipToMemory(body, DefaultUnzipLimits) + if err != nil { + r.logger.WarnContext(ctx, "agentresource: skip plugin, unzip failed", + slog.String("plugin", p.Name), + slog.String("s3_key", p.S3Key), + slog.Any("err", err), + ) + continue + } + r.logger.InfoContext(ctx, "agentresource: plugin resolved", + slog.String("plugin", p.Name), + slog.String("version", p.Version), + slog.String("entry", p.Entry), + slog.String("s3_key", p.S3Key), + slog.Int("files", len(files)), + ) + out = append(out, MaterializedAsset{Name: p.Name, Entry: p.Entry, Files: files}) + } + return out, nil +} + +// SkillRefs is the presigned-URL alternative to Skills. The repo query and +// {user-selected ∪ force-delivery} union logic are identical; only the +// per-skill payload differs: instead of downloading + unzipping in-process, +// the resolver presigns the S3 key so the codingmatrix agent fetches the +// zip itself inside the task VM. +// +// Per-skill presign failures are warn-logged and skipped to preserve the +// "one bad skill never breaks dispatch" contract that Skills() upholds. +func (r *Resolver) SkillRefs(ctx context.Context, userSelectedIDs []uuid.UUID) ([]SkillRef, error) { + skills, err := r.repo.ListActiveSkills(ctx, userSelectedIDs) + if err != nil { + return nil, fmt.Errorf("agentresource: list skills: %w", err) + } + out := make([]SkillRef, 0, len(skills)) + for _, s := range skills { + url, err := r.objstore.PresignGet(ctx, s.S3Key, defaultPresignTTL) + if err != nil { + r.logger.WarnContext(ctx, "agentresource: skip skill, presign failed", + slog.String("skill", s.Name), + slog.String("s3_key", s.S3Key), + slog.Any("err", err), + ) + continue + } + r.logger.InfoContext(ctx, "agentresource: skill ref resolved", + slog.String("skill", s.Name), + slog.String("version", s.Version), + slog.String("s3_key", s.S3Key), + slog.String("zip_url", url), + ) + out = append(out, SkillRef{ + Name: s.Name, + Version: s.Version, + ZipURL: url, + }) + } + return out, nil +} + +// PluginRefs mirrors SkillRefs for plugins and additionally carries the +// plugin entry filename — the mcai-backend task dispatcher needs that to +// patch the opencode.json `plugin` array with the right file:// URL. +func (r *Resolver) PluginRefs(ctx context.Context, userSelectedIDs []uuid.UUID) ([]PluginRef, error) { + plugins, err := r.repo.ListActivePlugins(ctx, userSelectedIDs) + if err != nil { + return nil, fmt.Errorf("agentresource: list plugins: %w", err) + } + out := make([]PluginRef, 0, len(plugins)) + for _, p := range plugins { + url, err := r.objstore.PresignGet(ctx, p.S3Key, defaultPresignTTL) + if err != nil { + r.logger.WarnContext(ctx, "agentresource: skip plugin, presign failed", + slog.String("plugin", p.Name), + slog.String("s3_key", p.S3Key), + slog.Any("err", err), + ) + continue + } + r.logger.InfoContext(ctx, "agentresource: plugin ref resolved", + slog.String("plugin", p.Name), + slog.String("version", p.Version), + slog.String("entry", p.Entry), + slog.String("s3_key", p.S3Key), + slog.String("zip_url", url), + ) + out = append(out, PluginRef{ + Name: p.Name, + Version: p.Version, + ZipURL: url, + EntryFilename: p.Entry, + }) + } + return out, nil +} + +// SkillRefsScoped is the three-tier-aware counterpart of SkillRefs. The repo +// query already enforces enabled=true + ScopeFilter + name override. +func (r *Resolver) SkillRefsScoped(ctx context.Context, sel SkillSelection) ([]SkillRef, error) { + skills, err := r.repo.ListActiveSkillsScoped(ctx, sel) + if err != nil { + return nil, fmt.Errorf("agentresource: list skills scoped: %w", err) + } + out := make([]SkillRef, 0, len(skills)) + for _, s := range skills { + url, err := r.objstore.PresignGet(ctx, s.S3Key, defaultPresignTTL) + if err != nil { + r.logger.WarnContext(ctx, "agentresource: skip skill (scoped), presign failed", + slog.String("skill", s.Name), + slog.String("s3_key", s.S3Key), + slog.Any("err", err), + ) + continue + } + out = append(out, SkillRef{Name: s.Name, Version: s.Version, ZipURL: url}) + } + return out, nil +} + +// PluginRefsScoped is the three-tier-aware counterpart of PluginRefs. +func (r *Resolver) PluginRefsScoped(ctx context.Context, sel SkillSelection) ([]PluginRef, error) { + plugins, err := r.repo.ListActivePluginsScoped(ctx, sel) + if err != nil { + return nil, fmt.Errorf("agentresource: list plugins scoped: %w", err) + } + out := make([]PluginRef, 0, len(plugins)) + for _, p := range plugins { + url, err := r.objstore.PresignGet(ctx, p.S3Key, defaultPresignTTL) + if err != nil { + r.logger.WarnContext(ctx, "agentresource: skip plugin (scoped), presign failed", + slog.String("plugin", p.Name), + slog.String("s3_key", p.S3Key), + slog.Any("err", err), + ) + continue + } + out = append(out, PluginRef{ + Name: p.Name, + Version: p.Version, + ZipURL: url, + EntryFilename: p.Entry, + }) + } + return out, nil +} + +// fetch pulls a single object body fully into memory. The body is always +// closed before returning, even on error. +func (r *Resolver) fetch(ctx context.Context, key string) ([]byte, error) { + rc, err := r.objstore.GetObject(ctx, key) + if err != nil { + return nil, err + } + defer rc.Close() + return io.ReadAll(rc) +} diff --git a/backend/biz/agentresource/resolver_test.go b/backend/biz/agentresource/resolver_test.go new file mode 100644 index 00000000..52096a37 --- /dev/null +++ b/backend/biz/agentresource/resolver_test.go @@ -0,0 +1,316 @@ +package agentresource + +import ( + "bytes" + "context" + "errors" + "io" + "sort" + "sync" + "testing" + "time" + + "github.com/google/uuid" +) + +// ---- fake ObjectStore ----------------------------------------------------- + +// fakeObjectStore is a thread-safe in-memory ObjectStore. Keys mapped in +// errFor return that error; otherwise the byte slice under data is wrapped +// in an io.NopCloser. +type fakeObjectStore struct { + mu sync.Mutex + data map[string][]byte + errFor map[string]error +} + +func newFakeObjectStore() *fakeObjectStore { + return &fakeObjectStore{ + data: map[string][]byte{}, + errFor: map[string]error{}, + } +} + +func (f *fakeObjectStore) put(key string, body []byte) { + f.mu.Lock() + defer f.mu.Unlock() + f.data[key] = body +} + +func (f *fakeObjectStore) GetObject(_ context.Context, key string) (io.ReadCloser, error) { + f.mu.Lock() + defer f.mu.Unlock() + if err, ok := f.errFor[key]; ok { + return nil, err + } + body, ok := f.data[key] + if !ok { + return nil, errors.New("fake: key not found: " + key) + } + return io.NopCloser(bytes.NewReader(body)), nil +} + +// PresignGet returns a deterministic fake URL ("https://fake/") so +// SkillRefs / PluginRefs tests can assert without touching real S3. Keys +// registered in errFor return that error instead. +func (f *fakeObjectStore) PutFile(_ context.Context, prefix, filename string, body io.Reader) error { + data, err := io.ReadAll(body) + if err != nil { + return err + } + f.put(prefix+"/"+filename, data) + return nil +} + +func (f *fakeObjectStore) PresignGet(_ context.Context, key string, _ time.Duration) (string, error) { + f.mu.Lock() + defer f.mu.Unlock() + if err, ok := f.errFor[key]; ok { + return "", err + } + return "https://fake/" + key, nil +} + +// ---- fake Repo ------------------------------------------------------------ + +type fakeRepo struct { + rules []*RuleWithVersion + rulesErr error + skills []*SkillWithVersion + skillsErr error + plugins []*PluginWithVersion + pluginsErr error + lastSkillIDs []uuid.UUID + lastPlugIDs []uuid.UUID +} + +func (f *fakeRepo) ListActiveRules(_ context.Context) ([]*RuleWithVersion, error) { + return f.rules, f.rulesErr +} +func (f *fakeRepo) ListActiveSkills(_ context.Context, ids []uuid.UUID) ([]*SkillWithVersion, error) { + f.lastSkillIDs = ids + return f.skills, f.skillsErr +} +func (f *fakeRepo) ListActivePlugins(_ context.Context, ids []uuid.UUID) ([]*PluginWithVersion, error) { + f.lastPlugIDs = ids + return f.plugins, f.pluginsErr +} +func (f *fakeRepo) ListSkillsForListing(_ context.Context) ([]*ResourceListItem, error) { + return nil, nil +} +func (f *fakeRepo) ListPluginsForListing(_ context.Context) ([]*ResourceListItem, error) { + return nil, nil +} +func (f *fakeRepo) ListSkillsForListingScoped(_ context.Context, _ ScopeFilter) ([]*ResourceListItem, error) { + return nil, nil +} +func (f *fakeRepo) ListPluginsForListingScoped(_ context.Context, _ ScopeFilter) ([]*ResourceListItem, error) { + return nil, nil +} +func (f *fakeRepo) ListActiveSkillsScoped(_ context.Context, sel SkillSelection) ([]*SkillWithVersion, error) { + f.lastSkillIDs = sel.UserSelectedIDs + return f.skills, f.skillsErr +} +func (f *fakeRepo) ListActivePluginsScoped(_ context.Context, sel SkillSelection) ([]*PluginWithVersion, error) { + f.lastPlugIDs = sel.UserSelectedIDs + return f.plugins, f.pluginsErr +} + +// ---- rules ---------------------------------------------------------------- + +func TestRules_HappyPath_TwoRules(t *testing.T) { + // Rule resolver reads content directly from the repo (DB) — no S3 fetch + // is performed, so we don't seed the fake objectstore here. + repo := &fakeRepo{rules: []*RuleWithVersion{ + {Name: "a", Content: "body-a"}, + {Name: "b", Content: "body-b"}, + }} + r := NewResolver(repo, newFakeObjectStore(), nil) + + got, err := r.Rules(context.Background()) + if err != nil { + t.Fatalf("unexpected err: %v", err) + } + if len(got) != 2 { + t.Fatalf("want 2 rules, got %d", len(got)) + } + if got[0].Name != "a" || got[0].Content != "body-a" { + t.Errorf("rule[0] = %+v", got[0]) + } + if got[1].Name != "b" || got[1].Content != "body-b" { + t.Errorf("rule[1] = %+v", got[1]) + } +} + +func TestRules_RepoErrorPropagates(t *testing.T) { + repo := &fakeRepo{rulesErr: errors.New("db down")} + r := NewResolver(repo, newFakeObjectStore(), nil) + _, err := r.Rules(context.Background()) + if err == nil { + t.Fatal("expected error") + } +} + +// ---- skills --------------------------------------------------------------- + +func TestSkills_UnzipPreservesRelPaths(t *testing.T) { + zipBytes := buildZip(t, map[string]string{ + "skill.md": "S", + "scripts/run.sh": "R", + }) + os := newFakeObjectStore() + os.put("skills/k.zip", zipBytes) + + repo := &fakeRepo{skills: []*SkillWithVersion{ + {Name: "k", S3Key: "skills/k.zip"}, + }} + r := NewResolver(repo, os, nil) + + got, err := r.Skills(context.Background(), nil) + if err != nil { + t.Fatalf("unexpected err: %v", err) + } + if len(got) != 1 || got[0].Name != "k" { + t.Fatalf("unexpected assets: %+v", got) + } + rel := map[string]string{} + for _, f := range got[0].Files { + rel[f.RelPath] = string(f.Content) + } + if rel["skill.md"] != "S" || rel["scripts/run.sh"] != "R" { + t.Errorf("relpaths = %+v", rel) + } +} + +func TestSkills_ZipBombGuard_FileTooBig_SkipsAsset(t *testing.T) { + // good skill is fine; bad skill has one entry > MaxFileSize. + good := buildZip(t, map[string]string{"ok.md": "ok"}) + + // 33 MiB of data — just over the 32 MiB default. + huge := bytes.Repeat([]byte("A"), int(DefaultUnzipLimits.MaxFileSize)+1024) + bad := buildZip(t, map[string]string{"big.bin": string(huge)}) + + os := newFakeObjectStore() + os.put("skills/good.zip", good) + os.put("skills/bad.zip", bad) + + repo := &fakeRepo{skills: []*SkillWithVersion{ + {Name: "good", S3Key: "skills/good.zip"}, + {Name: "bad", S3Key: "skills/bad.zip"}, + }} + r := NewResolver(repo, os, nil) + + got, err := r.Skills(context.Background(), nil) + if err != nil { + t.Fatalf("unexpected err: %v", err) + } + if len(got) != 1 || got[0].Name != "good" { + t.Fatalf("want only good skill, got %+v", got) + } +} + +func TestSkills_ZipSlip_Reject(t *testing.T) { + bad := buildZip(t, map[string]string{"../evil": "x"}) + good := buildZip(t, map[string]string{"a.md": "a"}) + + os := newFakeObjectStore() + os.put("skills/bad.zip", bad) + os.put("skills/good.zip", good) + + repo := &fakeRepo{skills: []*SkillWithVersion{ + {Name: "bad", S3Key: "skills/bad.zip"}, + {Name: "good", S3Key: "skills/good.zip"}, + }} + r := NewResolver(repo, os, nil) + + got, err := r.Skills(context.Background(), nil) + if err != nil { + t.Fatalf("unexpected err: %v", err) + } + if len(got) != 1 || got[0].Name != "good" { + t.Fatalf("want only good skill, got %+v", got) + } +} + +func TestSkills_UserSelectedUnion(t *testing.T) { + // Repo simulates the union itself; the resolver just needs to forward + // the IDs verbatim and materialize whatever the repo returned. + userID := uuid.New() + forceID := uuid.New() + + zipBytes := buildZip(t, map[string]string{"x.md": "x"}) + os := newFakeObjectStore() + os.put("u.zip", zipBytes) + os.put("f.zip", zipBytes) + + repo := &fakeRepo{skills: []*SkillWithVersion{ + {ID: userID, Name: "user-skill", S3Key: "u.zip"}, + {ID: forceID, Name: "force-skill", S3Key: "f.zip", IsForceDelivery: true}, + }} + r := NewResolver(repo, os, nil) + + got, err := r.Skills(context.Background(), []uuid.UUID{userID}) + if err != nil { + t.Fatalf("unexpected err: %v", err) + } + if len(got) != 2 { + t.Fatalf("want 2 skills, got %d", len(got)) + } + names := []string{got[0].Name, got[1].Name} + sort.Strings(names) + if names[0] != "force-skill" || names[1] != "user-skill" { + t.Errorf("names = %v", names) + } + if len(repo.lastSkillIDs) != 1 || repo.lastSkillIDs[0] != userID { + t.Errorf("repo received IDs = %v, want [%v]", repo.lastSkillIDs, userID) + } +} + +// ---- plugins -------------------------------------------------------------- + +func TestPlugins_EntryFieldPreserved(t *testing.T) { + zipBytes := buildZip(t, map[string]string{"main.js": "console.log(1)"}) + os := newFakeObjectStore() + os.put("plugins/p.zip", zipBytes) + + repo := &fakeRepo{plugins: []*PluginWithVersion{ + {Name: "p", S3Key: "plugins/p.zip", Entry: "main.js"}, + }} + r := NewResolver(repo, os, nil) + + got, err := r.Plugins(context.Background(), nil) + if err != nil { + t.Fatalf("unexpected err: %v", err) + } + if len(got) != 1 { + t.Fatalf("want 1 plugin, got %d", len(got)) + } + if got[0].Entry != "main.js" { + t.Errorf("entry = %q", got[0].Entry) + } + if len(got[0].Files) != 1 || got[0].Files[0].RelPath != "main.js" { + t.Errorf("files = %+v", got[0].Files) + } +} + +func TestPlugins_EmptyIDs_OnlyForce(t *testing.T) { + zipBytes := buildZip(t, map[string]string{"m.js": "x"}) + os := newFakeObjectStore() + os.put("only.zip", zipBytes) + + repo := &fakeRepo{plugins: []*PluginWithVersion{ + {Name: "force-only", S3Key: "only.zip", IsForceDelivery: true, Entry: "m.js"}, + }} + r := NewResolver(repo, os, nil) + + got, err := r.Plugins(context.Background(), nil) + if err != nil { + t.Fatalf("unexpected err: %v", err) + } + if len(got) != 1 || got[0].Name != "force-only" { + t.Fatalf("got %+v", got) + } + if len(repo.lastPlugIDs) != 0 { + t.Errorf("repo received IDs = %v, want empty", repo.lastPlugIDs) + } +} diff --git a/backend/biz/agentresource/types.go b/backend/biz/agentresource/types.go new file mode 100644 index 00000000..194bbff0 --- /dev/null +++ b/backend/biz/agentresource/types.go @@ -0,0 +1,169 @@ +// Package agentresource exposes read-only repository helpers for the agent +// rule / skill / plugin resources consumed by the task dispatch path. +// +// The package is intentionally narrow: it only surfaces the data needed by +// (a) the task usecase when assembling getCodingConfigs, and (b) the public +// list endpoints under /api/v1/skills + /api/v1/plugins. Mutations live in +// the admin BFF, not here. +package agentresource + +import ( + "time" + + "github.com/google/uuid" + + enttypes "github.com/chaitin/MonkeyCode/backend/ent/types" +) + +// RuleWithVersion is an agent rule joined with the row referenced by its +// active_version_id. Rule content is sourced directly from the +// agent_rule_versions.content column — there is no S3 indirection for rules +// (unlike skill / plugin which still go through S3-backed zip artifacts). +type RuleWithVersion struct { + ID uuid.UUID + Name string + Version string + Content string + UpdatedAt time.Time +} + +// SkillWithVersion is an agent skill joined with the row referenced by its +// active_version_id. Orphaned skills (is_orphan=true) are kept on purpose +// so that previously active versions remain deliverable until the operator +// explicitly deletes them. +type SkillWithVersion struct { + ID uuid.UUID + Name string + Description string + Version string + S3Key string + IsForceDelivery bool + IsOrphan bool + ParsedMeta enttypes.SkillParsedMeta + UpdatedAt time.Time +} + +// PluginWithVersion mirrors SkillWithVersion but for plugins. The Entry +// field is hoisted out of parsed_meta because the task dispatch path needs +// it as a flat string. +type PluginWithVersion struct { + ID uuid.UUID + Name string + Description string + Version string + S3Key string + IsForceDelivery bool + IsOrphan bool + Entry string + UpdatedAt time.Time +} + +// ResourceListItem is the lightweight projection returned to the public +// listing endpoints (skills / plugins). It deliberately omits S3 keys and +// orphan markers because those are dispatch-time concerns. +// +// Entry is only meaningful for plugins (taken from parsed_meta.entry) so +// the picker UI can preview where the plugin will be mounted; it is left +// empty for skills. +type ResourceListItem struct { + ID uuid.UUID + Name string + Description string + Version string + IsForceDelivery bool + Entry string + + // Below fields populated by the *Scoped variants used by the three-tier + // pickers. Old call sites that use the legacy listing methods see + // zero values for these; callers that consume the new fields should + // switch to ListSkillsForListingScoped / ListPluginsForListingScoped. + Tags []string + Categories []string + Enabled bool + ScopeType string // "global" | "team" | "user" + ScopeID string + // Groups is only populated when the skill is scope=team and the listing + // caller wants picker UI to show "shared with which team_group". plugin + // listing leaves it empty (plugins have no team-admin upload UX). + Groups []ResourceGroupRef +} + +// ResourceGroupRef is the minimal projection of team_groups exposed to the +// public skill picker so the UI can render the "shared with which group" +// chip without leaking the full team_group schema. +type ResourceGroupRef struct { + ID uuid.UUID + Name string +} + +// ScopeFilter constrains a listing or dispatch query to a subset of the +// three scope tiers. Used by the *Scoped Repo methods. +// +// Semantic: rows whose scope_type is "global" are included when +// IncludeGlobal is true; rows whose scope is "team" are included when +// TeamID != nil and matches; same for user. Multiple flags may be set — +// the result is the union, with name-based override (user > team > global) +// applied by the call sites that need overrides (Listing / dispatch). +type ScopeFilter struct { + IncludeGlobal bool + TeamID *uuid.UUID + UserID *uuid.UUID +} + +// GlobalOnlyScope is the default scope for back-compat call sites that +// haven't migrated to ScopeFilter yet. Matches the historical "global only" +// behavior of the unsuffixed Repo methods. +func GlobalOnlyScope() ScopeFilter { + return ScopeFilter{IncludeGlobal: true} +} + +// SkillSelection bundles a ScopeFilter with the user-picked skill IDs for +// the dispatch path. ListActiveSkillsScoped takes this so the same struct +// flows from the task usecase down to the SQL. +type SkillSelection struct { + Scope ScopeFilter + UserSelectedIDs []uuid.UUID +} + +// MaterializedRule is a fully fetched rule body, ready to be embedded into +// the getCodingConfigs response. +type MaterializedRule struct { + Name string + Content string +} + +// MaterializedFile is one entry inside an unzipped skill or plugin asset. +// RelPath is the path inside the archive (e.g. "skill.md", "scripts/run.sh"). +type MaterializedFile struct { + RelPath string + Content []byte +} + +// MaterializedAsset is a skill or plugin after S3 fetch + in-memory unzip. +// Entry is only populated for plugins (it is taken from parsed_meta.entry). +type MaterializedAsset struct { + Name string + Entry string + Files []MaterializedFile +} + +// SkillRef is a skill addressed by a presigned GET URL — the resolver no +// longer downloads + unzips the skill itself; the codingmatrix agent does +// that inside the task VM. This is the replacement for MaterializedAsset on +// the skill dispatch path and exists to keep the gRPC PushTasks payload +// under the 4MiB ceiling regardless of how many skills are in scope. +type SkillRef struct { + Name string + Version string + ZipURL string // presigned GET URL (TTL bound by the resolver) +} + +// PluginRef is the plugin counterpart of SkillRef. EntryFilename comes from +// parsed_meta.entry and is needed by mcai-backend to write the +// opencode.json `plugin` array — the agent itself does not consume it. +type PluginRef struct { + Name string + Version string + ZipURL string + EntryFilename string +} diff --git a/backend/biz/agentresource/unpack.go b/backend/biz/agentresource/unpack.go new file mode 100644 index 00000000..c611837c --- /dev/null +++ b/backend/biz/agentresource/unpack.go @@ -0,0 +1,127 @@ +package agentresource + +import ( + "archive/zip" + "bytes" + "fmt" + "io" + "path" + "strings" +) + +// UnzipLimits guards the in-memory unzipper against zip bombs and overly +// large archives. All limits are inclusive of the value (size == limit is OK). +type UnzipLimits struct { + MaxFileSize int64 // per-entry uncompressed size + MaxTotalSize int64 // sum of all entries' uncompressed sizes + MaxFiles int // max number of file entries +} + +// DefaultUnzipLimits is the policy used by the Resolver. +var DefaultUnzipLimits = UnzipLimits{ + MaxFileSize: 32 << 20, // 32 MiB + MaxTotalSize: 256 << 20, // 256 MiB + MaxFiles: 1000, +} + +// unzipToMemory reads a zip archive entirely from memory and returns its +// regular file entries. Directories are skipped. Paths are validated to +// reject zip-slip ("../..") and absolute paths. Entries that exceed the +// limits cause the entire archive to be rejected so callers can fall back +// to skipping the whole asset (matching the Resolver's per-skill policy). +func unzipToMemory(data []byte, limits UnzipLimits) ([]MaterializedFile, error) { + zr, err := zip.NewReader(bytes.NewReader(data), int64(len(data))) + if err != nil { + return nil, fmt.Errorf("agentresource: open zip: %w", err) + } + + // Pre-flight file count + declared uncompressed size. + fileCount := 0 + var totalDeclared uint64 + for _, f := range zr.File { + if f.FileInfo().IsDir() { + continue + } + fileCount++ + totalDeclared += f.UncompressedSize64 + } + if fileCount > limits.MaxFiles { + return nil, fmt.Errorf("agentresource: zip has %d files, max %d", fileCount, limits.MaxFiles) + } + if totalDeclared > uint64(limits.MaxTotalSize) { + return nil, fmt.Errorf("agentresource: zip declares %d bytes total, max %d", totalDeclared, limits.MaxTotalSize) + } + + out := make([]MaterializedFile, 0, fileCount) + var totalRead int64 + for _, f := range zr.File { + if f.FileInfo().IsDir() { + continue + } + + rel, err := sanitizeZipPath(f.Name) + if err != nil { + return nil, err + } + + // Trust-but-verify: even if UncompressedSize64 looks fine, cap + // per-entry reads to MaxFileSize via io.LimitReader. + if int64(f.UncompressedSize64) > limits.MaxFileSize { + return nil, fmt.Errorf("agentresource: zip entry %q declares %d bytes, max %d", + f.Name, f.UncompressedSize64, limits.MaxFileSize) + } + + rc, err := f.Open() + if err != nil { + return nil, fmt.Errorf("agentresource: open zip entry %q: %w", f.Name, err) + } + // limit + 1 so a file exactly at the limit reads cleanly but anything + // larger trips the over-cap check below. + limited := io.LimitReader(rc, limits.MaxFileSize+1) + buf, err := io.ReadAll(limited) + _ = rc.Close() + if err != nil { + return nil, fmt.Errorf("agentresource: read zip entry %q: %w", f.Name, err) + } + if int64(len(buf)) > limits.MaxFileSize { + return nil, fmt.Errorf("agentresource: zip entry %q exceeds per-file limit %d", + f.Name, limits.MaxFileSize) + } + totalRead += int64(len(buf)) + if totalRead > limits.MaxTotalSize { + return nil, fmt.Errorf("agentresource: zip exceeds total limit %d after entry %q", + limits.MaxTotalSize, f.Name) + } + + out = append(out, MaterializedFile{RelPath: rel, Content: buf}) + } + return out, nil +} + +// sanitizeZipPath rejects entries that try to escape the archive root via +// "..", absolute paths, or backslash separators. Forward-slash separators +// are preserved as-is so callers can write them out as relative paths. +func sanitizeZipPath(name string) (string, error) { + if name == "" { + return "", fmt.Errorf("agentresource: empty zip entry name") + } + // Reject Windows-style separators outright — Skill/Plugin packagers + // must use POSIX paths. + if strings.Contains(name, `\`) { + return "", fmt.Errorf("agentresource: zip entry %q uses backslash separator", name) + } + // Reject absolute paths. + if strings.HasPrefix(name, "/") { + return "", fmt.Errorf("agentresource: zip entry %q is absolute", name) + } + // path.Clean collapses ".." segments; if the result starts with ".." + // or equals "..", it tried to escape. + cleaned := path.Clean(name) + if cleaned == ".." || strings.HasPrefix(cleaned, "../") { + return "", fmt.Errorf("agentresource: zip-slip rejected for entry %q", name) + } + if cleaned == "." { + return "", fmt.Errorf("agentresource: zip entry %q resolves to root", name) + } + return cleaned, nil +} diff --git a/backend/biz/agentresource/unpack_test.go b/backend/biz/agentresource/unpack_test.go new file mode 100644 index 00000000..bf55f5ee --- /dev/null +++ b/backend/biz/agentresource/unpack_test.go @@ -0,0 +1,134 @@ +package agentresource + +import ( + "archive/zip" + "bytes" + "strings" + "testing" +) + +// buildZip is a tiny helper that produces an in-memory zip with the given +// entries. Used by both unpack_test.go and resolver_test.go. +func buildZip(t *testing.T, entries map[string]string) []byte { + t.Helper() + var buf bytes.Buffer + zw := zip.NewWriter(&buf) + for name, content := range entries { + w, err := zw.Create(name) + if err != nil { + t.Fatalf("zip create %s: %v", name, err) + } + if _, err := w.Write([]byte(content)); err != nil { + t.Fatalf("zip write %s: %v", name, err) + } + } + if err := zw.Close(); err != nil { + t.Fatalf("zip close: %v", err) + } + return buf.Bytes() +} + +func TestUnzipToMemory_HappyPath(t *testing.T) { + data := buildZip(t, map[string]string{ + "skill.md": "# hello", + "scripts/run.sh": "#!/bin/sh", + "docs/notes.txt": "n", + }) + files, err := unzipToMemory(data, DefaultUnzipLimits) + if err != nil { + t.Fatalf("unexpected err: %v", err) + } + if len(files) != 3 { + t.Fatalf("want 3 files, got %d", len(files)) + } + got := map[string]string{} + for _, f := range files { + got[f.RelPath] = string(f.Content) + } + if got["skill.md"] != "# hello" { + t.Errorf("skill.md content = %q", got["skill.md"]) + } + if got["scripts/run.sh"] != "#!/bin/sh" { + t.Errorf("scripts/run.sh content = %q", got["scripts/run.sh"]) + } +} + +func TestUnzipToMemory_RejectsZipSlip(t *testing.T) { + data := buildZip(t, map[string]string{ + "../evil.sh": "rm -rf /", + }) + _, err := unzipToMemory(data, DefaultUnzipLimits) + if err == nil { + t.Fatal("expected zip-slip rejection, got nil") + } + if !strings.Contains(err.Error(), "zip-slip") { + t.Errorf("err = %v, want zip-slip", err) + } +} + +func TestUnzipToMemory_RejectsAbsolutePath(t *testing.T) { + data := buildZip(t, map[string]string{ + "/etc/passwd": "x", + }) + _, err := unzipToMemory(data, DefaultUnzipLimits) + if err == nil { + t.Fatal("expected absolute-path rejection") + } +} + +func TestUnzipToMemory_FileTooBig(t *testing.T) { + big := strings.Repeat("A", 100) + data := buildZip(t, map[string]string{"a.txt": big}) + limits := UnzipLimits{MaxFileSize: 10, MaxTotalSize: 1000, MaxFiles: 10} + _, err := unzipToMemory(data, limits) + if err == nil { + t.Fatal("expected per-file limit rejection") + } +} + +func TestUnzipToMemory_TooManyFiles(t *testing.T) { + entries := map[string]string{} + for i := 0; i < 5; i++ { + entries[string(rune('a'+i))+".txt"] = "x" + } + data := buildZip(t, entries) + limits := UnzipLimits{MaxFileSize: 1000, MaxTotalSize: 1000, MaxFiles: 3} + _, err := unzipToMemory(data, limits) + if err == nil { + t.Fatal("expected file-count rejection") + } +} + +func TestUnzipToMemory_SkipsDirectories(t *testing.T) { + // Use a raw zip writer to add an explicit directory entry, which the + // helper map can't easily represent. + var buf bytes.Buffer + zw := zip.NewWriter(&buf) + if _, err := zw.Create("subdir/"); err != nil { + t.Fatalf("create dir: %v", err) + } + w, err := zw.Create("subdir/file.txt") + if err != nil { + t.Fatalf("create file: %v", err) + } + _, _ = w.Write([]byte("ok")) + _ = zw.Close() + + files, err := unzipToMemory(buf.Bytes(), DefaultUnzipLimits) + if err != nil { + t.Fatalf("unexpected err: %v", err) + } + if len(files) != 1 || files[0].RelPath != "subdir/file.txt" { + t.Fatalf("unexpected files: %+v", files) + } +} + +func TestUnzipToMemory_RejectsBackslash(t *testing.T) { + data := buildZip(t, map[string]string{ + `win\path.txt`: "x", + }) + _, err := unzipToMemory(data, DefaultUnzipLimits) + if err == nil { + t.Fatal("expected backslash rejection") + } +} diff --git a/backend/biz/plugin/handler/v1/plugin.go b/backend/biz/plugin/handler/v1/plugin.go new file mode 100644 index 00000000..6c864ff7 --- /dev/null +++ b/backend/biz/plugin/handler/v1/plugin.go @@ -0,0 +1,94 @@ +// Package v1 暴露 /api/v1/plugins 端点,从 agentresource.Repo 读 DB。仅 +// OpenCode CLI 会真正下发 plugin 资产,但列表端点对所有任务创建器可见。 +package v1 + +import ( + "log/slog" + + "github.com/GoYoko/web" + "github.com/samber/do" + + "github.com/chaitin/MonkeyCode/backend/biz/agentresource" + "github.com/chaitin/MonkeyCode/backend/db" + "github.com/chaitin/MonkeyCode/backend/db/teammember" + "github.com/chaitin/MonkeyCode/backend/domain" + "github.com/chaitin/MonkeyCode/backend/middleware" +) + +// PluginHandler plugin 列表处理器 +type PluginHandler struct { + repo agentresource.Repo + db *db.Client + logger *slog.Logger +} + +// NewPluginHandler 创建 plugin handler +func NewPluginHandler(i *do.Injector) (*PluginHandler, error) { + w := do.MustInvoke[*web.Web](i) + repo := do.MustInvoke[agentresource.Repo](i) + auth := do.MustInvoke[*middleware.AuthMiddleware](i) + targetActive := do.MustInvoke[*middleware.TargetActiveMiddleware](i) + logger := do.MustInvoke[*slog.Logger](i).With("handler", "plugin.handler") + + h := &PluginHandler{ + repo: repo, + db: do.MustInvoke[*db.Client](i), + logger: logger, + } + g := w.Group("/api/v1/plugins") + g.Use(auth.Auth(), targetActive.TargetActive()) + g.GET("", web.BaseHandler(h.ListEnabled)) + return h, nil +} + +// ListEnabled 获取当前用户视角下的 Plugins 列表 +// +// @Summary 获取 Plugins 列表 +// @Description 并集返回 (global ∪ 用户 active team) 两级 scope 下的 plugin,同名 team>global 覆盖;disabled 仍返回但 enabled=false。 +// @Tags 【公共】plugin +// @Security MonkeyCodeAIAuth +// @Accept json +// @Produce json +// @Success 200 {object} web.Resp{data=[]domain.PluginListItem} "获取成功" +// @Failure 500 {object} web.Resp "服务器内部错误" +// @Router /api/v1/plugins [get] +func (h *PluginHandler) ListEnabled(c *web.Context) error { + scope := h.userScope(c) + items, err := h.repo.ListPluginsForListingScoped(c.Request().Context(), scope) + if err != nil { + return err + } + resp := make([]*domain.PluginListItem, 0, len(items)) + for _, it := range items { + resp = append(resp, &domain.PluginListItem{ + ID: it.ID.String(), + Name: it.Name, + Description: it.Description, + Entry: it.Entry, + ActiveVersion: it.Version, + IsForceDelivery: it.IsForceDelivery, + Enabled: it.Enabled, + Scope: domain.SkillScope{Type: it.ScopeType, ID: it.ScopeID}, + }) + } + return c.Success(resp) +} + +func (h *PluginHandler) userScope(c *web.Context) agentresource.ScopeFilter { + f := agentresource.ScopeFilter{IncludeGlobal: true} + user := middleware.GetUser(c) + if user == nil { + return f + } + member, err := h.db.TeamMember.Query(). + Where(teammember.UserIDEQ(user.ID)). + First(c.Request().Context()) + if err != nil { + h.logger.WarnContext(c.Request().Context(), "userScope: query team_members failed", + "user_id", user.ID, "error", err) + return f + } + teamID := member.TeamID + f.TeamID = &teamID + return f +} diff --git a/backend/biz/plugin/register.go b/backend/biz/plugin/register.go new file mode 100644 index 00000000..279b57db --- /dev/null +++ b/backend/biz/plugin/register.go @@ -0,0 +1,15 @@ +package plugin + +import ( + "github.com/samber/do" + + v1 "github.com/chaitin/MonkeyCode/backend/biz/plugin/handler/v1" +) + +func ProvidePlugin(i *do.Injector) { + do.Provide(i, v1.NewPluginHandler) +} + +func InvokePlugin(i *do.Injector) { + do.MustInvoke[*v1.PluginHandler](i) +} diff --git a/backend/biz/register.go b/backend/biz/register.go index 62222b2b..2adfaf8f 100644 --- a/backend/biz/register.go +++ b/backend/biz/register.go @@ -6,14 +6,17 @@ import ( "github.com/google/uuid" "github.com/samber/do" + "github.com/chaitin/MonkeyCode/backend/biz/agentresource" "github.com/chaitin/MonkeyCode/backend/biz/file" "github.com/chaitin/MonkeyCode/backend/biz/git" "github.com/chaitin/MonkeyCode/backend/biz/host" "github.com/chaitin/MonkeyCode/backend/biz/llmproxy" "github.com/chaitin/MonkeyCode/backend/biz/notify" + "github.com/chaitin/MonkeyCode/backend/biz/plugin" "github.com/chaitin/MonkeyCode/backend/biz/project" "github.com/chaitin/MonkeyCode/backend/biz/public" "github.com/chaitin/MonkeyCode/backend/biz/setting" + "github.com/chaitin/MonkeyCode/backend/biz/skill" "github.com/chaitin/MonkeyCode/backend/biz/static" "github.com/chaitin/MonkeyCode/backend/biz/subscription" "github.com/chaitin/MonkeyCode/backend/biz/task" @@ -34,11 +37,14 @@ func RegisterAll(i *do.Injector) error { setting.ProvideSetting(i) team.ProvideTeam(i) host.ProvideHost(i) + agentresource.ProvideAgentResource(i) task.ProvideTask(i) git.ProvideGit(i) project.ProvideProject(i) file.ProvideFile(i) vmidle.ProvideVMIdle(i) + skill.ProvideSkill(i) + plugin.ProvidePlugin(i) return nil } @@ -54,6 +60,8 @@ func InvokeAll(i *do.Injector) { project.InvokeProject(i) file.InvokeFile(i) vmidle.InvokeVMIdle(i) + skill.InvokeSkill(i) + plugin.InvokePlugin(i) } // RegisterOpenSource 注册仅在开源项目中使用的模块 diff --git a/backend/biz/skill/handler/v1/skill.go b/backend/biz/skill/handler/v1/skill.go new file mode 100644 index 00000000..f2d5c560 --- /dev/null +++ b/backend/biz/skill/handler/v1/skill.go @@ -0,0 +1,106 @@ +// Package v1 暴露 /api/v1/skills 端点,从 agentresource.Repo 读 DB(agent_skills +// + agent_skill_versions),不再扫描 /app/skills 文件系统。 +package v1 + +import ( + "log/slog" + + "github.com/GoYoko/web" + "github.com/samber/do" + + "github.com/chaitin/MonkeyCode/backend/biz/agentresource" + "github.com/chaitin/MonkeyCode/backend/db" + "github.com/chaitin/MonkeyCode/backend/db/teammember" + "github.com/chaitin/MonkeyCode/backend/domain" + "github.com/chaitin/MonkeyCode/backend/middleware" +) + +// SkillHandler skill 列表处理器 +type SkillHandler struct { + repo agentresource.Repo + db *db.Client + logger *slog.Logger +} + +// NewSkillHandler 创建 skill handler +func NewSkillHandler(i *do.Injector) (*SkillHandler, error) { + w := do.MustInvoke[*web.Web](i) + repo := do.MustInvoke[agentresource.Repo](i) + auth := do.MustInvoke[*middleware.AuthMiddleware](i) + targetActive := do.MustInvoke[*middleware.TargetActiveMiddleware](i) + logger := do.MustInvoke[*slog.Logger](i).With("handler", "skill.handler") + + h := &SkillHandler{ + repo: repo, + db: do.MustInvoke[*db.Client](i), + logger: logger, + } + g := w.Group("/api/v1/skills") + g.Use(auth.Auth(), targetActive.TargetActive()) + g.GET("", web.BaseHandler(h.ListEnabled)) + return h, nil +} + +// ListEnabled 获取当前用户视角下的 Skill 列表 +// +// @Summary 获取本用户的 Skill 列表 +// @Description 并集返回 (global ∪ 用户 active team ∪ 用户个人) 三级 scope 下的 skill,禁用的 skill 返回 enabled=false。 +// @Tags 【用户】任务管理 +// @Security MonkeyCodeAIAuth +// @Accept json +// @Produce json +// @Success 200 {object} web.Resp{data=[]domain.SkillListItem} "获取成功" +// @Failure 500 {object} web.Resp "服务器内部错误" +// @Router /api/v1/skills [get] +func (h *SkillHandler) ListEnabled(c *web.Context) error { + scope := h.userScope(c) + items, err := h.repo.ListSkillsForListingScoped(c.Request().Context(), scope) + if err != nil { + return err + } + resp := make([]*domain.SkillListItem, 0, len(items)) + for _, it := range items { + groups := make([]domain.SkillGroupRef, 0, len(it.Groups)) + for _, g := range it.Groups { + groups = append(groups, domain.SkillGroupRef{ID: g.ID.String(), Name: g.Name}) + } + tags := it.Tags + if tags == nil { + tags = []string{} + } + resp = append(resp, &domain.SkillListItem{ + ID: it.ID.String(), + Name: it.Name, + Description: it.Description, + Tags: tags, + Categories: it.Categories, + ActiveVersion: it.Version, + IsForceDelivery: it.IsForceDelivery, + Enabled: it.Enabled, + Scope: domain.SkillScope{Type: it.ScopeType, ID: it.ScopeID}, + Groups: groups, + }) + } + return c.Success(resp) +} + +// userScope 从 DB 查用户所在 team(不依赖 session 里的 Team 字段),组装 +// ScopeFilter。当前取用户的第一个 team;后续多 team 场景可扩展为并集。 +func (h *SkillHandler) userScope(c *web.Context) agentresource.ScopeFilter { + f := agentresource.ScopeFilter{IncludeGlobal: true} + user := middleware.GetUser(c) + if user == nil { + return f + } + member, err := h.db.TeamMember.Query(). + Where(teammember.UserIDEQ(user.ID)). + First(c.Request().Context()) + if err != nil { + h.logger.WarnContext(c.Request().Context(), "userScope: query team_members failed", + "user_id", user.ID, "error", err) + return f + } + teamID := member.TeamID + f.TeamID = &teamID + return f +} diff --git a/backend/biz/skill/register.go b/backend/biz/skill/register.go new file mode 100644 index 00000000..76383432 --- /dev/null +++ b/backend/biz/skill/register.go @@ -0,0 +1,15 @@ +package skill + +import ( + "github.com/samber/do" + + v1 "github.com/chaitin/MonkeyCode/backend/biz/skill/handler/v1" +) + +func ProvideSkill(i *do.Injector) { + do.Provide(i, v1.NewSkillHandler) +} + +func InvokeSkill(i *do.Injector) { + do.MustInvoke[*v1.SkillHandler](i) +} diff --git a/backend/biz/task/handler/v1/speech.go b/backend/biz/task/handler/v1/speech.go index 63e91c0a..edc74d92 100644 --- a/backend/biz/task/handler/v1/speech.go +++ b/backend/biz/task/handler/v1/speech.go @@ -174,13 +174,13 @@ var speechStreamAllowedFormats = map[string]struct{}{ // @Description ### 1) start (第一帧必须是它) // @Description ```json // @Description { -// @Description "type": "start", -// @Description "format": "pcm", -// @Description "disfluency": false +// @Description "type": "start", +// @Description "format": "pcm", +// @Description "disfluency": false // @Description } // @Description ``` // @Description - `format` 可选,默认 `pcm`。支持 `pcm` / `wav` / `ogg` / `mp3`,单声道、16-bit、采样率固定 16000Hz -// @Description - `pcm` / `wav` 内部音频流必须是 `pcm_s16le`;`ogg` 必须为 `opus` 编码;`mp3` 由远端解码 +// @Description - `pcm` / `wav` 内部音频流必须是 `pcm_s16le`;`ogg` 必须为 `opus` 编码;`mp3` 由远端解码 // @Description - `disfluency` 可选,默认 `false`。`true` 时启用语义顺滑(过滤"嗯/啊"等口头禅、语义重复词) // @Description - 服务端校验通过 → 与豆包建立 WSS → 收到首个响应后向客户端下发 `ready` 事件(带 `logid`) // @Description - **客户端必须在收到 `ready` 之后才能发 Binary 音频帧** @@ -233,23 +233,23 @@ var speechStreamAllowedFormats = map[string]struct{}{ // @Description 豆包远端错误: // @Description ```json // @Description { -// @Description "type": "error", -// @Description "logid": "202407261553070FACFE6D19421815D605", -// @Description "error": { -// @Description "code": 45000001, -// @Description "message": "请求参数无效", -// @Description "request_id": "67ee89ba-7050-4c04-a3d7-ac61a63499b3", -// @Description "logid": "202407261553070FACFE6D19421815D605" -// @Description }, -// @Description "timestamp": 1733299205000 +// @Description "type": "error", +// @Description "logid": "202407261553070FACFE6D19421815D605", +// @Description "error": { +// @Description "code": 45000001, +// @Description "message": "请求参数无效", +// @Description "request_id": "67ee89ba-7050-4c04-a3d7-ac61a63499b3", +// @Description "logid": "202407261553070FACFE6D19421815D605" +// @Description }, +// @Description "timestamp": 1733299205000 // @Description } // @Description ``` // @Description 本服务前置校验错误(远端连接前):`code=0`,在 `message` 描述原因: // @Description ```json // @Description { -// @Description "type": "error", -// @Description "error": { "code": 0, "message": "first message must be a 'start' control message" }, -// @Description "timestamp": 1733299205000 +// @Description "type": "error", +// @Description "error": { "code": 0, "message": "first message must be a 'start' control message" }, +// @Description "timestamp": 1733299205000 // @Description } // @Description ``` // @Description @@ -281,13 +281,13 @@ var speechStreamAllowedFormats = map[string]struct{}{ // @Description - POST /speech-to-text:整段录音 → SSE 单段结果,适合短语音 ≤60s // @Description - 本接口:WS 双向实时流,支持长语音、句级 final、可被打断,适合 Web/移动端边说边显示 // @Description -// @Tags 【用户】任务管理 -// @Security MonkeyCodeAIAuth -// @Param start body domain.SpeechStreamStartReq false "[WS 协议] 客户端连接后首帧 JSON Text 控制消息 schema;不是 HTTP body,仅供前端代码生成 TS 类型,实际通过 WS Text 帧发送" -// @Success 101 {object} domain.SpeechStreamEvent "WebSocket 升级成功;此后通过 WS 帧通信,事件结构见上方说明" -// @Failure 401 {object} web.Resp "未授权" -// @Failure 500 {object} web.Resp "服务器内部错误(ASR 服务未配置等)" -// @Router /api/v1/users/tasks/speech-to-text-stream [get] +// @Tags 【用户】任务管理 +// @Security MonkeyCodeAIAuth +// @Param start body domain.SpeechStreamStartReq false "[WS 协议] 客户端连接后首帧 JSON Text 控制消息 schema;不是 HTTP body,仅供前端代码生成 TS 类型,实际通过 WS Text 帧发送" +// @Success 101 {object} domain.SpeechStreamEvent "WebSocket 升级成功;此后通过 WS 帧通信,事件结构见上方说明" +// @Failure 401 {object} web.Resp "未授权" +// @Failure 500 {object} web.Resp "服务器内部错误(ASR 服务未配置等)" +// @Router /api/v1/users/tasks/speech-to-text-stream [get] func (h *TaskHandler) SpeechToTextStream(c *web.Context) error { logger := h.logger.With("fn", "task.speech_to_text_stream") diff --git a/backend/biz/task/handler/v1/task.go b/backend/biz/task/handler/v1/task.go index b4a93a32..ebbf009a 100644 --- a/backend/biz/task/handler/v1/task.go +++ b/backend/biz/task/handler/v1/task.go @@ -6,9 +6,6 @@ import ( "errors" "fmt" "log/slog" - "os" - "path/filepath" - "strings" "time" "github.com/GoYoko/web" @@ -258,12 +255,8 @@ func (h *TaskHandler) Info(c *web.Context, req domain.IDReq[uuid.UUID]) error { func (h *TaskHandler) Create(c *web.Context, req domain.CreateTaskReq) error { user := middleware.GetUser(c) - // 校验 skill_ids - for _, skillID := range req.Extra.SkillIDs { - if err := validateSkillID(skillID); err != nil { - return errcode.ErrBadRequest.Wrap(err) - } - } + // skill_ids / plugin_ids 的 UUID 校验放到 usecase 层做,单条非法时跳过 + // 该 ID 并打 WARN 日志,避免脏数据把整个任务创建打挂。 // 公共主机处理 if req.HostID == consts.PUBLIC_HOST_ID { @@ -941,19 +934,3 @@ func (h *TaskHandler) ping( } } } - -// validateSkillID 验证 skillID 是否安全,防止路径遍历攻击 -func validateSkillID(skillID string) error { - if skillID == "" { - return fmt.Errorf("skill id cannot be empty") - } - cleanID := filepath.Clean(skillID) - if strings.Contains(cleanID, "..") || strings.HasPrefix(cleanID, "/") { - return fmt.Errorf("invalid skill id") - } - skilldir := filepath.Join(consts.SkillBaseDir, cleanID) - if !strings.HasPrefix(skilldir, consts.SkillBaseDir+string(os.PathSeparator)) { - return fmt.Errorf("skill path escape") - } - return nil -} diff --git a/backend/biz/task/usecase/task.go b/backend/biz/task/usecase/task.go index fb330fdb..c23d947b 100644 --- a/backend/biz/task/usecase/task.go +++ b/backend/biz/task/usecase/task.go @@ -7,7 +7,6 @@ import ( "encoding/json" "fmt" "log/slog" - "os" "path/filepath" "strings" "text/template" @@ -18,6 +17,8 @@ import ( "github.com/redis/go-redis/v9" "github.com/samber/do" + "github.com/chaitin/MonkeyCode/backend/biz/agentresource" + "github.com/chaitin/MonkeyCode/backend/db/teammember" gituc "github.com/chaitin/MonkeyCode/backend/biz/git/usecase" "github.com/chaitin/MonkeyCode/backend/biz/task/service" vmidle "github.com/chaitin/MonkeyCode/backend/biz/vmidle/usecase" @@ -60,6 +61,8 @@ type TaskUsecase struct { projectRepo domain.ProjectRepo taskActivityRefresher service.TaskActivityRefresher idleRefresher vmidle.VMIdleRefresher + dbClient *db.Client + resolver agentresource.ResolverInterface } // NewTaskUsecase 创建任务业务逻辑实例 @@ -80,6 +83,13 @@ func NewTaskUsecase(i *do.Injector) (domain.TaskUsecase, error) { projectRepo: do.MustInvoke[domain.ProjectRepo](i), taskActivityRefresher: do.MustInvoke[service.TaskActivityRefresher](i), idleRefresher: do.MustInvoke[vmidle.VMIdleRefresher](i), + dbClient: do.MustInvoke[*db.Client](i), + } + + // agentresource.ResolverInterface 注入失败时降级为 nil — getCodingConfigs + // 内部 nil-check,跳过 rule/skill/plugin 注入,并打 warn 日志。 + if r, err := do.Invoke[agentresource.ResolverInterface](i); err == nil { + u.resolver = r } // 可选注入 TaskHook @@ -191,13 +201,14 @@ func (a *TaskUsecase) SwitchModel(ctx context.Context, user *domain.User, taskID } } - coding, configs, err := a.getCodingConfigs(t.CliName, model, nil) + coding, configs, agentRes, err := a.getCodingConfigs(ctx, t.CliName, model, nil, nil, a.userScope(ctx, user)) if err != nil { return nil, err } if coding != taskflow.CodingAgentOpenCode { return nil, fmt.Errorf("switch model only supports opencode runtime") } + _ = agentRes // switch-model path does not currently forward AgentResources to taskflow. envs := map[string]string{ "OPENAI_API_KEY": model.APIKey, @@ -544,7 +555,7 @@ func (a *TaskUsecase) Create(ctx context.Context, user *domain.User, req domain. token = keys[0].APIKey } - coding, configs, err := a.getCodingConfigs(req.CliName, m, req.Extra.SkillIDs) + coding, configs, agentRes, err := a.getCodingConfigs(ctx, req.CliName, m, req.Extra.SkillIDs, req.Extra.PluginIDs, a.userScope(ctx, user)) if err != nil { return nil, err } @@ -580,7 +591,24 @@ func (a *TaskUsecase) Create(ctx context.Context, user *domain.User, req domain. mcps := a.buildMCPConfigs(t.ID, token) - // 存储 CreateTaskReq 到 Redis,供 Lifecycle Manager 消费 + // DEBUG: 把准备透传给 taskflow → codingmatrix 的整组 ConfigFile + // marshal 成一个 JSON 串、一行日志打出来。仅在 DEBUG 级别开启, + // 生产无噪声。 + if a.logger.Enabled(ctx, slog.LevelDebug) { + if payload, err := json.Marshal(configs); err != nil { + a.logger.WarnContext(ctx, "tasker configs marshal failed", + slog.String("task_id", t.ID.String()), + slog.Any("err", err)) + } else { + a.logger.DebugContext(ctx, "tasker configs", + slog.String("task_id", t.ID.String()), + slog.Int("count", len(configs)), + slog.String("configs", string(payload)), + ) + } + } + + // 存储 CreateTaskReq 到 Redis(10 分钟过期),供 Lifecycle Manager 消费 createTaskReq := &taskflow.CreateTaskReq{ ID: t.ID, VMID: vm.ID, @@ -594,9 +622,10 @@ func (a *TaskUsecase) Create(ctx context.Context, user *domain.User, req domain. Model: m.Model, ApiType: m.InterfaceType, }, - Configs: configs, - McpConfigs: mcps, - LogStore: normalizeTaskLogStore(t.LogStore), + Configs: configs, + McpConfigs: mcps, + LogStore: normalizeTaskLogStore(t.LogStore), + AgentResources: agentRes, } b, err := json.Marshal(createTaskReq) if err != nil { @@ -727,12 +756,92 @@ func modelRuntimeDefaults(m *db.Model) (thinking bool, contextLimit int, outputL return thinking, contextLimit, outputLimit } -func (a *TaskUsecase) getCodingConfigs(cli consts.CliName, m *db.Model, skillIDs []string) (taskflow.CodingAgent, []taskflow.ConfigFile, error) { +// agentRuleBaseDir / agentSkillBaseDir / agentPluginBaseDir 是 codingmatrix 在 +// VM 内部约定的 .ai-ready/ 投放路径。rule 走 .md 平铺;skill / plugin 解 zip +// 后按目录结构展开;plugin 的 entry 字段再以 file:// 注入到 opencode.json 的 +// `plugin` 数组里。Claude / Codex 不消费 plugin(spec §6.3)。 +const ( + agentRuleBaseDir = "/tmp/codingmatrix-project-tpl/.ai-ready/rules/" + agentSkillBaseDir = "/tmp/codingmatrix-project-tpl/.ai-ready/skills/" + agentPluginBaseDir = "/tmp/codingmatrix-project-tpl/.ai-ready/plugins/" +) + +// parseStringUUIDs 把字符串切片解析成 uuid.UUID 切片。单条解析失败时打一条 +// WARN 日志后跳过,避免一个脏 ID 把整个 task 创建打挂(resolver 内部对 +// per-resource fetch 失败也是 skip-and-log 的策略,这里保持一致)。 +// +// kind 用来在日志里区分是 skill_ids 还是 plugin_ids。 +func (a *TaskUsecase) parseStringUUIDs(ctx context.Context, kind string, raw []string) []uuid.UUID { + if len(raw) == 0 { + return nil + } + out := make([]uuid.UUID, 0, len(raw)) + for _, s := range raw { + trimmed := strings.TrimSpace(s) + id, err := uuid.Parse(trimmed) + if err != nil { + a.logger.WarnContext(ctx, "getCodingConfigs: skip invalid uuid", + slog.String("kind", kind), + slog.String("value", s), + slog.Any("err", err)) + continue + } + out = append(out, id) + } + return out +} + +// injectOpenCodePlugins 重写 cfs 中 path==opencodePath 的那个 ConfigFile, +// 把 file:// URL 列表注入到 JSON 的 `plugin` 数组。opencode.json 模板里 +// 没有 plugin 字段是有意为之(plugin 列表是运行时动态的),所以这里走渲染后 +// 后置处理而不是 fork 模板。 +func injectOpenCodePlugins(cfs []taskflow.ConfigFile, opencodePath string, pluginURLs []string) ([]taskflow.ConfigFile, error) { + for i, c := range cfs { + if c.Path != opencodePath { + continue + } + var obj map[string]any + if err := json.Unmarshal([]byte(c.Content), &obj); err != nil { + return nil, fmt.Errorf("unmarshal opencode.json: %w", err) + } + obj["plugin"] = pluginURLs + out, err := json.MarshalIndent(obj, "", " ") + if err != nil { + return nil, fmt.Errorf("marshal opencode.json: %w", err) + } + cfs[i].Content = string(out) + return cfs, nil + } + return nil, fmt.Errorf("opencode.json ConfigFile not found at %s", opencodePath) +} + +// userScope 从 DB 查用户所在 team,不依赖 session 里的 Team 字段。 +func (a *TaskUsecase) userScope(ctx context.Context, user *domain.User) agentresource.ScopeFilter { + f := agentresource.ScopeFilter{IncludeGlobal: true} + if user == nil || a.dbClient == nil { + return f + } + member, err := a.dbClient.TeamMember.Query(). + Where(teammember.UserIDEQ(user.ID)). + First(ctx) + if err != nil { + if a.logger != nil { + a.logger.WarnContext(ctx, "userScope: query team_members failed", + "user_id", user.ID, "error", err) + } + return f + } + teamID := member.TeamID + f.TeamID = &teamID + return f +} + +func (a *TaskUsecase) getCodingConfigs(ctx context.Context, cli consts.CliName, m *db.Model, skillIDs []string, pluginIDs []string, scope agentresource.ScopeFilter) (taskflow.CodingAgent, []taskflow.ConfigFile, *taskflow.AgentResources, error) { var tmp string var path string var coding taskflow.CodingAgent if m == nil { - return coding, nil, fmt.Errorf("model is nil") + return coding, nil, nil, fmt.Errorf("model is nil") } npmPackage := "@ai-sdk/openai-compatible" thinkingEnabled, contextLimit, outputLimit := modelRuntimeDefaults(m) @@ -757,19 +866,19 @@ func (a *TaskUsecase) getCodingConfigs(cli consts.CliName, m *db.Model, skillIDs var err error npmPackage, err = opencodeNpmPackage(m.InterfaceType) if err != nil { - return coding, nil, err + return coding, nil, nil, err } authtemp, err := template.New("auth").Parse(string(templates.OpenCodeAuth)) if err != nil { - return coding, nil, err + return coding, nil, nil, err } var authBuf bytes.Buffer if err := authtemp.Execute(&authBuf, map[string]any{ "api_key": m.APIKey, }); err != nil { - return coding, nil, err + return coding, nil, nil, err } authMode := uint32(0o600) cfs = append(cfs, taskflow.ConfigFile{ @@ -779,12 +888,12 @@ func (a *TaskUsecase) getCodingConfigs(cli consts.CliName, m *db.Model, skillIDs }) default: - return coding, nil, fmt.Errorf("unexpected consts.CliName: %#v", cli) + return coding, nil, nil, fmt.Errorf("unexpected consts.CliName: %#v", cli) } temp, err := template.New("config").Parse(tmp) if err != nil { - return coding, nil, err + return coding, nil, nil, err } var buf bytes.Buffer @@ -799,7 +908,7 @@ func (a *TaskUsecase) getCodingConfigs(cli consts.CliName, m *db.Model, skillIDs "context_limit": contextLimit, "output_limit": outputLimit, }); err != nil { - return coding, nil, err + return coding, nil, nil, err } cfs = append(cfs, taskflow.ConfigFile{ @@ -807,41 +916,94 @@ func (a *TaskUsecase) getCodingConfigs(cli consts.CliName, m *db.Model, skillIDs Content: buf.String(), }) - if len(skillIDs) == 0 { - return coding, cfs, nil + // 注入 agent-resource:rule 仍走 ConfigFile inline(DB content 小,对 + // gRPC 4MiB ceiling 不构成压力);skill / plugin 走 AgentResources + // presigned URL,由 codingmatrix agent 在 VM 内 HTTP GET + 解压。 + // resolver==nil 时(zero-value TaskUsecase{} 单测)整个块跳过。 + var agentRes *taskflow.AgentResources + if a.resolver == nil { + if a.logger != nil { + a.logger.WarnContext(ctx, "getCodingConfigs: resolver is nil, skipping rule/skill/plugin injection") + } + return coding, cfs, nil, nil } - for _, skillID := range skillIDs { - skilldir := filepath.Join(consts.SkillBaseDir, skillID) - if _, err := os.Stat(skilldir); os.IsNotExist(err) { - continue + // rule — 三种 CLI 都下发(仍走 inline ConfigFile) + if materializedRules, err := a.resolver.Rules(ctx); err != nil { + a.logger.WarnContext(ctx, "getCodingConfigs: list rules failed, continuing without rules", + slog.Any("err", err)) + } else { + for _, r := range materializedRules { + cfs = append(cfs, taskflow.ConfigFile{ + Path: filepath.Join(agentRuleBaseDir, r.Name+".md"), + Content: r.Content, + }) } - filepath.Walk(skilldir, func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - if info.IsDir() { - return nil + } + + // skill — 三种 CLI 都下发;resolver 内部按 scope 过滤 + 用户选中 ∪ + // force_delivery + name 覆盖(user>team>global) + 跳过 enabled=false。 + skillUUIDs := a.parseStringUUIDs(ctx, "skill_ids", skillIDs) + if skillRefs, err := a.resolver.SkillRefsScoped(ctx, agentresource.SkillSelection{ + Scope: scope, + UserSelectedIDs: skillUUIDs, + }); err != nil { + a.logger.WarnContext(ctx, "getCodingConfigs: list skill refs failed, continuing without skills", + slog.Any("err", err)) + } else if len(skillRefs) > 0 { + if agentRes == nil { + agentRes = &taskflow.AgentResources{} + } + for _, s := range skillRefs { + agentRes.Skills = append(agentRes.Skills, &taskflow.AgentResourceAssetRef{ + Name: s.Name, + Version: s.Version, + ZipURL: s.ZipURL, + }) + } + } + + // plugin — 仅 OpenCode 下发;其它 CLI 跳过省一次 S3 round-trip + if cli == consts.CliNameOpencode { + pluginUUIDs := a.parseStringUUIDs(ctx, "plugin_ids", pluginIDs) + if pluginRefs, err := a.resolver.PluginRefsScoped(ctx, agentresource.SkillSelection{ + Scope: scope, + UserSelectedIDs: pluginUUIDs, + }); err != nil { + a.logger.WarnContext(ctx, "getCodingConfigs: list plugin refs failed, continuing without plugins", + slog.Any("err", err)) + } else if len(pluginRefs) > 0 { + pluginURLs := make([]string, 0, len(pluginRefs)) + if agentRes == nil { + agentRes = &taskflow.AgentResources{} } - content, err := os.ReadFile(path) - if err != nil { - return err + for _, p := range pluginRefs { + agentRes.Plugins = append(agentRes.Plugins, &taskflow.AgentResourceAssetRef{ + Name: p.Name, + Version: p.Version, + ZipURL: p.ZipURL, + EntryFilename: p.EntryFilename, + }) + if p.EntryFilename == "" { + a.logger.WarnContext(ctx, "getCodingConfigs: plugin missing entry, skipping opencode.json registration", + slog.String("plugin", p.Name)) + continue + } + pluginURLs = append(pluginURLs, + "file://"+filepath.Join(agentPluginBaseDir, p.Name, p.EntryFilename)) } - // 获取相对于 skilldir 的相对路径,保留目录结构 - relPath, err := filepath.Rel(skilldir, path) - if err != nil { - return err + if len(pluginURLs) > 0 { + if patched, err := injectOpenCodePlugins(cfs, path, pluginURLs); err != nil { + a.logger.WarnContext(ctx, "getCodingConfigs: inject plugin array into opencode.json failed", + slog.Any("err", err)) + } else { + cfs = patched + } } - realSkillID := filepath.Base(skilldir) - agentSkillDir := "/tmp/codingmatrix-project-tpl/.ai-ready/skills/" - cfs = append(cfs, taskflow.ConfigFile{ - Path: filepath.Join(agentSkillDir, realSkillID, relPath), - Content: string(content), - }) - return nil - }) + } } - return coding, cfs, nil + + return coding, cfs, agentRes, nil } // Update implements domain.TaskUsecase. diff --git a/backend/biz/task/usecase/task_model_config_test.go b/backend/biz/task/usecase/task_model_config_test.go index 8e11f928..ce2f0aa2 100644 --- a/backend/biz/task/usecase/task_model_config_test.go +++ b/backend/biz/task/usecase/task_model_config_test.go @@ -1,10 +1,12 @@ package usecase import ( + "context" "encoding/json" "strings" "testing" + "github.com/chaitin/MonkeyCode/backend/biz/agentresource" "github.com/chaitin/MonkeyCode/backend/consts" "github.com/chaitin/MonkeyCode/backend/db" "github.com/chaitin/MonkeyCode/backend/pkg/taskflow" @@ -101,7 +103,7 @@ func TestGetCodingConfigsOpenCodeRendersRuntimeConfigEnabled(t *testing.T) { OutputLimit: 16000, } - coding, cfs, err := uc.getCodingConfigs(consts.CliNameOpencode, model, nil) + coding, cfs, _, err := uc.getCodingConfigs(context.Background(), consts.CliNameOpencode, model, nil, nil, agentresource.GlobalOnlyScope()) if err != nil { t.Fatalf("getCodingConfigs() error = %v", err) } @@ -141,7 +143,7 @@ func TestGetCodingConfigsOpenCodeRendersThinkingDisabled(t *testing.T) { ThinkingEnabled: false, } - _, cfs, err := uc.getCodingConfigs(consts.CliNameOpencode, model, nil) + _, cfs, _, err := uc.getCodingConfigs(context.Background(), consts.CliNameOpencode, model, nil, nil, agentresource.GlobalOnlyScope()) if err != nil { t.Fatalf("getCodingConfigs() error = %v", err) } @@ -177,7 +179,7 @@ func TestGetCodingConfigsOpenCodeRendersUltraForceReasoning(t *testing.T) { ThinkingEnabled: true, } - _, cfs, err := uc.getCodingConfigs(consts.CliNameOpencode, model, nil) + _, cfs, _, err := uc.getCodingConfigs(context.Background(), consts.CliNameOpencode, model, nil, nil, agentresource.GlobalOnlyScope()) if err != nil { t.Fatalf("getCodingConfigs() error = %v", err) } @@ -207,7 +209,7 @@ func TestGetCodingConfigsOpenCodeRendersSupportImage(t *testing.T) { SupportImage: true, } - _, cfs, err := uc.getCodingConfigs(consts.CliNameOpencode, model, nil) + _, cfs, _, err := uc.getCodingConfigs(context.Background(), consts.CliNameOpencode, model, nil, nil, agentresource.GlobalOnlyScope()) if err != nil { t.Fatalf("getCodingConfigs() error = %v", err) } @@ -226,7 +228,7 @@ func TestGetCodingConfigsOpenCodeRendersSupportImage(t *testing.T) { assertStringSlice(t, modalities["output"], []string{"text"}) model.SupportImage = false - _, cfs, err = uc.getCodingConfigs(consts.CliNameOpencode, model, nil) + _, cfs, _, err = uc.getCodingConfigs(context.Background(), consts.CliNameOpencode, model, nil, nil, agentresource.GlobalOnlyScope()) if err != nil { t.Fatalf("getCodingConfigs() error = %v", err) } @@ -243,7 +245,7 @@ func TestGetCodingConfigsOpenCodeRendersSupportImage(t *testing.T) { func TestGetCodingConfigsNilModel(t *testing.T) { uc := &TaskUsecase{} - _, _, err := uc.getCodingConfigs(consts.CliNameOpencode, nil, nil) + _, _, _, err := uc.getCodingConfigs(context.Background(), consts.CliNameOpencode, nil, nil, nil, agentresource.GlobalOnlyScope()) if err == nil { t.Fatal("getCodingConfigs() error is nil") } diff --git a/backend/biz/team/handler/http/v1/skill.go b/backend/biz/team/handler/http/v1/skill.go index 3e3b5993..a7622168 100644 --- a/backend/biz/team/handler/http/v1/skill.go +++ b/backend/biz/team/handler/http/v1/skill.go @@ -1,3 +1,6 @@ +// Package v1 — 团队管理员 skill 管理 HTTP 入口。契约对齐 main 上的 +// /api/v1/teams/skills/* 5 端点(对前端透明),底层换成 agent_skill bare repo +// 模型(scope_type=team, source_type=bare)。 package v1 import ( @@ -16,6 +19,8 @@ import ( "github.com/chaitin/MonkeyCode/backend/middleware" ) +const defaultSkillPackageMaxSize int64 = 50 << 20 // 50 MiB fallback + type TeamSkillHandler struct { usecase domain.TeamSkillUsecase cfg *config.Config @@ -43,29 +48,29 @@ func NewTeamSkillHandler(i *do.Injector) (*TeamSkillHandler, error) { } type addTeamSkillPackageFormReq struct { - Name string `form:"name" validate:"required"` - Description string `form:"description" validate:"required"` - Tags string `form:"tags"` - Content string `form:"content" validate:"required"` - GroupIDs string `form:"group_ids"` - SourceType string `form:"source_type" validate:"required"` - SourceLabel string `form:"source_label" validate:"required"` - SkillMDPath string `form:"skill_md_path"` - File *multipart.FileHeader `form:"file" validate:"required"` + Name string `form:"name" validate:"required"` + Description string `form:"description" validate:"required"` + Tags string `form:"tags"` + Content string `form:"content"` + GroupIDs string `form:"group_ids"` + SkillMDPath string `form:"skill_md_path"` + IsForceDelivery bool `form:"is_force_delivery"` + SourceType string `form:"source_type"` + SourceLabel string `form:"source_label"` + File *multipart.FileHeader `form:"file" validate:"required"` } -// List 获取团队 Skill 列表 +// List 团队 Skill 列表 // -// @Summary 获取团队 Skill 列表 -// @Description 获取团队 Skill 列表 -// @Tags 【Team 管理员】Skill 管理 -// @Accept json -// @Produce json -// @Security MonkeyCodeAITeamAuth -// @Success 200 {object} web.Resp{data=domain.ListTeamSkillsResp} "成功" -// @Failure 401 {object} web.Resp "未授权" -// @Failure 500 {object} web.Resp "服务器内部错误" -// @Router /api/v1/teams/skills [get] +// @Summary 获取团队 Skill 列表 +// @Tags 【Team 管理员】Skill 管理 +// @Accept json +// @Produce json +// @Security MonkeyCodeAITeamAuth +// @Success 200 {object} web.Resp{data=domain.ListTeamSkillsResp} "成功" +// @Failure 401 {object} web.Resp "未授权" +// @Failure 500 {object} web.Resp "服务器内部错误" +// @Router /api/v1/teams/skills [get] func (h *TeamSkillHandler) List(c *web.Context) error { teamUser := middleware.GetTeamUser(c) resp, err := h.usecase.List(c.Request().Context(), teamUser) @@ -75,19 +80,18 @@ func (h *TeamSkillHandler) List(c *web.Context) error { return c.Success(resp) } -// Add 添加团队 Skill +// Add 通过 JSON 添加(content 字段为 SKILL.md 全文) // -// @Summary 添加团队 Skill -// @Description 添加团队 Skill -// @Tags 【Team 管理员】Skill 管理 -// @Accept json -// @Produce json -// @Security MonkeyCodeAITeamAuth -// @Param req body domain.AddTeamSkillReq true "请求参数" -// @Success 200 {object} web.Resp{data=domain.TeamSkill} "成功" -// @Failure 401 {object} web.Resp "未授权" -// @Failure 500 {object} web.Resp "服务器内部错误" -// @Router /api/v1/teams/skills [post] +// @Summary 添加团队 Skill (JSON) +// @Tags 【Team 管理员】Skill 管理 +// @Accept json +// @Produce json +// @Security MonkeyCodeAITeamAuth +// @Param req body domain.AddTeamSkillReq true "请求参数" +// @Success 200 {object} web.Resp{data=domain.TeamSkill} "成功" +// @Failure 401 {object} web.Resp "未授权" +// @Failure 500 {object} web.Resp "服务器内部错误" +// @Router /api/v1/teams/skills [post] func (h *TeamSkillHandler) Add(c *web.Context, req domain.AddTeamSkillReq) error { teamUser := middleware.GetTeamUser(c) resp, err := h.usecase.Add(c.Request().Context(), teamUser, &req) @@ -97,27 +101,24 @@ func (h *TeamSkillHandler) Add(c *web.Context, req domain.AddTeamSkillReq) error return c.Success(resp) } -// AddPackage 上传团队 Skill zip 包 +// AddPackage multipart 上传 zip // -// @Summary 上传团队 Skill zip 包 -// @Description 上传团队 Skill zip 包 -// @Tags 【Team 管理员】Skill 管理 -// @Accept multipart/form-data -// @Produce json -// @Security MonkeyCodeAITeamAuth -// @Param name formData string true "Skill 名称" -// @Param description formData string true "Skill 描述" -// @Param tags formData string false "JSON 字符串数组" -// @Param content formData string true "SKILL.md 原文" -// @Param group_ids formData string false "JSON 字符串数组" -// @Param source_type formData string true "来源类型" -// @Param source_label formData string true "来源标签" -// @Param skill_md_path formData string false "zip 内 SKILL.md 路径" -// @Param file formData file true "Skill zip 包" -// @Success 200 {object} web.Resp{data=domain.TeamSkill} "成功" -// @Failure 401 {object} web.Resp "未授权" -// @Failure 500 {object} web.Resp "服务器内部错误" -// @Router /api/v1/teams/skills/package [post] +// @Summary 添加团队 Skill (multipart zip) +// @Tags 【Team 管理员】Skill 管理 +// @Security MonkeyCodeAITeamAuth +// @Accept multipart/form-data +// @Produce json +// @Param name formData string true "Skill 名称" +// @Param description formData string true "Skill 描述" +// @Param tags formData string false "JSON 字符串数组" +// @Param content formData string false "SKILL.md 原文(可选)" +// @Param group_ids formData string false "JSON 字符串数组" +// @Param skill_md_path formData string false "zip 内 SKILL.md 路径" +// @Param file formData file true "Skill zip 包" +// @Success 200 {object} web.Resp{data=domain.TeamSkill} "成功" +// @Failure 401 {object} web.Resp "未授权" +// @Failure 500 {object} web.Resp "服务器内部错误" +// @Router /api/v1/teams/skills/package [post] func (h *TeamSkillHandler) AddPackage(c *web.Context, req addTeamSkillPackageFormReq) error { teamUser := middleware.GetTeamUser(c) data, err := h.readPackageFile(req.File) @@ -134,14 +135,15 @@ func (h *TeamSkillHandler) AddPackage(c *web.Context, req addTeamSkillPackageFor } resp, err := h.usecase.AddPackage(c.Request().Context(), teamUser, &domain.AddTeamSkillPackageReq{ AddTeamSkillReq: domain.AddTeamSkillReq{ - Name: req.Name, - Description: req.Description, - Tags: tags, - Content: req.Content, - GroupIDs: groupIDs, - SourceType: req.SourceType, - SourceLabel: req.SourceLabel, - SkillMDPath: req.SkillMDPath, + Name: req.Name, + Description: req.Description, + Tags: tags, + Content: req.Content, + GroupIDs: groupIDs, + SkillMDPath: req.SkillMDPath, + IsForceDelivery: req.IsForceDelivery, + SourceType: req.SourceType, + SourceLabel: req.SourceLabel, }, PackageFilename: req.File.Filename, PackageData: data, @@ -155,7 +157,7 @@ func (h *TeamSkillHandler) AddPackage(c *web.Context, req addTeamSkillPackageFor // Update 更新团队 Skill // // @Summary 更新团队 Skill -// @Description 更新团队 Skill +// @Description 请求参数的 content 非空时,后端将 SKILL.md 重新打包上传 OSS 并创建新的 agent_skill_versions 并切到 active version 到新版本,否则仅更新当前版本的 description / tags / is_force_delivery / group_ids // @Tags 【Team 管理员】Skill 管理 // @Accept json // @Produce json @@ -175,16 +177,16 @@ func (h *TeamSkillHandler) Update(c *web.Context, req domain.UpdateTeamSkillReq) return c.Success(resp) } -// Delete 删除团队 Skill +// Delete 删除团队 Skill (软删 agent_skill 行,bare repo 本体不动) // // @Summary 删除团队 Skill -// @Description 删除团队 Skill +// @Description 从本团队 skill repo 中软删所选 agent skill // @Tags 【Team 管理员】Skill 管理 // @Accept json // @Produce json // @Security MonkeyCodeAITeamAuth // @Param skill_id path string true "Skill ID" -// @Success 200 {object} web.Resp{} "成功" +// @Success 200 {object} web.Resp "成功" // @Failure 401 {object} web.Resp "未授权" // @Failure 500 {object} web.Resp "服务器内部错误" // @Router /api/v1/teams/skills/{skill_id} [delete] @@ -196,13 +198,15 @@ func (h *TeamSkillHandler) Delete(c *web.Context, req domain.DeleteTeamSkillReq) return c.Success(nil) } +// ---- helpers ---- + func (h *TeamSkillHandler) readPackageFile(fileHeader *multipart.FileHeader) ([]byte, error) { if fileHeader == nil { return nil, errcode.ErrBadRequest.Wrap(fmt.Errorf("file is required")) } maxSize := h.cfg.ObjectStorage.MaxSize if maxSize <= 0 { - maxSize = 50 << 20 + maxSize = defaultSkillPackageMaxSize } if fileHeader.Size > maxSize { return nil, errcode.ErrBadRequest.Wrap(fmt.Errorf("file exceeds limit")) diff --git a/backend/biz/team/repo/default_group_test.go b/backend/biz/team/repo/default_group_test.go index ee4a84bf..8699931c 100644 --- a/backend/biz/team/repo/default_group_test.go +++ b/backend/biz/team/repo/default_group_test.go @@ -15,7 +15,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/teamgrouphost" "github.com/chaitin/MonkeyCode/backend/db/teamgroupimage" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/chaitin/MonkeyCode/backend/domain" "github.com/chaitin/MonkeyCode/backend/pkg/taskflow" ) @@ -184,113 +183,6 @@ func TestTeamHostUpsertUsesDefaultGroupForNewHost(t *testing.T) { t.Fatal("host was not added to default group") } } - -func TestTeamSkillCreateUsesDefaultGroupWhenGroupIDsEmpty(t *testing.T) { - ctx := context.Background() - client := newTeamRepoTestDB(t) - teamID := createTeamRepoTestTeam(t, client) - userID := createTeamRepoTestUser(t, client) - group := createTeamRepoDefaultGroup(t, client, teamID) - repo := &teamSkillRepo{ - db: client, - logger: slog.New(slog.NewTextHandler(io.Discard, nil)), - } - - skill, err := repo.Create(ctx, teamID, userID, &domain.AddTeamSkillReq{ - Name: "code-review", - Description: "Review code changes", - Content: "---\nname: code-review\ndescription: Review code changes\n---\n", - Tags: []string{"review", "go"}, - SourceType: "markdown", - SourceLabel: "SKILL.md", - }) - if err != nil { - t.Fatal(err) - } - - if exists := teamRepoSkillInGroup(t, client, group.ID, skill.ID); !exists { - t.Fatal("skill was not added to default group") - } -} - -func TestTeamSkillCreateKeepsExplicitGroup(t *testing.T) { - ctx := context.Background() - client := newTeamRepoTestDB(t) - teamID := createTeamRepoTestTeam(t, client) - userID := createTeamRepoTestUser(t, client) - defaultGroup := createTeamRepoDefaultGroup(t, client, teamID) - customGroup := createTeamRepoGroup(t, client, teamID, "Skill 分组") - repo := &teamSkillRepo{ - db: client, - logger: slog.New(slog.NewTextHandler(io.Discard, nil)), - } - - skill, err := repo.Create(ctx, teamID, userID, &domain.AddTeamSkillReq{ - Name: "frontend-polish", - Description: "Polish frontend UX", - Content: "---\nname: frontend-polish\ndescription: Polish frontend UX\n---\n", - GroupIDs: []uuid.UUID{customGroup.ID}, - SourceType: "markdown", - SourceLabel: "SKILL.md", - }) - if err != nil { - t.Fatal(err) - } - - if exists := teamRepoSkillInGroup(t, client, customGroup.ID, skill.ID); !exists { - t.Fatal("skill was not added to explicit group") - } - if exists := teamRepoSkillInGroup(t, client, defaultGroup.ID, skill.ID); exists { - t.Fatal("skill was added to default group despite explicit group") - } -} - -func TestTeamSkillUpdateReplacesGroups(t *testing.T) { - ctx := context.Background() - client := newTeamRepoTestDB(t) - teamID := createTeamRepoTestTeam(t, client) - userID := createTeamRepoTestUser(t, client) - oldGroup := createTeamRepoGroup(t, client, teamID, "旧分组") - newGroup := createTeamRepoGroup(t, client, teamID, "新分组") - repo := &teamSkillRepo{ - db: client, - logger: slog.New(slog.NewTextHandler(io.Discard, nil)), - } - - skill, err := repo.Create(ctx, teamID, userID, &domain.AddTeamSkillReq{ - Name: "plan-writer", - Description: "Write plans", - Content: "---\nname: plan-writer\ndescription: Write plans\n---\n", - GroupIDs: []uuid.UUID{oldGroup.ID}, - SourceType: "markdown", - SourceLabel: "SKILL.md", - }) - if err != nil { - t.Fatal(err) - } - - updated, err := repo.Update(ctx, teamID, &domain.UpdateTeamSkillReq{ - SkillID: skill.ID, - Name: "plan-writer-v2", - Description: "Write implementation plans", - Tags: []string{"planning"}, - GroupIDs: []uuid.UUID{newGroup.ID}, - }) - if err != nil { - t.Fatal(err) - } - - if updated.Name != "plan-writer-v2" { - t.Fatalf("skill name = %q, want plan-writer-v2", updated.Name) - } - if exists := teamRepoSkillInGroup(t, client, oldGroup.ID, skill.ID); exists { - t.Fatal("skill still belongs to old group") - } - if exists := teamRepoSkillInGroup(t, client, newGroup.ID, skill.ID); !exists { - t.Fatal("skill was not added to new group") - } -} - func createTeamRepoTestUser(t *testing.T, client *db.Client) uuid.UUID { t.Helper() userID := uuid.New() @@ -346,14 +238,3 @@ func teamRepoModelInGroup(t *testing.T, client *db.Client, groupID, modelID uuid } return exists } - -func teamRepoSkillInGroup(t *testing.T, client *db.Client, groupID, skillID uuid.UUID) bool { - t.Helper() - exists, err := client.TeamGroupSkill.Query(). - Where(teamgroupskill.GroupIDEQ(groupID), teamgroupskill.SkillIDEQ(skillID)). - Exist(context.Background()) - if err != nil { - t.Fatal(err) - } - return exists -} diff --git a/backend/biz/team/repo/extension_package.go b/backend/biz/team/repo/extension_package.go index 121880a0..a0f294af 100644 --- a/backend/biz/team/repo/extension_package.go +++ b/backend/biz/team/repo/extension_package.go @@ -11,7 +11,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/db" "github.com/chaitin/MonkeyCode/backend/db/image" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/team" "github.com/chaitin/MonkeyCode/backend/db/teamextensionimagearchive" "github.com/chaitin/MonkeyCode/backend/domain" @@ -33,19 +32,8 @@ func NewTeamExtensionPackageRepo(i *do.Injector) (domain.TeamExtensionPackageRep func (r *teamExtensionPackageRepo) ImportResources(ctx context.Context, teamID, userID uuid.UUID, req *domain.TeamExtensionImport) (*domain.TeamExtensionImportResult, error) { result := &domain.TeamExtensionImportResult{} + // Skill 导入已移到 usecase 层(走 TeamSkillUsecase.Add),这里只处理 images。 err := entx.WithTx2(ctx, r.db, func(tx *db.Tx) error { - for _, item := range req.Skills { - created, err := r.upsertSkill(ctx, tx, teamID, userID, req, item) - if err != nil { - return err - } - if created { - result.CreatedSkills++ - } else { - result.UpdatedSkills++ - } - } - for _, item := range req.Images { if err := r.checkImageNameConflict(ctx, tx, teamID, req.PackageID, item); err != nil { return err @@ -87,74 +75,6 @@ func (r *teamExtensionPackageRepo) ListImageArchives(ctx context.Context, teamID return archives, nil } -func (r *teamExtensionPackageRepo) upsertSkill(ctx context.Context, tx *db.Tx, teamID, userID uuid.UUID, req *domain.TeamExtensionImport, item domain.TeamExtensionSkillImport) (bool, error) { - existing, err := tx.Skill.Query(). - Where( - skill.HasTeamsWith(team.ID(teamID)), - skill.ExtensionPackageID(req.PackageID), - skill.ExtensionSkillID(item.SkillID), - ). - Only(ctx) - if err != nil && !db.IsNotFound(err) { - return false, errcode.ErrDatabaseQuery.Wrap(err) - } - if err == nil { - if err := tx.Skill.UpdateOneID(existing.ID). - Where(skill.HasTeamsWith(team.ID(teamID))). - SetName(item.Name). - SetDescription(item.Description). - SetTags(item.Tags). - SetContent(item.Content). - SetPackageObjectKey(item.PackageObjectKey). - SetPackageURL(item.PackageURL). - SetSourceType("extension-package"). - SetSourceLabel(req.PackageID). - SetSkillMdPath(item.Path). - SetExtensionPackageID(req.PackageID). - SetExtensionSkillID(item.SkillID). - SetExtensionVersion(req.Version). - Exec(ctx); err != nil { - return false, errcode.ErrDatabaseOperation.Wrap(err) - } - return false, nil - } - - newSkill, err := tx.Skill.Create(). - SetID(uuid.New()). - SetUserID(userID). - SetName(item.Name). - SetDescription(item.Description). - SetTags(item.Tags). - SetContent(item.Content). - SetPackageObjectKey(item.PackageObjectKey). - SetPackageURL(item.PackageURL). - SetSourceType("extension-package"). - SetSourceLabel(req.PackageID). - SetSkillMdPath(item.Path). - SetExtensionPackageID(req.PackageID). - SetExtensionSkillID(item.SkillID). - SetExtensionVersion(req.Version). - Save(ctx) - if err != nil { - return false, errcode.ErrDatabaseOperation.Wrap(err) - } - if err := tx.TeamSkill.Create(). - SetID(uuid.New()). - SetTeamID(teamID). - SetSkillID(newSkill.ID). - Exec(ctx); err != nil { - return false, errcode.ErrDatabaseOperation.Wrap(err) - } - groupIDs, err := ensureDefaultGroupIDs(ctx, tx, teamID, nil) - if err != nil { - return false, errcode.ErrDatabaseQuery.Wrap(err) - } - if err := replaceTeamSkillGroups(ctx, tx, newSkill.ID, groupIDs); err != nil { - return false, errcode.ErrDatabaseOperation.Wrap(err) - } - return true, nil -} - func (r *teamExtensionPackageRepo) checkImageNameConflict(ctx context.Context, tx *db.Tx, teamID uuid.UUID, packageID string, item domain.TeamExtensionImageImport) error { conflict, err := tx.Image.Query(). Where( diff --git a/backend/biz/team/repo/extension_package_test.go b/backend/biz/team/repo/extension_package_test.go deleted file mode 100644 index f2d61a50..00000000 --- a/backend/biz/team/repo/extension_package_test.go +++ /dev/null @@ -1,167 +0,0 @@ -package repo - -import ( - "context" - "io" - "log/slog" - "testing" - - "github.com/chaitin/MonkeyCode/backend/db/image" - "github.com/chaitin/MonkeyCode/backend/db/skill" - "github.com/chaitin/MonkeyCode/backend/db/teamextensionimagearchive" - "github.com/chaitin/MonkeyCode/backend/domain" -) - -func TestTeamExtensionPackageRepoImportResourcesUpsertsByExtensionID(t *testing.T) { - ctx := context.Background() - client := newTeamRepoTestDB(t) - teamID := createTeamRepoTestTeam(t, client) - userID := createTeamRepoTestUser(t, client) - group := createTeamRepoDefaultGroup(t, client, teamID) - repo := &teamExtensionPackageRepo{ - db: client, - logger: slog.New(slog.NewTextHandler(io.Discard, nil)), - } - - req := &domain.TeamExtensionImport{ - PackageID: "pack", - Version: "1.0.0", - Skills: []domain.TeamExtensionSkillImport{{ - SkillID: "reviewer", - Name: "Reviewer", - Description: "Review code", - Tags: []string{"review"}, - Content: "---\nname: Reviewer\ndescription: Review code\n---\n", - Path: "skills/reviewer/SKILL.md", - }}, - Images: []domain.TeamExtensionImageImport{{ - ImageID: "devbox", - Name: "repo/devbox:1", - Remark: "Devbox", - Archives: []domain.TeamExtensionImageArchiveImport{{ - Arch: "x86_64", - SHA256: "sha256-first", - ArchivePath: "static/extensions/devbox.tar.gz", - ArchiveURL: "/static/extensions/devbox.tar.gz", - }}, - }}, - } - - first, err := repo.ImportResources(ctx, teamID, userID, req) - if err != nil { - t.Fatal(err) - } - if first.CreatedSkills != 1 || first.CreatedImages != 1 || first.UpdatedSkills != 0 || first.UpdatedImages != 0 { - t.Fatalf("first result = %#v", first) - } - createdSkill, err := client.Skill.Query(). - Where(skill.ExtensionPackageID("pack"), skill.ExtensionSkillID("reviewer")). - Only(ctx) - if err != nil { - t.Fatal(err) - } - if exists := teamRepoSkillInGroup(t, client, group.ID, createdSkill.ID); !exists { - t.Fatal("extension skill was not added to default group") - } - createdImage, err := client.Image.Query(). - Where(image.ExtensionPackageID("pack"), image.ExtensionImageID("devbox")). - Only(ctx) - if err != nil { - t.Fatal(err) - } - if exists := teamRepoImageInGroup(t, client, group.ID, createdImage.ID); !exists { - t.Fatal("extension image was not added to default group") - } - - req.Version = "1.1.0" - req.Skills[0].Description = "Updated" - req.Images[0].Remark = "Updated image" - req.Images[0].Archives[0].ArchivePath = "static/extensions/devbox-v2.tar.gz" - req.Images[0].Archives[0].ArchiveURL = "/static/extensions/devbox-v2.tar.gz" - req.Images[0].Archives[0].SHA256 = "sha256-second" - second, err := repo.ImportResources(ctx, teamID, userID, req) - if err != nil { - t.Fatal(err) - } - if second.CreatedSkills != 0 || second.CreatedImages != 0 || second.UpdatedSkills != 1 || second.UpdatedImages != 1 { - t.Fatalf("second result = %#v", second) - } - - if count, err := client.Skill.Query().Where(skill.ExtensionPackageID("pack"), skill.ExtensionSkillID("reviewer")).Count(ctx); err != nil { - t.Fatal(err) - } else if count != 1 { - t.Fatalf("skill count = %d, want 1", count) - } - updatedSkill, err := client.Skill.Query(). - Where(skill.ExtensionPackageID("pack"), skill.ExtensionSkillID("reviewer")). - Only(ctx) - if err != nil { - t.Fatal(err) - } - if updatedSkill.Description != "Updated" || updatedSkill.ExtensionVersion != "1.1.0" { - t.Fatalf("updated skill = %#v", updatedSkill) - } - if count, err := client.Image.Query().Where(image.ExtensionPackageID("pack"), image.ExtensionImageID("devbox")).Count(ctx); err != nil { - t.Fatal(err) - } else if count != 1 { - t.Fatalf("image count = %d, want 1", count) - } - updatedArchive, err := client.TeamExtensionImageArchive.Query(). - Where( - teamextensionimagearchive.PackageID("pack"), - teamextensionimagearchive.ExtensionImageID("devbox"), - teamextensionimagearchive.Arch("x86_64"), - ). - Only(ctx) - if err != nil { - t.Fatal(err) - } - if updatedArchive.Version != "1.1.0" || updatedArchive.ArchivePath != "static/extensions/devbox-v2.tar.gz" || updatedArchive.Sha256 != "sha256-second" { - t.Fatalf("updated archive = %#v", updatedArchive) - } -} - -func TestTeamExtensionPackageRepoImportResourcesRejectsImageNameOwnedByAnotherPackage(t *testing.T) { - ctx := context.Background() - client := newTeamRepoTestDB(t) - teamID := createTeamRepoTestTeam(t, client) - userID := createTeamRepoTestUser(t, client) - createTeamRepoDefaultGroup(t, client, teamID) - repo := &teamExtensionPackageRepo{ - db: client, - logger: slog.New(slog.NewTextHandler(io.Discard, nil)), - } - - if _, err := repo.ImportResources(ctx, teamID, userID, &domain.TeamExtensionImport{ - PackageID: "pack-a", - Version: "1.0.0", - Images: []domain.TeamExtensionImageImport{{ - ImageID: "devbox-a", - Name: "repo/devbox:1", - Archives: []domain.TeamExtensionImageArchiveImport{{ - Arch: "x86_64", - ArchivePath: "static/extensions/a.tar.gz", - ArchiveURL: "/static/extensions/a.tar.gz", - }}, - }}, - }); err != nil { - t.Fatal(err) - } - - _, err := repo.ImportResources(ctx, teamID, userID, &domain.TeamExtensionImport{ - PackageID: "pack-b", - Version: "1.0.0", - Images: []domain.TeamExtensionImageImport{{ - ImageID: "devbox-b", - Name: "repo/devbox:1", - Archives: []domain.TeamExtensionImageArchiveImport{{ - Arch: "x86_64", - ArchivePath: "static/extensions/b.tar.gz", - ArchiveURL: "/static/extensions/b.tar.gz", - }}, - }}, - }) - if err == nil { - t.Fatal("expected image name conflict") - } -} diff --git a/backend/biz/team/repo/skill.go b/backend/biz/team/repo/skill.go index 6c5d514e..0a9db3e7 100644 --- a/backend/biz/team/repo/skill.go +++ b/backend/biz/team/repo/skill.go @@ -1,208 +1,293 @@ +// Package repo — 团队管理员侧的 agent_skill CRUD,对应 docs/skill-architecture.md +// 中"团队管理员通过团队后台手动上传"的链路。 +// +// 所有写入都把 skill 挂到 team 的 bare repo 下(scope_type=team, source_type=bare), +// agent_skill_versions 走标准的 active_version_id 切换语义,group bindings 用 +// agent_skill_group_bindings 表显式 join。 package repo import ( "context" - "log/slog" + "fmt" + "strconv" + "strings" + "time" - "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/samber/do" + "github.com/chaitin/MonkeyCode/backend/biz/agentresource" "github.com/chaitin/MonkeyCode/backend/db" - "github.com/chaitin/MonkeyCode/backend/db/skill" - "github.com/chaitin/MonkeyCode/backend/db/team" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" "github.com/chaitin/MonkeyCode/backend/domain" - "github.com/chaitin/MonkeyCode/backend/errcode" - "github.com/chaitin/MonkeyCode/backend/pkg/cvt" + "github.com/chaitin/MonkeyCode/backend/ent/types" "github.com/chaitin/MonkeyCode/backend/pkg/entx" ) type teamSkillRepo struct { - db *db.Client - logger *slog.Logger + client *db.Client } +// NewTeamSkillRepo 注入 ent client。 func NewTeamSkillRepo(i *do.Injector) (domain.TeamSkillRepo, error) { - return &teamSkillRepo{ - db: do.MustInvoke[*db.Client](i), - logger: do.MustInvoke[*slog.Logger](i), - }, nil + return &teamSkillRepo{client: do.MustInvoke[*db.Client](i)}, nil } -func (r *teamSkillRepo) List(ctx context.Context, teamID uuid.UUID) ([]*db.Skill, error) { - tss, err := r.db.TeamSkill.Query(). - WithSkill(func(sq *db.SkillQuery) { - sq.WithGroups() - }). - Where(teamskill.TeamID(teamID)). - Order(teamskill.ByCreatedAt(sql.OrderDesc())). +func (r *teamSkillRepo) List(ctx context.Context, teamID uuid.UUID) ([]*db.AgentSkill, error) { + repoID, err := r.GetBareRepoID(ctx, teamID) + if err != nil { + return nil, err + } + return r.client.AgentSkill.Query(). + Where( + agentskill.RepoIDEQ(repoID), + agentskill.IsDeletedEQ(false), + agentskill.ScopeTypeEQ(agentskill.ScopeTypeTeam), + agentskill.ScopeIDEQ(teamID.String()), + ). + Order(db.Asc(agentskill.FieldName)). All(ctx) +} + +func (r *teamSkillRepo) GetSkill(ctx context.Context, teamID, skillID uuid.UUID) (*db.AgentSkill, error) { + return r.client.AgentSkill.Query(). + Where( + agentskill.IDEQ(skillID), + agentskill.ScopeTypeEQ(agentskill.ScopeTypeTeam), + agentskill.ScopeIDEQ(teamID.String()), + agentskill.IsDeletedEQ(false), + ). + First(ctx) +} + +func (r *teamSkillRepo) GetBareRepoID(ctx context.Context, teamID uuid.UUID) (uuid.UUID, error) { + row, err := r.client.AgentSkillRepo.Query(). + Where( + agentskillrepo.ScopeTypeEQ(agentskillrepo.ScopeTypeTeam), + agentskillrepo.ScopeIDEQ(teamID.String()), + agentskillrepo.SourceTypeEQ(agentskillrepo.SourceTypeBare), + agentskillrepo.IsDeletedEQ(false), + ). + First(ctx) if err != nil { - return nil, errcode.ErrDatabaseQuery.Wrap(err) + return uuid.Nil, fmt.Errorf("team_skill_repo: bare repo missing for team %s: %w", teamID, err) } - return cvt.Iter(tss, func(_ int, ts *db.TeamSkill) *db.Skill { - return ts.Edges.Skill - }), nil + return row.ID, nil } -func (r *teamSkillRepo) Create(ctx context.Context, teamID, userID uuid.UUID, req *domain.AddTeamSkillReq) (*db.Skill, error) { - var skillID uuid.UUID - err := entx.WithTx2(ctx, r.db, func(tx *db.Tx) error { - groupIDs, err := resolveTeamSkillGroupIDs(ctx, tx, teamID, req.GroupIDs) - if err != nil { - return err - } +func (r *teamSkillRepo) UpsertSkill(ctx context.Context, teamID, repoID, userID uuid.UUID, name, description string, isForceDelivery bool, extensionPackageID string) (*db.AgentSkill, error) { + existing, err := r.client.AgentSkill.Query(). + Where( + agentskill.RepoIDEQ(repoID), + agentskill.NameEQ(name), + agentskill.IsDeletedEQ(false), + ). + First(ctx) + if err == nil { + return existing, nil + } + if !db.IsNotFound(err) { + return nil, err + } + return r.client.AgentSkill.Create(). + SetID(uuid.New()). + SetRepoID(repoID). + SetName(name). + SetDescription(description). + SetScopeType(agentskill.ScopeTypeTeam). + SetScopeID(teamID.String()). + SetCreatedBy(userID). + SetIsForceDelivery(isForceDelivery). + SetEnabled(true). + SetNillableExtensionPackageID(nillableString(extensionPackageID)). + Save(ctx) +} - newSkill, err := tx.Skill.Create(). +func (r *teamSkillRepo) CreateVersion(ctx context.Context, skillID uuid.UUID, version, s3Key string, meta domain.SkillVersionMeta) (*db.AgentSkillVersion, error) { + var out *db.AgentSkillVersion + err := entx.WithTx2(ctx, r.client, func(tx *db.Tx) error { + v, err := tx.AgentSkillVersion.Create(). SetID(uuid.New()). - SetUserID(userID). - SetName(req.Name). - SetDescription(req.Description). - SetTags(req.Tags). - SetContent(req.Content). - SetPackageObjectKey(req.PackageObjectKey). - SetPackageURL(req.PackageURL). - SetSourceType(req.SourceType). - SetSourceLabel(req.SourceLabel). - SetSkillMdPath(req.SkillMDPath). + SetResourceID(skillID). + SetVersion(version). + SetS3Key(s3Key). + SetParsedMeta(types.SkillParsedMeta{ + Description: meta.Description, + Categories: meta.Categories, + Tags: meta.Tags, + SourceType: meta.SourceType, + SourceLabel: meta.SourceLabel, + }). Save(ctx) if err != nil { return err } - skillID = newSkill.ID - - if err := tx.TeamSkill.Create(). - SetID(uuid.New()). - SetTeamID(teamID). - SetSkillID(newSkill.ID). - Exec(ctx); err != nil { + if _, err := tx.AgentSkill.UpdateOneID(skillID). + SetActiveVersionID(v.ID). + SetUpdatedAt(time.Now()). + Save(ctx); err != nil { return err } - - return replaceTeamSkillGroups(ctx, tx, newSkill.ID, groupIDs) + out = v + return nil }) + return out, err +} + +func (r *teamSkillRepo) UpdateMeta(ctx context.Context, teamID, skillID uuid.UUID, name string, description *string, isForceDelivery *bool) (*db.AgentSkill, error) { + u := r.client.AgentSkill.UpdateOneID(skillID). + Where( + agentskill.ScopeTypeEQ(agentskill.ScopeTypeTeam), + agentskill.ScopeIDEQ(teamID.String()), + agentskill.IsDeletedEQ(false), + ). + SetUpdatedAt(time.Now()) + if strings.TrimSpace(name) != "" { + u = u.SetName(name) + } + if description != nil { + u = u.SetDescription(*description) + } + if isForceDelivery != nil { + u = u.SetIsForceDelivery(*isForceDelivery) + } + return u.Save(ctx) +} + +func (r *teamSkillRepo) UpdateActiveVersionTags(ctx context.Context, skillID uuid.UUID, tags []string) error { + skill, err := r.client.AgentSkill.Get(ctx, skillID) if err != nil { - r.logger.Error("create team skill", "error", err) - return nil, errcode.ErrDatabaseOperation.Wrap(err) + return err } - return r.get(ctx, teamID, skillID) + if skill.ActiveVersionID == nil { + return nil + } + ver, err := r.client.AgentSkillVersion.Get(ctx, *skill.ActiveVersionID) + if err != nil { + return err + } + meta := ver.ParsedMeta + meta.Tags = tags + _, err = r.client.AgentSkillVersion.UpdateOneID(ver.ID). + SetParsedMeta(meta). + Save(ctx) + return err +} + +func (r *teamSkillRepo) SoftDeleteSkill(ctx context.Context, teamID, skillID uuid.UUID) error { + _, err := r.client.AgentSkill.UpdateOneID(skillID). + Where( + agentskill.ScopeTypeEQ(agentskill.ScopeTypeTeam), + agentskill.ScopeIDEQ(teamID.String()), + ). + SetIsDeleted(true). + SetUpdatedAt(time.Now()). + Save(ctx) + return err } -func (r *teamSkillRepo) Update(ctx context.Context, teamID uuid.UUID, req *domain.UpdateTeamSkillReq) (*db.Skill, error) { - err := entx.WithTx2(ctx, r.db, func(tx *db.Tx) error { - groupIDs, err := resolveTeamSkillGroupIDs(ctx, tx, teamID, req.GroupIDs) +func (r *teamSkillRepo) ReplaceGroupBindings(ctx context.Context, teamID, skillID uuid.UUID, groupIDs []uuid.UUID) error { + // 仅在 group_id 属于该 team 时才接受,防止跨 team 越权关联。 + if len(groupIDs) > 0 { + cnt, err := r.client.TeamGroup.Query(). + Where(teamgroup.IDIn(groupIDs...), teamgroup.TeamIDEQ(teamID)). + Count(ctx) if err != nil { return err } - - upt := tx.Skill.UpdateOneID(req.SkillID).Where(skill.HasTeamsWith(team.ID(teamID))) - if req.Name != "" { - upt.SetName(req.Name) - } - if req.Description != "" { - upt.SetDescription(req.Description) - } - if req.Tags != nil { - upt.SetTags(req.Tags) - } - if req.Content != "" { - upt.SetContent(req.Content) - } - if req.SourceType != "" { - upt.SetSourceType(req.SourceType) + if cnt != len(groupIDs) { + return fmt.Errorf("team_skill_repo: some group ids do not belong to team %s", teamID) } - if req.SourceLabel != "" { - upt.SetSourceLabel(req.SourceLabel) - } - if req.SkillMDPath != nil { - upt.SetSkillMdPath(*req.SkillMDPath) - } - if err := upt.Exec(ctx); err != nil { + } + return entx.WithTx2(ctx, r.client, func(tx *db.Tx) error { + if _, err := tx.AgentSkillGroupBinding.Delete(). + Where(agentskillgroupbinding.SkillIDEQ(skillID)). + Exec(ctx); err != nil { return err } - - if req.GroupIDs != nil { - return replaceTeamSkillGroups(ctx, tx, req.SkillID, groupIDs) + for _, gid := range groupIDs { + if _, err := tx.AgentSkillGroupBinding.Create(). + SetID(uuid.New()). + SetSkillID(skillID). + SetGroupID(gid). + Save(ctx); err != nil { + return err + } } return nil }) +} + +func (r *teamSkillRepo) GetActiveVersion(ctx context.Context, skillID uuid.UUID) (*db.AgentSkillVersion, error) { + skill, err := r.client.AgentSkill.Get(ctx, skillID) if err != nil { - return nil, errcode.ErrDatabaseOperation.Wrap(err) + return nil, err } - return r.get(ctx, teamID, req.SkillID) + if skill.ActiveVersionID == nil { + return nil, nil + } + return r.client.AgentSkillVersion.Get(ctx, *skill.ActiveVersionID) } -func (r *teamSkillRepo) Delete(ctx context.Context, teamID, skillID uuid.UUID) error { - err := entx.WithTx2(ctx, r.db, func(tx *db.Tx) error { - if err := tx.Skill.DeleteOneID(skillID).Where(skill.HasTeamsWith(team.ID(teamID))).Exec(ctx); err != nil { - return err +func (r *teamSkillRepo) NextVersionFor(ctx context.Context, skillID uuid.UUID) (string, error) { + versions, err := r.client.AgentSkillVersion.Query(). + Where(agentskillversion.ResourceIDEQ(skillID)). + All(ctx) + if err != nil { + return "", err + } + max := 0 + for _, v := range versions { + // version 形如 "v3" / "v10";容错:非 vN 形式跳过。 + s := strings.TrimPrefix(v.Version, "v") + n, err := strconv.Atoi(s) + if err != nil { + continue } - if _, err := tx.TeamSkill.Delete(). - Where(teamskill.TeamID(teamID)). - Where(teamskill.SkillID(skillID)). - Exec(ctx); err != nil { - return err + if n > max { + max = n } - _, err := tx.TeamGroupSkill.Delete().Where(teamgroupskill.SkillIDEQ(skillID)).Exec(ctx) - return err - }) - if err != nil { - r.logger.Error("delete team skill", "error", err) - return errcode.ErrDatabaseOperation.Wrap(err) } - return nil + return fmt.Sprintf("v%d", max+1), nil } -func (r *teamSkillRepo) get(ctx context.Context, teamID, skillID uuid.UUID) (*db.Skill, error) { - ts, err := r.db.TeamSkill.Query(). - WithSkill(func(sq *db.SkillQuery) { - sq.WithGroups() - }). - Where(teamskill.TeamID(teamID)). - Where(teamskill.SkillID(skillID)). - First(ctx) +func (r *teamSkillRepo) LoadGroups(ctx context.Context, skillID uuid.UUID) ([]domain.SkillGroupRef, error) { + bindings, err := r.client.AgentSkillGroupBinding.Query(). + Where(agentskillgroupbinding.SkillIDEQ(skillID)). + All(ctx) if err != nil { - return nil, errcode.ErrDatabaseQuery.Wrap(err) + return nil, err } - return ts.Edges.Skill, nil -} - -func resolveTeamSkillGroupIDs(ctx context.Context, tx *db.Tx, teamID uuid.UUID, reqGroupIDs []uuid.UUID) ([]uuid.UUID, error) { - useDefaultGroup := len(reqGroupIDs) == 0 - groups, err := tx.TeamGroup.Query(). - Where(teamgroup.TeamID(teamID)). - Where(teamgroup.IDIn(reqGroupIDs...)). + if len(bindings) == 0 { + return nil, nil + } + groupIDs := make([]uuid.UUID, 0, len(bindings)) + for _, b := range bindings { + groupIDs = append(groupIDs, b.GroupID) + } + groups, err := r.client.TeamGroup.Query(). + Where(teamgroup.IDIn(groupIDs...)). All(ctx) if err != nil { return nil, err } - groupIDs := cvt.Iter(groups, func(_ int, group *db.TeamGroup) uuid.UUID { - return group.ID - }) - if useDefaultGroup { - return ensureDefaultGroupIDs(ctx, tx, teamID, groupIDs) + out := make([]domain.SkillGroupRef, 0, len(groups)) + for _, g := range groups { + out = append(out, domain.SkillGroupRef{ID: g.ID.String(), Name: g.Name}) } - return groupIDs, nil + return out, nil } -func replaceTeamSkillGroups(ctx context.Context, tx *db.Tx, skillID uuid.UUID, groupIDs []uuid.UUID) error { - if _, err := tx.TeamGroupSkill.Delete().Where(teamgroupskill.SkillIDEQ(skillID)).Exec(ctx); err != nil { - return err - } - - builders := make([]*db.TeamGroupSkillCreate, 0, len(groupIDs)) - for _, groupID := range groupIDs { - builders = append(builders, tx.TeamGroupSkill.Create(). - SetID(uuid.New()). - SetGroupID(groupID). - SetSkillID(skillID)) - } - if len(builders) == 0 { +// agentresource 引用仅用于 enum 字符串常量校验/IDE 跳转;实际未使用。 +func nillableString(s string) *string { + if s == "" { return nil } - _, err := tx.TeamGroupSkill.CreateBulk(builders...).Save(ctx) - return err + return &s } + +var _ = agentresource.BareRepoSourceType diff --git a/backend/biz/team/repo/user.go b/backend/biz/team/repo/user.go index d8ffcf53..6504fc1a 100644 --- a/backend/biz/team/repo/user.go +++ b/backend/biz/team/repo/user.go @@ -9,6 +9,7 @@ import ( "github.com/redis/go-redis/v9" "github.com/samber/do" + "github.com/chaitin/MonkeyCode/backend/biz/agentresource" "github.com/chaitin/MonkeyCode/backend/config" "github.com/chaitin/MonkeyCode/backend/consts" "github.com/chaitin/MonkeyCode/backend/db" @@ -368,6 +369,11 @@ func (r *TeamGroupUserRepo) InitTeam(ctx context.Context, email string, name str if err := r.ensureInitTeamMember(ctx, tx, initTeam.ID, email, name, hashedPassword, defaultGroup.ID); err != nil { return err } + // Provision team 私有的 bare skill_repo / plugin_repo,供团队管理员 + // 后续上传 zip 时挂载子 skill。幂等(已存在则跳过)。 + if _, _, err := agentresource.EnsureTeamBareReposTx(ctx, tx, initTeam.ID, initUser.ID); err != nil { + return err + } return r.initTeamImage(ctx, tx, initTeam.ID, defaultGroup.ID, initUser.ID, imageName) }) } diff --git a/backend/biz/team/usecase/extension_package.go b/backend/biz/team/usecase/extension_package.go index f689450e..ccf36f88 100644 --- a/backend/biz/team/usecase/extension_package.go +++ b/backend/biz/team/usecase/extension_package.go @@ -19,6 +19,7 @@ import ( type teamExtensionPackageUsecase struct { repo domain.TeamExtensionPackageRepo + skillUsecase domain.TeamSkillUsecase staticDir string staticRoutePrefix string logger *slog.Logger @@ -28,6 +29,7 @@ func NewTeamExtensionPackageUsecase(i *do.Injector) (domain.TeamExtensionPackage cfg := do.MustInvoke[*config.Config](i) return &teamExtensionPackageUsecase{ repo: do.MustInvoke[domain.TeamExtensionPackageRepo](i), + skillUsecase: do.MustInvoke[domain.TeamSkillUsecase](i), staticDir: cfg.StaticFiles.Dir, staticRoutePrefix: cfg.StaticFiles.RoutePrefix, logger: do.MustInvoke[*slog.Logger](i), @@ -41,6 +43,30 @@ func (u *teamExtensionPackageUsecase) Import(ctx context.Context, teamUser *doma } teamID := teamUser.GetTeamID() + + // Skill 导入:复用 TeamSkillUsecase.Add 走 bare repo + agent_skill 标准流程。 + // extension_version 作为 agent_skill_version 的版本号,name 做幂等匹配。 + var createdSkills, updatedSkills int + for _, s := range extensionSkillImports(pkg) { + _, err := u.skillUsecase.Add(ctx, teamUser, &domain.AddTeamSkillReq{ + Name: s.Name, + Description: s.Description, + Tags: s.Tags, + Content: s.Content, + SkillMDPath: s.Path, + SourceType: "extension-package", + SourceLabel: pkg.PackageID, + ExtensionPackageID: pkg.PackageID, + }) + if err != nil { + return nil, err + } + // Add 内部按 name upsert:已存在 → 新版本(算 updated),不存在 → 新建(算 created)。 + // 这里简化为全算 updated(首次也创建了 version);精确区分需要 Add 返回 created flag。 + updatedSkills++ + } + + // Image 导入:保持原有流程。 images, err := publishExtensionImages(u.staticDir, u.staticRoutePrefix, teamID, pkg) if err != nil { return nil, err @@ -48,13 +74,14 @@ func (u *teamExtensionPackageUsecase) Import(ctx context.Context, teamUser *doma importReq := &domain.TeamExtensionImport{ PackageID: pkg.PackageID, Version: pkg.Version, - Skills: extensionSkillImports(pkg), Images: images, } result, err := u.repo.ImportResources(ctx, teamID, teamUser.User.ID, importReq) if err != nil { return nil, err } + result.CreatedSkills = createdSkills + result.UpdatedSkills = updatedSkills archives, err := u.repo.ListImageArchives(ctx, teamID) if err != nil { return nil, err diff --git a/backend/biz/team/usecase/skill.go b/backend/biz/team/usecase/skill.go index 3af27190..f764dfea 100644 --- a/backend/biz/team/usecase/skill.go +++ b/backend/biz/team/usecase/skill.go @@ -1,3 +1,6 @@ +// Package usecase — 团队管理员侧 skill 的业务逻辑:zip 校验 + OSS 上传 + +// agent_skill upsert + new version + group binding 替换。D3 语义:Content +// 非空 → 新版本;只改元数据 → mutate 行。 package usecase import ( @@ -5,134 +8,321 @@ import ( "bytes" "context" "fmt" + "io" "log/slog" - "path/filepath" + "path" "strings" "github.com/google/uuid" "github.com/samber/do" - "github.com/chaitin/MonkeyCode/backend/config" + "github.com/chaitin/MonkeyCode/backend/biz/agentresource" "github.com/chaitin/MonkeyCode/backend/db" "github.com/chaitin/MonkeyCode/backend/domain" "github.com/chaitin/MonkeyCode/backend/errcode" "github.com/chaitin/MonkeyCode/backend/pkg/cvt" - "github.com/chaitin/MonkeyCode/backend/pkg/oss" ) -const skillPackagePrefix = "skills" +// skillS3KeyPrefix:S3 上每个 skill 版本对应的 key 形如 +// agent-resources/skills/team///.zip +const skillS3KeyPrefix = "agent-resources/skills/team" type teamSkillUsecase struct { - repo domain.TeamSkillRepo - packageStore skillPackageStore - logger *slog.Logger + repo domain.TeamSkillRepo + objstore agentresource.ObjectStore + logger *slog.Logger } func NewTeamSkillUsecase(i *do.Injector) (domain.TeamSkillUsecase, error) { - cfg := do.MustInvoke[*config.Config](i) - var store skillPackageStore - if cfg.ObjectStorage.Enabled { - client, err := oss.NewS3Compatible(context.Background(), cfg.ObjectStorage, oss.S3Option{ - ForcePathStyle: cfg.ObjectStorage.ForcePathStyle, - InitBucket: cfg.ObjectStorage.InitBucket, - }) - if err != nil { - return nil, err - } - store = &ossSkillPackageStore{client: client.WithAccessEndpoint(cfg.ObjectStorage.AccessEndpoint)} - } return &teamSkillUsecase{ - repo: do.MustInvoke[domain.TeamSkillRepo](i), - packageStore: store, - logger: do.MustInvoke[*slog.Logger](i), + repo: do.MustInvoke[domain.TeamSkillRepo](i), + objstore: do.MustInvoke[agentresource.ObjectStore](i), + logger: do.MustInvoke[*slog.Logger](i), }, nil } -func (u *teamSkillUsecase) Add(ctx context.Context, teamUser *domain.TeamUser, req *domain.AddTeamSkillReq) (*domain.TeamSkill, error) { - if req.PackageObjectKey == "" { - if u.packageStore == nil { - return nil, errcode.ErrBadRequest.Wrap(fmt.Errorf("object storage is disabled")) - } - data, err := packageSkillMarkdownContent(req.Content) - if err != nil { - return nil, err - } - objectKey, url, err := u.packageStore.Put(ctx, skillPackageFilename(req.Name), data) +func (u *teamSkillUsecase) List(ctx context.Context, teamUser *domain.TeamUser) (*domain.ListTeamSkillsResp, error) { + skills, err := u.repo.List(ctx, teamUser.GetTeamID()) + if err != nil { + return nil, err + } + out := make([]*domain.TeamSkill, 0, len(skills)) + for _, s := range skills { + ts, err := u.skillToDTO(ctx, s) if err != nil { return nil, err } - req.PackageObjectKey = objectKey - req.PackageURL = url + out = append(out, ts) } + return &domain.ListTeamSkillsResp{Skills: out}, nil +} - skill, err := u.repo.Create(ctx, teamUser.GetTeamID(), teamUser.User.ID, req) +func (u *teamSkillUsecase) Add(ctx context.Context, teamUser *domain.TeamUser, req *domain.AddTeamSkillReq) (*domain.TeamSkill, error) { + // JSON 入口:把 Content (SKILL.md 文本) 打成单文件 zip,再走 AddPackage 路径。 + data, err := packageSkillMarkdownContent(req.Content) if err != nil { return nil, err } - return cvt.From(skill, &domain.TeamSkill{}), nil + pkg := &domain.AddTeamSkillPackageReq{ + AddTeamSkillReq: *req, + PackageFilename: skillPackageFilename(req.Name), + PackageData: data, + } + return u.AddPackage(ctx, teamUser, pkg) } func (u *teamSkillUsecase) AddPackage(ctx context.Context, teamUser *domain.TeamUser, req *domain.AddTeamSkillPackageReq) (*domain.TeamSkill, error) { - if u.packageStore == nil { - return nil, errcode.ErrBadRequest.Wrap(fmt.Errorf("object storage is disabled")) - } - if err := validateSkillZipPackage(req.PackageData); err != nil { + teamID := teamUser.GetTeamID() + userID := teamUser.User.ID + + frontmatterTags, err := validateSkillZipPackage(req.PackageData) + if err != nil { return nil, err } - filename := skillPackageFilename(req.PackageFilename) - if strings.TrimSpace(req.Name) != "" { - filename = skillPackageFilename(req.Name) + + // 取 team 的 bare repo;不存在视为系统级 bug(InitTeam 应已 provision)。 + repoID, err := u.repo.GetBareRepoID(ctx, teamID) + if err != nil { + return nil, err } - objectKey, url, err := u.packageStore.Put(ctx, filename, req.PackageData) + + // upsert agent_skill 行 + skill, err := u.repo.UpsertSkill(ctx, teamID, repoID, userID, req.Name, req.Description, req.IsForceDelivery, req.ExtensionPackageID) if err != nil { return nil, err } - req.PackageObjectKey = objectKey - req.PackageURL = url - return u.Add(ctx, teamUser, &req.AddTeamSkillReq) -} -func (u *teamSkillUsecase) List(ctx context.Context, teamUser *domain.TeamUser) (*domain.ListTeamSkillsResp, error) { - skills, err := u.repo.List(ctx, teamUser.GetTeamID()) + // 算 next version + nextVer, err := u.repo.NextVersionFor(ctx, skill.ID) if err != nil { return nil, err } - return &domain.ListTeamSkillsResp{ - Skills: cvt.Iter(skills, func(_ int, skill *db.Skill) *domain.TeamSkill { - return cvt.From(skill, &domain.TeamSkill{}) - }), - }, nil + + // 上传 OSS + s3Key := fmt.Sprintf("%s/%s/%s/%s.zip", skillS3KeyPrefix, teamID.String(), skill.ID.String(), nextVer) + prefix, filename := path.Split(s3Key) + if err := u.objstore.PutFile(ctx, strings.TrimSuffix(prefix, "/"), filename, bytes.NewReader(req.PackageData)); err != nil { + return nil, err + } + + // tags 优先级:form 字段 present → 覆盖;absent → 用 frontmatter 解析出来的 + tags := req.Tags + if tags == nil { + tags = frontmatterTags + } + + // 写新 version + 切 active_version_id + if _, err := u.repo.CreateVersion(ctx, skill.ID, nextVer, s3Key, domain.SkillVersionMeta{ + Description: req.Description, + Tags: tags, + // Categories: 当前 frontmatter 解析不暴露,留空。 + SourceType: req.SourceType, + SourceLabel: req.SourceLabel, + }); err != nil { + return nil, err + } + + // group binding 全量替换 + if err := u.repo.ReplaceGroupBindings(ctx, teamID, skill.ID, req.GroupIDs); err != nil { + return nil, err + } + + return u.loadDTO(ctx, teamID, skill.ID) } func (u *teamSkillUsecase) Update(ctx context.Context, teamUser *domain.TeamUser, req *domain.UpdateTeamSkillReq) (*domain.TeamSkill, error) { - skill, err := u.repo.Update(ctx, teamUser.GetTeamID(), req) - if err != nil { + teamID := teamUser.GetTeamID() + + // D3:Content 非空 → 内容变更 → 新版本;否则只改元数据。 + if strings.TrimSpace(req.Content) != "" { + // 走 Add 同款流程:打包 + upload + new version + data, err := packageSkillMarkdownContent(req.Content) + if err != nil { + return nil, err + } + // 先 load skill 拿 name(name 不允许改);再走 AddPackage + skills, err := u.repo.List(ctx, teamID) + if err != nil { + return nil, err + } + var existing *db.AgentSkill + for _, s := range skills { + if s.ID == req.SkillID { + existing = s + break + } + } + if existing == nil { + return nil, errcode.ErrBadRequest.Wrap(fmt.Errorf("skill not found")) + } + pkg := &domain.AddTeamSkillPackageReq{ + AddTeamSkillReq: domain.AddTeamSkillReq{ + Name: existing.Name, + Description: strDerefOr(req.Description, existing.Description), + Tags: req.Tags, + Content: req.Content, + GroupIDs: req.GroupIDs, + SkillMDPath: strDeref(req.SkillMDPath), + IsForceDelivery: boolDeref(req.IsForceDelivery, existing.IsForceDelivery), + SourceType: strDeref(req.SourceType), + SourceLabel: strDeref(req.SourceLabel), + }, + PackageFilename: skillPackageFilename(existing.Name), + PackageData: data, + } + return u.AddPackage(ctx, teamUser, pkg) + } + + // 仅 metadata 更新(name / description / is_force_delivery) + if _, err := u.repo.UpdateMeta(ctx, teamID, req.SkillID, req.Name, req.Description, req.IsForceDelivery); err != nil { return nil, err } - return cvt.From(skill, &domain.TeamSkill{}), nil + // tags 存在 active version 的 parsed_meta 上,原地更新(不建新版本)。 + if req.Tags != nil { + if err := u.repo.UpdateActiveVersionTags(ctx, req.SkillID, req.Tags); err != nil { + return nil, err + } + } + if req.GroupIDs != nil { + if err := u.repo.ReplaceGroupBindings(ctx, teamID, req.SkillID, req.GroupIDs); err != nil { + return nil, err + } + } + return u.loadDTO(ctx, teamID, req.SkillID) } func (u *teamSkillUsecase) Delete(ctx context.Context, teamUser *domain.TeamUser, req *domain.DeleteTeamSkillReq) error { - return u.repo.Delete(ctx, teamUser.GetTeamID(), req.SkillID) + return u.repo.SoftDeleteSkill(ctx, teamUser.GetTeamID(), req.SkillID) } -type skillPackageStore interface { - Put(ctx context.Context, filename string, data []byte) (objectKey string, url string, err error) +// ---- DTO helpers ---- + +func (u *teamSkillUsecase) loadDTO(ctx context.Context, teamID, skillID uuid.UUID) (*domain.TeamSkill, error) { + skill, err := u.repo.GetSkill(ctx, teamID, skillID) + if err != nil { + return nil, err + } + return u.skillToDTO(ctx, skill) } -type ossSkillPackageStore struct { - client *oss.Client +func (u *teamSkillUsecase) skillToDTO(ctx context.Context, s *db.AgentSkill) (*domain.TeamSkill, error) { + dto := &domain.TeamSkill{ + ID: s.ID, + Name: s.Name, + Description: s.Description, + IsForceDelivery: s.IsForceDelivery, + Enabled: s.Enabled, + CreatedAt: s.CreatedAt.Unix(), + UpdatedAt: s.UpdatedAt.Unix(), + } + if s.ActiveVersionID != nil { + ver, err := u.repo.GetActiveVersion(ctx, s.ID) + if err != nil { + return nil, err + } + if ver != nil { + dto.ActiveVersion = ver.Version + dto.S3Key = ver.S3Key + dto.Tags = ver.ParsedMeta.Tags + dto.Categories = ver.ParsedMeta.Categories + dto.SourceType = ver.ParsedMeta.SourceType + dto.SourceLabel = ver.ParsedMeta.SourceLabel + } + } + groups, err := u.repo.LoadGroups(ctx, s.ID) + if err != nil { + return nil, err + } + dto.Groups = groups + return dto, nil } -func (s *ossSkillPackageStore) Put(ctx context.Context, filename string, data []byte) (string, string, error) { - if s == nil || s.client == nil { - return "", "", errcode.ErrBadRequest.Wrap(fmt.Errorf("object storage is disabled")) +// ---- zip helpers ---- + +// validateSkillZipPackage 校验 zip 至少含一个 SKILL.md(大小写不敏感),返回 +// frontmatter 解析出的 tags(没有则 nil)。 +func validateSkillZipPackage(data []byte) ([]string, error) { + reader, err := zip.NewReader(bytes.NewReader(data), int64(len(data))) + if err != nil { + return nil, errcode.ErrBadRequest.Wrap(fmt.Errorf("invalid skill zip package")) } - if err := s.client.PutFile(ctx, skillPackagePrefix, filename, bytes.NewReader(data)); err != nil { - return "", "", err + for _, f := range reader.File { + if f.FileInfo().IsDir() { + continue + } + if !strings.EqualFold(path.Base(f.Name), "SKILL.md") { + continue + } + rc, err := f.Open() + if err != nil { + return nil, errcode.ErrBadRequest.Wrap(err) + } + body, err := io.ReadAll(rc) + _ = rc.Close() + if err != nil { + return nil, errcode.ErrBadRequest.Wrap(err) + } + return parseFrontmatterTags(body), nil } - objectKey := strings.Trim(filepath.ToSlash(filepath.Join(skillPackagePrefix, filepath.Base(filename))), "/") - return objectKey, s.client.GetURL(skillPackagePrefix, filename), nil + return nil, errcode.ErrBadRequest.Wrap(fmt.Errorf("zip package missing SKILL.md")) +} + +// parseFrontmatterTags 极简 YAML frontmatter 解析:支持 +// tags: ["a", "b"] +// tags: [a, b] +// tags: +// - a +// - b +// 找不到/形式不对就返回 nil(降级到 frontmatter 无 tags)。 +func parseFrontmatterTags(body []byte) []string { + s := string(body) + if !strings.HasPrefix(s, "---") { + return nil + } + end := strings.Index(s[3:], "\n---") + if end < 0 { + return nil + } + fm := s[3 : 3+end] + lines := strings.Split(fm, "\n") + for i, line := range lines { + trimmed := strings.TrimSpace(line) + if !strings.HasPrefix(trimmed, "tags:") { + continue + } + rest := strings.TrimSpace(strings.TrimPrefix(trimmed, "tags:")) + if rest != "" { + // inline array + rest = strings.TrimSpace(rest) + if strings.HasPrefix(rest, "[") && strings.HasSuffix(rest, "]") { + inner := strings.TrimSuffix(strings.TrimPrefix(rest, "["), "]") + parts := strings.Split(inner, ",") + out := make([]string, 0, len(parts)) + for _, p := range parts { + p = strings.Trim(strings.TrimSpace(p), `"'`) + if p != "" { + out = append(out, p) + } + } + return out + } + return nil + } + // block list:- a / - b / ... + var out []string + for _, sub := range lines[i+1:] { + ts := strings.TrimSpace(sub) + if !strings.HasPrefix(ts, "-") { + break + } + val := strings.Trim(strings.TrimSpace(strings.TrimPrefix(ts, "-")), `"'`) + if val != "" { + out = append(out, val) + } + } + return out + } + return nil } func packageSkillMarkdownContent(content string) ([]byte, error) { @@ -152,33 +342,39 @@ func packageSkillMarkdownContent(content string) ([]byte, error) { return buf.Bytes(), nil } -func validateSkillZipPackage(data []byte) error { - reader, err := zip.NewReader(bytes.NewReader(data), int64(len(data))) - if err != nil { - return errcode.ErrBadRequest.Wrap(fmt.Errorf("invalid skill zip package")) - } - for _, file := range reader.File { - if file.FileInfo().IsDir() { - continue - } - if strings.EqualFold(filepath.Base(file.Name), "SKILL.md") { - return nil - } - } - return errcode.ErrBadRequest.Wrap(fmt.Errorf("zip package missing SKILL.md")) -} - func skillPackageFilename(name string) string { name = strings.TrimSpace(name) if name == "" { name = "skill" - } else if ext := filepath.Ext(name); strings.EqualFold(ext, ".zip") { - name = strings.TrimSuffix(name, ext) } replacer := strings.NewReplacer("/", "-", "\\", "-", ":", "-", " ", "-") name = strings.Trim(replacer.Replace(name), ".-") if name == "" { name = "skill" } - return fmt.Sprintf("%s-%s.zip", name, uuid.NewString()) + return fmt.Sprintf("%s.zip", name) +} + +// ---- misc ---- + +func strDeref(p *string) string { + if p == nil { + return "" + } + return *p +} +func boolDeref(p *bool, dflt bool) bool { + if p == nil { + return dflt + } + return *p } +func strDerefOr(p *string, dflt string) string { + if p == nil { + return dflt + } + return *p +} + +// silence cvt import if unused in some build flag +var _ = cvt.Iter[int, int] diff --git a/backend/biz/team/usecase/skill_package_test.go b/backend/biz/team/usecase/skill_package_test.go deleted file mode 100644 index 3269e7aa..00000000 --- a/backend/biz/team/usecase/skill_package_test.go +++ /dev/null @@ -1,194 +0,0 @@ -package usecase - -import ( - "archive/zip" - "bytes" - "context" - "io" - "log/slog" - "strings" - "testing" - - "github.com/google/uuid" - - "github.com/chaitin/MonkeyCode/backend/db" - "github.com/chaitin/MonkeyCode/backend/domain" -) - -func TestPackageSkillMarkdownContentCreatesRootSkillMarkdown(t *testing.T) { - content := "---\nname: reviewer\ndescription: Review code\n---\n" - data, err := packageSkillMarkdownContent(content) - if err != nil { - t.Fatal(err) - } - - got := readZipFile(t, data, "SKILL.md") - if got != content { - t.Fatalf("SKILL.md content = %q, want %q", got, content) - } -} - -func TestTeamSkillUsecaseAddUploadsPackageAndKeepsContent(t *testing.T) { - ctx := context.Background() - teamID := uuid.New() - userID := uuid.New() - repo := &teamSkillRepoStub{} - store := &skillPackageStoreStub{} - u := &teamSkillUsecase{ - repo: repo, - packageStore: store, - logger: slog.Default(), - } - - content := "---\nname: planner\ndescription: Write plans\n---\n" - _, err := u.Add(ctx, &domain.TeamUser{ - User: &domain.User{ID: userID}, - Team: &domain.Team{ID: teamID}, - }, &domain.AddTeamSkillReq{ - Name: "planner", - Description: "Write plans", - Content: content, - SourceType: "text", - SourceLabel: "粘贴文本", - }) - if err != nil { - t.Fatal(err) - } - - if repo.createdReq == nil { - t.Fatal("repo Create was not called") - } - if repo.createdReq.Content != content { - t.Fatalf("content = %q, want original content", repo.createdReq.Content) - } - if !strings.HasPrefix(repo.createdReq.PackageObjectKey, "skills/planner-") || !strings.HasSuffix(repo.createdReq.PackageObjectKey, ".zip") { - t.Fatalf("package object key = %q", repo.createdReq.PackageObjectKey) - } - if !strings.HasPrefix(repo.createdReq.PackageURL, "https://oss.example.com/skills/planner-") || !strings.HasSuffix(repo.createdReq.PackageURL, ".zip") { - t.Fatalf("package url = %q", repo.createdReq.PackageURL) - } - if got := readZipFile(t, store.data, "SKILL.md"); got != content { - t.Fatalf("uploaded SKILL.md content = %q, want %q", got, content) - } -} - -func TestTeamSkillUsecaseAddPackageUploadsOriginalZipAndKeepsContent(t *testing.T) { - ctx := context.Background() - teamID := uuid.New() - userID := uuid.New() - repo := &teamSkillRepoStub{} - store := &skillPackageStoreStub{} - u := &teamSkillUsecase{ - repo: repo, - packageStore: store, - logger: slog.Default(), - } - - content := "---\nname: packaged\ndescription: Packaged skill\n---\n" - zipData := makeSkillZip(t, content, "references/guide.md", "guide") - _, err := u.AddPackage(ctx, &domain.TeamUser{ - User: &domain.User{ID: userID}, - Team: &domain.Team{ID: teamID}, - }, &domain.AddTeamSkillPackageReq{ - AddTeamSkillReq: domain.AddTeamSkillReq{ - Name: "packaged", - Description: "Packaged skill", - Content: content, - SourceType: "zip", - SourceLabel: "packaged.zip", - }, - PackageFilename: "packaged.zip", - PackageData: zipData, - }) - if err != nil { - t.Fatal(err) - } - - if !bytes.Equal(store.data, zipData) { - t.Fatal("uploaded data is not the original zip package") - } - if repo.createdReq.Content != content { - t.Fatalf("content = %q, want original SKILL.md content", repo.createdReq.Content) - } - if got := readZipFile(t, store.data, "references/guide.md"); got != "guide" { - t.Fatalf("zip reference file = %q, want guide", got) - } -} - -type teamSkillRepoStub struct { - domain.TeamSkillRepo - createdReq *domain.AddTeamSkillReq -} - -func makeSkillZip(t *testing.T, skillContent string, extraName string, extraContent string) []byte { - t.Helper() - var buf bytes.Buffer - zw := zip.NewWriter(&buf) - for name, content := range map[string]string{ - "SKILL.md": skillContent, - extraName: extraContent, - } { - w, err := zw.Create(name) - if err != nil { - t.Fatal(err) - } - if _, err := w.Write([]byte(content)); err != nil { - t.Fatal(err) - } - } - if err := zw.Close(); err != nil { - t.Fatal(err) - } - return buf.Bytes() -} - -func (r *teamSkillRepoStub) Create(ctx context.Context, teamID, userID uuid.UUID, req *domain.AddTeamSkillReq) (*db.Skill, error) { - r.createdReq = req - return &db.Skill{ - ID: uuid.New(), - UserID: userID, - Name: req.Name, - Description: req.Description, - Tags: req.Tags, - Content: req.Content, - SourceType: req.SourceType, - SourceLabel: req.SourceLabel, - SkillMdPath: req.SkillMDPath, - PackageObjectKey: req.PackageObjectKey, - PackageURL: req.PackageURL, - }, nil -} - -type skillPackageStoreStub struct { - data []byte -} - -func (s *skillPackageStoreStub) Put(ctx context.Context, filename string, data []byte) (string, string, error) { - s.data = append([]byte(nil), data...) - return "skills/" + filename, "https://oss.example.com/skills/" + filename, nil -} - -func readZipFile(t *testing.T, data []byte, name string) string { - t.Helper() - reader, err := zip.NewReader(bytes.NewReader(data), int64(len(data))) - if err != nil { - t.Fatal(err) - } - for _, file := range reader.File { - if file.Name != name { - continue - } - rc, err := file.Open() - if err != nil { - t.Fatal(err) - } - defer rc.Close() - content, err := io.ReadAll(rc) - if err != nil { - t.Fatal(err) - } - return string(content) - } - t.Fatalf("%s not found in zip", name) - return "" -} diff --git a/backend/config/config.go b/backend/config/config.go index 277d007b..0e532545 100644 --- a/backend/config/config.go +++ b/backend/config/config.go @@ -57,8 +57,12 @@ type Config struct { VMIdle VMIdle `mapstructure:"vm_idle"` Attachment Attachment `mapstructure:"attachment"` ObjectStorage ObjectStorageConfig `mapstructure:"object_storage"` - StaticFiles StaticFilesConfig `mapstructure:"static_files"` - HostInstaller HostInstaller `mapstructure:"host_installer"` + // Aliyun mirrors mcai-backend's aliyun.public_oss block so the agent- + // resources Resolver can fall back to that bucket when ObjectStorage is + // disabled (the same OSS that admin-new writes assets into). Optional. + Aliyun AliyunConfig `mapstructure:"aliyun"` + StaticFiles StaticFilesConfig `mapstructure:"static_files"` + HostInstaller HostInstaller `mapstructure:"host_installer"` // Context7 API 配置 Context7ApiKey string `mapstructure:"context7_api_key"` @@ -91,6 +95,31 @@ type ReviewAgent struct { Image string `mapstructure:"image"` } +// AliyunOSSConfig is structurally identical to mcai-backend's config.OSSConfig +// so the same aliyun.public_oss yaml block can be pasted into mcai-gh/backend +// deploys. Only Endpoint / Bucket / AccessKey / AccessKeySecret / Region are +// read by the agent-resources Resolver; the *Prefix fields are accepted for +// shape parity but unused on this side. +type AliyunOSSConfig struct { + AvatarPrefix string `mapstructure:"avatar_prefix"` + SpecPrefix string `mapstructure:"spec_prefix"` + RepoPrefix string `mapstructure:"repo_prefix"` + TempPrefix string `mapstructure:"temp_prefix"` + Endpoint string `mapstructure:"endpoint"` + AccessEndpoint string `mapstructure:"access_endpoint"` + AccessKey string `mapstructure:"access_key"` + AccessKeySecret string `mapstructure:"access_key_secret"` + Bucket string `mapstructure:"bucket"` + Region string `mapstructure:"region"` + MaxSize int64 `mapstructure:"max_size"` +} + +// AliyunConfig mirrors mcai-backend's config.AliyunConfig. +type AliyunConfig struct { + PublicOSS AliyunOSSConfig `mapstructure:"public_oss"` + PrivateOSS AliyunOSSConfig `mapstructure:"private_oss"` +} + // NLS 阿里云语音识别配置 type NLS struct { AppKey string `mapstructure:"app_key"` diff --git a/backend/consts/task.go b/backend/consts/task.go index ebe0b341..9b6c4f81 100644 --- a/backend/consts/task.go +++ b/backend/consts/task.go @@ -63,6 +63,3 @@ const ( // TaskSummaryQueueKey 任务摘要队列 Redis key const TaskSummaryQueueKey = "tasksummary:queue" - -// SkillBaseDir 技能文件存储基目录 -const SkillBaseDir = "/app/skills" diff --git a/backend/db/agentplugin.go b/backend/db/agentplugin.go new file mode 100644 index 00000000..3260307b --- /dev/null +++ b/backend/db/agentplugin.go @@ -0,0 +1,291 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/google/uuid" +) + +// AgentPlugin is the model entity for the AgentPlugin schema. +type AgentPlugin struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // RepoID holds the value of the "repo_id" field. + RepoID uuid.UUID `json:"repo_id,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // ScopeType holds the value of the "scope_type" field. + ScopeType agentplugin.ScopeType `json:"scope_type,omitempty"` + // ScopeID holds the value of the "scope_id" field. + ScopeID string `json:"scope_id,omitempty"` + // CreatedBy holds the value of the "created_by" field. + CreatedBy uuid.UUID `json:"created_by,omitempty"` + // ActiveVersionID holds the value of the "active_version_id" field. + ActiveVersionID *uuid.UUID `json:"active_version_id,omitempty"` + // IsForceDelivery holds the value of the "is_force_delivery" field. + IsForceDelivery bool `json:"is_force_delivery,omitempty"` + // IsOrphan holds the value of the "is_orphan" field. + IsOrphan bool `json:"is_orphan,omitempty"` + // IsDeleted holds the value of the "is_deleted" field. + IsDeleted bool `json:"is_deleted,omitempty"` + // Enabled holds the value of the "enabled" field. + Enabled bool `json:"enabled,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the AgentPluginQuery when eager-loading is set. + Edges AgentPluginEdges `json:"edges"` + selectValues sql.SelectValues +} + +// AgentPluginEdges holds the relations/edges for other nodes in the graph. +type AgentPluginEdges struct { + // Repo holds the value of the repo edge. + Repo *AgentPluginRepo `json:"repo,omitempty"` + // Versions holds the value of the versions edge. + Versions []*AgentPluginVersion `json:"versions,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// RepoOrErr returns the Repo value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e AgentPluginEdges) RepoOrErr() (*AgentPluginRepo, error) { + if e.Repo != nil { + return e.Repo, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: agentpluginrepo.Label} + } + return nil, &NotLoadedError{edge: "repo"} +} + +// VersionsOrErr returns the Versions value or an error if the edge +// was not loaded in eager-loading. +func (e AgentPluginEdges) VersionsOrErr() ([]*AgentPluginVersion, error) { + if e.loadedTypes[1] { + return e.Versions, nil + } + return nil, &NotLoadedError{edge: "versions"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*AgentPlugin) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case agentplugin.FieldActiveVersionID: + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + case agentplugin.FieldIsForceDelivery, agentplugin.FieldIsOrphan, agentplugin.FieldIsDeleted, agentplugin.FieldEnabled: + values[i] = new(sql.NullBool) + case agentplugin.FieldName, agentplugin.FieldDescription, agentplugin.FieldScopeType, agentplugin.FieldScopeID: + values[i] = new(sql.NullString) + case agentplugin.FieldCreatedAt, agentplugin.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case agentplugin.FieldID, agentplugin.FieldRepoID, agentplugin.FieldCreatedBy: + values[i] = new(uuid.UUID) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the AgentPlugin fields. +func (_m *AgentPlugin) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case agentplugin.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case agentplugin.FieldRepoID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field repo_id", values[i]) + } else if value != nil { + _m.RepoID = *value + } + case agentplugin.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case agentplugin.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case agentplugin.FieldScopeType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope_type", values[i]) + } else if value.Valid { + _m.ScopeType = agentplugin.ScopeType(value.String) + } + case agentplugin.FieldScopeID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope_id", values[i]) + } else if value.Valid { + _m.ScopeID = value.String + } + case agentplugin.FieldCreatedBy: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field created_by", values[i]) + } else if value != nil { + _m.CreatedBy = *value + } + case agentplugin.FieldActiveVersionID: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field active_version_id", values[i]) + } else if value.Valid { + _m.ActiveVersionID = new(uuid.UUID) + *_m.ActiveVersionID = *value.S.(*uuid.UUID) + } + case agentplugin.FieldIsForceDelivery: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_force_delivery", values[i]) + } else if value.Valid { + _m.IsForceDelivery = value.Bool + } + case agentplugin.FieldIsOrphan: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_orphan", values[i]) + } else if value.Valid { + _m.IsOrphan = value.Bool + } + case agentplugin.FieldIsDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_deleted", values[i]) + } else if value.Valid { + _m.IsDeleted = value.Bool + } + case agentplugin.FieldEnabled: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field enabled", values[i]) + } else if value.Valid { + _m.Enabled = value.Bool + } + case agentplugin.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case agentplugin.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the AgentPlugin. +// This includes values selected through modifiers, order, etc. +func (_m *AgentPlugin) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryRepo queries the "repo" edge of the AgentPlugin entity. +func (_m *AgentPlugin) QueryRepo() *AgentPluginRepoQuery { + return NewAgentPluginClient(_m.config).QueryRepo(_m) +} + +// QueryVersions queries the "versions" edge of the AgentPlugin entity. +func (_m *AgentPlugin) QueryVersions() *AgentPluginVersionQuery { + return NewAgentPluginClient(_m.config).QueryVersions(_m) +} + +// Update returns a builder for updating this AgentPlugin. +// Note that you need to call AgentPlugin.Unwrap() before calling this method if this AgentPlugin +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *AgentPlugin) Update() *AgentPluginUpdateOne { + return NewAgentPluginClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the AgentPlugin entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *AgentPlugin) Unwrap() *AgentPlugin { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("db: AgentPlugin is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *AgentPlugin) String() string { + var builder strings.Builder + builder.WriteString("AgentPlugin(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("repo_id=") + builder.WriteString(fmt.Sprintf("%v", _m.RepoID)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteString(", ") + builder.WriteString("scope_type=") + builder.WriteString(fmt.Sprintf("%v", _m.ScopeType)) + builder.WriteString(", ") + builder.WriteString("scope_id=") + builder.WriteString(_m.ScopeID) + builder.WriteString(", ") + builder.WriteString("created_by=") + builder.WriteString(fmt.Sprintf("%v", _m.CreatedBy)) + builder.WriteString(", ") + if v := _m.ActiveVersionID; v != nil { + builder.WriteString("active_version_id=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + builder.WriteString("is_force_delivery=") + builder.WriteString(fmt.Sprintf("%v", _m.IsForceDelivery)) + builder.WriteString(", ") + builder.WriteString("is_orphan=") + builder.WriteString(fmt.Sprintf("%v", _m.IsOrphan)) + builder.WriteString(", ") + builder.WriteString("is_deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.IsDeleted)) + builder.WriteString(", ") + builder.WriteString("enabled=") + builder.WriteString(fmt.Sprintf("%v", _m.Enabled)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// AgentPlugins is a parsable slice of AgentPlugin. +type AgentPlugins []*AgentPlugin diff --git a/backend/db/agentplugin/agentplugin.go b/backend/db/agentplugin/agentplugin.go new file mode 100644 index 00000000..0e0f2f6b --- /dev/null +++ b/backend/db/agentplugin/agentplugin.go @@ -0,0 +1,251 @@ +// Code generated by ent, DO NOT EDIT. + +package agentplugin + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the agentplugin type in the database. + Label = "agent_plugin" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldRepoID holds the string denoting the repo_id field in the database. + FieldRepoID = "repo_id" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldScopeType holds the string denoting the scope_type field in the database. + FieldScopeType = "scope_type" + // FieldScopeID holds the string denoting the scope_id field in the database. + FieldScopeID = "scope_id" + // FieldCreatedBy holds the string denoting the created_by field in the database. + FieldCreatedBy = "created_by" + // FieldActiveVersionID holds the string denoting the active_version_id field in the database. + FieldActiveVersionID = "active_version_id" + // FieldIsForceDelivery holds the string denoting the is_force_delivery field in the database. + FieldIsForceDelivery = "is_force_delivery" + // FieldIsOrphan holds the string denoting the is_orphan field in the database. + FieldIsOrphan = "is_orphan" + // FieldIsDeleted holds the string denoting the is_deleted field in the database. + FieldIsDeleted = "is_deleted" + // FieldEnabled holds the string denoting the enabled field in the database. + FieldEnabled = "enabled" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // EdgeRepo holds the string denoting the repo edge name in mutations. + EdgeRepo = "repo" + // EdgeVersions holds the string denoting the versions edge name in mutations. + EdgeVersions = "versions" + // Table holds the table name of the agentplugin in the database. + Table = "agent_plugins" + // RepoTable is the table that holds the repo relation/edge. + RepoTable = "agent_plugins" + // RepoInverseTable is the table name for the AgentPluginRepo entity. + // It exists in this package in order to avoid circular dependency with the "agentpluginrepo" package. + RepoInverseTable = "agent_plugin_repos" + // RepoColumn is the table column denoting the repo relation/edge. + RepoColumn = "repo_id" + // VersionsTable is the table that holds the versions relation/edge. + VersionsTable = "agent_plugin_versions" + // VersionsInverseTable is the table name for the AgentPluginVersion entity. + // It exists in this package in order to avoid circular dependency with the "agentpluginversion" package. + VersionsInverseTable = "agent_plugin_versions" + // VersionsColumn is the table column denoting the versions relation/edge. + VersionsColumn = "resource_id" +) + +// Columns holds all SQL columns for agentplugin fields. +var Columns = []string{ + FieldID, + FieldRepoID, + FieldName, + FieldDescription, + FieldScopeType, + FieldScopeID, + FieldCreatedBy, + FieldActiveVersionID, + FieldIsForceDelivery, + FieldIsOrphan, + FieldIsDeleted, + FieldEnabled, + FieldCreatedAt, + FieldUpdatedAt, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultScopeID holds the default value on creation for the "scope_id" field. + DefaultScopeID string + // DefaultIsForceDelivery holds the default value on creation for the "is_force_delivery" field. + DefaultIsForceDelivery bool + // DefaultIsOrphan holds the default value on creation for the "is_orphan" field. + DefaultIsOrphan bool + // DefaultIsDeleted holds the default value on creation for the "is_deleted" field. + DefaultIsDeleted bool + // DefaultEnabled holds the default value on creation for the "enabled" field. + DefaultEnabled bool + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// ScopeType defines the type for the "scope_type" enum field. +type ScopeType string + +// ScopeTypeGlobal is the default value of the ScopeType enum. +const DefaultScopeType = ScopeTypeGlobal + +// ScopeType values. +const ( + ScopeTypeGlobal ScopeType = "global" + ScopeTypeTeam ScopeType = "team" + ScopeTypeUser ScopeType = "user" +) + +func (st ScopeType) String() string { + return string(st) +} + +// ScopeTypeValidator is a validator for the "scope_type" field enum values. It is called by the builders before save. +func ScopeTypeValidator(st ScopeType) error { + switch st { + case ScopeTypeGlobal, ScopeTypeTeam, ScopeTypeUser: + return nil + default: + return fmt.Errorf("agentplugin: invalid enum value for scope_type field: %q", st) + } +} + +// OrderOption defines the ordering options for the AgentPlugin queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByRepoID orders the results by the repo_id field. +func ByRepoID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRepoID, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByScopeType orders the results by the scope_type field. +func ByScopeType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScopeType, opts...).ToFunc() +} + +// ByScopeID orders the results by the scope_id field. +func ByScopeID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScopeID, opts...).ToFunc() +} + +// ByCreatedBy orders the results by the created_by field. +func ByCreatedBy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedBy, opts...).ToFunc() +} + +// ByActiveVersionID orders the results by the active_version_id field. +func ByActiveVersionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldActiveVersionID, opts...).ToFunc() +} + +// ByIsForceDelivery orders the results by the is_force_delivery field. +func ByIsForceDelivery(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsForceDelivery, opts...).ToFunc() +} + +// ByIsOrphan orders the results by the is_orphan field. +func ByIsOrphan(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsOrphan, opts...).ToFunc() +} + +// ByIsDeleted orders the results by the is_deleted field. +func ByIsDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsDeleted, opts...).ToFunc() +} + +// ByEnabled orders the results by the enabled field. +func ByEnabled(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEnabled, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByRepoField orders the results by repo field. +func ByRepoField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRepoStep(), sql.OrderByField(field, opts...)) + } +} + +// ByVersionsCount orders the results by versions count. +func ByVersionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newVersionsStep(), opts...) + } +} + +// ByVersions orders the results by versions terms. +func ByVersions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newVersionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newRepoStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RepoInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, RepoTable, RepoColumn), + ) +} +func newVersionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(VersionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, VersionsTable, VersionsColumn), + ) +} diff --git a/backend/db/agentplugin/where.go b/backend/db/agentplugin/where.go new file mode 100644 index 00000000..d96fbe16 --- /dev/null +++ b/backend/db/agentplugin/where.go @@ -0,0 +1,633 @@ +// Code generated by ent, DO NOT EDIT. + +package agentplugin + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLTE(FieldID, id)) +} + +// RepoID applies equality check predicate on the "repo_id" field. It's identical to RepoIDEQ. +func RepoID(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldRepoID, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldName, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldDescription, v)) +} + +// ScopeID applies equality check predicate on the "scope_id" field. It's identical to ScopeIDEQ. +func ScopeID(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldScopeID, v)) +} + +// CreatedBy applies equality check predicate on the "created_by" field. It's identical to CreatedByEQ. +func CreatedBy(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldCreatedBy, v)) +} + +// ActiveVersionID applies equality check predicate on the "active_version_id" field. It's identical to ActiveVersionIDEQ. +func ActiveVersionID(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldActiveVersionID, v)) +} + +// IsForceDelivery applies equality check predicate on the "is_force_delivery" field. It's identical to IsForceDeliveryEQ. +func IsForceDelivery(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldIsForceDelivery, v)) +} + +// IsOrphan applies equality check predicate on the "is_orphan" field. It's identical to IsOrphanEQ. +func IsOrphan(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldIsOrphan, v)) +} + +// IsDeleted applies equality check predicate on the "is_deleted" field. It's identical to IsDeletedEQ. +func IsDeleted(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldIsDeleted, v)) +} + +// Enabled applies equality check predicate on the "enabled" field. It's identical to EnabledEQ. +func Enabled(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldEnabled, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// RepoIDEQ applies the EQ predicate on the "repo_id" field. +func RepoIDEQ(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldRepoID, v)) +} + +// RepoIDNEQ applies the NEQ predicate on the "repo_id" field. +func RepoIDNEQ(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldRepoID, v)) +} + +// RepoIDIn applies the In predicate on the "repo_id" field. +func RepoIDIn(vs ...uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIn(FieldRepoID, vs...)) +} + +// RepoIDNotIn applies the NotIn predicate on the "repo_id" field. +func RepoIDNotIn(vs ...uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotIn(FieldRepoID, vs...)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldContainsFold(FieldName, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldContainsFold(FieldDescription, v)) +} + +// ScopeTypeEQ applies the EQ predicate on the "scope_type" field. +func ScopeTypeEQ(v ScopeType) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldScopeType, v)) +} + +// ScopeTypeNEQ applies the NEQ predicate on the "scope_type" field. +func ScopeTypeNEQ(v ScopeType) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldScopeType, v)) +} + +// ScopeTypeIn applies the In predicate on the "scope_type" field. +func ScopeTypeIn(vs ...ScopeType) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIn(FieldScopeType, vs...)) +} + +// ScopeTypeNotIn applies the NotIn predicate on the "scope_type" field. +func ScopeTypeNotIn(vs ...ScopeType) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotIn(FieldScopeType, vs...)) +} + +// ScopeIDEQ applies the EQ predicate on the "scope_id" field. +func ScopeIDEQ(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldScopeID, v)) +} + +// ScopeIDNEQ applies the NEQ predicate on the "scope_id" field. +func ScopeIDNEQ(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldScopeID, v)) +} + +// ScopeIDIn applies the In predicate on the "scope_id" field. +func ScopeIDIn(vs ...string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIn(FieldScopeID, vs...)) +} + +// ScopeIDNotIn applies the NotIn predicate on the "scope_id" field. +func ScopeIDNotIn(vs ...string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotIn(FieldScopeID, vs...)) +} + +// ScopeIDGT applies the GT predicate on the "scope_id" field. +func ScopeIDGT(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGT(FieldScopeID, v)) +} + +// ScopeIDGTE applies the GTE predicate on the "scope_id" field. +func ScopeIDGTE(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGTE(FieldScopeID, v)) +} + +// ScopeIDLT applies the LT predicate on the "scope_id" field. +func ScopeIDLT(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLT(FieldScopeID, v)) +} + +// ScopeIDLTE applies the LTE predicate on the "scope_id" field. +func ScopeIDLTE(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLTE(FieldScopeID, v)) +} + +// ScopeIDContains applies the Contains predicate on the "scope_id" field. +func ScopeIDContains(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldContains(FieldScopeID, v)) +} + +// ScopeIDHasPrefix applies the HasPrefix predicate on the "scope_id" field. +func ScopeIDHasPrefix(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldHasPrefix(FieldScopeID, v)) +} + +// ScopeIDHasSuffix applies the HasSuffix predicate on the "scope_id" field. +func ScopeIDHasSuffix(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldHasSuffix(FieldScopeID, v)) +} + +// ScopeIDEqualFold applies the EqualFold predicate on the "scope_id" field. +func ScopeIDEqualFold(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEqualFold(FieldScopeID, v)) +} + +// ScopeIDContainsFold applies the ContainsFold predicate on the "scope_id" field. +func ScopeIDContainsFold(v string) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldContainsFold(FieldScopeID, v)) +} + +// CreatedByEQ applies the EQ predicate on the "created_by" field. +func CreatedByEQ(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldCreatedBy, v)) +} + +// CreatedByNEQ applies the NEQ predicate on the "created_by" field. +func CreatedByNEQ(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldCreatedBy, v)) +} + +// CreatedByIn applies the In predicate on the "created_by" field. +func CreatedByIn(vs ...uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIn(FieldCreatedBy, vs...)) +} + +// CreatedByNotIn applies the NotIn predicate on the "created_by" field. +func CreatedByNotIn(vs ...uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotIn(FieldCreatedBy, vs...)) +} + +// CreatedByGT applies the GT predicate on the "created_by" field. +func CreatedByGT(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGT(FieldCreatedBy, v)) +} + +// CreatedByGTE applies the GTE predicate on the "created_by" field. +func CreatedByGTE(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGTE(FieldCreatedBy, v)) +} + +// CreatedByLT applies the LT predicate on the "created_by" field. +func CreatedByLT(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLT(FieldCreatedBy, v)) +} + +// CreatedByLTE applies the LTE predicate on the "created_by" field. +func CreatedByLTE(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLTE(FieldCreatedBy, v)) +} + +// ActiveVersionIDEQ applies the EQ predicate on the "active_version_id" field. +func ActiveVersionIDEQ(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldActiveVersionID, v)) +} + +// ActiveVersionIDNEQ applies the NEQ predicate on the "active_version_id" field. +func ActiveVersionIDNEQ(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldActiveVersionID, v)) +} + +// ActiveVersionIDIn applies the In predicate on the "active_version_id" field. +func ActiveVersionIDIn(vs ...uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIn(FieldActiveVersionID, vs...)) +} + +// ActiveVersionIDNotIn applies the NotIn predicate on the "active_version_id" field. +func ActiveVersionIDNotIn(vs ...uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotIn(FieldActiveVersionID, vs...)) +} + +// ActiveVersionIDGT applies the GT predicate on the "active_version_id" field. +func ActiveVersionIDGT(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGT(FieldActiveVersionID, v)) +} + +// ActiveVersionIDGTE applies the GTE predicate on the "active_version_id" field. +func ActiveVersionIDGTE(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGTE(FieldActiveVersionID, v)) +} + +// ActiveVersionIDLT applies the LT predicate on the "active_version_id" field. +func ActiveVersionIDLT(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLT(FieldActiveVersionID, v)) +} + +// ActiveVersionIDLTE applies the LTE predicate on the "active_version_id" field. +func ActiveVersionIDLTE(v uuid.UUID) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLTE(FieldActiveVersionID, v)) +} + +// ActiveVersionIDIsNil applies the IsNil predicate on the "active_version_id" field. +func ActiveVersionIDIsNil() predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIsNull(FieldActiveVersionID)) +} + +// ActiveVersionIDNotNil applies the NotNil predicate on the "active_version_id" field. +func ActiveVersionIDNotNil() predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotNull(FieldActiveVersionID)) +} + +// IsForceDeliveryEQ applies the EQ predicate on the "is_force_delivery" field. +func IsForceDeliveryEQ(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldIsForceDelivery, v)) +} + +// IsForceDeliveryNEQ applies the NEQ predicate on the "is_force_delivery" field. +func IsForceDeliveryNEQ(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldIsForceDelivery, v)) +} + +// IsOrphanEQ applies the EQ predicate on the "is_orphan" field. +func IsOrphanEQ(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldIsOrphan, v)) +} + +// IsOrphanNEQ applies the NEQ predicate on the "is_orphan" field. +func IsOrphanNEQ(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldIsOrphan, v)) +} + +// IsDeletedEQ applies the EQ predicate on the "is_deleted" field. +func IsDeletedEQ(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldIsDeleted, v)) +} + +// IsDeletedNEQ applies the NEQ predicate on the "is_deleted" field. +func IsDeletedNEQ(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldIsDeleted, v)) +} + +// EnabledEQ applies the EQ predicate on the "enabled" field. +func EnabledEQ(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldEnabled, v)) +} + +// EnabledNEQ applies the NEQ predicate on the "enabled" field. +func EnabledNEQ(v bool) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldEnabled, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// HasRepo applies the HasEdge predicate on the "repo" edge. +func HasRepo() predicate.AgentPlugin { + return predicate.AgentPlugin(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, RepoTable, RepoColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRepoWith applies the HasEdge predicate on the "repo" edge with a given conditions (other predicates). +func HasRepoWith(preds ...predicate.AgentPluginRepo) predicate.AgentPlugin { + return predicate.AgentPlugin(func(s *sql.Selector) { + step := newRepoStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasVersions applies the HasEdge predicate on the "versions" edge. +func HasVersions() predicate.AgentPlugin { + return predicate.AgentPlugin(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, VersionsTable, VersionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasVersionsWith applies the HasEdge predicate on the "versions" edge with a given conditions (other predicates). +func HasVersionsWith(preds ...predicate.AgentPluginVersion) predicate.AgentPlugin { + return predicate.AgentPlugin(func(s *sql.Selector) { + step := newVersionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.AgentPlugin) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.AgentPlugin) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.AgentPlugin) predicate.AgentPlugin { + return predicate.AgentPlugin(sql.NotPredicates(p)) +} diff --git a/backend/db/agentplugin_create.go b/backend/db/agentplugin_create.go new file mode 100644 index 00000000..cc1c9921 --- /dev/null +++ b/backend/db/agentplugin_create.go @@ -0,0 +1,1355 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/google/uuid" +) + +// AgentPluginCreate is the builder for creating a AgentPlugin entity. +type AgentPluginCreate struct { + config + mutation *AgentPluginMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetRepoID sets the "repo_id" field. +func (_c *AgentPluginCreate) SetRepoID(v uuid.UUID) *AgentPluginCreate { + _c.mutation.SetRepoID(v) + return _c +} + +// SetName sets the "name" field. +func (_c *AgentPluginCreate) SetName(v string) *AgentPluginCreate { + _c.mutation.SetName(v) + return _c +} + +// SetDescription sets the "description" field. +func (_c *AgentPluginCreate) SetDescription(v string) *AgentPluginCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableDescription(v *string) *AgentPluginCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetScopeType sets the "scope_type" field. +func (_c *AgentPluginCreate) SetScopeType(v agentplugin.ScopeType) *AgentPluginCreate { + _c.mutation.SetScopeType(v) + return _c +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableScopeType(v *agentplugin.ScopeType) *AgentPluginCreate { + if v != nil { + _c.SetScopeType(*v) + } + return _c +} + +// SetScopeID sets the "scope_id" field. +func (_c *AgentPluginCreate) SetScopeID(v string) *AgentPluginCreate { + _c.mutation.SetScopeID(v) + return _c +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableScopeID(v *string) *AgentPluginCreate { + if v != nil { + _c.SetScopeID(*v) + } + return _c +} + +// SetCreatedBy sets the "created_by" field. +func (_c *AgentPluginCreate) SetCreatedBy(v uuid.UUID) *AgentPluginCreate { + _c.mutation.SetCreatedBy(v) + return _c +} + +// SetActiveVersionID sets the "active_version_id" field. +func (_c *AgentPluginCreate) SetActiveVersionID(v uuid.UUID) *AgentPluginCreate { + _c.mutation.SetActiveVersionID(v) + return _c +} + +// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableActiveVersionID(v *uuid.UUID) *AgentPluginCreate { + if v != nil { + _c.SetActiveVersionID(*v) + } + return _c +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (_c *AgentPluginCreate) SetIsForceDelivery(v bool) *AgentPluginCreate { + _c.mutation.SetIsForceDelivery(v) + return _c +} + +// SetNillableIsForceDelivery sets the "is_force_delivery" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableIsForceDelivery(v *bool) *AgentPluginCreate { + if v != nil { + _c.SetIsForceDelivery(*v) + } + return _c +} + +// SetIsOrphan sets the "is_orphan" field. +func (_c *AgentPluginCreate) SetIsOrphan(v bool) *AgentPluginCreate { + _c.mutation.SetIsOrphan(v) + return _c +} + +// SetNillableIsOrphan sets the "is_orphan" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableIsOrphan(v *bool) *AgentPluginCreate { + if v != nil { + _c.SetIsOrphan(*v) + } + return _c +} + +// SetIsDeleted sets the "is_deleted" field. +func (_c *AgentPluginCreate) SetIsDeleted(v bool) *AgentPluginCreate { + _c.mutation.SetIsDeleted(v) + return _c +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableIsDeleted(v *bool) *AgentPluginCreate { + if v != nil { + _c.SetIsDeleted(*v) + } + return _c +} + +// SetEnabled sets the "enabled" field. +func (_c *AgentPluginCreate) SetEnabled(v bool) *AgentPluginCreate { + _c.mutation.SetEnabled(v) + return _c +} + +// SetNillableEnabled sets the "enabled" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableEnabled(v *bool) *AgentPluginCreate { + if v != nil { + _c.SetEnabled(*v) + } + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AgentPluginCreate) SetCreatedAt(v time.Time) *AgentPluginCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableCreatedAt(v *time.Time) *AgentPluginCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *AgentPluginCreate) SetUpdatedAt(v time.Time) *AgentPluginCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableUpdatedAt(v *time.Time) *AgentPluginCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AgentPluginCreate) SetID(v uuid.UUID) *AgentPluginCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AgentPluginCreate) SetNillableID(v *uuid.UUID) *AgentPluginCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetRepo sets the "repo" edge to the AgentPluginRepo entity. +func (_c *AgentPluginCreate) SetRepo(v *AgentPluginRepo) *AgentPluginCreate { + return _c.SetRepoID(v.ID) +} + +// AddVersionIDs adds the "versions" edge to the AgentPluginVersion entity by IDs. +func (_c *AgentPluginCreate) AddVersionIDs(ids ...uuid.UUID) *AgentPluginCreate { + _c.mutation.AddVersionIDs(ids...) + return _c +} + +// AddVersions adds the "versions" edges to the AgentPluginVersion entity. +func (_c *AgentPluginCreate) AddVersions(v ...*AgentPluginVersion) *AgentPluginCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddVersionIDs(ids...) +} + +// Mutation returns the AgentPluginMutation object of the builder. +func (_c *AgentPluginCreate) Mutation() *AgentPluginMutation { + return _c.mutation +} + +// Save creates the AgentPlugin in the database. +func (_c *AgentPluginCreate) Save(ctx context.Context) (*AgentPlugin, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AgentPluginCreate) SaveX(ctx context.Context) *AgentPlugin { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentPluginCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentPluginCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AgentPluginCreate) defaults() { + if _, ok := _c.mutation.ScopeType(); !ok { + v := agentplugin.DefaultScopeType + _c.mutation.SetScopeType(v) + } + if _, ok := _c.mutation.ScopeID(); !ok { + v := agentplugin.DefaultScopeID + _c.mutation.SetScopeID(v) + } + if _, ok := _c.mutation.IsForceDelivery(); !ok { + v := agentplugin.DefaultIsForceDelivery + _c.mutation.SetIsForceDelivery(v) + } + if _, ok := _c.mutation.IsOrphan(); !ok { + v := agentplugin.DefaultIsOrphan + _c.mutation.SetIsOrphan(v) + } + if _, ok := _c.mutation.IsDeleted(); !ok { + v := agentplugin.DefaultIsDeleted + _c.mutation.SetIsDeleted(v) + } + if _, ok := _c.mutation.Enabled(); !ok { + v := agentplugin.DefaultEnabled + _c.mutation.SetEnabled(v) + } + if _, ok := _c.mutation.CreatedAt(); !ok { + v := agentplugin.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := agentplugin.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := agentplugin.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AgentPluginCreate) check() error { + if _, ok := _c.mutation.RepoID(); !ok { + return &ValidationError{Name: "repo_id", err: errors.New(`db: missing required field "AgentPlugin.repo_id"`)} + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`db: missing required field "AgentPlugin.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := agentplugin.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentPlugin.name": %w`, err)} + } + } + if _, ok := _c.mutation.ScopeType(); !ok { + return &ValidationError{Name: "scope_type", err: errors.New(`db: missing required field "AgentPlugin.scope_type"`)} + } + if v, ok := _c.mutation.ScopeType(); ok { + if err := agentplugin.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentPlugin.scope_type": %w`, err)} + } + } + if _, ok := _c.mutation.ScopeID(); !ok { + return &ValidationError{Name: "scope_id", err: errors.New(`db: missing required field "AgentPlugin.scope_id"`)} + } + if _, ok := _c.mutation.CreatedBy(); !ok { + return &ValidationError{Name: "created_by", err: errors.New(`db: missing required field "AgentPlugin.created_by"`)} + } + if _, ok := _c.mutation.IsForceDelivery(); !ok { + return &ValidationError{Name: "is_force_delivery", err: errors.New(`db: missing required field "AgentPlugin.is_force_delivery"`)} + } + if _, ok := _c.mutation.IsOrphan(); !ok { + return &ValidationError{Name: "is_orphan", err: errors.New(`db: missing required field "AgentPlugin.is_orphan"`)} + } + if _, ok := _c.mutation.IsDeleted(); !ok { + return &ValidationError{Name: "is_deleted", err: errors.New(`db: missing required field "AgentPlugin.is_deleted"`)} + } + if _, ok := _c.mutation.Enabled(); !ok { + return &ValidationError{Name: "enabled", err: errors.New(`db: missing required field "AgentPlugin.enabled"`)} + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentPlugin.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "AgentPlugin.updated_at"`)} + } + if len(_c.mutation.RepoIDs()) == 0 { + return &ValidationError{Name: "repo", err: errors.New(`db: missing required edge "AgentPlugin.repo"`)} + } + return nil +} + +func (_c *AgentPluginCreate) sqlSave(ctx context.Context) (*AgentPlugin, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AgentPluginCreate) createSpec() (*AgentPlugin, *sqlgraph.CreateSpec) { + var ( + _node = &AgentPlugin{config: _c.config} + _spec = sqlgraph.NewCreateSpec(agentplugin.Table, sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID)) + ) + _spec.OnConflict = _c.conflict + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(agentplugin.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(agentplugin.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := _c.mutation.ScopeType(); ok { + _spec.SetField(agentplugin.FieldScopeType, field.TypeEnum, value) + _node.ScopeType = value + } + if value, ok := _c.mutation.ScopeID(); ok { + _spec.SetField(agentplugin.FieldScopeID, field.TypeString, value) + _node.ScopeID = value + } + if value, ok := _c.mutation.CreatedBy(); ok { + _spec.SetField(agentplugin.FieldCreatedBy, field.TypeUUID, value) + _node.CreatedBy = value + } + if value, ok := _c.mutation.ActiveVersionID(); ok { + _spec.SetField(agentplugin.FieldActiveVersionID, field.TypeUUID, value) + _node.ActiveVersionID = &value + } + if value, ok := _c.mutation.IsForceDelivery(); ok { + _spec.SetField(agentplugin.FieldIsForceDelivery, field.TypeBool, value) + _node.IsForceDelivery = value + } + if value, ok := _c.mutation.IsOrphan(); ok { + _spec.SetField(agentplugin.FieldIsOrphan, field.TypeBool, value) + _node.IsOrphan = value + } + if value, ok := _c.mutation.IsDeleted(); ok { + _spec.SetField(agentplugin.FieldIsDeleted, field.TypeBool, value) + _node.IsDeleted = value + } + if value, ok := _c.mutation.Enabled(); ok { + _spec.SetField(agentplugin.FieldEnabled, field.TypeBool, value) + _node.Enabled = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(agentplugin.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(agentplugin.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if nodes := _c.mutation.RepoIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentplugin.RepoTable, + Columns: []string{agentplugin.RepoColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginrepo.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.RepoID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentplugin.VersionsTable, + Columns: []string{agentplugin.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentPlugin.Create(). +// SetRepoID(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentPluginUpsert) { +// SetRepoID(v+v). +// }). +// Exec(ctx) +func (_c *AgentPluginCreate) OnConflict(opts ...sql.ConflictOption) *AgentPluginUpsertOne { + _c.conflict = opts + return &AgentPluginUpsertOne{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentPlugin.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentPluginCreate) OnConflictColumns(columns ...string) *AgentPluginUpsertOne { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentPluginUpsertOne{ + create: _c, + } +} + +type ( + // AgentPluginUpsertOne is the builder for "upsert"-ing + // one AgentPlugin node. + AgentPluginUpsertOne struct { + create *AgentPluginCreate + } + + // AgentPluginUpsert is the "OnConflict" setter. + AgentPluginUpsert struct { + *sql.UpdateSet + } +) + +// SetRepoID sets the "repo_id" field. +func (u *AgentPluginUpsert) SetRepoID(v uuid.UUID) *AgentPluginUpsert { + u.Set(agentplugin.FieldRepoID, v) + return u +} + +// UpdateRepoID sets the "repo_id" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateRepoID() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldRepoID) + return u +} + +// SetName sets the "name" field. +func (u *AgentPluginUpsert) SetName(v string) *AgentPluginUpsert { + u.Set(agentplugin.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateName() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldName) + return u +} + +// SetDescription sets the "description" field. +func (u *AgentPluginUpsert) SetDescription(v string) *AgentPluginUpsert { + u.Set(agentplugin.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateDescription() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldDescription) + return u +} + +// ClearDescription clears the value of the "description" field. +func (u *AgentPluginUpsert) ClearDescription() *AgentPluginUpsert { + u.SetNull(agentplugin.FieldDescription) + return u +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentPluginUpsert) SetScopeType(v agentplugin.ScopeType) *AgentPluginUpsert { + u.Set(agentplugin.FieldScopeType, v) + return u +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateScopeType() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldScopeType) + return u +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentPluginUpsert) SetScopeID(v string) *AgentPluginUpsert { + u.Set(agentplugin.FieldScopeID, v) + return u +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateScopeID() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldScopeID) + return u +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentPluginUpsert) SetCreatedBy(v uuid.UUID) *AgentPluginUpsert { + u.Set(agentplugin.FieldCreatedBy, v) + return u +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateCreatedBy() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldCreatedBy) + return u +} + +// SetActiveVersionID sets the "active_version_id" field. +func (u *AgentPluginUpsert) SetActiveVersionID(v uuid.UUID) *AgentPluginUpsert { + u.Set(agentplugin.FieldActiveVersionID, v) + return u +} + +// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateActiveVersionID() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldActiveVersionID) + return u +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (u *AgentPluginUpsert) ClearActiveVersionID() *AgentPluginUpsert { + u.SetNull(agentplugin.FieldActiveVersionID) + return u +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (u *AgentPluginUpsert) SetIsForceDelivery(v bool) *AgentPluginUpsert { + u.Set(agentplugin.FieldIsForceDelivery, v) + return u +} + +// UpdateIsForceDelivery sets the "is_force_delivery" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateIsForceDelivery() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldIsForceDelivery) + return u +} + +// SetIsOrphan sets the "is_orphan" field. +func (u *AgentPluginUpsert) SetIsOrphan(v bool) *AgentPluginUpsert { + u.Set(agentplugin.FieldIsOrphan, v) + return u +} + +// UpdateIsOrphan sets the "is_orphan" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateIsOrphan() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldIsOrphan) + return u +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentPluginUpsert) SetIsDeleted(v bool) *AgentPluginUpsert { + u.Set(agentplugin.FieldIsDeleted, v) + return u +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateIsDeleted() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldIsDeleted) + return u +} + +// SetEnabled sets the "enabled" field. +func (u *AgentPluginUpsert) SetEnabled(v bool) *AgentPluginUpsert { + u.Set(agentplugin.FieldEnabled, v) + return u +} + +// UpdateEnabled sets the "enabled" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateEnabled() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldEnabled) + return u +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentPluginUpsert) SetCreatedAt(v time.Time) *AgentPluginUpsert { + u.Set(agentplugin.FieldCreatedAt, v) + return u +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateCreatedAt() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldCreatedAt) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentPluginUpsert) SetUpdatedAt(v time.Time) *AgentPluginUpsert { + u.Set(agentplugin.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentPluginUpsert) UpdateUpdatedAt() *AgentPluginUpsert { + u.SetExcluded(agentplugin.FieldUpdatedAt) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.AgentPlugin.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentplugin.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentPluginUpsertOne) UpdateNewValues() *AgentPluginUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(agentplugin.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentPlugin.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentPluginUpsertOne) Ignore() *AgentPluginUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentPluginUpsertOne) DoNothing() *AgentPluginUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentPluginCreate.OnConflict +// documentation for more info. +func (u *AgentPluginUpsertOne) Update(set func(*AgentPluginUpsert)) *AgentPluginUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentPluginUpsert{UpdateSet: update}) + })) + return u +} + +// SetRepoID sets the "repo_id" field. +func (u *AgentPluginUpsertOne) SetRepoID(v uuid.UUID) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetRepoID(v) + }) +} + +// UpdateRepoID sets the "repo_id" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateRepoID() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateRepoID() + }) +} + +// SetName sets the "name" field. +func (u *AgentPluginUpsertOne) SetName(v string) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateName() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *AgentPluginUpsertOne) SetDescription(v string) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateDescription() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *AgentPluginUpsertOne) ClearDescription() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.ClearDescription() + }) +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentPluginUpsertOne) SetScopeType(v agentplugin.ScopeType) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetScopeType(v) + }) +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateScopeType() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateScopeType() + }) +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentPluginUpsertOne) SetScopeID(v string) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetScopeID(v) + }) +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateScopeID() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateScopeID() + }) +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentPluginUpsertOne) SetCreatedBy(v uuid.UUID) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetCreatedBy(v) + }) +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateCreatedBy() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateCreatedBy() + }) +} + +// SetActiveVersionID sets the "active_version_id" field. +func (u *AgentPluginUpsertOne) SetActiveVersionID(v uuid.UUID) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetActiveVersionID(v) + }) +} + +// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateActiveVersionID() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateActiveVersionID() + }) +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (u *AgentPluginUpsertOne) ClearActiveVersionID() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.ClearActiveVersionID() + }) +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (u *AgentPluginUpsertOne) SetIsForceDelivery(v bool) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetIsForceDelivery(v) + }) +} + +// UpdateIsForceDelivery sets the "is_force_delivery" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateIsForceDelivery() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateIsForceDelivery() + }) +} + +// SetIsOrphan sets the "is_orphan" field. +func (u *AgentPluginUpsertOne) SetIsOrphan(v bool) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetIsOrphan(v) + }) +} + +// UpdateIsOrphan sets the "is_orphan" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateIsOrphan() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateIsOrphan() + }) +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentPluginUpsertOne) SetIsDeleted(v bool) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetIsDeleted(v) + }) +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateIsDeleted() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateIsDeleted() + }) +} + +// SetEnabled sets the "enabled" field. +func (u *AgentPluginUpsertOne) SetEnabled(v bool) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetEnabled(v) + }) +} + +// UpdateEnabled sets the "enabled" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateEnabled() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateEnabled() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentPluginUpsertOne) SetCreatedAt(v time.Time) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateCreatedAt() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentPluginUpsertOne) SetUpdatedAt(v time.Time) *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentPluginUpsertOne) UpdateUpdatedAt() *AgentPluginUpsertOne { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentPluginUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentPluginCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentPluginUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *AgentPluginUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: AgentPluginUpsertOne.ID is not supported by MySQL driver. Use AgentPluginUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *AgentPluginUpsertOne) IDX(ctx context.Context) uuid.UUID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// AgentPluginCreateBulk is the builder for creating many AgentPlugin entities in bulk. +type AgentPluginCreateBulk struct { + config + err error + builders []*AgentPluginCreate + conflict []sql.ConflictOption +} + +// Save creates the AgentPlugin entities in the database. +func (_c *AgentPluginCreateBulk) Save(ctx context.Context) ([]*AgentPlugin, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*AgentPlugin, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AgentPluginMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = _c.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AgentPluginCreateBulk) SaveX(ctx context.Context) []*AgentPlugin { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentPluginCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentPluginCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentPlugin.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentPluginUpsert) { +// SetRepoID(v+v). +// }). +// Exec(ctx) +func (_c *AgentPluginCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentPluginUpsertBulk { + _c.conflict = opts + return &AgentPluginUpsertBulk{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentPlugin.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentPluginCreateBulk) OnConflictColumns(columns ...string) *AgentPluginUpsertBulk { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentPluginUpsertBulk{ + create: _c, + } +} + +// AgentPluginUpsertBulk is the builder for "upsert"-ing +// a bulk of AgentPlugin nodes. +type AgentPluginUpsertBulk struct { + create *AgentPluginCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.AgentPlugin.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentplugin.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentPluginUpsertBulk) UpdateNewValues() *AgentPluginUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(agentplugin.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentPlugin.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentPluginUpsertBulk) Ignore() *AgentPluginUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentPluginUpsertBulk) DoNothing() *AgentPluginUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentPluginCreateBulk.OnConflict +// documentation for more info. +func (u *AgentPluginUpsertBulk) Update(set func(*AgentPluginUpsert)) *AgentPluginUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentPluginUpsert{UpdateSet: update}) + })) + return u +} + +// SetRepoID sets the "repo_id" field. +func (u *AgentPluginUpsertBulk) SetRepoID(v uuid.UUID) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetRepoID(v) + }) +} + +// UpdateRepoID sets the "repo_id" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateRepoID() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateRepoID() + }) +} + +// SetName sets the "name" field. +func (u *AgentPluginUpsertBulk) SetName(v string) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateName() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *AgentPluginUpsertBulk) SetDescription(v string) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateDescription() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *AgentPluginUpsertBulk) ClearDescription() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.ClearDescription() + }) +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentPluginUpsertBulk) SetScopeType(v agentplugin.ScopeType) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetScopeType(v) + }) +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateScopeType() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateScopeType() + }) +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentPluginUpsertBulk) SetScopeID(v string) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetScopeID(v) + }) +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateScopeID() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateScopeID() + }) +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentPluginUpsertBulk) SetCreatedBy(v uuid.UUID) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetCreatedBy(v) + }) +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateCreatedBy() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateCreatedBy() + }) +} + +// SetActiveVersionID sets the "active_version_id" field. +func (u *AgentPluginUpsertBulk) SetActiveVersionID(v uuid.UUID) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetActiveVersionID(v) + }) +} + +// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateActiveVersionID() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateActiveVersionID() + }) +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (u *AgentPluginUpsertBulk) ClearActiveVersionID() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.ClearActiveVersionID() + }) +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (u *AgentPluginUpsertBulk) SetIsForceDelivery(v bool) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetIsForceDelivery(v) + }) +} + +// UpdateIsForceDelivery sets the "is_force_delivery" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateIsForceDelivery() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateIsForceDelivery() + }) +} + +// SetIsOrphan sets the "is_orphan" field. +func (u *AgentPluginUpsertBulk) SetIsOrphan(v bool) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetIsOrphan(v) + }) +} + +// UpdateIsOrphan sets the "is_orphan" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateIsOrphan() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateIsOrphan() + }) +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentPluginUpsertBulk) SetIsDeleted(v bool) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetIsDeleted(v) + }) +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateIsDeleted() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateIsDeleted() + }) +} + +// SetEnabled sets the "enabled" field. +func (u *AgentPluginUpsertBulk) SetEnabled(v bool) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetEnabled(v) + }) +} + +// UpdateEnabled sets the "enabled" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateEnabled() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateEnabled() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentPluginUpsertBulk) SetCreatedAt(v time.Time) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateCreatedAt() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentPluginUpsertBulk) SetUpdatedAt(v time.Time) *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentPluginUpsertBulk) UpdateUpdatedAt() *AgentPluginUpsertBulk { + return u.Update(func(s *AgentPluginUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentPluginUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentPluginCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentPluginCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentPluginUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentplugin_delete.go b/backend/db/agentplugin_delete.go new file mode 100644 index 00000000..82fcd0ba --- /dev/null +++ b/backend/db/agentplugin_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/predicate" +) + +// AgentPluginDelete is the builder for deleting a AgentPlugin entity. +type AgentPluginDelete struct { + config + hooks []Hook + mutation *AgentPluginMutation +} + +// Where appends a list predicates to the AgentPluginDelete builder. +func (_d *AgentPluginDelete) Where(ps ...predicate.AgentPlugin) *AgentPluginDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *AgentPluginDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentPluginDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *AgentPluginDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(agentplugin.Table, sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// AgentPluginDeleteOne is the builder for deleting a single AgentPlugin entity. +type AgentPluginDeleteOne struct { + _d *AgentPluginDelete +} + +// Where appends a list predicates to the AgentPluginDelete builder. +func (_d *AgentPluginDeleteOne) Where(ps ...predicate.AgentPlugin) *AgentPluginDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *AgentPluginDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{agentplugin.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentPluginDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentplugin_query.go b/backend/db/agentplugin_query.go new file mode 100644 index 00000000..fc8d11e0 --- /dev/null +++ b/backend/db/agentplugin_query.go @@ -0,0 +1,732 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentPluginQuery is the builder for querying AgentPlugin entities. +type AgentPluginQuery struct { + config + ctx *QueryContext + order []agentplugin.OrderOption + inters []Interceptor + predicates []predicate.AgentPlugin + withRepo *AgentPluginRepoQuery + withVersions *AgentPluginVersionQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the AgentPluginQuery builder. +func (_q *AgentPluginQuery) Where(ps ...predicate.AgentPlugin) *AgentPluginQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *AgentPluginQuery) Limit(limit int) *AgentPluginQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *AgentPluginQuery) Offset(offset int) *AgentPluginQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *AgentPluginQuery) Unique(unique bool) *AgentPluginQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *AgentPluginQuery) Order(o ...agentplugin.OrderOption) *AgentPluginQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryRepo chains the current query on the "repo" edge. +func (_q *AgentPluginQuery) QueryRepo() *AgentPluginRepoQuery { + query := (&AgentPluginRepoClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(agentplugin.Table, agentplugin.FieldID, selector), + sqlgraph.To(agentpluginrepo.Table, agentpluginrepo.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, agentplugin.RepoTable, agentplugin.RepoColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryVersions chains the current query on the "versions" edge. +func (_q *AgentPluginQuery) QueryVersions() *AgentPluginVersionQuery { + query := (&AgentPluginVersionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(agentplugin.Table, agentplugin.FieldID, selector), + sqlgraph.To(agentpluginversion.Table, agentpluginversion.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, agentplugin.VersionsTable, agentplugin.VersionsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first AgentPlugin entity from the query. +// Returns a *NotFoundError when no AgentPlugin was found. +func (_q *AgentPluginQuery) First(ctx context.Context) (*AgentPlugin, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{agentplugin.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *AgentPluginQuery) FirstX(ctx context.Context) *AgentPlugin { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first AgentPlugin ID from the query. +// Returns a *NotFoundError when no AgentPlugin ID was found. +func (_q *AgentPluginQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{agentplugin.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *AgentPluginQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single AgentPlugin entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one AgentPlugin entity is found. +// Returns a *NotFoundError when no AgentPlugin entities are found. +func (_q *AgentPluginQuery) Only(ctx context.Context) (*AgentPlugin, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{agentplugin.Label} + default: + return nil, &NotSingularError{agentplugin.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *AgentPluginQuery) OnlyX(ctx context.Context) *AgentPlugin { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only AgentPlugin ID in the query. +// Returns a *NotSingularError when more than one AgentPlugin ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *AgentPluginQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{agentplugin.Label} + default: + err = &NotSingularError{agentplugin.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *AgentPluginQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of AgentPlugins. +func (_q *AgentPluginQuery) All(ctx context.Context) ([]*AgentPlugin, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*AgentPlugin, *AgentPluginQuery]() + return withInterceptors[[]*AgentPlugin](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *AgentPluginQuery) AllX(ctx context.Context) []*AgentPlugin { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of AgentPlugin IDs. +func (_q *AgentPluginQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(agentplugin.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *AgentPluginQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *AgentPluginQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*AgentPluginQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *AgentPluginQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *AgentPluginQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *AgentPluginQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AgentPluginQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *AgentPluginQuery) Clone() *AgentPluginQuery { + if _q == nil { + return nil + } + return &AgentPluginQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]agentplugin.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.AgentPlugin{}, _q.predicates...), + withRepo: _q.withRepo.Clone(), + withVersions: _q.withVersions.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithRepo tells the query-builder to eager-load the nodes that are connected to +// the "repo" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentPluginQuery) WithRepo(opts ...func(*AgentPluginRepoQuery)) *AgentPluginQuery { + query := (&AgentPluginRepoClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRepo = query + return _q +} + +// WithVersions tells the query-builder to eager-load the nodes that are connected to +// the "versions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentPluginQuery) WithVersions(opts ...func(*AgentPluginVersionQuery)) *AgentPluginQuery { + query := (&AgentPluginVersionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withVersions = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// RepoID uuid.UUID `json:"repo_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.AgentPlugin.Query(). +// GroupBy(agentplugin.FieldRepoID). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (_q *AgentPluginQuery) GroupBy(field string, fields ...string) *AgentPluginGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &AgentPluginGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = agentplugin.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// RepoID uuid.UUID `json:"repo_id,omitempty"` +// } +// +// client.AgentPlugin.Query(). +// Select(agentplugin.FieldRepoID). +// Scan(ctx, &v) +func (_q *AgentPluginQuery) Select(fields ...string) *AgentPluginSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &AgentPluginSelect{AgentPluginQuery: _q} + sbuild.label = agentplugin.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AgentPluginSelect configured with the given aggregations. +func (_q *AgentPluginQuery) Aggregate(fns ...AggregateFunc) *AgentPluginSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *AgentPluginQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !agentplugin.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *AgentPluginQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AgentPlugin, error) { + var ( + nodes = []*AgentPlugin{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withRepo != nil, + _q.withVersions != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*AgentPlugin).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &AgentPlugin{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withRepo; query != nil { + if err := _q.loadRepo(ctx, query, nodes, nil, + func(n *AgentPlugin, e *AgentPluginRepo) { n.Edges.Repo = e }); err != nil { + return nil, err + } + } + if query := _q.withVersions; query != nil { + if err := _q.loadVersions(ctx, query, nodes, + func(n *AgentPlugin) { n.Edges.Versions = []*AgentPluginVersion{} }, + func(n *AgentPlugin, e *AgentPluginVersion) { n.Edges.Versions = append(n.Edges.Versions, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *AgentPluginQuery) loadRepo(ctx context.Context, query *AgentPluginRepoQuery, nodes []*AgentPlugin, init func(*AgentPlugin), assign func(*AgentPlugin, *AgentPluginRepo)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*AgentPlugin) + for i := range nodes { + fk := nodes[i].RepoID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(agentpluginrepo.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "repo_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *AgentPluginQuery) loadVersions(ctx context.Context, query *AgentPluginVersionQuery, nodes []*AgentPlugin, init func(*AgentPlugin), assign func(*AgentPlugin, *AgentPluginVersion)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*AgentPlugin) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(agentpluginversion.FieldResourceID) + } + query.Where(predicate.AgentPluginVersion(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(agentplugin.VersionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ResourceID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "resource_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *AgentPluginQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *AgentPluginQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(agentplugin.Table, agentplugin.Columns, sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentplugin.FieldID) + for i := range fields { + if fields[i] != agentplugin.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withRepo != nil { + _spec.Node.AddColumnOnce(agentplugin.FieldRepoID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *AgentPluginQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(agentplugin.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = agentplugin.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *AgentPluginQuery) ForUpdate(opts ...sql.LockOption) *AgentPluginQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *AgentPluginQuery) ForShare(opts ...sql.LockOption) *AgentPluginQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *AgentPluginQuery) Modify(modifiers ...func(s *sql.Selector)) *AgentPluginSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// AgentPluginGroupBy is the group-by builder for AgentPlugin entities. +type AgentPluginGroupBy struct { + selector + build *AgentPluginQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *AgentPluginGroupBy) Aggregate(fns ...AggregateFunc) *AgentPluginGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *AgentPluginGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentPluginQuery, *AgentPluginGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *AgentPluginGroupBy) sqlScan(ctx context.Context, root *AgentPluginQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// AgentPluginSelect is the builder for selecting fields of AgentPlugin entities. +type AgentPluginSelect struct { + *AgentPluginQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *AgentPluginSelect) Aggregate(fns ...AggregateFunc) *AgentPluginSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *AgentPluginSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentPluginQuery, *AgentPluginSelect](ctx, _s.AgentPluginQuery, _s, _s.inters, v) +} + +func (_s *AgentPluginSelect) sqlScan(ctx context.Context, root *AgentPluginQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *AgentPluginSelect) Modify(modifiers ...func(s *sql.Selector)) *AgentPluginSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/backend/db/agentplugin_update.go b/backend/db/agentplugin_update.go new file mode 100644 index 00000000..ac395d1f --- /dev/null +++ b/backend/db/agentplugin_update.go @@ -0,0 +1,953 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentPluginUpdate is the builder for updating AgentPlugin entities. +type AgentPluginUpdate struct { + config + hooks []Hook + mutation *AgentPluginMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the AgentPluginUpdate builder. +func (_u *AgentPluginUpdate) Where(ps ...predicate.AgentPlugin) *AgentPluginUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetRepoID sets the "repo_id" field. +func (_u *AgentPluginUpdate) SetRepoID(v uuid.UUID) *AgentPluginUpdate { + _u.mutation.SetRepoID(v) + return _u +} + +// SetNillableRepoID sets the "repo_id" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableRepoID(v *uuid.UUID) *AgentPluginUpdate { + if v != nil { + _u.SetRepoID(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *AgentPluginUpdate) SetName(v string) *AgentPluginUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableName(v *string) *AgentPluginUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *AgentPluginUpdate) SetDescription(v string) *AgentPluginUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableDescription(v *string) *AgentPluginUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *AgentPluginUpdate) ClearDescription() *AgentPluginUpdate { + _u.mutation.ClearDescription() + return _u +} + +// SetScopeType sets the "scope_type" field. +func (_u *AgentPluginUpdate) SetScopeType(v agentplugin.ScopeType) *AgentPluginUpdate { + _u.mutation.SetScopeType(v) + return _u +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableScopeType(v *agentplugin.ScopeType) *AgentPluginUpdate { + if v != nil { + _u.SetScopeType(*v) + } + return _u +} + +// SetScopeID sets the "scope_id" field. +func (_u *AgentPluginUpdate) SetScopeID(v string) *AgentPluginUpdate { + _u.mutation.SetScopeID(v) + return _u +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableScopeID(v *string) *AgentPluginUpdate { + if v != nil { + _u.SetScopeID(*v) + } + return _u +} + +// SetCreatedBy sets the "created_by" field. +func (_u *AgentPluginUpdate) SetCreatedBy(v uuid.UUID) *AgentPluginUpdate { + _u.mutation.SetCreatedBy(v) + return _u +} + +// SetNillableCreatedBy sets the "created_by" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableCreatedBy(v *uuid.UUID) *AgentPluginUpdate { + if v != nil { + _u.SetCreatedBy(*v) + } + return _u +} + +// SetActiveVersionID sets the "active_version_id" field. +func (_u *AgentPluginUpdate) SetActiveVersionID(v uuid.UUID) *AgentPluginUpdate { + _u.mutation.SetActiveVersionID(v) + return _u +} + +// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableActiveVersionID(v *uuid.UUID) *AgentPluginUpdate { + if v != nil { + _u.SetActiveVersionID(*v) + } + return _u +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (_u *AgentPluginUpdate) ClearActiveVersionID() *AgentPluginUpdate { + _u.mutation.ClearActiveVersionID() + return _u +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (_u *AgentPluginUpdate) SetIsForceDelivery(v bool) *AgentPluginUpdate { + _u.mutation.SetIsForceDelivery(v) + return _u +} + +// SetNillableIsForceDelivery sets the "is_force_delivery" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableIsForceDelivery(v *bool) *AgentPluginUpdate { + if v != nil { + _u.SetIsForceDelivery(*v) + } + return _u +} + +// SetIsOrphan sets the "is_orphan" field. +func (_u *AgentPluginUpdate) SetIsOrphan(v bool) *AgentPluginUpdate { + _u.mutation.SetIsOrphan(v) + return _u +} + +// SetNillableIsOrphan sets the "is_orphan" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableIsOrphan(v *bool) *AgentPluginUpdate { + if v != nil { + _u.SetIsOrphan(*v) + } + return _u +} + +// SetIsDeleted sets the "is_deleted" field. +func (_u *AgentPluginUpdate) SetIsDeleted(v bool) *AgentPluginUpdate { + _u.mutation.SetIsDeleted(v) + return _u +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableIsDeleted(v *bool) *AgentPluginUpdate { + if v != nil { + _u.SetIsDeleted(*v) + } + return _u +} + +// SetEnabled sets the "enabled" field. +func (_u *AgentPluginUpdate) SetEnabled(v bool) *AgentPluginUpdate { + _u.mutation.SetEnabled(v) + return _u +} + +// SetNillableEnabled sets the "enabled" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableEnabled(v *bool) *AgentPluginUpdate { + if v != nil { + _u.SetEnabled(*v) + } + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentPluginUpdate) SetCreatedAt(v time.Time) *AgentPluginUpdate { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentPluginUpdate) SetNillableCreatedAt(v *time.Time) *AgentPluginUpdate { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentPluginUpdate) SetUpdatedAt(v time.Time) *AgentPluginUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetRepo sets the "repo" edge to the AgentPluginRepo entity. +func (_u *AgentPluginUpdate) SetRepo(v *AgentPluginRepo) *AgentPluginUpdate { + return _u.SetRepoID(v.ID) +} + +// AddVersionIDs adds the "versions" edge to the AgentPluginVersion entity by IDs. +func (_u *AgentPluginUpdate) AddVersionIDs(ids ...uuid.UUID) *AgentPluginUpdate { + _u.mutation.AddVersionIDs(ids...) + return _u +} + +// AddVersions adds the "versions" edges to the AgentPluginVersion entity. +func (_u *AgentPluginUpdate) AddVersions(v ...*AgentPluginVersion) *AgentPluginUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddVersionIDs(ids...) +} + +// Mutation returns the AgentPluginMutation object of the builder. +func (_u *AgentPluginUpdate) Mutation() *AgentPluginMutation { + return _u.mutation +} + +// ClearRepo clears the "repo" edge to the AgentPluginRepo entity. +func (_u *AgentPluginUpdate) ClearRepo() *AgentPluginUpdate { + _u.mutation.ClearRepo() + return _u +} + +// ClearVersions clears all "versions" edges to the AgentPluginVersion entity. +func (_u *AgentPluginUpdate) ClearVersions() *AgentPluginUpdate { + _u.mutation.ClearVersions() + return _u +} + +// RemoveVersionIDs removes the "versions" edge to AgentPluginVersion entities by IDs. +func (_u *AgentPluginUpdate) RemoveVersionIDs(ids ...uuid.UUID) *AgentPluginUpdate { + _u.mutation.RemoveVersionIDs(ids...) + return _u +} + +// RemoveVersions removes "versions" edges to AgentPluginVersion entities. +func (_u *AgentPluginUpdate) RemoveVersions(v ...*AgentPluginVersion) *AgentPluginUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveVersionIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AgentPluginUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentPluginUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AgentPluginUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentPluginUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentPluginUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentplugin.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentPluginUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := agentplugin.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentPlugin.name": %w`, err)} + } + } + if v, ok := _u.mutation.ScopeType(); ok { + if err := agentplugin.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentPlugin.scope_type": %w`, err)} + } + } + if _u.mutation.RepoCleared() && len(_u.mutation.RepoIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentPlugin.repo"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentPluginUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentPluginUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentPluginUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentplugin.Table, agentplugin.Columns, sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(agentplugin.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(agentplugin.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(agentplugin.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.ScopeType(); ok { + _spec.SetField(agentplugin.FieldScopeType, field.TypeEnum, value) + } + if value, ok := _u.mutation.ScopeID(); ok { + _spec.SetField(agentplugin.FieldScopeID, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedBy(); ok { + _spec.SetField(agentplugin.FieldCreatedBy, field.TypeUUID, value) + } + if value, ok := _u.mutation.ActiveVersionID(); ok { + _spec.SetField(agentplugin.FieldActiveVersionID, field.TypeUUID, value) + } + if _u.mutation.ActiveVersionIDCleared() { + _spec.ClearField(agentplugin.FieldActiveVersionID, field.TypeUUID) + } + if value, ok := _u.mutation.IsForceDelivery(); ok { + _spec.SetField(agentplugin.FieldIsForceDelivery, field.TypeBool, value) + } + if value, ok := _u.mutation.IsOrphan(); ok { + _spec.SetField(agentplugin.FieldIsOrphan, field.TypeBool, value) + } + if value, ok := _u.mutation.IsDeleted(); ok { + _spec.SetField(agentplugin.FieldIsDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.Enabled(); ok { + _spec.SetField(agentplugin.FieldEnabled, field.TypeBool, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentplugin.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentplugin.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.RepoCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentplugin.RepoTable, + Columns: []string{agentplugin.RepoColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginrepo.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RepoIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentplugin.RepoTable, + Columns: []string{agentplugin.RepoColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginrepo.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentplugin.VersionsTable, + Columns: []string{agentplugin.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedVersionsIDs(); len(nodes) > 0 && !_u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentplugin.VersionsTable, + Columns: []string{agentplugin.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentplugin.VersionsTable, + Columns: []string{agentplugin.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentplugin.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AgentPluginUpdateOne is the builder for updating a single AgentPlugin entity. +type AgentPluginUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AgentPluginMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetRepoID sets the "repo_id" field. +func (_u *AgentPluginUpdateOne) SetRepoID(v uuid.UUID) *AgentPluginUpdateOne { + _u.mutation.SetRepoID(v) + return _u +} + +// SetNillableRepoID sets the "repo_id" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableRepoID(v *uuid.UUID) *AgentPluginUpdateOne { + if v != nil { + _u.SetRepoID(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *AgentPluginUpdateOne) SetName(v string) *AgentPluginUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableName(v *string) *AgentPluginUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *AgentPluginUpdateOne) SetDescription(v string) *AgentPluginUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableDescription(v *string) *AgentPluginUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *AgentPluginUpdateOne) ClearDescription() *AgentPluginUpdateOne { + _u.mutation.ClearDescription() + return _u +} + +// SetScopeType sets the "scope_type" field. +func (_u *AgentPluginUpdateOne) SetScopeType(v agentplugin.ScopeType) *AgentPluginUpdateOne { + _u.mutation.SetScopeType(v) + return _u +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableScopeType(v *agentplugin.ScopeType) *AgentPluginUpdateOne { + if v != nil { + _u.SetScopeType(*v) + } + return _u +} + +// SetScopeID sets the "scope_id" field. +func (_u *AgentPluginUpdateOne) SetScopeID(v string) *AgentPluginUpdateOne { + _u.mutation.SetScopeID(v) + return _u +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableScopeID(v *string) *AgentPluginUpdateOne { + if v != nil { + _u.SetScopeID(*v) + } + return _u +} + +// SetCreatedBy sets the "created_by" field. +func (_u *AgentPluginUpdateOne) SetCreatedBy(v uuid.UUID) *AgentPluginUpdateOne { + _u.mutation.SetCreatedBy(v) + return _u +} + +// SetNillableCreatedBy sets the "created_by" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableCreatedBy(v *uuid.UUID) *AgentPluginUpdateOne { + if v != nil { + _u.SetCreatedBy(*v) + } + return _u +} + +// SetActiveVersionID sets the "active_version_id" field. +func (_u *AgentPluginUpdateOne) SetActiveVersionID(v uuid.UUID) *AgentPluginUpdateOne { + _u.mutation.SetActiveVersionID(v) + return _u +} + +// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableActiveVersionID(v *uuid.UUID) *AgentPluginUpdateOne { + if v != nil { + _u.SetActiveVersionID(*v) + } + return _u +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (_u *AgentPluginUpdateOne) ClearActiveVersionID() *AgentPluginUpdateOne { + _u.mutation.ClearActiveVersionID() + return _u +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (_u *AgentPluginUpdateOne) SetIsForceDelivery(v bool) *AgentPluginUpdateOne { + _u.mutation.SetIsForceDelivery(v) + return _u +} + +// SetNillableIsForceDelivery sets the "is_force_delivery" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableIsForceDelivery(v *bool) *AgentPluginUpdateOne { + if v != nil { + _u.SetIsForceDelivery(*v) + } + return _u +} + +// SetIsOrphan sets the "is_orphan" field. +func (_u *AgentPluginUpdateOne) SetIsOrphan(v bool) *AgentPluginUpdateOne { + _u.mutation.SetIsOrphan(v) + return _u +} + +// SetNillableIsOrphan sets the "is_orphan" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableIsOrphan(v *bool) *AgentPluginUpdateOne { + if v != nil { + _u.SetIsOrphan(*v) + } + return _u +} + +// SetIsDeleted sets the "is_deleted" field. +func (_u *AgentPluginUpdateOne) SetIsDeleted(v bool) *AgentPluginUpdateOne { + _u.mutation.SetIsDeleted(v) + return _u +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableIsDeleted(v *bool) *AgentPluginUpdateOne { + if v != nil { + _u.SetIsDeleted(*v) + } + return _u +} + +// SetEnabled sets the "enabled" field. +func (_u *AgentPluginUpdateOne) SetEnabled(v bool) *AgentPluginUpdateOne { + _u.mutation.SetEnabled(v) + return _u +} + +// SetNillableEnabled sets the "enabled" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableEnabled(v *bool) *AgentPluginUpdateOne { + if v != nil { + _u.SetEnabled(*v) + } + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentPluginUpdateOne) SetCreatedAt(v time.Time) *AgentPluginUpdateOne { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentPluginUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentPluginUpdateOne { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentPluginUpdateOne) SetUpdatedAt(v time.Time) *AgentPluginUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetRepo sets the "repo" edge to the AgentPluginRepo entity. +func (_u *AgentPluginUpdateOne) SetRepo(v *AgentPluginRepo) *AgentPluginUpdateOne { + return _u.SetRepoID(v.ID) +} + +// AddVersionIDs adds the "versions" edge to the AgentPluginVersion entity by IDs. +func (_u *AgentPluginUpdateOne) AddVersionIDs(ids ...uuid.UUID) *AgentPluginUpdateOne { + _u.mutation.AddVersionIDs(ids...) + return _u +} + +// AddVersions adds the "versions" edges to the AgentPluginVersion entity. +func (_u *AgentPluginUpdateOne) AddVersions(v ...*AgentPluginVersion) *AgentPluginUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddVersionIDs(ids...) +} + +// Mutation returns the AgentPluginMutation object of the builder. +func (_u *AgentPluginUpdateOne) Mutation() *AgentPluginMutation { + return _u.mutation +} + +// ClearRepo clears the "repo" edge to the AgentPluginRepo entity. +func (_u *AgentPluginUpdateOne) ClearRepo() *AgentPluginUpdateOne { + _u.mutation.ClearRepo() + return _u +} + +// ClearVersions clears all "versions" edges to the AgentPluginVersion entity. +func (_u *AgentPluginUpdateOne) ClearVersions() *AgentPluginUpdateOne { + _u.mutation.ClearVersions() + return _u +} + +// RemoveVersionIDs removes the "versions" edge to AgentPluginVersion entities by IDs. +func (_u *AgentPluginUpdateOne) RemoveVersionIDs(ids ...uuid.UUID) *AgentPluginUpdateOne { + _u.mutation.RemoveVersionIDs(ids...) + return _u +} + +// RemoveVersions removes "versions" edges to AgentPluginVersion entities. +func (_u *AgentPluginUpdateOne) RemoveVersions(v ...*AgentPluginVersion) *AgentPluginUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveVersionIDs(ids...) +} + +// Where appends a list predicates to the AgentPluginUpdate builder. +func (_u *AgentPluginUpdateOne) Where(ps ...predicate.AgentPlugin) *AgentPluginUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *AgentPluginUpdateOne) Select(field string, fields ...string) *AgentPluginUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated AgentPlugin entity. +func (_u *AgentPluginUpdateOne) Save(ctx context.Context) (*AgentPlugin, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentPluginUpdateOne) SaveX(ctx context.Context) *AgentPlugin { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AgentPluginUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentPluginUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentPluginUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentplugin.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentPluginUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := agentplugin.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentPlugin.name": %w`, err)} + } + } + if v, ok := _u.mutation.ScopeType(); ok { + if err := agentplugin.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentPlugin.scope_type": %w`, err)} + } + } + if _u.mutation.RepoCleared() && len(_u.mutation.RepoIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentPlugin.repo"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentPluginUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentPluginUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentPluginUpdateOne) sqlSave(ctx context.Context) (_node *AgentPlugin, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentplugin.Table, agentplugin.Columns, sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentPlugin.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentplugin.FieldID) + for _, f := range fields { + if !agentplugin.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != agentplugin.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(agentplugin.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(agentplugin.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(agentplugin.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.ScopeType(); ok { + _spec.SetField(agentplugin.FieldScopeType, field.TypeEnum, value) + } + if value, ok := _u.mutation.ScopeID(); ok { + _spec.SetField(agentplugin.FieldScopeID, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedBy(); ok { + _spec.SetField(agentplugin.FieldCreatedBy, field.TypeUUID, value) + } + if value, ok := _u.mutation.ActiveVersionID(); ok { + _spec.SetField(agentplugin.FieldActiveVersionID, field.TypeUUID, value) + } + if _u.mutation.ActiveVersionIDCleared() { + _spec.ClearField(agentplugin.FieldActiveVersionID, field.TypeUUID) + } + if value, ok := _u.mutation.IsForceDelivery(); ok { + _spec.SetField(agentplugin.FieldIsForceDelivery, field.TypeBool, value) + } + if value, ok := _u.mutation.IsOrphan(); ok { + _spec.SetField(agentplugin.FieldIsOrphan, field.TypeBool, value) + } + if value, ok := _u.mutation.IsDeleted(); ok { + _spec.SetField(agentplugin.FieldIsDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.Enabled(); ok { + _spec.SetField(agentplugin.FieldEnabled, field.TypeBool, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentplugin.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentplugin.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.RepoCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentplugin.RepoTable, + Columns: []string{agentplugin.RepoColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginrepo.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RepoIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentplugin.RepoTable, + Columns: []string{agentplugin.RepoColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginrepo.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentplugin.VersionsTable, + Columns: []string{agentplugin.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedVersionsIDs(); len(nodes) > 0 && !_u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentplugin.VersionsTable, + Columns: []string{agentplugin.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentplugin.VersionsTable, + Columns: []string{agentplugin.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &AgentPlugin{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentplugin.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/db/agentpluginrepo.go b/backend/db/agentpluginrepo.go new file mode 100644 index 00000000..b347aa5d --- /dev/null +++ b/backend/db/agentpluginrepo.go @@ -0,0 +1,352 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentPluginRepo is the model entity for the AgentPluginRepo schema. +type AgentPluginRepo struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // ScopeType holds the value of the "scope_type" field. + ScopeType agentpluginrepo.ScopeType `json:"scope_type,omitempty"` + // ScopeID holds the value of the "scope_id" field. + ScopeID string `json:"scope_id,omitempty"` + // CreatedBy holds the value of the "created_by" field. + CreatedBy uuid.UUID `json:"created_by,omitempty"` + // SourceType holds the value of the "source_type" field. + SourceType agentpluginrepo.SourceType `json:"source_type,omitempty"` + // GithubURL holds the value of the "github_url" field. + GithubURL *string `json:"github_url,omitempty"` + // RefType holds the value of the "ref_type" field. + RefType *agentpluginrepo.RefType `json:"ref_type,omitempty"` + // RefValue holds the value of the "ref_value" field. + RefValue *string `json:"ref_value,omitempty"` + // LastUploadFilename holds the value of the "last_upload_filename" field. + LastUploadFilename *string `json:"last_upload_filename,omitempty"` + // LastUploadAt holds the value of the "last_upload_at" field. + LastUploadAt *time.Time `json:"last_upload_at,omitempty"` + // PluginDiscoveryAutoPackageJSON holds the value of the "plugin_discovery_auto_package_json" field. + PluginDiscoveryAutoPackageJSON bool `json:"plugin_discovery_auto_package_json,omitempty"` + // PluginManualEntries holds the value of the "plugin_manual_entries" field. + PluginManualEntries types.PluginManualEntries `json:"plugin_manual_entries,omitempty"` + // NpmPackageName holds the value of the "npm_package_name" field. + NpmPackageName *string `json:"npm_package_name,omitempty"` + // NpmVersionSpec holds the value of the "npm_version_spec" field. + NpmVersionSpec *string `json:"npm_version_spec,omitempty"` + // NpmRegistryURL holds the value of the "npm_registry_url" field. + NpmRegistryURL *string `json:"npm_registry_url,omitempty"` + // IsDeleted holds the value of the "is_deleted" field. + IsDeleted bool `json:"is_deleted,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the AgentPluginRepoQuery when eager-loading is set. + Edges AgentPluginRepoEdges `json:"edges"` + selectValues sql.SelectValues +} + +// AgentPluginRepoEdges holds the relations/edges for other nodes in the graph. +type AgentPluginRepoEdges struct { + // Plugins holds the value of the plugins edge. + Plugins []*AgentPlugin `json:"plugins,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// PluginsOrErr returns the Plugins value or an error if the edge +// was not loaded in eager-loading. +func (e AgentPluginRepoEdges) PluginsOrErr() ([]*AgentPlugin, error) { + if e.loadedTypes[0] { + return e.Plugins, nil + } + return nil, &NotLoadedError{edge: "plugins"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*AgentPluginRepo) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case agentpluginrepo.FieldPluginManualEntries: + values[i] = new([]byte) + case agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON, agentpluginrepo.FieldIsDeleted: + values[i] = new(sql.NullBool) + case agentpluginrepo.FieldName, agentpluginrepo.FieldScopeType, agentpluginrepo.FieldScopeID, agentpluginrepo.FieldSourceType, agentpluginrepo.FieldGithubURL, agentpluginrepo.FieldRefType, agentpluginrepo.FieldRefValue, agentpluginrepo.FieldLastUploadFilename, agentpluginrepo.FieldNpmPackageName, agentpluginrepo.FieldNpmVersionSpec, agentpluginrepo.FieldNpmRegistryURL: + values[i] = new(sql.NullString) + case agentpluginrepo.FieldLastUploadAt, agentpluginrepo.FieldCreatedAt, agentpluginrepo.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case agentpluginrepo.FieldID, agentpluginrepo.FieldCreatedBy: + values[i] = new(uuid.UUID) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the AgentPluginRepo fields. +func (_m *AgentPluginRepo) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case agentpluginrepo.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case agentpluginrepo.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case agentpluginrepo.FieldScopeType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope_type", values[i]) + } else if value.Valid { + _m.ScopeType = agentpluginrepo.ScopeType(value.String) + } + case agentpluginrepo.FieldScopeID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope_id", values[i]) + } else if value.Valid { + _m.ScopeID = value.String + } + case agentpluginrepo.FieldCreatedBy: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field created_by", values[i]) + } else if value != nil { + _m.CreatedBy = *value + } + case agentpluginrepo.FieldSourceType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field source_type", values[i]) + } else if value.Valid { + _m.SourceType = agentpluginrepo.SourceType(value.String) + } + case agentpluginrepo.FieldGithubURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field github_url", values[i]) + } else if value.Valid { + _m.GithubURL = new(string) + *_m.GithubURL = value.String + } + case agentpluginrepo.FieldRefType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field ref_type", values[i]) + } else if value.Valid { + _m.RefType = new(agentpluginrepo.RefType) + *_m.RefType = agentpluginrepo.RefType(value.String) + } + case agentpluginrepo.FieldRefValue: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field ref_value", values[i]) + } else if value.Valid { + _m.RefValue = new(string) + *_m.RefValue = value.String + } + case agentpluginrepo.FieldLastUploadFilename: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field last_upload_filename", values[i]) + } else if value.Valid { + _m.LastUploadFilename = new(string) + *_m.LastUploadFilename = value.String + } + case agentpluginrepo.FieldLastUploadAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_upload_at", values[i]) + } else if value.Valid { + _m.LastUploadAt = new(time.Time) + *_m.LastUploadAt = value.Time + } + case agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field plugin_discovery_auto_package_json", values[i]) + } else if value.Valid { + _m.PluginDiscoveryAutoPackageJSON = value.Bool + } + case agentpluginrepo.FieldPluginManualEntries: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field plugin_manual_entries", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.PluginManualEntries); err != nil { + return fmt.Errorf("unmarshal field plugin_manual_entries: %w", err) + } + } + case agentpluginrepo.FieldNpmPackageName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field npm_package_name", values[i]) + } else if value.Valid { + _m.NpmPackageName = new(string) + *_m.NpmPackageName = value.String + } + case agentpluginrepo.FieldNpmVersionSpec: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field npm_version_spec", values[i]) + } else if value.Valid { + _m.NpmVersionSpec = new(string) + *_m.NpmVersionSpec = value.String + } + case agentpluginrepo.FieldNpmRegistryURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field npm_registry_url", values[i]) + } else if value.Valid { + _m.NpmRegistryURL = new(string) + *_m.NpmRegistryURL = value.String + } + case agentpluginrepo.FieldIsDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_deleted", values[i]) + } else if value.Valid { + _m.IsDeleted = value.Bool + } + case agentpluginrepo.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case agentpluginrepo.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the AgentPluginRepo. +// This includes values selected through modifiers, order, etc. +func (_m *AgentPluginRepo) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryPlugins queries the "plugins" edge of the AgentPluginRepo entity. +func (_m *AgentPluginRepo) QueryPlugins() *AgentPluginQuery { + return NewAgentPluginRepoClient(_m.config).QueryPlugins(_m) +} + +// Update returns a builder for updating this AgentPluginRepo. +// Note that you need to call AgentPluginRepo.Unwrap() before calling this method if this AgentPluginRepo +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *AgentPluginRepo) Update() *AgentPluginRepoUpdateOne { + return NewAgentPluginRepoClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the AgentPluginRepo entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *AgentPluginRepo) Unwrap() *AgentPluginRepo { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("db: AgentPluginRepo is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *AgentPluginRepo) String() string { + var builder strings.Builder + builder.WriteString("AgentPluginRepo(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("scope_type=") + builder.WriteString(fmt.Sprintf("%v", _m.ScopeType)) + builder.WriteString(", ") + builder.WriteString("scope_id=") + builder.WriteString(_m.ScopeID) + builder.WriteString(", ") + builder.WriteString("created_by=") + builder.WriteString(fmt.Sprintf("%v", _m.CreatedBy)) + builder.WriteString(", ") + builder.WriteString("source_type=") + builder.WriteString(fmt.Sprintf("%v", _m.SourceType)) + builder.WriteString(", ") + if v := _m.GithubURL; v != nil { + builder.WriteString("github_url=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.RefType; v != nil { + builder.WriteString("ref_type=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + if v := _m.RefValue; v != nil { + builder.WriteString("ref_value=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.LastUploadFilename; v != nil { + builder.WriteString("last_upload_filename=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.LastUploadAt; v != nil { + builder.WriteString("last_upload_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("plugin_discovery_auto_package_json=") + builder.WriteString(fmt.Sprintf("%v", _m.PluginDiscoveryAutoPackageJSON)) + builder.WriteString(", ") + builder.WriteString("plugin_manual_entries=") + builder.WriteString(fmt.Sprintf("%v", _m.PluginManualEntries)) + builder.WriteString(", ") + if v := _m.NpmPackageName; v != nil { + builder.WriteString("npm_package_name=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.NpmVersionSpec; v != nil { + builder.WriteString("npm_version_spec=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.NpmRegistryURL; v != nil { + builder.WriteString("npm_registry_url=") + builder.WriteString(*v) + } + builder.WriteString(", ") + builder.WriteString("is_deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.IsDeleted)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// AgentPluginRepos is a parsable slice of AgentPluginRepo. +type AgentPluginRepos []*AgentPluginRepo diff --git a/backend/db/agentpluginrepo/agentpluginrepo.go b/backend/db/agentpluginrepo/agentpluginrepo.go new file mode 100644 index 00000000..08b3f9a5 --- /dev/null +++ b/backend/db/agentpluginrepo/agentpluginrepo.go @@ -0,0 +1,308 @@ +// Code generated by ent, DO NOT EDIT. + +package agentpluginrepo + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the agentpluginrepo type in the database. + Label = "agent_plugin_repo" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldScopeType holds the string denoting the scope_type field in the database. + FieldScopeType = "scope_type" + // FieldScopeID holds the string denoting the scope_id field in the database. + FieldScopeID = "scope_id" + // FieldCreatedBy holds the string denoting the created_by field in the database. + FieldCreatedBy = "created_by" + // FieldSourceType holds the string denoting the source_type field in the database. + FieldSourceType = "source_type" + // FieldGithubURL holds the string denoting the github_url field in the database. + FieldGithubURL = "github_url" + // FieldRefType holds the string denoting the ref_type field in the database. + FieldRefType = "ref_type" + // FieldRefValue holds the string denoting the ref_value field in the database. + FieldRefValue = "ref_value" + // FieldLastUploadFilename holds the string denoting the last_upload_filename field in the database. + FieldLastUploadFilename = "last_upload_filename" + // FieldLastUploadAt holds the string denoting the last_upload_at field in the database. + FieldLastUploadAt = "last_upload_at" + // FieldPluginDiscoveryAutoPackageJSON holds the string denoting the plugin_discovery_auto_package_json field in the database. + FieldPluginDiscoveryAutoPackageJSON = "plugin_discovery_auto_package_json" + // FieldPluginManualEntries holds the string denoting the plugin_manual_entries field in the database. + FieldPluginManualEntries = "plugin_manual_entries" + // FieldNpmPackageName holds the string denoting the npm_package_name field in the database. + FieldNpmPackageName = "npm_package_name" + // FieldNpmVersionSpec holds the string denoting the npm_version_spec field in the database. + FieldNpmVersionSpec = "npm_version_spec" + // FieldNpmRegistryURL holds the string denoting the npm_registry_url field in the database. + FieldNpmRegistryURL = "npm_registry_url" + // FieldIsDeleted holds the string denoting the is_deleted field in the database. + FieldIsDeleted = "is_deleted" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // EdgePlugins holds the string denoting the plugins edge name in mutations. + EdgePlugins = "plugins" + // Table holds the table name of the agentpluginrepo in the database. + Table = "agent_plugin_repos" + // PluginsTable is the table that holds the plugins relation/edge. + PluginsTable = "agent_plugins" + // PluginsInverseTable is the table name for the AgentPlugin entity. + // It exists in this package in order to avoid circular dependency with the "agentplugin" package. + PluginsInverseTable = "agent_plugins" + // PluginsColumn is the table column denoting the plugins relation/edge. + PluginsColumn = "repo_id" +) + +// Columns holds all SQL columns for agentpluginrepo fields. +var Columns = []string{ + FieldID, + FieldName, + FieldScopeType, + FieldScopeID, + FieldCreatedBy, + FieldSourceType, + FieldGithubURL, + FieldRefType, + FieldRefValue, + FieldLastUploadFilename, + FieldLastUploadAt, + FieldPluginDiscoveryAutoPackageJSON, + FieldPluginManualEntries, + FieldNpmPackageName, + FieldNpmVersionSpec, + FieldNpmRegistryURL, + FieldIsDeleted, + FieldCreatedAt, + FieldUpdatedAt, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultScopeID holds the default value on creation for the "scope_id" field. + DefaultScopeID string + // DefaultPluginDiscoveryAutoPackageJSON holds the default value on creation for the "plugin_discovery_auto_package_json" field. + DefaultPluginDiscoveryAutoPackageJSON bool + // DefaultIsDeleted holds the default value on creation for the "is_deleted" field. + DefaultIsDeleted bool + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// ScopeType defines the type for the "scope_type" enum field. +type ScopeType string + +// ScopeTypeGlobal is the default value of the ScopeType enum. +const DefaultScopeType = ScopeTypeGlobal + +// ScopeType values. +const ( + ScopeTypeGlobal ScopeType = "global" + ScopeTypeTeam ScopeType = "team" + ScopeTypeUser ScopeType = "user" +) + +func (st ScopeType) String() string { + return string(st) +} + +// ScopeTypeValidator is a validator for the "scope_type" field enum values. It is called by the builders before save. +func ScopeTypeValidator(st ScopeType) error { + switch st { + case ScopeTypeGlobal, ScopeTypeTeam, ScopeTypeUser: + return nil + default: + return fmt.Errorf("agentpluginrepo: invalid enum value for scope_type field: %q", st) + } +} + +// SourceType defines the type for the "source_type" enum field. +type SourceType string + +// SourceType values. +const ( + SourceTypeGithub SourceType = "github" + SourceTypeUpload SourceType = "upload" + SourceTypeNpm SourceType = "npm" + SourceTypeBare SourceType = "bare" +) + +func (st SourceType) String() string { + return string(st) +} + +// SourceTypeValidator is a validator for the "source_type" field enum values. It is called by the builders before save. +func SourceTypeValidator(st SourceType) error { + switch st { + case SourceTypeGithub, SourceTypeUpload, SourceTypeNpm, SourceTypeBare: + return nil + default: + return fmt.Errorf("agentpluginrepo: invalid enum value for source_type field: %q", st) + } +} + +// RefType defines the type for the "ref_type" enum field. +type RefType string + +// RefType values. +const ( + RefTypeBranch RefType = "branch" + RefTypeTag RefType = "tag" + RefTypeCommit RefType = "commit" +) + +func (rt RefType) String() string { + return string(rt) +} + +// RefTypeValidator is a validator for the "ref_type" field enum values. It is called by the builders before save. +func RefTypeValidator(rt RefType) error { + switch rt { + case RefTypeBranch, RefTypeTag, RefTypeCommit: + return nil + default: + return fmt.Errorf("agentpluginrepo: invalid enum value for ref_type field: %q", rt) + } +} + +// OrderOption defines the ordering options for the AgentPluginRepo queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByScopeType orders the results by the scope_type field. +func ByScopeType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScopeType, opts...).ToFunc() +} + +// ByScopeID orders the results by the scope_id field. +func ByScopeID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScopeID, opts...).ToFunc() +} + +// ByCreatedBy orders the results by the created_by field. +func ByCreatedBy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedBy, opts...).ToFunc() +} + +// BySourceType orders the results by the source_type field. +func BySourceType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSourceType, opts...).ToFunc() +} + +// ByGithubURL orders the results by the github_url field. +func ByGithubURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGithubURL, opts...).ToFunc() +} + +// ByRefType orders the results by the ref_type field. +func ByRefType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefType, opts...).ToFunc() +} + +// ByRefValue orders the results by the ref_value field. +func ByRefValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefValue, opts...).ToFunc() +} + +// ByLastUploadFilename orders the results by the last_upload_filename field. +func ByLastUploadFilename(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastUploadFilename, opts...).ToFunc() +} + +// ByLastUploadAt orders the results by the last_upload_at field. +func ByLastUploadAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastUploadAt, opts...).ToFunc() +} + +// ByPluginDiscoveryAutoPackageJSON orders the results by the plugin_discovery_auto_package_json field. +func ByPluginDiscoveryAutoPackageJSON(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPluginDiscoveryAutoPackageJSON, opts...).ToFunc() +} + +// ByNpmPackageName orders the results by the npm_package_name field. +func ByNpmPackageName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNpmPackageName, opts...).ToFunc() +} + +// ByNpmVersionSpec orders the results by the npm_version_spec field. +func ByNpmVersionSpec(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNpmVersionSpec, opts...).ToFunc() +} + +// ByNpmRegistryURL orders the results by the npm_registry_url field. +func ByNpmRegistryURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNpmRegistryURL, opts...).ToFunc() +} + +// ByIsDeleted orders the results by the is_deleted field. +func ByIsDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsDeleted, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByPluginsCount orders the results by plugins count. +func ByPluginsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPluginsStep(), opts...) + } +} + +// ByPlugins orders the results by plugins terms. +func ByPlugins(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPluginsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newPluginsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PluginsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, PluginsTable, PluginsColumn), + ) +} diff --git a/backend/db/agentpluginrepo/where.go b/backend/db/agentpluginrepo/where.go new file mode 100644 index 00000000..0e96ea76 --- /dev/null +++ b/backend/db/agentpluginrepo/where.go @@ -0,0 +1,1015 @@ +// Code generated by ent, DO NOT EDIT. + +package agentpluginrepo + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldID, id)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldName, v)) +} + +// ScopeID applies equality check predicate on the "scope_id" field. It's identical to ScopeIDEQ. +func ScopeID(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldScopeID, v)) +} + +// CreatedBy applies equality check predicate on the "created_by" field. It's identical to CreatedByEQ. +func CreatedBy(v uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldCreatedBy, v)) +} + +// GithubURL applies equality check predicate on the "github_url" field. It's identical to GithubURLEQ. +func GithubURL(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldGithubURL, v)) +} + +// RefValue applies equality check predicate on the "ref_value" field. It's identical to RefValueEQ. +func RefValue(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldRefValue, v)) +} + +// LastUploadFilename applies equality check predicate on the "last_upload_filename" field. It's identical to LastUploadFilenameEQ. +func LastUploadFilename(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldLastUploadFilename, v)) +} + +// LastUploadAt applies equality check predicate on the "last_upload_at" field. It's identical to LastUploadAtEQ. +func LastUploadAt(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldLastUploadAt, v)) +} + +// PluginDiscoveryAutoPackageJSON applies equality check predicate on the "plugin_discovery_auto_package_json" field. It's identical to PluginDiscoveryAutoPackageJSONEQ. +func PluginDiscoveryAutoPackageJSON(v bool) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldPluginDiscoveryAutoPackageJSON, v)) +} + +// NpmPackageName applies equality check predicate on the "npm_package_name" field. It's identical to NpmPackageNameEQ. +func NpmPackageName(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldNpmPackageName, v)) +} + +// NpmVersionSpec applies equality check predicate on the "npm_version_spec" field. It's identical to NpmVersionSpecEQ. +func NpmVersionSpec(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldNpmVersionSpec, v)) +} + +// NpmRegistryURL applies equality check predicate on the "npm_registry_url" field. It's identical to NpmRegistryURLEQ. +func NpmRegistryURL(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldNpmRegistryURL, v)) +} + +// IsDeleted applies equality check predicate on the "is_deleted" field. It's identical to IsDeletedEQ. +func IsDeleted(v bool) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldIsDeleted, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContainsFold(FieldName, v)) +} + +// ScopeTypeEQ applies the EQ predicate on the "scope_type" field. +func ScopeTypeEQ(v ScopeType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldScopeType, v)) +} + +// ScopeTypeNEQ applies the NEQ predicate on the "scope_type" field. +func ScopeTypeNEQ(v ScopeType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldScopeType, v)) +} + +// ScopeTypeIn applies the In predicate on the "scope_type" field. +func ScopeTypeIn(vs ...ScopeType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldScopeType, vs...)) +} + +// ScopeTypeNotIn applies the NotIn predicate on the "scope_type" field. +func ScopeTypeNotIn(vs ...ScopeType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldScopeType, vs...)) +} + +// ScopeIDEQ applies the EQ predicate on the "scope_id" field. +func ScopeIDEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldScopeID, v)) +} + +// ScopeIDNEQ applies the NEQ predicate on the "scope_id" field. +func ScopeIDNEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldScopeID, v)) +} + +// ScopeIDIn applies the In predicate on the "scope_id" field. +func ScopeIDIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldScopeID, vs...)) +} + +// ScopeIDNotIn applies the NotIn predicate on the "scope_id" field. +func ScopeIDNotIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldScopeID, vs...)) +} + +// ScopeIDGT applies the GT predicate on the "scope_id" field. +func ScopeIDGT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldScopeID, v)) +} + +// ScopeIDGTE applies the GTE predicate on the "scope_id" field. +func ScopeIDGTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldScopeID, v)) +} + +// ScopeIDLT applies the LT predicate on the "scope_id" field. +func ScopeIDLT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldScopeID, v)) +} + +// ScopeIDLTE applies the LTE predicate on the "scope_id" field. +func ScopeIDLTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldScopeID, v)) +} + +// ScopeIDContains applies the Contains predicate on the "scope_id" field. +func ScopeIDContains(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContains(FieldScopeID, v)) +} + +// ScopeIDHasPrefix applies the HasPrefix predicate on the "scope_id" field. +func ScopeIDHasPrefix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasPrefix(FieldScopeID, v)) +} + +// ScopeIDHasSuffix applies the HasSuffix predicate on the "scope_id" field. +func ScopeIDHasSuffix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasSuffix(FieldScopeID, v)) +} + +// ScopeIDEqualFold applies the EqualFold predicate on the "scope_id" field. +func ScopeIDEqualFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEqualFold(FieldScopeID, v)) +} + +// ScopeIDContainsFold applies the ContainsFold predicate on the "scope_id" field. +func ScopeIDContainsFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContainsFold(FieldScopeID, v)) +} + +// CreatedByEQ applies the EQ predicate on the "created_by" field. +func CreatedByEQ(v uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldCreatedBy, v)) +} + +// CreatedByNEQ applies the NEQ predicate on the "created_by" field. +func CreatedByNEQ(v uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldCreatedBy, v)) +} + +// CreatedByIn applies the In predicate on the "created_by" field. +func CreatedByIn(vs ...uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldCreatedBy, vs...)) +} + +// CreatedByNotIn applies the NotIn predicate on the "created_by" field. +func CreatedByNotIn(vs ...uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldCreatedBy, vs...)) +} + +// CreatedByGT applies the GT predicate on the "created_by" field. +func CreatedByGT(v uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldCreatedBy, v)) +} + +// CreatedByGTE applies the GTE predicate on the "created_by" field. +func CreatedByGTE(v uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldCreatedBy, v)) +} + +// CreatedByLT applies the LT predicate on the "created_by" field. +func CreatedByLT(v uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldCreatedBy, v)) +} + +// CreatedByLTE applies the LTE predicate on the "created_by" field. +func CreatedByLTE(v uuid.UUID) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldCreatedBy, v)) +} + +// SourceTypeEQ applies the EQ predicate on the "source_type" field. +func SourceTypeEQ(v SourceType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldSourceType, v)) +} + +// SourceTypeNEQ applies the NEQ predicate on the "source_type" field. +func SourceTypeNEQ(v SourceType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldSourceType, v)) +} + +// SourceTypeIn applies the In predicate on the "source_type" field. +func SourceTypeIn(vs ...SourceType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldSourceType, vs...)) +} + +// SourceTypeNotIn applies the NotIn predicate on the "source_type" field. +func SourceTypeNotIn(vs ...SourceType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldSourceType, vs...)) +} + +// GithubURLEQ applies the EQ predicate on the "github_url" field. +func GithubURLEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldGithubURL, v)) +} + +// GithubURLNEQ applies the NEQ predicate on the "github_url" field. +func GithubURLNEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldGithubURL, v)) +} + +// GithubURLIn applies the In predicate on the "github_url" field. +func GithubURLIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldGithubURL, vs...)) +} + +// GithubURLNotIn applies the NotIn predicate on the "github_url" field. +func GithubURLNotIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldGithubURL, vs...)) +} + +// GithubURLGT applies the GT predicate on the "github_url" field. +func GithubURLGT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldGithubURL, v)) +} + +// GithubURLGTE applies the GTE predicate on the "github_url" field. +func GithubURLGTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldGithubURL, v)) +} + +// GithubURLLT applies the LT predicate on the "github_url" field. +func GithubURLLT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldGithubURL, v)) +} + +// GithubURLLTE applies the LTE predicate on the "github_url" field. +func GithubURLLTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldGithubURL, v)) +} + +// GithubURLContains applies the Contains predicate on the "github_url" field. +func GithubURLContains(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContains(FieldGithubURL, v)) +} + +// GithubURLHasPrefix applies the HasPrefix predicate on the "github_url" field. +func GithubURLHasPrefix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasPrefix(FieldGithubURL, v)) +} + +// GithubURLHasSuffix applies the HasSuffix predicate on the "github_url" field. +func GithubURLHasSuffix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasSuffix(FieldGithubURL, v)) +} + +// GithubURLIsNil applies the IsNil predicate on the "github_url" field. +func GithubURLIsNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIsNull(FieldGithubURL)) +} + +// GithubURLNotNil applies the NotNil predicate on the "github_url" field. +func GithubURLNotNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotNull(FieldGithubURL)) +} + +// GithubURLEqualFold applies the EqualFold predicate on the "github_url" field. +func GithubURLEqualFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEqualFold(FieldGithubURL, v)) +} + +// GithubURLContainsFold applies the ContainsFold predicate on the "github_url" field. +func GithubURLContainsFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContainsFold(FieldGithubURL, v)) +} + +// RefTypeEQ applies the EQ predicate on the "ref_type" field. +func RefTypeEQ(v RefType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldRefType, v)) +} + +// RefTypeNEQ applies the NEQ predicate on the "ref_type" field. +func RefTypeNEQ(v RefType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldRefType, v)) +} + +// RefTypeIn applies the In predicate on the "ref_type" field. +func RefTypeIn(vs ...RefType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldRefType, vs...)) +} + +// RefTypeNotIn applies the NotIn predicate on the "ref_type" field. +func RefTypeNotIn(vs ...RefType) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldRefType, vs...)) +} + +// RefTypeIsNil applies the IsNil predicate on the "ref_type" field. +func RefTypeIsNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIsNull(FieldRefType)) +} + +// RefTypeNotNil applies the NotNil predicate on the "ref_type" field. +func RefTypeNotNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotNull(FieldRefType)) +} + +// RefValueEQ applies the EQ predicate on the "ref_value" field. +func RefValueEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldRefValue, v)) +} + +// RefValueNEQ applies the NEQ predicate on the "ref_value" field. +func RefValueNEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldRefValue, v)) +} + +// RefValueIn applies the In predicate on the "ref_value" field. +func RefValueIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldRefValue, vs...)) +} + +// RefValueNotIn applies the NotIn predicate on the "ref_value" field. +func RefValueNotIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldRefValue, vs...)) +} + +// RefValueGT applies the GT predicate on the "ref_value" field. +func RefValueGT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldRefValue, v)) +} + +// RefValueGTE applies the GTE predicate on the "ref_value" field. +func RefValueGTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldRefValue, v)) +} + +// RefValueLT applies the LT predicate on the "ref_value" field. +func RefValueLT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldRefValue, v)) +} + +// RefValueLTE applies the LTE predicate on the "ref_value" field. +func RefValueLTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldRefValue, v)) +} + +// RefValueContains applies the Contains predicate on the "ref_value" field. +func RefValueContains(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContains(FieldRefValue, v)) +} + +// RefValueHasPrefix applies the HasPrefix predicate on the "ref_value" field. +func RefValueHasPrefix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasPrefix(FieldRefValue, v)) +} + +// RefValueHasSuffix applies the HasSuffix predicate on the "ref_value" field. +func RefValueHasSuffix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasSuffix(FieldRefValue, v)) +} + +// RefValueIsNil applies the IsNil predicate on the "ref_value" field. +func RefValueIsNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIsNull(FieldRefValue)) +} + +// RefValueNotNil applies the NotNil predicate on the "ref_value" field. +func RefValueNotNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotNull(FieldRefValue)) +} + +// RefValueEqualFold applies the EqualFold predicate on the "ref_value" field. +func RefValueEqualFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEqualFold(FieldRefValue, v)) +} + +// RefValueContainsFold applies the ContainsFold predicate on the "ref_value" field. +func RefValueContainsFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContainsFold(FieldRefValue, v)) +} + +// LastUploadFilenameEQ applies the EQ predicate on the "last_upload_filename" field. +func LastUploadFilenameEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameNEQ applies the NEQ predicate on the "last_upload_filename" field. +func LastUploadFilenameNEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameIn applies the In predicate on the "last_upload_filename" field. +func LastUploadFilenameIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldLastUploadFilename, vs...)) +} + +// LastUploadFilenameNotIn applies the NotIn predicate on the "last_upload_filename" field. +func LastUploadFilenameNotIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldLastUploadFilename, vs...)) +} + +// LastUploadFilenameGT applies the GT predicate on the "last_upload_filename" field. +func LastUploadFilenameGT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameGTE applies the GTE predicate on the "last_upload_filename" field. +func LastUploadFilenameGTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameLT applies the LT predicate on the "last_upload_filename" field. +func LastUploadFilenameLT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameLTE applies the LTE predicate on the "last_upload_filename" field. +func LastUploadFilenameLTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameContains applies the Contains predicate on the "last_upload_filename" field. +func LastUploadFilenameContains(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContains(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameHasPrefix applies the HasPrefix predicate on the "last_upload_filename" field. +func LastUploadFilenameHasPrefix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasPrefix(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameHasSuffix applies the HasSuffix predicate on the "last_upload_filename" field. +func LastUploadFilenameHasSuffix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasSuffix(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameIsNil applies the IsNil predicate on the "last_upload_filename" field. +func LastUploadFilenameIsNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIsNull(FieldLastUploadFilename)) +} + +// LastUploadFilenameNotNil applies the NotNil predicate on the "last_upload_filename" field. +func LastUploadFilenameNotNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotNull(FieldLastUploadFilename)) +} + +// LastUploadFilenameEqualFold applies the EqualFold predicate on the "last_upload_filename" field. +func LastUploadFilenameEqualFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEqualFold(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameContainsFold applies the ContainsFold predicate on the "last_upload_filename" field. +func LastUploadFilenameContainsFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContainsFold(FieldLastUploadFilename, v)) +} + +// LastUploadAtEQ applies the EQ predicate on the "last_upload_at" field. +func LastUploadAtEQ(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldLastUploadAt, v)) +} + +// LastUploadAtNEQ applies the NEQ predicate on the "last_upload_at" field. +func LastUploadAtNEQ(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldLastUploadAt, v)) +} + +// LastUploadAtIn applies the In predicate on the "last_upload_at" field. +func LastUploadAtIn(vs ...time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldLastUploadAt, vs...)) +} + +// LastUploadAtNotIn applies the NotIn predicate on the "last_upload_at" field. +func LastUploadAtNotIn(vs ...time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldLastUploadAt, vs...)) +} + +// LastUploadAtGT applies the GT predicate on the "last_upload_at" field. +func LastUploadAtGT(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldLastUploadAt, v)) +} + +// LastUploadAtGTE applies the GTE predicate on the "last_upload_at" field. +func LastUploadAtGTE(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldLastUploadAt, v)) +} + +// LastUploadAtLT applies the LT predicate on the "last_upload_at" field. +func LastUploadAtLT(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldLastUploadAt, v)) +} + +// LastUploadAtLTE applies the LTE predicate on the "last_upload_at" field. +func LastUploadAtLTE(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldLastUploadAt, v)) +} + +// LastUploadAtIsNil applies the IsNil predicate on the "last_upload_at" field. +func LastUploadAtIsNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIsNull(FieldLastUploadAt)) +} + +// LastUploadAtNotNil applies the NotNil predicate on the "last_upload_at" field. +func LastUploadAtNotNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotNull(FieldLastUploadAt)) +} + +// PluginDiscoveryAutoPackageJSONEQ applies the EQ predicate on the "plugin_discovery_auto_package_json" field. +func PluginDiscoveryAutoPackageJSONEQ(v bool) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldPluginDiscoveryAutoPackageJSON, v)) +} + +// PluginDiscoveryAutoPackageJSONNEQ applies the NEQ predicate on the "plugin_discovery_auto_package_json" field. +func PluginDiscoveryAutoPackageJSONNEQ(v bool) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldPluginDiscoveryAutoPackageJSON, v)) +} + +// PluginManualEntriesIsNil applies the IsNil predicate on the "plugin_manual_entries" field. +func PluginManualEntriesIsNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIsNull(FieldPluginManualEntries)) +} + +// PluginManualEntriesNotNil applies the NotNil predicate on the "plugin_manual_entries" field. +func PluginManualEntriesNotNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotNull(FieldPluginManualEntries)) +} + +// NpmPackageNameEQ applies the EQ predicate on the "npm_package_name" field. +func NpmPackageNameEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldNpmPackageName, v)) +} + +// NpmPackageNameNEQ applies the NEQ predicate on the "npm_package_name" field. +func NpmPackageNameNEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldNpmPackageName, v)) +} + +// NpmPackageNameIn applies the In predicate on the "npm_package_name" field. +func NpmPackageNameIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldNpmPackageName, vs...)) +} + +// NpmPackageNameNotIn applies the NotIn predicate on the "npm_package_name" field. +func NpmPackageNameNotIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldNpmPackageName, vs...)) +} + +// NpmPackageNameGT applies the GT predicate on the "npm_package_name" field. +func NpmPackageNameGT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldNpmPackageName, v)) +} + +// NpmPackageNameGTE applies the GTE predicate on the "npm_package_name" field. +func NpmPackageNameGTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldNpmPackageName, v)) +} + +// NpmPackageNameLT applies the LT predicate on the "npm_package_name" field. +func NpmPackageNameLT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldNpmPackageName, v)) +} + +// NpmPackageNameLTE applies the LTE predicate on the "npm_package_name" field. +func NpmPackageNameLTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldNpmPackageName, v)) +} + +// NpmPackageNameContains applies the Contains predicate on the "npm_package_name" field. +func NpmPackageNameContains(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContains(FieldNpmPackageName, v)) +} + +// NpmPackageNameHasPrefix applies the HasPrefix predicate on the "npm_package_name" field. +func NpmPackageNameHasPrefix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasPrefix(FieldNpmPackageName, v)) +} + +// NpmPackageNameHasSuffix applies the HasSuffix predicate on the "npm_package_name" field. +func NpmPackageNameHasSuffix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasSuffix(FieldNpmPackageName, v)) +} + +// NpmPackageNameIsNil applies the IsNil predicate on the "npm_package_name" field. +func NpmPackageNameIsNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIsNull(FieldNpmPackageName)) +} + +// NpmPackageNameNotNil applies the NotNil predicate on the "npm_package_name" field. +func NpmPackageNameNotNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotNull(FieldNpmPackageName)) +} + +// NpmPackageNameEqualFold applies the EqualFold predicate on the "npm_package_name" field. +func NpmPackageNameEqualFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEqualFold(FieldNpmPackageName, v)) +} + +// NpmPackageNameContainsFold applies the ContainsFold predicate on the "npm_package_name" field. +func NpmPackageNameContainsFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContainsFold(FieldNpmPackageName, v)) +} + +// NpmVersionSpecEQ applies the EQ predicate on the "npm_version_spec" field. +func NpmVersionSpecEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldNpmVersionSpec, v)) +} + +// NpmVersionSpecNEQ applies the NEQ predicate on the "npm_version_spec" field. +func NpmVersionSpecNEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldNpmVersionSpec, v)) +} + +// NpmVersionSpecIn applies the In predicate on the "npm_version_spec" field. +func NpmVersionSpecIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldNpmVersionSpec, vs...)) +} + +// NpmVersionSpecNotIn applies the NotIn predicate on the "npm_version_spec" field. +func NpmVersionSpecNotIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldNpmVersionSpec, vs...)) +} + +// NpmVersionSpecGT applies the GT predicate on the "npm_version_spec" field. +func NpmVersionSpecGT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldNpmVersionSpec, v)) +} + +// NpmVersionSpecGTE applies the GTE predicate on the "npm_version_spec" field. +func NpmVersionSpecGTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldNpmVersionSpec, v)) +} + +// NpmVersionSpecLT applies the LT predicate on the "npm_version_spec" field. +func NpmVersionSpecLT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldNpmVersionSpec, v)) +} + +// NpmVersionSpecLTE applies the LTE predicate on the "npm_version_spec" field. +func NpmVersionSpecLTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldNpmVersionSpec, v)) +} + +// NpmVersionSpecContains applies the Contains predicate on the "npm_version_spec" field. +func NpmVersionSpecContains(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContains(FieldNpmVersionSpec, v)) +} + +// NpmVersionSpecHasPrefix applies the HasPrefix predicate on the "npm_version_spec" field. +func NpmVersionSpecHasPrefix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasPrefix(FieldNpmVersionSpec, v)) +} + +// NpmVersionSpecHasSuffix applies the HasSuffix predicate on the "npm_version_spec" field. +func NpmVersionSpecHasSuffix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasSuffix(FieldNpmVersionSpec, v)) +} + +// NpmVersionSpecIsNil applies the IsNil predicate on the "npm_version_spec" field. +func NpmVersionSpecIsNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIsNull(FieldNpmVersionSpec)) +} + +// NpmVersionSpecNotNil applies the NotNil predicate on the "npm_version_spec" field. +func NpmVersionSpecNotNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotNull(FieldNpmVersionSpec)) +} + +// NpmVersionSpecEqualFold applies the EqualFold predicate on the "npm_version_spec" field. +func NpmVersionSpecEqualFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEqualFold(FieldNpmVersionSpec, v)) +} + +// NpmVersionSpecContainsFold applies the ContainsFold predicate on the "npm_version_spec" field. +func NpmVersionSpecContainsFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContainsFold(FieldNpmVersionSpec, v)) +} + +// NpmRegistryURLEQ applies the EQ predicate on the "npm_registry_url" field. +func NpmRegistryURLEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldNpmRegistryURL, v)) +} + +// NpmRegistryURLNEQ applies the NEQ predicate on the "npm_registry_url" field. +func NpmRegistryURLNEQ(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldNpmRegistryURL, v)) +} + +// NpmRegistryURLIn applies the In predicate on the "npm_registry_url" field. +func NpmRegistryURLIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldNpmRegistryURL, vs...)) +} + +// NpmRegistryURLNotIn applies the NotIn predicate on the "npm_registry_url" field. +func NpmRegistryURLNotIn(vs ...string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldNpmRegistryURL, vs...)) +} + +// NpmRegistryURLGT applies the GT predicate on the "npm_registry_url" field. +func NpmRegistryURLGT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldNpmRegistryURL, v)) +} + +// NpmRegistryURLGTE applies the GTE predicate on the "npm_registry_url" field. +func NpmRegistryURLGTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldNpmRegistryURL, v)) +} + +// NpmRegistryURLLT applies the LT predicate on the "npm_registry_url" field. +func NpmRegistryURLLT(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldNpmRegistryURL, v)) +} + +// NpmRegistryURLLTE applies the LTE predicate on the "npm_registry_url" field. +func NpmRegistryURLLTE(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldNpmRegistryURL, v)) +} + +// NpmRegistryURLContains applies the Contains predicate on the "npm_registry_url" field. +func NpmRegistryURLContains(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContains(FieldNpmRegistryURL, v)) +} + +// NpmRegistryURLHasPrefix applies the HasPrefix predicate on the "npm_registry_url" field. +func NpmRegistryURLHasPrefix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasPrefix(FieldNpmRegistryURL, v)) +} + +// NpmRegistryURLHasSuffix applies the HasSuffix predicate on the "npm_registry_url" field. +func NpmRegistryURLHasSuffix(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldHasSuffix(FieldNpmRegistryURL, v)) +} + +// NpmRegistryURLIsNil applies the IsNil predicate on the "npm_registry_url" field. +func NpmRegistryURLIsNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIsNull(FieldNpmRegistryURL)) +} + +// NpmRegistryURLNotNil applies the NotNil predicate on the "npm_registry_url" field. +func NpmRegistryURLNotNil() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotNull(FieldNpmRegistryURL)) +} + +// NpmRegistryURLEqualFold applies the EqualFold predicate on the "npm_registry_url" field. +func NpmRegistryURLEqualFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEqualFold(FieldNpmRegistryURL, v)) +} + +// NpmRegistryURLContainsFold applies the ContainsFold predicate on the "npm_registry_url" field. +func NpmRegistryURLContainsFold(v string) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldContainsFold(FieldNpmRegistryURL, v)) +} + +// IsDeletedEQ applies the EQ predicate on the "is_deleted" field. +func IsDeletedEQ(v bool) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldIsDeleted, v)) +} + +// IsDeletedNEQ applies the NEQ predicate on the "is_deleted" field. +func IsDeletedNEQ(v bool) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldIsDeleted, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// HasPlugins applies the HasEdge predicate on the "plugins" edge. +func HasPlugins() predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, PluginsTable, PluginsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPluginsWith applies the HasEdge predicate on the "plugins" edge with a given conditions (other predicates). +func HasPluginsWith(preds ...predicate.AgentPlugin) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(func(s *sql.Selector) { + step := newPluginsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.AgentPluginRepo) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.AgentPluginRepo) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.AgentPluginRepo) predicate.AgentPluginRepo { + return predicate.AgentPluginRepo(sql.NotPredicates(p)) +} diff --git a/backend/db/agentpluginrepo_create.go b/backend/db/agentpluginrepo_create.go new file mode 100644 index 00000000..d4d7166b --- /dev/null +++ b/backend/db/agentpluginrepo_create.go @@ -0,0 +1,1752 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentPluginRepoCreate is the builder for creating a AgentPluginRepo entity. +type AgentPluginRepoCreate struct { + config + mutation *AgentPluginRepoMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetName sets the "name" field. +func (_c *AgentPluginRepoCreate) SetName(v string) *AgentPluginRepoCreate { + _c.mutation.SetName(v) + return _c +} + +// SetScopeType sets the "scope_type" field. +func (_c *AgentPluginRepoCreate) SetScopeType(v agentpluginrepo.ScopeType) *AgentPluginRepoCreate { + _c.mutation.SetScopeType(v) + return _c +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableScopeType(v *agentpluginrepo.ScopeType) *AgentPluginRepoCreate { + if v != nil { + _c.SetScopeType(*v) + } + return _c +} + +// SetScopeID sets the "scope_id" field. +func (_c *AgentPluginRepoCreate) SetScopeID(v string) *AgentPluginRepoCreate { + _c.mutation.SetScopeID(v) + return _c +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableScopeID(v *string) *AgentPluginRepoCreate { + if v != nil { + _c.SetScopeID(*v) + } + return _c +} + +// SetCreatedBy sets the "created_by" field. +func (_c *AgentPluginRepoCreate) SetCreatedBy(v uuid.UUID) *AgentPluginRepoCreate { + _c.mutation.SetCreatedBy(v) + return _c +} + +// SetSourceType sets the "source_type" field. +func (_c *AgentPluginRepoCreate) SetSourceType(v agentpluginrepo.SourceType) *AgentPluginRepoCreate { + _c.mutation.SetSourceType(v) + return _c +} + +// SetGithubURL sets the "github_url" field. +func (_c *AgentPluginRepoCreate) SetGithubURL(v string) *AgentPluginRepoCreate { + _c.mutation.SetGithubURL(v) + return _c +} + +// SetNillableGithubURL sets the "github_url" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableGithubURL(v *string) *AgentPluginRepoCreate { + if v != nil { + _c.SetGithubURL(*v) + } + return _c +} + +// SetRefType sets the "ref_type" field. +func (_c *AgentPluginRepoCreate) SetRefType(v agentpluginrepo.RefType) *AgentPluginRepoCreate { + _c.mutation.SetRefType(v) + return _c +} + +// SetNillableRefType sets the "ref_type" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableRefType(v *agentpluginrepo.RefType) *AgentPluginRepoCreate { + if v != nil { + _c.SetRefType(*v) + } + return _c +} + +// SetRefValue sets the "ref_value" field. +func (_c *AgentPluginRepoCreate) SetRefValue(v string) *AgentPluginRepoCreate { + _c.mutation.SetRefValue(v) + return _c +} + +// SetNillableRefValue sets the "ref_value" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableRefValue(v *string) *AgentPluginRepoCreate { + if v != nil { + _c.SetRefValue(*v) + } + return _c +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (_c *AgentPluginRepoCreate) SetLastUploadFilename(v string) *AgentPluginRepoCreate { + _c.mutation.SetLastUploadFilename(v) + return _c +} + +// SetNillableLastUploadFilename sets the "last_upload_filename" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableLastUploadFilename(v *string) *AgentPluginRepoCreate { + if v != nil { + _c.SetLastUploadFilename(*v) + } + return _c +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (_c *AgentPluginRepoCreate) SetLastUploadAt(v time.Time) *AgentPluginRepoCreate { + _c.mutation.SetLastUploadAt(v) + return _c +} + +// SetNillableLastUploadAt sets the "last_upload_at" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableLastUploadAt(v *time.Time) *AgentPluginRepoCreate { + if v != nil { + _c.SetLastUploadAt(*v) + } + return _c +} + +// SetPluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field. +func (_c *AgentPluginRepoCreate) SetPluginDiscoveryAutoPackageJSON(v bool) *AgentPluginRepoCreate { + _c.mutation.SetPluginDiscoveryAutoPackageJSON(v) + return _c +} + +// SetNillablePluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillablePluginDiscoveryAutoPackageJSON(v *bool) *AgentPluginRepoCreate { + if v != nil { + _c.SetPluginDiscoveryAutoPackageJSON(*v) + } + return _c +} + +// SetPluginManualEntries sets the "plugin_manual_entries" field. +func (_c *AgentPluginRepoCreate) SetPluginManualEntries(v types.PluginManualEntries) *AgentPluginRepoCreate { + _c.mutation.SetPluginManualEntries(v) + return _c +} + +// SetNpmPackageName sets the "npm_package_name" field. +func (_c *AgentPluginRepoCreate) SetNpmPackageName(v string) *AgentPluginRepoCreate { + _c.mutation.SetNpmPackageName(v) + return _c +} + +// SetNillableNpmPackageName sets the "npm_package_name" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableNpmPackageName(v *string) *AgentPluginRepoCreate { + if v != nil { + _c.SetNpmPackageName(*v) + } + return _c +} + +// SetNpmVersionSpec sets the "npm_version_spec" field. +func (_c *AgentPluginRepoCreate) SetNpmVersionSpec(v string) *AgentPluginRepoCreate { + _c.mutation.SetNpmVersionSpec(v) + return _c +} + +// SetNillableNpmVersionSpec sets the "npm_version_spec" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableNpmVersionSpec(v *string) *AgentPluginRepoCreate { + if v != nil { + _c.SetNpmVersionSpec(*v) + } + return _c +} + +// SetNpmRegistryURL sets the "npm_registry_url" field. +func (_c *AgentPluginRepoCreate) SetNpmRegistryURL(v string) *AgentPluginRepoCreate { + _c.mutation.SetNpmRegistryURL(v) + return _c +} + +// SetNillableNpmRegistryURL sets the "npm_registry_url" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableNpmRegistryURL(v *string) *AgentPluginRepoCreate { + if v != nil { + _c.SetNpmRegistryURL(*v) + } + return _c +} + +// SetIsDeleted sets the "is_deleted" field. +func (_c *AgentPluginRepoCreate) SetIsDeleted(v bool) *AgentPluginRepoCreate { + _c.mutation.SetIsDeleted(v) + return _c +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableIsDeleted(v *bool) *AgentPluginRepoCreate { + if v != nil { + _c.SetIsDeleted(*v) + } + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AgentPluginRepoCreate) SetCreatedAt(v time.Time) *AgentPluginRepoCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableCreatedAt(v *time.Time) *AgentPluginRepoCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *AgentPluginRepoCreate) SetUpdatedAt(v time.Time) *AgentPluginRepoCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableUpdatedAt(v *time.Time) *AgentPluginRepoCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AgentPluginRepoCreate) SetID(v uuid.UUID) *AgentPluginRepoCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AgentPluginRepoCreate) SetNillableID(v *uuid.UUID) *AgentPluginRepoCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// AddPluginIDs adds the "plugins" edge to the AgentPlugin entity by IDs. +func (_c *AgentPluginRepoCreate) AddPluginIDs(ids ...uuid.UUID) *AgentPluginRepoCreate { + _c.mutation.AddPluginIDs(ids...) + return _c +} + +// AddPlugins adds the "plugins" edges to the AgentPlugin entity. +func (_c *AgentPluginRepoCreate) AddPlugins(v ...*AgentPlugin) *AgentPluginRepoCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddPluginIDs(ids...) +} + +// Mutation returns the AgentPluginRepoMutation object of the builder. +func (_c *AgentPluginRepoCreate) Mutation() *AgentPluginRepoMutation { + return _c.mutation +} + +// Save creates the AgentPluginRepo in the database. +func (_c *AgentPluginRepoCreate) Save(ctx context.Context) (*AgentPluginRepo, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AgentPluginRepoCreate) SaveX(ctx context.Context) *AgentPluginRepo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentPluginRepoCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentPluginRepoCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AgentPluginRepoCreate) defaults() { + if _, ok := _c.mutation.ScopeType(); !ok { + v := agentpluginrepo.DefaultScopeType + _c.mutation.SetScopeType(v) + } + if _, ok := _c.mutation.ScopeID(); !ok { + v := agentpluginrepo.DefaultScopeID + _c.mutation.SetScopeID(v) + } + if _, ok := _c.mutation.PluginDiscoveryAutoPackageJSON(); !ok { + v := agentpluginrepo.DefaultPluginDiscoveryAutoPackageJSON + _c.mutation.SetPluginDiscoveryAutoPackageJSON(v) + } + if _, ok := _c.mutation.IsDeleted(); !ok { + v := agentpluginrepo.DefaultIsDeleted + _c.mutation.SetIsDeleted(v) + } + if _, ok := _c.mutation.CreatedAt(); !ok { + v := agentpluginrepo.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := agentpluginrepo.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := agentpluginrepo.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AgentPluginRepoCreate) check() error { + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`db: missing required field "AgentPluginRepo.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := agentpluginrepo.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.name": %w`, err)} + } + } + if _, ok := _c.mutation.ScopeType(); !ok { + return &ValidationError{Name: "scope_type", err: errors.New(`db: missing required field "AgentPluginRepo.scope_type"`)} + } + if v, ok := _c.mutation.ScopeType(); ok { + if err := agentpluginrepo.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.scope_type": %w`, err)} + } + } + if _, ok := _c.mutation.ScopeID(); !ok { + return &ValidationError{Name: "scope_id", err: errors.New(`db: missing required field "AgentPluginRepo.scope_id"`)} + } + if _, ok := _c.mutation.CreatedBy(); !ok { + return &ValidationError{Name: "created_by", err: errors.New(`db: missing required field "AgentPluginRepo.created_by"`)} + } + if _, ok := _c.mutation.SourceType(); !ok { + return &ValidationError{Name: "source_type", err: errors.New(`db: missing required field "AgentPluginRepo.source_type"`)} + } + if v, ok := _c.mutation.SourceType(); ok { + if err := agentpluginrepo.SourceTypeValidator(v); err != nil { + return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.source_type": %w`, err)} + } + } + if v, ok := _c.mutation.RefType(); ok { + if err := agentpluginrepo.RefTypeValidator(v); err != nil { + return &ValidationError{Name: "ref_type", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.ref_type": %w`, err)} + } + } + if _, ok := _c.mutation.PluginDiscoveryAutoPackageJSON(); !ok { + return &ValidationError{Name: "plugin_discovery_auto_package_json", err: errors.New(`db: missing required field "AgentPluginRepo.plugin_discovery_auto_package_json"`)} + } + if _, ok := _c.mutation.IsDeleted(); !ok { + return &ValidationError{Name: "is_deleted", err: errors.New(`db: missing required field "AgentPluginRepo.is_deleted"`)} + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentPluginRepo.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "AgentPluginRepo.updated_at"`)} + } + return nil +} + +func (_c *AgentPluginRepoCreate) sqlSave(ctx context.Context) (*AgentPluginRepo, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AgentPluginRepoCreate) createSpec() (*AgentPluginRepo, *sqlgraph.CreateSpec) { + var ( + _node = &AgentPluginRepo{config: _c.config} + _spec = sqlgraph.NewCreateSpec(agentpluginrepo.Table, sqlgraph.NewFieldSpec(agentpluginrepo.FieldID, field.TypeUUID)) + ) + _spec.OnConflict = _c.conflict + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(agentpluginrepo.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.ScopeType(); ok { + _spec.SetField(agentpluginrepo.FieldScopeType, field.TypeEnum, value) + _node.ScopeType = value + } + if value, ok := _c.mutation.ScopeID(); ok { + _spec.SetField(agentpluginrepo.FieldScopeID, field.TypeString, value) + _node.ScopeID = value + } + if value, ok := _c.mutation.CreatedBy(); ok { + _spec.SetField(agentpluginrepo.FieldCreatedBy, field.TypeUUID, value) + _node.CreatedBy = value + } + if value, ok := _c.mutation.SourceType(); ok { + _spec.SetField(agentpluginrepo.FieldSourceType, field.TypeEnum, value) + _node.SourceType = value + } + if value, ok := _c.mutation.GithubURL(); ok { + _spec.SetField(agentpluginrepo.FieldGithubURL, field.TypeString, value) + _node.GithubURL = &value + } + if value, ok := _c.mutation.RefType(); ok { + _spec.SetField(agentpluginrepo.FieldRefType, field.TypeEnum, value) + _node.RefType = &value + } + if value, ok := _c.mutation.RefValue(); ok { + _spec.SetField(agentpluginrepo.FieldRefValue, field.TypeString, value) + _node.RefValue = &value + } + if value, ok := _c.mutation.LastUploadFilename(); ok { + _spec.SetField(agentpluginrepo.FieldLastUploadFilename, field.TypeString, value) + _node.LastUploadFilename = &value + } + if value, ok := _c.mutation.LastUploadAt(); ok { + _spec.SetField(agentpluginrepo.FieldLastUploadAt, field.TypeTime, value) + _node.LastUploadAt = &value + } + if value, ok := _c.mutation.PluginDiscoveryAutoPackageJSON(); ok { + _spec.SetField(agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON, field.TypeBool, value) + _node.PluginDiscoveryAutoPackageJSON = value + } + if value, ok := _c.mutation.PluginManualEntries(); ok { + _spec.SetField(agentpluginrepo.FieldPluginManualEntries, field.TypeJSON, value) + _node.PluginManualEntries = value + } + if value, ok := _c.mutation.NpmPackageName(); ok { + _spec.SetField(agentpluginrepo.FieldNpmPackageName, field.TypeString, value) + _node.NpmPackageName = &value + } + if value, ok := _c.mutation.NpmVersionSpec(); ok { + _spec.SetField(agentpluginrepo.FieldNpmVersionSpec, field.TypeString, value) + _node.NpmVersionSpec = &value + } + if value, ok := _c.mutation.NpmRegistryURL(); ok { + _spec.SetField(agentpluginrepo.FieldNpmRegistryURL, field.TypeString, value) + _node.NpmRegistryURL = &value + } + if value, ok := _c.mutation.IsDeleted(); ok { + _spec.SetField(agentpluginrepo.FieldIsDeleted, field.TypeBool, value) + _node.IsDeleted = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(agentpluginrepo.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(agentpluginrepo.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if nodes := _c.mutation.PluginsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentpluginrepo.PluginsTable, + Columns: []string{agentpluginrepo.PluginsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentPluginRepo.Create(). +// SetName(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentPluginRepoUpsert) { +// SetName(v+v). +// }). +// Exec(ctx) +func (_c *AgentPluginRepoCreate) OnConflict(opts ...sql.ConflictOption) *AgentPluginRepoUpsertOne { + _c.conflict = opts + return &AgentPluginRepoUpsertOne{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentPluginRepo.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentPluginRepoCreate) OnConflictColumns(columns ...string) *AgentPluginRepoUpsertOne { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentPluginRepoUpsertOne{ + create: _c, + } +} + +type ( + // AgentPluginRepoUpsertOne is the builder for "upsert"-ing + // one AgentPluginRepo node. + AgentPluginRepoUpsertOne struct { + create *AgentPluginRepoCreate + } + + // AgentPluginRepoUpsert is the "OnConflict" setter. + AgentPluginRepoUpsert struct { + *sql.UpdateSet + } +) + +// SetName sets the "name" field. +func (u *AgentPluginRepoUpsert) SetName(v string) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateName() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldName) + return u +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentPluginRepoUpsert) SetScopeType(v agentpluginrepo.ScopeType) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldScopeType, v) + return u +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateScopeType() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldScopeType) + return u +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentPluginRepoUpsert) SetScopeID(v string) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldScopeID, v) + return u +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateScopeID() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldScopeID) + return u +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentPluginRepoUpsert) SetCreatedBy(v uuid.UUID) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldCreatedBy, v) + return u +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateCreatedBy() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldCreatedBy) + return u +} + +// SetSourceType sets the "source_type" field. +func (u *AgentPluginRepoUpsert) SetSourceType(v agentpluginrepo.SourceType) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldSourceType, v) + return u +} + +// UpdateSourceType sets the "source_type" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateSourceType() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldSourceType) + return u +} + +// SetGithubURL sets the "github_url" field. +func (u *AgentPluginRepoUpsert) SetGithubURL(v string) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldGithubURL, v) + return u +} + +// UpdateGithubURL sets the "github_url" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateGithubURL() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldGithubURL) + return u +} + +// ClearGithubURL clears the value of the "github_url" field. +func (u *AgentPluginRepoUpsert) ClearGithubURL() *AgentPluginRepoUpsert { + u.SetNull(agentpluginrepo.FieldGithubURL) + return u +} + +// SetRefType sets the "ref_type" field. +func (u *AgentPluginRepoUpsert) SetRefType(v agentpluginrepo.RefType) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldRefType, v) + return u +} + +// UpdateRefType sets the "ref_type" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateRefType() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldRefType) + return u +} + +// ClearRefType clears the value of the "ref_type" field. +func (u *AgentPluginRepoUpsert) ClearRefType() *AgentPluginRepoUpsert { + u.SetNull(agentpluginrepo.FieldRefType) + return u +} + +// SetRefValue sets the "ref_value" field. +func (u *AgentPluginRepoUpsert) SetRefValue(v string) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldRefValue, v) + return u +} + +// UpdateRefValue sets the "ref_value" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateRefValue() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldRefValue) + return u +} + +// ClearRefValue clears the value of the "ref_value" field. +func (u *AgentPluginRepoUpsert) ClearRefValue() *AgentPluginRepoUpsert { + u.SetNull(agentpluginrepo.FieldRefValue) + return u +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (u *AgentPluginRepoUpsert) SetLastUploadFilename(v string) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldLastUploadFilename, v) + return u +} + +// UpdateLastUploadFilename sets the "last_upload_filename" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateLastUploadFilename() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldLastUploadFilename) + return u +} + +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (u *AgentPluginRepoUpsert) ClearLastUploadFilename() *AgentPluginRepoUpsert { + u.SetNull(agentpluginrepo.FieldLastUploadFilename) + return u +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (u *AgentPluginRepoUpsert) SetLastUploadAt(v time.Time) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldLastUploadAt, v) + return u +} + +// UpdateLastUploadAt sets the "last_upload_at" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateLastUploadAt() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldLastUploadAt) + return u +} + +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (u *AgentPluginRepoUpsert) ClearLastUploadAt() *AgentPluginRepoUpsert { + u.SetNull(agentpluginrepo.FieldLastUploadAt) + return u +} + +// SetPluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field. +func (u *AgentPluginRepoUpsert) SetPluginDiscoveryAutoPackageJSON(v bool) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON, v) + return u +} + +// UpdatePluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdatePluginDiscoveryAutoPackageJSON() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON) + return u +} + +// SetPluginManualEntries sets the "plugin_manual_entries" field. +func (u *AgentPluginRepoUpsert) SetPluginManualEntries(v types.PluginManualEntries) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldPluginManualEntries, v) + return u +} + +// UpdatePluginManualEntries sets the "plugin_manual_entries" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdatePluginManualEntries() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldPluginManualEntries) + return u +} + +// ClearPluginManualEntries clears the value of the "plugin_manual_entries" field. +func (u *AgentPluginRepoUpsert) ClearPluginManualEntries() *AgentPluginRepoUpsert { + u.SetNull(agentpluginrepo.FieldPluginManualEntries) + return u +} + +// SetNpmPackageName sets the "npm_package_name" field. +func (u *AgentPluginRepoUpsert) SetNpmPackageName(v string) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldNpmPackageName, v) + return u +} + +// UpdateNpmPackageName sets the "npm_package_name" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateNpmPackageName() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldNpmPackageName) + return u +} + +// ClearNpmPackageName clears the value of the "npm_package_name" field. +func (u *AgentPluginRepoUpsert) ClearNpmPackageName() *AgentPluginRepoUpsert { + u.SetNull(agentpluginrepo.FieldNpmPackageName) + return u +} + +// SetNpmVersionSpec sets the "npm_version_spec" field. +func (u *AgentPluginRepoUpsert) SetNpmVersionSpec(v string) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldNpmVersionSpec, v) + return u +} + +// UpdateNpmVersionSpec sets the "npm_version_spec" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateNpmVersionSpec() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldNpmVersionSpec) + return u +} + +// ClearNpmVersionSpec clears the value of the "npm_version_spec" field. +func (u *AgentPluginRepoUpsert) ClearNpmVersionSpec() *AgentPluginRepoUpsert { + u.SetNull(agentpluginrepo.FieldNpmVersionSpec) + return u +} + +// SetNpmRegistryURL sets the "npm_registry_url" field. +func (u *AgentPluginRepoUpsert) SetNpmRegistryURL(v string) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldNpmRegistryURL, v) + return u +} + +// UpdateNpmRegistryURL sets the "npm_registry_url" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateNpmRegistryURL() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldNpmRegistryURL) + return u +} + +// ClearNpmRegistryURL clears the value of the "npm_registry_url" field. +func (u *AgentPluginRepoUpsert) ClearNpmRegistryURL() *AgentPluginRepoUpsert { + u.SetNull(agentpluginrepo.FieldNpmRegistryURL) + return u +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentPluginRepoUpsert) SetIsDeleted(v bool) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldIsDeleted, v) + return u +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateIsDeleted() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldIsDeleted) + return u +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentPluginRepoUpsert) SetCreatedAt(v time.Time) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldCreatedAt, v) + return u +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateCreatedAt() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldCreatedAt) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentPluginRepoUpsert) SetUpdatedAt(v time.Time) *AgentPluginRepoUpsert { + u.Set(agentpluginrepo.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentPluginRepoUpsert) UpdateUpdatedAt() *AgentPluginRepoUpsert { + u.SetExcluded(agentpluginrepo.FieldUpdatedAt) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.AgentPluginRepo.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentpluginrepo.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentPluginRepoUpsertOne) UpdateNewValues() *AgentPluginRepoUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(agentpluginrepo.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentPluginRepo.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentPluginRepoUpsertOne) Ignore() *AgentPluginRepoUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentPluginRepoUpsertOne) DoNothing() *AgentPluginRepoUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentPluginRepoCreate.OnConflict +// documentation for more info. +func (u *AgentPluginRepoUpsertOne) Update(set func(*AgentPluginRepoUpsert)) *AgentPluginRepoUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentPluginRepoUpsert{UpdateSet: update}) + })) + return u +} + +// SetName sets the "name" field. +func (u *AgentPluginRepoUpsertOne) SetName(v string) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateName() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateName() + }) +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentPluginRepoUpsertOne) SetScopeType(v agentpluginrepo.ScopeType) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetScopeType(v) + }) +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateScopeType() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateScopeType() + }) +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentPluginRepoUpsertOne) SetScopeID(v string) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetScopeID(v) + }) +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateScopeID() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateScopeID() + }) +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentPluginRepoUpsertOne) SetCreatedBy(v uuid.UUID) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetCreatedBy(v) + }) +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateCreatedBy() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateCreatedBy() + }) +} + +// SetSourceType sets the "source_type" field. +func (u *AgentPluginRepoUpsertOne) SetSourceType(v agentpluginrepo.SourceType) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetSourceType(v) + }) +} + +// UpdateSourceType sets the "source_type" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateSourceType() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateSourceType() + }) +} + +// SetGithubURL sets the "github_url" field. +func (u *AgentPluginRepoUpsertOne) SetGithubURL(v string) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetGithubURL(v) + }) +} + +// UpdateGithubURL sets the "github_url" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateGithubURL() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateGithubURL() + }) +} + +// ClearGithubURL clears the value of the "github_url" field. +func (u *AgentPluginRepoUpsertOne) ClearGithubURL() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearGithubURL() + }) +} + +// SetRefType sets the "ref_type" field. +func (u *AgentPluginRepoUpsertOne) SetRefType(v agentpluginrepo.RefType) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetRefType(v) + }) +} + +// UpdateRefType sets the "ref_type" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateRefType() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateRefType() + }) +} + +// ClearRefType clears the value of the "ref_type" field. +func (u *AgentPluginRepoUpsertOne) ClearRefType() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearRefType() + }) +} + +// SetRefValue sets the "ref_value" field. +func (u *AgentPluginRepoUpsertOne) SetRefValue(v string) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetRefValue(v) + }) +} + +// UpdateRefValue sets the "ref_value" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateRefValue() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateRefValue() + }) +} + +// ClearRefValue clears the value of the "ref_value" field. +func (u *AgentPluginRepoUpsertOne) ClearRefValue() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearRefValue() + }) +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (u *AgentPluginRepoUpsertOne) SetLastUploadFilename(v string) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetLastUploadFilename(v) + }) +} + +// UpdateLastUploadFilename sets the "last_upload_filename" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateLastUploadFilename() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateLastUploadFilename() + }) +} + +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (u *AgentPluginRepoUpsertOne) ClearLastUploadFilename() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearLastUploadFilename() + }) +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (u *AgentPluginRepoUpsertOne) SetLastUploadAt(v time.Time) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetLastUploadAt(v) + }) +} + +// UpdateLastUploadAt sets the "last_upload_at" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateLastUploadAt() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateLastUploadAt() + }) +} + +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (u *AgentPluginRepoUpsertOne) ClearLastUploadAt() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearLastUploadAt() + }) +} + +// SetPluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field. +func (u *AgentPluginRepoUpsertOne) SetPluginDiscoveryAutoPackageJSON(v bool) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetPluginDiscoveryAutoPackageJSON(v) + }) +} + +// UpdatePluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdatePluginDiscoveryAutoPackageJSON() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdatePluginDiscoveryAutoPackageJSON() + }) +} + +// SetPluginManualEntries sets the "plugin_manual_entries" field. +func (u *AgentPluginRepoUpsertOne) SetPluginManualEntries(v types.PluginManualEntries) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetPluginManualEntries(v) + }) +} + +// UpdatePluginManualEntries sets the "plugin_manual_entries" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdatePluginManualEntries() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdatePluginManualEntries() + }) +} + +// ClearPluginManualEntries clears the value of the "plugin_manual_entries" field. +func (u *AgentPluginRepoUpsertOne) ClearPluginManualEntries() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearPluginManualEntries() + }) +} + +// SetNpmPackageName sets the "npm_package_name" field. +func (u *AgentPluginRepoUpsertOne) SetNpmPackageName(v string) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetNpmPackageName(v) + }) +} + +// UpdateNpmPackageName sets the "npm_package_name" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateNpmPackageName() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateNpmPackageName() + }) +} + +// ClearNpmPackageName clears the value of the "npm_package_name" field. +func (u *AgentPluginRepoUpsertOne) ClearNpmPackageName() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearNpmPackageName() + }) +} + +// SetNpmVersionSpec sets the "npm_version_spec" field. +func (u *AgentPluginRepoUpsertOne) SetNpmVersionSpec(v string) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetNpmVersionSpec(v) + }) +} + +// UpdateNpmVersionSpec sets the "npm_version_spec" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateNpmVersionSpec() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateNpmVersionSpec() + }) +} + +// ClearNpmVersionSpec clears the value of the "npm_version_spec" field. +func (u *AgentPluginRepoUpsertOne) ClearNpmVersionSpec() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearNpmVersionSpec() + }) +} + +// SetNpmRegistryURL sets the "npm_registry_url" field. +func (u *AgentPluginRepoUpsertOne) SetNpmRegistryURL(v string) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetNpmRegistryURL(v) + }) +} + +// UpdateNpmRegistryURL sets the "npm_registry_url" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateNpmRegistryURL() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateNpmRegistryURL() + }) +} + +// ClearNpmRegistryURL clears the value of the "npm_registry_url" field. +func (u *AgentPluginRepoUpsertOne) ClearNpmRegistryURL() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearNpmRegistryURL() + }) +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentPluginRepoUpsertOne) SetIsDeleted(v bool) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetIsDeleted(v) + }) +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateIsDeleted() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateIsDeleted() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentPluginRepoUpsertOne) SetCreatedAt(v time.Time) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateCreatedAt() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentPluginRepoUpsertOne) SetUpdatedAt(v time.Time) *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertOne) UpdateUpdatedAt() *AgentPluginRepoUpsertOne { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentPluginRepoUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentPluginRepoCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentPluginRepoUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *AgentPluginRepoUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: AgentPluginRepoUpsertOne.ID is not supported by MySQL driver. Use AgentPluginRepoUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *AgentPluginRepoUpsertOne) IDX(ctx context.Context) uuid.UUID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// AgentPluginRepoCreateBulk is the builder for creating many AgentPluginRepo entities in bulk. +type AgentPluginRepoCreateBulk struct { + config + err error + builders []*AgentPluginRepoCreate + conflict []sql.ConflictOption +} + +// Save creates the AgentPluginRepo entities in the database. +func (_c *AgentPluginRepoCreateBulk) Save(ctx context.Context) ([]*AgentPluginRepo, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*AgentPluginRepo, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AgentPluginRepoMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = _c.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AgentPluginRepoCreateBulk) SaveX(ctx context.Context) []*AgentPluginRepo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentPluginRepoCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentPluginRepoCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentPluginRepo.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentPluginRepoUpsert) { +// SetName(v+v). +// }). +// Exec(ctx) +func (_c *AgentPluginRepoCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentPluginRepoUpsertBulk { + _c.conflict = opts + return &AgentPluginRepoUpsertBulk{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentPluginRepo.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentPluginRepoCreateBulk) OnConflictColumns(columns ...string) *AgentPluginRepoUpsertBulk { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentPluginRepoUpsertBulk{ + create: _c, + } +} + +// AgentPluginRepoUpsertBulk is the builder for "upsert"-ing +// a bulk of AgentPluginRepo nodes. +type AgentPluginRepoUpsertBulk struct { + create *AgentPluginRepoCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.AgentPluginRepo.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentpluginrepo.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentPluginRepoUpsertBulk) UpdateNewValues() *AgentPluginRepoUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(agentpluginrepo.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentPluginRepo.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentPluginRepoUpsertBulk) Ignore() *AgentPluginRepoUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentPluginRepoUpsertBulk) DoNothing() *AgentPluginRepoUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentPluginRepoCreateBulk.OnConflict +// documentation for more info. +func (u *AgentPluginRepoUpsertBulk) Update(set func(*AgentPluginRepoUpsert)) *AgentPluginRepoUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentPluginRepoUpsert{UpdateSet: update}) + })) + return u +} + +// SetName sets the "name" field. +func (u *AgentPluginRepoUpsertBulk) SetName(v string) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateName() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateName() + }) +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentPluginRepoUpsertBulk) SetScopeType(v agentpluginrepo.ScopeType) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetScopeType(v) + }) +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateScopeType() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateScopeType() + }) +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentPluginRepoUpsertBulk) SetScopeID(v string) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetScopeID(v) + }) +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateScopeID() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateScopeID() + }) +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentPluginRepoUpsertBulk) SetCreatedBy(v uuid.UUID) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetCreatedBy(v) + }) +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateCreatedBy() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateCreatedBy() + }) +} + +// SetSourceType sets the "source_type" field. +func (u *AgentPluginRepoUpsertBulk) SetSourceType(v agentpluginrepo.SourceType) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetSourceType(v) + }) +} + +// UpdateSourceType sets the "source_type" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateSourceType() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateSourceType() + }) +} + +// SetGithubURL sets the "github_url" field. +func (u *AgentPluginRepoUpsertBulk) SetGithubURL(v string) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetGithubURL(v) + }) +} + +// UpdateGithubURL sets the "github_url" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateGithubURL() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateGithubURL() + }) +} + +// ClearGithubURL clears the value of the "github_url" field. +func (u *AgentPluginRepoUpsertBulk) ClearGithubURL() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearGithubURL() + }) +} + +// SetRefType sets the "ref_type" field. +func (u *AgentPluginRepoUpsertBulk) SetRefType(v agentpluginrepo.RefType) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetRefType(v) + }) +} + +// UpdateRefType sets the "ref_type" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateRefType() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateRefType() + }) +} + +// ClearRefType clears the value of the "ref_type" field. +func (u *AgentPluginRepoUpsertBulk) ClearRefType() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearRefType() + }) +} + +// SetRefValue sets the "ref_value" field. +func (u *AgentPluginRepoUpsertBulk) SetRefValue(v string) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetRefValue(v) + }) +} + +// UpdateRefValue sets the "ref_value" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateRefValue() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateRefValue() + }) +} + +// ClearRefValue clears the value of the "ref_value" field. +func (u *AgentPluginRepoUpsertBulk) ClearRefValue() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearRefValue() + }) +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (u *AgentPluginRepoUpsertBulk) SetLastUploadFilename(v string) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetLastUploadFilename(v) + }) +} + +// UpdateLastUploadFilename sets the "last_upload_filename" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateLastUploadFilename() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateLastUploadFilename() + }) +} + +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (u *AgentPluginRepoUpsertBulk) ClearLastUploadFilename() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearLastUploadFilename() + }) +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (u *AgentPluginRepoUpsertBulk) SetLastUploadAt(v time.Time) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetLastUploadAt(v) + }) +} + +// UpdateLastUploadAt sets the "last_upload_at" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateLastUploadAt() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateLastUploadAt() + }) +} + +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (u *AgentPluginRepoUpsertBulk) ClearLastUploadAt() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearLastUploadAt() + }) +} + +// SetPluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field. +func (u *AgentPluginRepoUpsertBulk) SetPluginDiscoveryAutoPackageJSON(v bool) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetPluginDiscoveryAutoPackageJSON(v) + }) +} + +// UpdatePluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdatePluginDiscoveryAutoPackageJSON() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdatePluginDiscoveryAutoPackageJSON() + }) +} + +// SetPluginManualEntries sets the "plugin_manual_entries" field. +func (u *AgentPluginRepoUpsertBulk) SetPluginManualEntries(v types.PluginManualEntries) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetPluginManualEntries(v) + }) +} + +// UpdatePluginManualEntries sets the "plugin_manual_entries" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdatePluginManualEntries() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdatePluginManualEntries() + }) +} + +// ClearPluginManualEntries clears the value of the "plugin_manual_entries" field. +func (u *AgentPluginRepoUpsertBulk) ClearPluginManualEntries() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearPluginManualEntries() + }) +} + +// SetNpmPackageName sets the "npm_package_name" field. +func (u *AgentPluginRepoUpsertBulk) SetNpmPackageName(v string) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetNpmPackageName(v) + }) +} + +// UpdateNpmPackageName sets the "npm_package_name" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateNpmPackageName() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateNpmPackageName() + }) +} + +// ClearNpmPackageName clears the value of the "npm_package_name" field. +func (u *AgentPluginRepoUpsertBulk) ClearNpmPackageName() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearNpmPackageName() + }) +} + +// SetNpmVersionSpec sets the "npm_version_spec" field. +func (u *AgentPluginRepoUpsertBulk) SetNpmVersionSpec(v string) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetNpmVersionSpec(v) + }) +} + +// UpdateNpmVersionSpec sets the "npm_version_spec" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateNpmVersionSpec() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateNpmVersionSpec() + }) +} + +// ClearNpmVersionSpec clears the value of the "npm_version_spec" field. +func (u *AgentPluginRepoUpsertBulk) ClearNpmVersionSpec() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearNpmVersionSpec() + }) +} + +// SetNpmRegistryURL sets the "npm_registry_url" field. +func (u *AgentPluginRepoUpsertBulk) SetNpmRegistryURL(v string) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetNpmRegistryURL(v) + }) +} + +// UpdateNpmRegistryURL sets the "npm_registry_url" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateNpmRegistryURL() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateNpmRegistryURL() + }) +} + +// ClearNpmRegistryURL clears the value of the "npm_registry_url" field. +func (u *AgentPluginRepoUpsertBulk) ClearNpmRegistryURL() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.ClearNpmRegistryURL() + }) +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentPluginRepoUpsertBulk) SetIsDeleted(v bool) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetIsDeleted(v) + }) +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateIsDeleted() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateIsDeleted() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentPluginRepoUpsertBulk) SetCreatedAt(v time.Time) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateCreatedAt() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentPluginRepoUpsertBulk) SetUpdatedAt(v time.Time) *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentPluginRepoUpsertBulk) UpdateUpdatedAt() *AgentPluginRepoUpsertBulk { + return u.Update(func(s *AgentPluginRepoUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentPluginRepoUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentPluginRepoCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentPluginRepoCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentPluginRepoUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentpluginrepo_delete.go b/backend/db/agentpluginrepo_delete.go new file mode 100644 index 00000000..52ae3cc2 --- /dev/null +++ b/backend/db/agentpluginrepo_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/predicate" +) + +// AgentPluginRepoDelete is the builder for deleting a AgentPluginRepo entity. +type AgentPluginRepoDelete struct { + config + hooks []Hook + mutation *AgentPluginRepoMutation +} + +// Where appends a list predicates to the AgentPluginRepoDelete builder. +func (_d *AgentPluginRepoDelete) Where(ps ...predicate.AgentPluginRepo) *AgentPluginRepoDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *AgentPluginRepoDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentPluginRepoDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *AgentPluginRepoDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(agentpluginrepo.Table, sqlgraph.NewFieldSpec(agentpluginrepo.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// AgentPluginRepoDeleteOne is the builder for deleting a single AgentPluginRepo entity. +type AgentPluginRepoDeleteOne struct { + _d *AgentPluginRepoDelete +} + +// Where appends a list predicates to the AgentPluginRepoDelete builder. +func (_d *AgentPluginRepoDeleteOne) Where(ps ...predicate.AgentPluginRepo) *AgentPluginRepoDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *AgentPluginRepoDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{agentpluginrepo.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentPluginRepoDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentpluginrepo_query.go b/backend/db/agentpluginrepo_query.go new file mode 100644 index 00000000..b4728654 --- /dev/null +++ b/backend/db/agentpluginrepo_query.go @@ -0,0 +1,657 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentPluginRepoQuery is the builder for querying AgentPluginRepo entities. +type AgentPluginRepoQuery struct { + config + ctx *QueryContext + order []agentpluginrepo.OrderOption + inters []Interceptor + predicates []predicate.AgentPluginRepo + withPlugins *AgentPluginQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the AgentPluginRepoQuery builder. +func (_q *AgentPluginRepoQuery) Where(ps ...predicate.AgentPluginRepo) *AgentPluginRepoQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *AgentPluginRepoQuery) Limit(limit int) *AgentPluginRepoQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *AgentPluginRepoQuery) Offset(offset int) *AgentPluginRepoQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *AgentPluginRepoQuery) Unique(unique bool) *AgentPluginRepoQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *AgentPluginRepoQuery) Order(o ...agentpluginrepo.OrderOption) *AgentPluginRepoQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryPlugins chains the current query on the "plugins" edge. +func (_q *AgentPluginRepoQuery) QueryPlugins() *AgentPluginQuery { + query := (&AgentPluginClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(agentpluginrepo.Table, agentpluginrepo.FieldID, selector), + sqlgraph.To(agentplugin.Table, agentplugin.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, agentpluginrepo.PluginsTable, agentpluginrepo.PluginsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first AgentPluginRepo entity from the query. +// Returns a *NotFoundError when no AgentPluginRepo was found. +func (_q *AgentPluginRepoQuery) First(ctx context.Context) (*AgentPluginRepo, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{agentpluginrepo.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *AgentPluginRepoQuery) FirstX(ctx context.Context) *AgentPluginRepo { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first AgentPluginRepo ID from the query. +// Returns a *NotFoundError when no AgentPluginRepo ID was found. +func (_q *AgentPluginRepoQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{agentpluginrepo.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *AgentPluginRepoQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single AgentPluginRepo entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one AgentPluginRepo entity is found. +// Returns a *NotFoundError when no AgentPluginRepo entities are found. +func (_q *AgentPluginRepoQuery) Only(ctx context.Context) (*AgentPluginRepo, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{agentpluginrepo.Label} + default: + return nil, &NotSingularError{agentpluginrepo.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *AgentPluginRepoQuery) OnlyX(ctx context.Context) *AgentPluginRepo { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only AgentPluginRepo ID in the query. +// Returns a *NotSingularError when more than one AgentPluginRepo ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *AgentPluginRepoQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{agentpluginrepo.Label} + default: + err = &NotSingularError{agentpluginrepo.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *AgentPluginRepoQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of AgentPluginRepos. +func (_q *AgentPluginRepoQuery) All(ctx context.Context) ([]*AgentPluginRepo, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*AgentPluginRepo, *AgentPluginRepoQuery]() + return withInterceptors[[]*AgentPluginRepo](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *AgentPluginRepoQuery) AllX(ctx context.Context) []*AgentPluginRepo { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of AgentPluginRepo IDs. +func (_q *AgentPluginRepoQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(agentpluginrepo.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *AgentPluginRepoQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *AgentPluginRepoQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*AgentPluginRepoQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *AgentPluginRepoQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *AgentPluginRepoQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *AgentPluginRepoQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AgentPluginRepoQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *AgentPluginRepoQuery) Clone() *AgentPluginRepoQuery { + if _q == nil { + return nil + } + return &AgentPluginRepoQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]agentpluginrepo.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.AgentPluginRepo{}, _q.predicates...), + withPlugins: _q.withPlugins.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithPlugins tells the query-builder to eager-load the nodes that are connected to +// the "plugins" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentPluginRepoQuery) WithPlugins(opts ...func(*AgentPluginQuery)) *AgentPluginRepoQuery { + query := (&AgentPluginClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withPlugins = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Name string `json:"name,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.AgentPluginRepo.Query(). +// GroupBy(agentpluginrepo.FieldName). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (_q *AgentPluginRepoQuery) GroupBy(field string, fields ...string) *AgentPluginRepoGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &AgentPluginRepoGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = agentpluginrepo.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Name string `json:"name,omitempty"` +// } +// +// client.AgentPluginRepo.Query(). +// Select(agentpluginrepo.FieldName). +// Scan(ctx, &v) +func (_q *AgentPluginRepoQuery) Select(fields ...string) *AgentPluginRepoSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &AgentPluginRepoSelect{AgentPluginRepoQuery: _q} + sbuild.label = agentpluginrepo.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AgentPluginRepoSelect configured with the given aggregations. +func (_q *AgentPluginRepoQuery) Aggregate(fns ...AggregateFunc) *AgentPluginRepoSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *AgentPluginRepoQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !agentpluginrepo.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *AgentPluginRepoQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AgentPluginRepo, error) { + var ( + nodes = []*AgentPluginRepo{} + _spec = _q.querySpec() + loadedTypes = [1]bool{ + _q.withPlugins != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*AgentPluginRepo).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &AgentPluginRepo{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withPlugins; query != nil { + if err := _q.loadPlugins(ctx, query, nodes, + func(n *AgentPluginRepo) { n.Edges.Plugins = []*AgentPlugin{} }, + func(n *AgentPluginRepo, e *AgentPlugin) { n.Edges.Plugins = append(n.Edges.Plugins, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *AgentPluginRepoQuery) loadPlugins(ctx context.Context, query *AgentPluginQuery, nodes []*AgentPluginRepo, init func(*AgentPluginRepo), assign func(*AgentPluginRepo, *AgentPlugin)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*AgentPluginRepo) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(agentplugin.FieldRepoID) + } + query.Where(predicate.AgentPlugin(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(agentpluginrepo.PluginsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.RepoID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "repo_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *AgentPluginRepoQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *AgentPluginRepoQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(agentpluginrepo.Table, agentpluginrepo.Columns, sqlgraph.NewFieldSpec(agentpluginrepo.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentpluginrepo.FieldID) + for i := range fields { + if fields[i] != agentpluginrepo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *AgentPluginRepoQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(agentpluginrepo.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = agentpluginrepo.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *AgentPluginRepoQuery) ForUpdate(opts ...sql.LockOption) *AgentPluginRepoQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *AgentPluginRepoQuery) ForShare(opts ...sql.LockOption) *AgentPluginRepoQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *AgentPluginRepoQuery) Modify(modifiers ...func(s *sql.Selector)) *AgentPluginRepoSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// AgentPluginRepoGroupBy is the group-by builder for AgentPluginRepo entities. +type AgentPluginRepoGroupBy struct { + selector + build *AgentPluginRepoQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *AgentPluginRepoGroupBy) Aggregate(fns ...AggregateFunc) *AgentPluginRepoGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *AgentPluginRepoGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentPluginRepoQuery, *AgentPluginRepoGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *AgentPluginRepoGroupBy) sqlScan(ctx context.Context, root *AgentPluginRepoQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// AgentPluginRepoSelect is the builder for selecting fields of AgentPluginRepo entities. +type AgentPluginRepoSelect struct { + *AgentPluginRepoQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *AgentPluginRepoSelect) Aggregate(fns ...AggregateFunc) *AgentPluginRepoSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *AgentPluginRepoSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentPluginRepoQuery, *AgentPluginRepoSelect](ctx, _s.AgentPluginRepoQuery, _s, _s.inters, v) +} + +func (_s *AgentPluginRepoSelect) sqlScan(ctx context.Context, root *AgentPluginRepoQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *AgentPluginRepoSelect) Modify(modifiers ...func(s *sql.Selector)) *AgentPluginRepoSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/backend/db/agentpluginrepo_update.go b/backend/db/agentpluginrepo_update.go new file mode 100644 index 00000000..2281f2ea --- /dev/null +++ b/backend/db/agentpluginrepo_update.go @@ -0,0 +1,1196 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/dialect/sql/sqljson" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentPluginRepoUpdate is the builder for updating AgentPluginRepo entities. +type AgentPluginRepoUpdate struct { + config + hooks []Hook + mutation *AgentPluginRepoMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the AgentPluginRepoUpdate builder. +func (_u *AgentPluginRepoUpdate) Where(ps ...predicate.AgentPluginRepo) *AgentPluginRepoUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetName sets the "name" field. +func (_u *AgentPluginRepoUpdate) SetName(v string) *AgentPluginRepoUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableName(v *string) *AgentPluginRepoUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetScopeType sets the "scope_type" field. +func (_u *AgentPluginRepoUpdate) SetScopeType(v agentpluginrepo.ScopeType) *AgentPluginRepoUpdate { + _u.mutation.SetScopeType(v) + return _u +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableScopeType(v *agentpluginrepo.ScopeType) *AgentPluginRepoUpdate { + if v != nil { + _u.SetScopeType(*v) + } + return _u +} + +// SetScopeID sets the "scope_id" field. +func (_u *AgentPluginRepoUpdate) SetScopeID(v string) *AgentPluginRepoUpdate { + _u.mutation.SetScopeID(v) + return _u +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableScopeID(v *string) *AgentPluginRepoUpdate { + if v != nil { + _u.SetScopeID(*v) + } + return _u +} + +// SetCreatedBy sets the "created_by" field. +func (_u *AgentPluginRepoUpdate) SetCreatedBy(v uuid.UUID) *AgentPluginRepoUpdate { + _u.mutation.SetCreatedBy(v) + return _u +} + +// SetNillableCreatedBy sets the "created_by" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableCreatedBy(v *uuid.UUID) *AgentPluginRepoUpdate { + if v != nil { + _u.SetCreatedBy(*v) + } + return _u +} + +// SetSourceType sets the "source_type" field. +func (_u *AgentPluginRepoUpdate) SetSourceType(v agentpluginrepo.SourceType) *AgentPluginRepoUpdate { + _u.mutation.SetSourceType(v) + return _u +} + +// SetNillableSourceType sets the "source_type" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableSourceType(v *agentpluginrepo.SourceType) *AgentPluginRepoUpdate { + if v != nil { + _u.SetSourceType(*v) + } + return _u +} + +// SetGithubURL sets the "github_url" field. +func (_u *AgentPluginRepoUpdate) SetGithubURL(v string) *AgentPluginRepoUpdate { + _u.mutation.SetGithubURL(v) + return _u +} + +// SetNillableGithubURL sets the "github_url" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableGithubURL(v *string) *AgentPluginRepoUpdate { + if v != nil { + _u.SetGithubURL(*v) + } + return _u +} + +// ClearGithubURL clears the value of the "github_url" field. +func (_u *AgentPluginRepoUpdate) ClearGithubURL() *AgentPluginRepoUpdate { + _u.mutation.ClearGithubURL() + return _u +} + +// SetRefType sets the "ref_type" field. +func (_u *AgentPluginRepoUpdate) SetRefType(v agentpluginrepo.RefType) *AgentPluginRepoUpdate { + _u.mutation.SetRefType(v) + return _u +} + +// SetNillableRefType sets the "ref_type" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableRefType(v *agentpluginrepo.RefType) *AgentPluginRepoUpdate { + if v != nil { + _u.SetRefType(*v) + } + return _u +} + +// ClearRefType clears the value of the "ref_type" field. +func (_u *AgentPluginRepoUpdate) ClearRefType() *AgentPluginRepoUpdate { + _u.mutation.ClearRefType() + return _u +} + +// SetRefValue sets the "ref_value" field. +func (_u *AgentPluginRepoUpdate) SetRefValue(v string) *AgentPluginRepoUpdate { + _u.mutation.SetRefValue(v) + return _u +} + +// SetNillableRefValue sets the "ref_value" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableRefValue(v *string) *AgentPluginRepoUpdate { + if v != nil { + _u.SetRefValue(*v) + } + return _u +} + +// ClearRefValue clears the value of the "ref_value" field. +func (_u *AgentPluginRepoUpdate) ClearRefValue() *AgentPluginRepoUpdate { + _u.mutation.ClearRefValue() + return _u +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (_u *AgentPluginRepoUpdate) SetLastUploadFilename(v string) *AgentPluginRepoUpdate { + _u.mutation.SetLastUploadFilename(v) + return _u +} + +// SetNillableLastUploadFilename sets the "last_upload_filename" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableLastUploadFilename(v *string) *AgentPluginRepoUpdate { + if v != nil { + _u.SetLastUploadFilename(*v) + } + return _u +} + +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (_u *AgentPluginRepoUpdate) ClearLastUploadFilename() *AgentPluginRepoUpdate { + _u.mutation.ClearLastUploadFilename() + return _u +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (_u *AgentPluginRepoUpdate) SetLastUploadAt(v time.Time) *AgentPluginRepoUpdate { + _u.mutation.SetLastUploadAt(v) + return _u +} + +// SetNillableLastUploadAt sets the "last_upload_at" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableLastUploadAt(v *time.Time) *AgentPluginRepoUpdate { + if v != nil { + _u.SetLastUploadAt(*v) + } + return _u +} + +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (_u *AgentPluginRepoUpdate) ClearLastUploadAt() *AgentPluginRepoUpdate { + _u.mutation.ClearLastUploadAt() + return _u +} + +// SetPluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field. +func (_u *AgentPluginRepoUpdate) SetPluginDiscoveryAutoPackageJSON(v bool) *AgentPluginRepoUpdate { + _u.mutation.SetPluginDiscoveryAutoPackageJSON(v) + return _u +} + +// SetNillablePluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillablePluginDiscoveryAutoPackageJSON(v *bool) *AgentPluginRepoUpdate { + if v != nil { + _u.SetPluginDiscoveryAutoPackageJSON(*v) + } + return _u +} + +// SetPluginManualEntries sets the "plugin_manual_entries" field. +func (_u *AgentPluginRepoUpdate) SetPluginManualEntries(v types.PluginManualEntries) *AgentPluginRepoUpdate { + _u.mutation.SetPluginManualEntries(v) + return _u +} + +// AppendPluginManualEntries appends value to the "plugin_manual_entries" field. +func (_u *AgentPluginRepoUpdate) AppendPluginManualEntries(v types.PluginManualEntries) *AgentPluginRepoUpdate { + _u.mutation.AppendPluginManualEntries(v) + return _u +} + +// ClearPluginManualEntries clears the value of the "plugin_manual_entries" field. +func (_u *AgentPluginRepoUpdate) ClearPluginManualEntries() *AgentPluginRepoUpdate { + _u.mutation.ClearPluginManualEntries() + return _u +} + +// SetNpmPackageName sets the "npm_package_name" field. +func (_u *AgentPluginRepoUpdate) SetNpmPackageName(v string) *AgentPluginRepoUpdate { + _u.mutation.SetNpmPackageName(v) + return _u +} + +// SetNillableNpmPackageName sets the "npm_package_name" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableNpmPackageName(v *string) *AgentPluginRepoUpdate { + if v != nil { + _u.SetNpmPackageName(*v) + } + return _u +} + +// ClearNpmPackageName clears the value of the "npm_package_name" field. +func (_u *AgentPluginRepoUpdate) ClearNpmPackageName() *AgentPluginRepoUpdate { + _u.mutation.ClearNpmPackageName() + return _u +} + +// SetNpmVersionSpec sets the "npm_version_spec" field. +func (_u *AgentPluginRepoUpdate) SetNpmVersionSpec(v string) *AgentPluginRepoUpdate { + _u.mutation.SetNpmVersionSpec(v) + return _u +} + +// SetNillableNpmVersionSpec sets the "npm_version_spec" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableNpmVersionSpec(v *string) *AgentPluginRepoUpdate { + if v != nil { + _u.SetNpmVersionSpec(*v) + } + return _u +} + +// ClearNpmVersionSpec clears the value of the "npm_version_spec" field. +func (_u *AgentPluginRepoUpdate) ClearNpmVersionSpec() *AgentPluginRepoUpdate { + _u.mutation.ClearNpmVersionSpec() + return _u +} + +// SetNpmRegistryURL sets the "npm_registry_url" field. +func (_u *AgentPluginRepoUpdate) SetNpmRegistryURL(v string) *AgentPluginRepoUpdate { + _u.mutation.SetNpmRegistryURL(v) + return _u +} + +// SetNillableNpmRegistryURL sets the "npm_registry_url" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableNpmRegistryURL(v *string) *AgentPluginRepoUpdate { + if v != nil { + _u.SetNpmRegistryURL(*v) + } + return _u +} + +// ClearNpmRegistryURL clears the value of the "npm_registry_url" field. +func (_u *AgentPluginRepoUpdate) ClearNpmRegistryURL() *AgentPluginRepoUpdate { + _u.mutation.ClearNpmRegistryURL() + return _u +} + +// SetIsDeleted sets the "is_deleted" field. +func (_u *AgentPluginRepoUpdate) SetIsDeleted(v bool) *AgentPluginRepoUpdate { + _u.mutation.SetIsDeleted(v) + return _u +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableIsDeleted(v *bool) *AgentPluginRepoUpdate { + if v != nil { + _u.SetIsDeleted(*v) + } + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentPluginRepoUpdate) SetCreatedAt(v time.Time) *AgentPluginRepoUpdate { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentPluginRepoUpdate) SetNillableCreatedAt(v *time.Time) *AgentPluginRepoUpdate { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentPluginRepoUpdate) SetUpdatedAt(v time.Time) *AgentPluginRepoUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// AddPluginIDs adds the "plugins" edge to the AgentPlugin entity by IDs. +func (_u *AgentPluginRepoUpdate) AddPluginIDs(ids ...uuid.UUID) *AgentPluginRepoUpdate { + _u.mutation.AddPluginIDs(ids...) + return _u +} + +// AddPlugins adds the "plugins" edges to the AgentPlugin entity. +func (_u *AgentPluginRepoUpdate) AddPlugins(v ...*AgentPlugin) *AgentPluginRepoUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPluginIDs(ids...) +} + +// Mutation returns the AgentPluginRepoMutation object of the builder. +func (_u *AgentPluginRepoUpdate) Mutation() *AgentPluginRepoMutation { + return _u.mutation +} + +// ClearPlugins clears all "plugins" edges to the AgentPlugin entity. +func (_u *AgentPluginRepoUpdate) ClearPlugins() *AgentPluginRepoUpdate { + _u.mutation.ClearPlugins() + return _u +} + +// RemovePluginIDs removes the "plugins" edge to AgentPlugin entities by IDs. +func (_u *AgentPluginRepoUpdate) RemovePluginIDs(ids ...uuid.UUID) *AgentPluginRepoUpdate { + _u.mutation.RemovePluginIDs(ids...) + return _u +} + +// RemovePlugins removes "plugins" edges to AgentPlugin entities. +func (_u *AgentPluginRepoUpdate) RemovePlugins(v ...*AgentPlugin) *AgentPluginRepoUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePluginIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AgentPluginRepoUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentPluginRepoUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AgentPluginRepoUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentPluginRepoUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentPluginRepoUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentpluginrepo.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentPluginRepoUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := agentpluginrepo.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.name": %w`, err)} + } + } + if v, ok := _u.mutation.ScopeType(); ok { + if err := agentpluginrepo.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.scope_type": %w`, err)} + } + } + if v, ok := _u.mutation.SourceType(); ok { + if err := agentpluginrepo.SourceTypeValidator(v); err != nil { + return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.source_type": %w`, err)} + } + } + if v, ok := _u.mutation.RefType(); ok { + if err := agentpluginrepo.RefTypeValidator(v); err != nil { + return &ValidationError{Name: "ref_type", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.ref_type": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentPluginRepoUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentPluginRepoUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentPluginRepoUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentpluginrepo.Table, agentpluginrepo.Columns, sqlgraph.NewFieldSpec(agentpluginrepo.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(agentpluginrepo.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.ScopeType(); ok { + _spec.SetField(agentpluginrepo.FieldScopeType, field.TypeEnum, value) + } + if value, ok := _u.mutation.ScopeID(); ok { + _spec.SetField(agentpluginrepo.FieldScopeID, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedBy(); ok { + _spec.SetField(agentpluginrepo.FieldCreatedBy, field.TypeUUID, value) + } + if value, ok := _u.mutation.SourceType(); ok { + _spec.SetField(agentpluginrepo.FieldSourceType, field.TypeEnum, value) + } + if value, ok := _u.mutation.GithubURL(); ok { + _spec.SetField(agentpluginrepo.FieldGithubURL, field.TypeString, value) + } + if _u.mutation.GithubURLCleared() { + _spec.ClearField(agentpluginrepo.FieldGithubURL, field.TypeString) + } + if value, ok := _u.mutation.RefType(); ok { + _spec.SetField(agentpluginrepo.FieldRefType, field.TypeEnum, value) + } + if _u.mutation.RefTypeCleared() { + _spec.ClearField(agentpluginrepo.FieldRefType, field.TypeEnum) + } + if value, ok := _u.mutation.RefValue(); ok { + _spec.SetField(agentpluginrepo.FieldRefValue, field.TypeString, value) + } + if _u.mutation.RefValueCleared() { + _spec.ClearField(agentpluginrepo.FieldRefValue, field.TypeString) + } + if value, ok := _u.mutation.LastUploadFilename(); ok { + _spec.SetField(agentpluginrepo.FieldLastUploadFilename, field.TypeString, value) + } + if _u.mutation.LastUploadFilenameCleared() { + _spec.ClearField(agentpluginrepo.FieldLastUploadFilename, field.TypeString) + } + if value, ok := _u.mutation.LastUploadAt(); ok { + _spec.SetField(agentpluginrepo.FieldLastUploadAt, field.TypeTime, value) + } + if _u.mutation.LastUploadAtCleared() { + _spec.ClearField(agentpluginrepo.FieldLastUploadAt, field.TypeTime) + } + if value, ok := _u.mutation.PluginDiscoveryAutoPackageJSON(); ok { + _spec.SetField(agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON, field.TypeBool, value) + } + if value, ok := _u.mutation.PluginManualEntries(); ok { + _spec.SetField(agentpluginrepo.FieldPluginManualEntries, field.TypeJSON, value) + } + if value, ok := _u.mutation.AppendedPluginManualEntries(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, agentpluginrepo.FieldPluginManualEntries, value) + }) + } + if _u.mutation.PluginManualEntriesCleared() { + _spec.ClearField(agentpluginrepo.FieldPluginManualEntries, field.TypeJSON) + } + if value, ok := _u.mutation.NpmPackageName(); ok { + _spec.SetField(agentpluginrepo.FieldNpmPackageName, field.TypeString, value) + } + if _u.mutation.NpmPackageNameCleared() { + _spec.ClearField(agentpluginrepo.FieldNpmPackageName, field.TypeString) + } + if value, ok := _u.mutation.NpmVersionSpec(); ok { + _spec.SetField(agentpluginrepo.FieldNpmVersionSpec, field.TypeString, value) + } + if _u.mutation.NpmVersionSpecCleared() { + _spec.ClearField(agentpluginrepo.FieldNpmVersionSpec, field.TypeString) + } + if value, ok := _u.mutation.NpmRegistryURL(); ok { + _spec.SetField(agentpluginrepo.FieldNpmRegistryURL, field.TypeString, value) + } + if _u.mutation.NpmRegistryURLCleared() { + _spec.ClearField(agentpluginrepo.FieldNpmRegistryURL, field.TypeString) + } + if value, ok := _u.mutation.IsDeleted(); ok { + _spec.SetField(agentpluginrepo.FieldIsDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentpluginrepo.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentpluginrepo.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.PluginsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentpluginrepo.PluginsTable, + Columns: []string{agentpluginrepo.PluginsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPluginsIDs(); len(nodes) > 0 && !_u.mutation.PluginsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentpluginrepo.PluginsTable, + Columns: []string{agentpluginrepo.PluginsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PluginsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentpluginrepo.PluginsTable, + Columns: []string{agentpluginrepo.PluginsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentpluginrepo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AgentPluginRepoUpdateOne is the builder for updating a single AgentPluginRepo entity. +type AgentPluginRepoUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AgentPluginRepoMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetName sets the "name" field. +func (_u *AgentPluginRepoUpdateOne) SetName(v string) *AgentPluginRepoUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableName(v *string) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetScopeType sets the "scope_type" field. +func (_u *AgentPluginRepoUpdateOne) SetScopeType(v agentpluginrepo.ScopeType) *AgentPluginRepoUpdateOne { + _u.mutation.SetScopeType(v) + return _u +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableScopeType(v *agentpluginrepo.ScopeType) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetScopeType(*v) + } + return _u +} + +// SetScopeID sets the "scope_id" field. +func (_u *AgentPluginRepoUpdateOne) SetScopeID(v string) *AgentPluginRepoUpdateOne { + _u.mutation.SetScopeID(v) + return _u +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableScopeID(v *string) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetScopeID(*v) + } + return _u +} + +// SetCreatedBy sets the "created_by" field. +func (_u *AgentPluginRepoUpdateOne) SetCreatedBy(v uuid.UUID) *AgentPluginRepoUpdateOne { + _u.mutation.SetCreatedBy(v) + return _u +} + +// SetNillableCreatedBy sets the "created_by" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableCreatedBy(v *uuid.UUID) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetCreatedBy(*v) + } + return _u +} + +// SetSourceType sets the "source_type" field. +func (_u *AgentPluginRepoUpdateOne) SetSourceType(v agentpluginrepo.SourceType) *AgentPluginRepoUpdateOne { + _u.mutation.SetSourceType(v) + return _u +} + +// SetNillableSourceType sets the "source_type" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableSourceType(v *agentpluginrepo.SourceType) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetSourceType(*v) + } + return _u +} + +// SetGithubURL sets the "github_url" field. +func (_u *AgentPluginRepoUpdateOne) SetGithubURL(v string) *AgentPluginRepoUpdateOne { + _u.mutation.SetGithubURL(v) + return _u +} + +// SetNillableGithubURL sets the "github_url" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableGithubURL(v *string) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetGithubURL(*v) + } + return _u +} + +// ClearGithubURL clears the value of the "github_url" field. +func (_u *AgentPluginRepoUpdateOne) ClearGithubURL() *AgentPluginRepoUpdateOne { + _u.mutation.ClearGithubURL() + return _u +} + +// SetRefType sets the "ref_type" field. +func (_u *AgentPluginRepoUpdateOne) SetRefType(v agentpluginrepo.RefType) *AgentPluginRepoUpdateOne { + _u.mutation.SetRefType(v) + return _u +} + +// SetNillableRefType sets the "ref_type" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableRefType(v *agentpluginrepo.RefType) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetRefType(*v) + } + return _u +} + +// ClearRefType clears the value of the "ref_type" field. +func (_u *AgentPluginRepoUpdateOne) ClearRefType() *AgentPluginRepoUpdateOne { + _u.mutation.ClearRefType() + return _u +} + +// SetRefValue sets the "ref_value" field. +func (_u *AgentPluginRepoUpdateOne) SetRefValue(v string) *AgentPluginRepoUpdateOne { + _u.mutation.SetRefValue(v) + return _u +} + +// SetNillableRefValue sets the "ref_value" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableRefValue(v *string) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetRefValue(*v) + } + return _u +} + +// ClearRefValue clears the value of the "ref_value" field. +func (_u *AgentPluginRepoUpdateOne) ClearRefValue() *AgentPluginRepoUpdateOne { + _u.mutation.ClearRefValue() + return _u +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (_u *AgentPluginRepoUpdateOne) SetLastUploadFilename(v string) *AgentPluginRepoUpdateOne { + _u.mutation.SetLastUploadFilename(v) + return _u +} + +// SetNillableLastUploadFilename sets the "last_upload_filename" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableLastUploadFilename(v *string) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetLastUploadFilename(*v) + } + return _u +} + +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (_u *AgentPluginRepoUpdateOne) ClearLastUploadFilename() *AgentPluginRepoUpdateOne { + _u.mutation.ClearLastUploadFilename() + return _u +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (_u *AgentPluginRepoUpdateOne) SetLastUploadAt(v time.Time) *AgentPluginRepoUpdateOne { + _u.mutation.SetLastUploadAt(v) + return _u +} + +// SetNillableLastUploadAt sets the "last_upload_at" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableLastUploadAt(v *time.Time) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetLastUploadAt(*v) + } + return _u +} + +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (_u *AgentPluginRepoUpdateOne) ClearLastUploadAt() *AgentPluginRepoUpdateOne { + _u.mutation.ClearLastUploadAt() + return _u +} + +// SetPluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field. +func (_u *AgentPluginRepoUpdateOne) SetPluginDiscoveryAutoPackageJSON(v bool) *AgentPluginRepoUpdateOne { + _u.mutation.SetPluginDiscoveryAutoPackageJSON(v) + return _u +} + +// SetNillablePluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillablePluginDiscoveryAutoPackageJSON(v *bool) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetPluginDiscoveryAutoPackageJSON(*v) + } + return _u +} + +// SetPluginManualEntries sets the "plugin_manual_entries" field. +func (_u *AgentPluginRepoUpdateOne) SetPluginManualEntries(v types.PluginManualEntries) *AgentPluginRepoUpdateOne { + _u.mutation.SetPluginManualEntries(v) + return _u +} + +// AppendPluginManualEntries appends value to the "plugin_manual_entries" field. +func (_u *AgentPluginRepoUpdateOne) AppendPluginManualEntries(v types.PluginManualEntries) *AgentPluginRepoUpdateOne { + _u.mutation.AppendPluginManualEntries(v) + return _u +} + +// ClearPluginManualEntries clears the value of the "plugin_manual_entries" field. +func (_u *AgentPluginRepoUpdateOne) ClearPluginManualEntries() *AgentPluginRepoUpdateOne { + _u.mutation.ClearPluginManualEntries() + return _u +} + +// SetNpmPackageName sets the "npm_package_name" field. +func (_u *AgentPluginRepoUpdateOne) SetNpmPackageName(v string) *AgentPluginRepoUpdateOne { + _u.mutation.SetNpmPackageName(v) + return _u +} + +// SetNillableNpmPackageName sets the "npm_package_name" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableNpmPackageName(v *string) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetNpmPackageName(*v) + } + return _u +} + +// ClearNpmPackageName clears the value of the "npm_package_name" field. +func (_u *AgentPluginRepoUpdateOne) ClearNpmPackageName() *AgentPluginRepoUpdateOne { + _u.mutation.ClearNpmPackageName() + return _u +} + +// SetNpmVersionSpec sets the "npm_version_spec" field. +func (_u *AgentPluginRepoUpdateOne) SetNpmVersionSpec(v string) *AgentPluginRepoUpdateOne { + _u.mutation.SetNpmVersionSpec(v) + return _u +} + +// SetNillableNpmVersionSpec sets the "npm_version_spec" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableNpmVersionSpec(v *string) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetNpmVersionSpec(*v) + } + return _u +} + +// ClearNpmVersionSpec clears the value of the "npm_version_spec" field. +func (_u *AgentPluginRepoUpdateOne) ClearNpmVersionSpec() *AgentPluginRepoUpdateOne { + _u.mutation.ClearNpmVersionSpec() + return _u +} + +// SetNpmRegistryURL sets the "npm_registry_url" field. +func (_u *AgentPluginRepoUpdateOne) SetNpmRegistryURL(v string) *AgentPluginRepoUpdateOne { + _u.mutation.SetNpmRegistryURL(v) + return _u +} + +// SetNillableNpmRegistryURL sets the "npm_registry_url" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableNpmRegistryURL(v *string) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetNpmRegistryURL(*v) + } + return _u +} + +// ClearNpmRegistryURL clears the value of the "npm_registry_url" field. +func (_u *AgentPluginRepoUpdateOne) ClearNpmRegistryURL() *AgentPluginRepoUpdateOne { + _u.mutation.ClearNpmRegistryURL() + return _u +} + +// SetIsDeleted sets the "is_deleted" field. +func (_u *AgentPluginRepoUpdateOne) SetIsDeleted(v bool) *AgentPluginRepoUpdateOne { + _u.mutation.SetIsDeleted(v) + return _u +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableIsDeleted(v *bool) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetIsDeleted(*v) + } + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentPluginRepoUpdateOne) SetCreatedAt(v time.Time) *AgentPluginRepoUpdateOne { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentPluginRepoUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentPluginRepoUpdateOne { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentPluginRepoUpdateOne) SetUpdatedAt(v time.Time) *AgentPluginRepoUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// AddPluginIDs adds the "plugins" edge to the AgentPlugin entity by IDs. +func (_u *AgentPluginRepoUpdateOne) AddPluginIDs(ids ...uuid.UUID) *AgentPluginRepoUpdateOne { + _u.mutation.AddPluginIDs(ids...) + return _u +} + +// AddPlugins adds the "plugins" edges to the AgentPlugin entity. +func (_u *AgentPluginRepoUpdateOne) AddPlugins(v ...*AgentPlugin) *AgentPluginRepoUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPluginIDs(ids...) +} + +// Mutation returns the AgentPluginRepoMutation object of the builder. +func (_u *AgentPluginRepoUpdateOne) Mutation() *AgentPluginRepoMutation { + return _u.mutation +} + +// ClearPlugins clears all "plugins" edges to the AgentPlugin entity. +func (_u *AgentPluginRepoUpdateOne) ClearPlugins() *AgentPluginRepoUpdateOne { + _u.mutation.ClearPlugins() + return _u +} + +// RemovePluginIDs removes the "plugins" edge to AgentPlugin entities by IDs. +func (_u *AgentPluginRepoUpdateOne) RemovePluginIDs(ids ...uuid.UUID) *AgentPluginRepoUpdateOne { + _u.mutation.RemovePluginIDs(ids...) + return _u +} + +// RemovePlugins removes "plugins" edges to AgentPlugin entities. +func (_u *AgentPluginRepoUpdateOne) RemovePlugins(v ...*AgentPlugin) *AgentPluginRepoUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePluginIDs(ids...) +} + +// Where appends a list predicates to the AgentPluginRepoUpdate builder. +func (_u *AgentPluginRepoUpdateOne) Where(ps ...predicate.AgentPluginRepo) *AgentPluginRepoUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *AgentPluginRepoUpdateOne) Select(field string, fields ...string) *AgentPluginRepoUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated AgentPluginRepo entity. +func (_u *AgentPluginRepoUpdateOne) Save(ctx context.Context) (*AgentPluginRepo, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentPluginRepoUpdateOne) SaveX(ctx context.Context) *AgentPluginRepo { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AgentPluginRepoUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentPluginRepoUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentPluginRepoUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentpluginrepo.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentPluginRepoUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := agentpluginrepo.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.name": %w`, err)} + } + } + if v, ok := _u.mutation.ScopeType(); ok { + if err := agentpluginrepo.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.scope_type": %w`, err)} + } + } + if v, ok := _u.mutation.SourceType(); ok { + if err := agentpluginrepo.SourceTypeValidator(v); err != nil { + return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.source_type": %w`, err)} + } + } + if v, ok := _u.mutation.RefType(); ok { + if err := agentpluginrepo.RefTypeValidator(v); err != nil { + return &ValidationError{Name: "ref_type", err: fmt.Errorf(`db: validator failed for field "AgentPluginRepo.ref_type": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentPluginRepoUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentPluginRepoUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentPluginRepoUpdateOne) sqlSave(ctx context.Context) (_node *AgentPluginRepo, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentpluginrepo.Table, agentpluginrepo.Columns, sqlgraph.NewFieldSpec(agentpluginrepo.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentPluginRepo.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentpluginrepo.FieldID) + for _, f := range fields { + if !agentpluginrepo.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != agentpluginrepo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(agentpluginrepo.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.ScopeType(); ok { + _spec.SetField(agentpluginrepo.FieldScopeType, field.TypeEnum, value) + } + if value, ok := _u.mutation.ScopeID(); ok { + _spec.SetField(agentpluginrepo.FieldScopeID, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedBy(); ok { + _spec.SetField(agentpluginrepo.FieldCreatedBy, field.TypeUUID, value) + } + if value, ok := _u.mutation.SourceType(); ok { + _spec.SetField(agentpluginrepo.FieldSourceType, field.TypeEnum, value) + } + if value, ok := _u.mutation.GithubURL(); ok { + _spec.SetField(agentpluginrepo.FieldGithubURL, field.TypeString, value) + } + if _u.mutation.GithubURLCleared() { + _spec.ClearField(agentpluginrepo.FieldGithubURL, field.TypeString) + } + if value, ok := _u.mutation.RefType(); ok { + _spec.SetField(agentpluginrepo.FieldRefType, field.TypeEnum, value) + } + if _u.mutation.RefTypeCleared() { + _spec.ClearField(agentpluginrepo.FieldRefType, field.TypeEnum) + } + if value, ok := _u.mutation.RefValue(); ok { + _spec.SetField(agentpluginrepo.FieldRefValue, field.TypeString, value) + } + if _u.mutation.RefValueCleared() { + _spec.ClearField(agentpluginrepo.FieldRefValue, field.TypeString) + } + if value, ok := _u.mutation.LastUploadFilename(); ok { + _spec.SetField(agentpluginrepo.FieldLastUploadFilename, field.TypeString, value) + } + if _u.mutation.LastUploadFilenameCleared() { + _spec.ClearField(agentpluginrepo.FieldLastUploadFilename, field.TypeString) + } + if value, ok := _u.mutation.LastUploadAt(); ok { + _spec.SetField(agentpluginrepo.FieldLastUploadAt, field.TypeTime, value) + } + if _u.mutation.LastUploadAtCleared() { + _spec.ClearField(agentpluginrepo.FieldLastUploadAt, field.TypeTime) + } + if value, ok := _u.mutation.PluginDiscoveryAutoPackageJSON(); ok { + _spec.SetField(agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON, field.TypeBool, value) + } + if value, ok := _u.mutation.PluginManualEntries(); ok { + _spec.SetField(agentpluginrepo.FieldPluginManualEntries, field.TypeJSON, value) + } + if value, ok := _u.mutation.AppendedPluginManualEntries(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, agentpluginrepo.FieldPluginManualEntries, value) + }) + } + if _u.mutation.PluginManualEntriesCleared() { + _spec.ClearField(agentpluginrepo.FieldPluginManualEntries, field.TypeJSON) + } + if value, ok := _u.mutation.NpmPackageName(); ok { + _spec.SetField(agentpluginrepo.FieldNpmPackageName, field.TypeString, value) + } + if _u.mutation.NpmPackageNameCleared() { + _spec.ClearField(agentpluginrepo.FieldNpmPackageName, field.TypeString) + } + if value, ok := _u.mutation.NpmVersionSpec(); ok { + _spec.SetField(agentpluginrepo.FieldNpmVersionSpec, field.TypeString, value) + } + if _u.mutation.NpmVersionSpecCleared() { + _spec.ClearField(agentpluginrepo.FieldNpmVersionSpec, field.TypeString) + } + if value, ok := _u.mutation.NpmRegistryURL(); ok { + _spec.SetField(agentpluginrepo.FieldNpmRegistryURL, field.TypeString, value) + } + if _u.mutation.NpmRegistryURLCleared() { + _spec.ClearField(agentpluginrepo.FieldNpmRegistryURL, field.TypeString) + } + if value, ok := _u.mutation.IsDeleted(); ok { + _spec.SetField(agentpluginrepo.FieldIsDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentpluginrepo.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentpluginrepo.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.PluginsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentpluginrepo.PluginsTable, + Columns: []string{agentpluginrepo.PluginsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPluginsIDs(); len(nodes) > 0 && !_u.mutation.PluginsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentpluginrepo.PluginsTable, + Columns: []string{agentpluginrepo.PluginsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PluginsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentpluginrepo.PluginsTable, + Columns: []string{agentpluginrepo.PluginsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &AgentPluginRepo{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentpluginrepo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/db/agentpluginversion.go b/backend/db/agentpluginversion.go new file mode 100644 index 00000000..f265e317 --- /dev/null +++ b/backend/db/agentpluginversion.go @@ -0,0 +1,186 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentPluginVersion is the model entity for the AgentPluginVersion schema. +type AgentPluginVersion struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // ResourceID holds the value of the "resource_id" field. + ResourceID uuid.UUID `json:"resource_id,omitempty"` + // Version holds the value of the "version" field. + Version string `json:"version,omitempty"` + // S3Key holds the value of the "s3_key" field. + S3Key string `json:"s3_key,omitempty"` + // ParsedMeta holds the value of the "parsed_meta" field. + ParsedMeta types.PluginParsedMeta `json:"parsed_meta,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the AgentPluginVersionQuery when eager-loading is set. + Edges AgentPluginVersionEdges `json:"edges"` + selectValues sql.SelectValues +} + +// AgentPluginVersionEdges holds the relations/edges for other nodes in the graph. +type AgentPluginVersionEdges struct { + // Plugin holds the value of the plugin edge. + Plugin *AgentPlugin `json:"plugin,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// PluginOrErr returns the Plugin value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e AgentPluginVersionEdges) PluginOrErr() (*AgentPlugin, error) { + if e.Plugin != nil { + return e.Plugin, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: agentplugin.Label} + } + return nil, &NotLoadedError{edge: "plugin"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*AgentPluginVersion) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case agentpluginversion.FieldParsedMeta: + values[i] = new([]byte) + case agentpluginversion.FieldVersion, agentpluginversion.FieldS3Key: + values[i] = new(sql.NullString) + case agentpluginversion.FieldCreatedAt: + values[i] = new(sql.NullTime) + case agentpluginversion.FieldID, agentpluginversion.FieldResourceID: + values[i] = new(uuid.UUID) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the AgentPluginVersion fields. +func (_m *AgentPluginVersion) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case agentpluginversion.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case agentpluginversion.FieldResourceID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field resource_id", values[i]) + } else if value != nil { + _m.ResourceID = *value + } + case agentpluginversion.FieldVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version", values[i]) + } else if value.Valid { + _m.Version = value.String + } + case agentpluginversion.FieldS3Key: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field s3_key", values[i]) + } else if value.Valid { + _m.S3Key = value.String + } + case agentpluginversion.FieldParsedMeta: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field parsed_meta", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.ParsedMeta); err != nil { + return fmt.Errorf("unmarshal field parsed_meta: %w", err) + } + } + case agentpluginversion.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the AgentPluginVersion. +// This includes values selected through modifiers, order, etc. +func (_m *AgentPluginVersion) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryPlugin queries the "plugin" edge of the AgentPluginVersion entity. +func (_m *AgentPluginVersion) QueryPlugin() *AgentPluginQuery { + return NewAgentPluginVersionClient(_m.config).QueryPlugin(_m) +} + +// Update returns a builder for updating this AgentPluginVersion. +// Note that you need to call AgentPluginVersion.Unwrap() before calling this method if this AgentPluginVersion +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *AgentPluginVersion) Update() *AgentPluginVersionUpdateOne { + return NewAgentPluginVersionClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the AgentPluginVersion entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *AgentPluginVersion) Unwrap() *AgentPluginVersion { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("db: AgentPluginVersion is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *AgentPluginVersion) String() string { + var builder strings.Builder + builder.WriteString("AgentPluginVersion(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("resource_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ResourceID)) + builder.WriteString(", ") + builder.WriteString("version=") + builder.WriteString(_m.Version) + builder.WriteString(", ") + builder.WriteString("s3_key=") + builder.WriteString(_m.S3Key) + builder.WriteString(", ") + builder.WriteString("parsed_meta=") + builder.WriteString(fmt.Sprintf("%v", _m.ParsedMeta)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// AgentPluginVersions is a parsable slice of AgentPluginVersion. +type AgentPluginVersions []*AgentPluginVersion diff --git a/backend/db/agentpluginversion/agentpluginversion.go b/backend/db/agentpluginversion/agentpluginversion.go new file mode 100644 index 00000000..bde38d0a --- /dev/null +++ b/backend/db/agentpluginversion/agentpluginversion.go @@ -0,0 +1,112 @@ +// Code generated by ent, DO NOT EDIT. + +package agentpluginversion + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the agentpluginversion type in the database. + Label = "agent_plugin_version" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldResourceID holds the string denoting the resource_id field in the database. + FieldResourceID = "resource_id" + // FieldVersion holds the string denoting the version field in the database. + FieldVersion = "version" + // FieldS3Key holds the string denoting the s3_key field in the database. + FieldS3Key = "s3_key" + // FieldParsedMeta holds the string denoting the parsed_meta field in the database. + FieldParsedMeta = "parsed_meta" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // EdgePlugin holds the string denoting the plugin edge name in mutations. + EdgePlugin = "plugin" + // Table holds the table name of the agentpluginversion in the database. + Table = "agent_plugin_versions" + // PluginTable is the table that holds the plugin relation/edge. + PluginTable = "agent_plugin_versions" + // PluginInverseTable is the table name for the AgentPlugin entity. + // It exists in this package in order to avoid circular dependency with the "agentplugin" package. + PluginInverseTable = "agent_plugins" + // PluginColumn is the table column denoting the plugin relation/edge. + PluginColumn = "resource_id" +) + +// Columns holds all SQL columns for agentpluginversion fields. +var Columns = []string{ + FieldID, + FieldResourceID, + FieldVersion, + FieldS3Key, + FieldParsedMeta, + FieldCreatedAt, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // VersionValidator is a validator for the "version" field. It is called by the builders before save. + VersionValidator func(string) error + // S3KeyValidator is a validator for the "s3_key" field. It is called by the builders before save. + S3KeyValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// OrderOption defines the ordering options for the AgentPluginVersion queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByResourceID orders the results by the resource_id field. +func ByResourceID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldResourceID, opts...).ToFunc() +} + +// ByVersion orders the results by the version field. +func ByVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersion, opts...).ToFunc() +} + +// ByS3Key orders the results by the s3_key field. +func ByS3Key(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldS3Key, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByPluginField orders the results by plugin field. +func ByPluginField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPluginStep(), sql.OrderByField(field, opts...)) + } +} +func newPluginStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PluginInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, PluginTable, PluginColumn), + ) +} diff --git a/backend/db/agentpluginversion/where.go b/backend/db/agentpluginversion/where.go new file mode 100644 index 00000000..395c1d66 --- /dev/null +++ b/backend/db/agentpluginversion/where.go @@ -0,0 +1,315 @@ +// Code generated by ent, DO NOT EDIT. + +package agentpluginversion + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldLTE(FieldID, id)) +} + +// ResourceID applies equality check predicate on the "resource_id" field. It's identical to ResourceIDEQ. +func ResourceID(v uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEQ(FieldResourceID, v)) +} + +// Version applies equality check predicate on the "version" field. It's identical to VersionEQ. +func Version(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEQ(FieldVersion, v)) +} + +// S3Key applies equality check predicate on the "s3_key" field. It's identical to S3KeyEQ. +func S3Key(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEQ(FieldS3Key, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEQ(FieldCreatedAt, v)) +} + +// ResourceIDEQ applies the EQ predicate on the "resource_id" field. +func ResourceIDEQ(v uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEQ(FieldResourceID, v)) +} + +// ResourceIDNEQ applies the NEQ predicate on the "resource_id" field. +func ResourceIDNEQ(v uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNEQ(FieldResourceID, v)) +} + +// ResourceIDIn applies the In predicate on the "resource_id" field. +func ResourceIDIn(vs ...uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldIn(FieldResourceID, vs...)) +} + +// ResourceIDNotIn applies the NotIn predicate on the "resource_id" field. +func ResourceIDNotIn(vs ...uuid.UUID) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNotIn(FieldResourceID, vs...)) +} + +// VersionEQ applies the EQ predicate on the "version" field. +func VersionEQ(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEQ(FieldVersion, v)) +} + +// VersionNEQ applies the NEQ predicate on the "version" field. +func VersionNEQ(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNEQ(FieldVersion, v)) +} + +// VersionIn applies the In predicate on the "version" field. +func VersionIn(vs ...string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldIn(FieldVersion, vs...)) +} + +// VersionNotIn applies the NotIn predicate on the "version" field. +func VersionNotIn(vs ...string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNotIn(FieldVersion, vs...)) +} + +// VersionGT applies the GT predicate on the "version" field. +func VersionGT(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldGT(FieldVersion, v)) +} + +// VersionGTE applies the GTE predicate on the "version" field. +func VersionGTE(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldGTE(FieldVersion, v)) +} + +// VersionLT applies the LT predicate on the "version" field. +func VersionLT(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldLT(FieldVersion, v)) +} + +// VersionLTE applies the LTE predicate on the "version" field. +func VersionLTE(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldLTE(FieldVersion, v)) +} + +// VersionContains applies the Contains predicate on the "version" field. +func VersionContains(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldContains(FieldVersion, v)) +} + +// VersionHasPrefix applies the HasPrefix predicate on the "version" field. +func VersionHasPrefix(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldHasPrefix(FieldVersion, v)) +} + +// VersionHasSuffix applies the HasSuffix predicate on the "version" field. +func VersionHasSuffix(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldHasSuffix(FieldVersion, v)) +} + +// VersionEqualFold applies the EqualFold predicate on the "version" field. +func VersionEqualFold(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEqualFold(FieldVersion, v)) +} + +// VersionContainsFold applies the ContainsFold predicate on the "version" field. +func VersionContainsFold(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldContainsFold(FieldVersion, v)) +} + +// S3KeyEQ applies the EQ predicate on the "s3_key" field. +func S3KeyEQ(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEQ(FieldS3Key, v)) +} + +// S3KeyNEQ applies the NEQ predicate on the "s3_key" field. +func S3KeyNEQ(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNEQ(FieldS3Key, v)) +} + +// S3KeyIn applies the In predicate on the "s3_key" field. +func S3KeyIn(vs ...string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldIn(FieldS3Key, vs...)) +} + +// S3KeyNotIn applies the NotIn predicate on the "s3_key" field. +func S3KeyNotIn(vs ...string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNotIn(FieldS3Key, vs...)) +} + +// S3KeyGT applies the GT predicate on the "s3_key" field. +func S3KeyGT(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldGT(FieldS3Key, v)) +} + +// S3KeyGTE applies the GTE predicate on the "s3_key" field. +func S3KeyGTE(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldGTE(FieldS3Key, v)) +} + +// S3KeyLT applies the LT predicate on the "s3_key" field. +func S3KeyLT(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldLT(FieldS3Key, v)) +} + +// S3KeyLTE applies the LTE predicate on the "s3_key" field. +func S3KeyLTE(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldLTE(FieldS3Key, v)) +} + +// S3KeyContains applies the Contains predicate on the "s3_key" field. +func S3KeyContains(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldContains(FieldS3Key, v)) +} + +// S3KeyHasPrefix applies the HasPrefix predicate on the "s3_key" field. +func S3KeyHasPrefix(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldHasPrefix(FieldS3Key, v)) +} + +// S3KeyHasSuffix applies the HasSuffix predicate on the "s3_key" field. +func S3KeyHasSuffix(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldHasSuffix(FieldS3Key, v)) +} + +// S3KeyEqualFold applies the EqualFold predicate on the "s3_key" field. +func S3KeyEqualFold(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEqualFold(FieldS3Key, v)) +} + +// S3KeyContainsFold applies the ContainsFold predicate on the "s3_key" field. +func S3KeyContainsFold(v string) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldContainsFold(FieldS3Key, v)) +} + +// ParsedMetaIsNil applies the IsNil predicate on the "parsed_meta" field. +func ParsedMetaIsNil() predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldIsNull(FieldParsedMeta)) +} + +// ParsedMetaNotNil applies the NotNil predicate on the "parsed_meta" field. +func ParsedMetaNotNil() predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNotNull(FieldParsedMeta)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.FieldLTE(FieldCreatedAt, v)) +} + +// HasPlugin applies the HasEdge predicate on the "plugin" edge. +func HasPlugin() predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, PluginTable, PluginColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPluginWith applies the HasEdge predicate on the "plugin" edge with a given conditions (other predicates). +func HasPluginWith(preds ...predicate.AgentPlugin) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(func(s *sql.Selector) { + step := newPluginStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.AgentPluginVersion) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.AgentPluginVersion) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.AgentPluginVersion) predicate.AgentPluginVersion { + return predicate.AgentPluginVersion(sql.NotPredicates(p)) +} diff --git a/backend/db/agentpluginversion_create.go b/backend/db/agentpluginversion_create.go new file mode 100644 index 00000000..ea5b46cd --- /dev/null +++ b/backend/db/agentpluginversion_create.go @@ -0,0 +1,797 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentPluginVersionCreate is the builder for creating a AgentPluginVersion entity. +type AgentPluginVersionCreate struct { + config + mutation *AgentPluginVersionMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetResourceID sets the "resource_id" field. +func (_c *AgentPluginVersionCreate) SetResourceID(v uuid.UUID) *AgentPluginVersionCreate { + _c.mutation.SetResourceID(v) + return _c +} + +// SetVersion sets the "version" field. +func (_c *AgentPluginVersionCreate) SetVersion(v string) *AgentPluginVersionCreate { + _c.mutation.SetVersion(v) + return _c +} + +// SetS3Key sets the "s3_key" field. +func (_c *AgentPluginVersionCreate) SetS3Key(v string) *AgentPluginVersionCreate { + _c.mutation.SetS3Key(v) + return _c +} + +// SetParsedMeta sets the "parsed_meta" field. +func (_c *AgentPluginVersionCreate) SetParsedMeta(v types.PluginParsedMeta) *AgentPluginVersionCreate { + _c.mutation.SetParsedMeta(v) + return _c +} + +// SetNillableParsedMeta sets the "parsed_meta" field if the given value is not nil. +func (_c *AgentPluginVersionCreate) SetNillableParsedMeta(v *types.PluginParsedMeta) *AgentPluginVersionCreate { + if v != nil { + _c.SetParsedMeta(*v) + } + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AgentPluginVersionCreate) SetCreatedAt(v time.Time) *AgentPluginVersionCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AgentPluginVersionCreate) SetNillableCreatedAt(v *time.Time) *AgentPluginVersionCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AgentPluginVersionCreate) SetID(v uuid.UUID) *AgentPluginVersionCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AgentPluginVersionCreate) SetNillableID(v *uuid.UUID) *AgentPluginVersionCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetPluginID sets the "plugin" edge to the AgentPlugin entity by ID. +func (_c *AgentPluginVersionCreate) SetPluginID(id uuid.UUID) *AgentPluginVersionCreate { + _c.mutation.SetPluginID(id) + return _c +} + +// SetPlugin sets the "plugin" edge to the AgentPlugin entity. +func (_c *AgentPluginVersionCreate) SetPlugin(v *AgentPlugin) *AgentPluginVersionCreate { + return _c.SetPluginID(v.ID) +} + +// Mutation returns the AgentPluginVersionMutation object of the builder. +func (_c *AgentPluginVersionCreate) Mutation() *AgentPluginVersionMutation { + return _c.mutation +} + +// Save creates the AgentPluginVersion in the database. +func (_c *AgentPluginVersionCreate) Save(ctx context.Context) (*AgentPluginVersion, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AgentPluginVersionCreate) SaveX(ctx context.Context) *AgentPluginVersion { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentPluginVersionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentPluginVersionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AgentPluginVersionCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := agentpluginversion.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := agentpluginversion.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AgentPluginVersionCreate) check() error { + if _, ok := _c.mutation.ResourceID(); !ok { + return &ValidationError{Name: "resource_id", err: errors.New(`db: missing required field "AgentPluginVersion.resource_id"`)} + } + if _, ok := _c.mutation.Version(); !ok { + return &ValidationError{Name: "version", err: errors.New(`db: missing required field "AgentPluginVersion.version"`)} + } + if v, ok := _c.mutation.Version(); ok { + if err := agentpluginversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "AgentPluginVersion.version": %w`, err)} + } + } + if _, ok := _c.mutation.S3Key(); !ok { + return &ValidationError{Name: "s3_key", err: errors.New(`db: missing required field "AgentPluginVersion.s3_key"`)} + } + if v, ok := _c.mutation.S3Key(); ok { + if err := agentpluginversion.S3KeyValidator(v); err != nil { + return &ValidationError{Name: "s3_key", err: fmt.Errorf(`db: validator failed for field "AgentPluginVersion.s3_key": %w`, err)} + } + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentPluginVersion.created_at"`)} + } + if len(_c.mutation.PluginIDs()) == 0 { + return &ValidationError{Name: "plugin", err: errors.New(`db: missing required edge "AgentPluginVersion.plugin"`)} + } + return nil +} + +func (_c *AgentPluginVersionCreate) sqlSave(ctx context.Context) (*AgentPluginVersion, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AgentPluginVersionCreate) createSpec() (*AgentPluginVersion, *sqlgraph.CreateSpec) { + var ( + _node = &AgentPluginVersion{config: _c.config} + _spec = sqlgraph.NewCreateSpec(agentpluginversion.Table, sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID)) + ) + _spec.OnConflict = _c.conflict + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.Version(); ok { + _spec.SetField(agentpluginversion.FieldVersion, field.TypeString, value) + _node.Version = value + } + if value, ok := _c.mutation.S3Key(); ok { + _spec.SetField(agentpluginversion.FieldS3Key, field.TypeString, value) + _node.S3Key = value + } + if value, ok := _c.mutation.ParsedMeta(); ok { + _spec.SetField(agentpluginversion.FieldParsedMeta, field.TypeJSON, value) + _node.ParsedMeta = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(agentpluginversion.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if nodes := _c.mutation.PluginIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentpluginversion.PluginTable, + Columns: []string{agentpluginversion.PluginColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ResourceID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentPluginVersion.Create(). +// SetResourceID(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentPluginVersionUpsert) { +// SetResourceID(v+v). +// }). +// Exec(ctx) +func (_c *AgentPluginVersionCreate) OnConflict(opts ...sql.ConflictOption) *AgentPluginVersionUpsertOne { + _c.conflict = opts + return &AgentPluginVersionUpsertOne{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentPluginVersion.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentPluginVersionCreate) OnConflictColumns(columns ...string) *AgentPluginVersionUpsertOne { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentPluginVersionUpsertOne{ + create: _c, + } +} + +type ( + // AgentPluginVersionUpsertOne is the builder for "upsert"-ing + // one AgentPluginVersion node. + AgentPluginVersionUpsertOne struct { + create *AgentPluginVersionCreate + } + + // AgentPluginVersionUpsert is the "OnConflict" setter. + AgentPluginVersionUpsert struct { + *sql.UpdateSet + } +) + +// SetResourceID sets the "resource_id" field. +func (u *AgentPluginVersionUpsert) SetResourceID(v uuid.UUID) *AgentPluginVersionUpsert { + u.Set(agentpluginversion.FieldResourceID, v) + return u +} + +// UpdateResourceID sets the "resource_id" field to the value that was provided on create. +func (u *AgentPluginVersionUpsert) UpdateResourceID() *AgentPluginVersionUpsert { + u.SetExcluded(agentpluginversion.FieldResourceID) + return u +} + +// SetVersion sets the "version" field. +func (u *AgentPluginVersionUpsert) SetVersion(v string) *AgentPluginVersionUpsert { + u.Set(agentpluginversion.FieldVersion, v) + return u +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *AgentPluginVersionUpsert) UpdateVersion() *AgentPluginVersionUpsert { + u.SetExcluded(agentpluginversion.FieldVersion) + return u +} + +// SetS3Key sets the "s3_key" field. +func (u *AgentPluginVersionUpsert) SetS3Key(v string) *AgentPluginVersionUpsert { + u.Set(agentpluginversion.FieldS3Key, v) + return u +} + +// UpdateS3Key sets the "s3_key" field to the value that was provided on create. +func (u *AgentPluginVersionUpsert) UpdateS3Key() *AgentPluginVersionUpsert { + u.SetExcluded(agentpluginversion.FieldS3Key) + return u +} + +// SetParsedMeta sets the "parsed_meta" field. +func (u *AgentPluginVersionUpsert) SetParsedMeta(v types.PluginParsedMeta) *AgentPluginVersionUpsert { + u.Set(agentpluginversion.FieldParsedMeta, v) + return u +} + +// UpdateParsedMeta sets the "parsed_meta" field to the value that was provided on create. +func (u *AgentPluginVersionUpsert) UpdateParsedMeta() *AgentPluginVersionUpsert { + u.SetExcluded(agentpluginversion.FieldParsedMeta) + return u +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (u *AgentPluginVersionUpsert) ClearParsedMeta() *AgentPluginVersionUpsert { + u.SetNull(agentpluginversion.FieldParsedMeta) + return u +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentPluginVersionUpsert) SetCreatedAt(v time.Time) *AgentPluginVersionUpsert { + u.Set(agentpluginversion.FieldCreatedAt, v) + return u +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentPluginVersionUpsert) UpdateCreatedAt() *AgentPluginVersionUpsert { + u.SetExcluded(agentpluginversion.FieldCreatedAt) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.AgentPluginVersion.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentpluginversion.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentPluginVersionUpsertOne) UpdateNewValues() *AgentPluginVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(agentpluginversion.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentPluginVersion.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentPluginVersionUpsertOne) Ignore() *AgentPluginVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentPluginVersionUpsertOne) DoNothing() *AgentPluginVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentPluginVersionCreate.OnConflict +// documentation for more info. +func (u *AgentPluginVersionUpsertOne) Update(set func(*AgentPluginVersionUpsert)) *AgentPluginVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentPluginVersionUpsert{UpdateSet: update}) + })) + return u +} + +// SetResourceID sets the "resource_id" field. +func (u *AgentPluginVersionUpsertOne) SetResourceID(v uuid.UUID) *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.SetResourceID(v) + }) +} + +// UpdateResourceID sets the "resource_id" field to the value that was provided on create. +func (u *AgentPluginVersionUpsertOne) UpdateResourceID() *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.UpdateResourceID() + }) +} + +// SetVersion sets the "version" field. +func (u *AgentPluginVersionUpsertOne) SetVersion(v string) *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *AgentPluginVersionUpsertOne) UpdateVersion() *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.UpdateVersion() + }) +} + +// SetS3Key sets the "s3_key" field. +func (u *AgentPluginVersionUpsertOne) SetS3Key(v string) *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.SetS3Key(v) + }) +} + +// UpdateS3Key sets the "s3_key" field to the value that was provided on create. +func (u *AgentPluginVersionUpsertOne) UpdateS3Key() *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.UpdateS3Key() + }) +} + +// SetParsedMeta sets the "parsed_meta" field. +func (u *AgentPluginVersionUpsertOne) SetParsedMeta(v types.PluginParsedMeta) *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.SetParsedMeta(v) + }) +} + +// UpdateParsedMeta sets the "parsed_meta" field to the value that was provided on create. +func (u *AgentPluginVersionUpsertOne) UpdateParsedMeta() *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.UpdateParsedMeta() + }) +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (u *AgentPluginVersionUpsertOne) ClearParsedMeta() *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.ClearParsedMeta() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentPluginVersionUpsertOne) SetCreatedAt(v time.Time) *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentPluginVersionUpsertOne) UpdateCreatedAt() *AgentPluginVersionUpsertOne { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.UpdateCreatedAt() + }) +} + +// Exec executes the query. +func (u *AgentPluginVersionUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentPluginVersionCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentPluginVersionUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *AgentPluginVersionUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: AgentPluginVersionUpsertOne.ID is not supported by MySQL driver. Use AgentPluginVersionUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *AgentPluginVersionUpsertOne) IDX(ctx context.Context) uuid.UUID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// AgentPluginVersionCreateBulk is the builder for creating many AgentPluginVersion entities in bulk. +type AgentPluginVersionCreateBulk struct { + config + err error + builders []*AgentPluginVersionCreate + conflict []sql.ConflictOption +} + +// Save creates the AgentPluginVersion entities in the database. +func (_c *AgentPluginVersionCreateBulk) Save(ctx context.Context) ([]*AgentPluginVersion, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*AgentPluginVersion, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AgentPluginVersionMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = _c.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AgentPluginVersionCreateBulk) SaveX(ctx context.Context) []*AgentPluginVersion { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentPluginVersionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentPluginVersionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentPluginVersion.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentPluginVersionUpsert) { +// SetResourceID(v+v). +// }). +// Exec(ctx) +func (_c *AgentPluginVersionCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentPluginVersionUpsertBulk { + _c.conflict = opts + return &AgentPluginVersionUpsertBulk{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentPluginVersion.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentPluginVersionCreateBulk) OnConflictColumns(columns ...string) *AgentPluginVersionUpsertBulk { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentPluginVersionUpsertBulk{ + create: _c, + } +} + +// AgentPluginVersionUpsertBulk is the builder for "upsert"-ing +// a bulk of AgentPluginVersion nodes. +type AgentPluginVersionUpsertBulk struct { + create *AgentPluginVersionCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.AgentPluginVersion.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentpluginversion.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentPluginVersionUpsertBulk) UpdateNewValues() *AgentPluginVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(agentpluginversion.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentPluginVersion.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentPluginVersionUpsertBulk) Ignore() *AgentPluginVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentPluginVersionUpsertBulk) DoNothing() *AgentPluginVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentPluginVersionCreateBulk.OnConflict +// documentation for more info. +func (u *AgentPluginVersionUpsertBulk) Update(set func(*AgentPluginVersionUpsert)) *AgentPluginVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentPluginVersionUpsert{UpdateSet: update}) + })) + return u +} + +// SetResourceID sets the "resource_id" field. +func (u *AgentPluginVersionUpsertBulk) SetResourceID(v uuid.UUID) *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.SetResourceID(v) + }) +} + +// UpdateResourceID sets the "resource_id" field to the value that was provided on create. +func (u *AgentPluginVersionUpsertBulk) UpdateResourceID() *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.UpdateResourceID() + }) +} + +// SetVersion sets the "version" field. +func (u *AgentPluginVersionUpsertBulk) SetVersion(v string) *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *AgentPluginVersionUpsertBulk) UpdateVersion() *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.UpdateVersion() + }) +} + +// SetS3Key sets the "s3_key" field. +func (u *AgentPluginVersionUpsertBulk) SetS3Key(v string) *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.SetS3Key(v) + }) +} + +// UpdateS3Key sets the "s3_key" field to the value that was provided on create. +func (u *AgentPluginVersionUpsertBulk) UpdateS3Key() *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.UpdateS3Key() + }) +} + +// SetParsedMeta sets the "parsed_meta" field. +func (u *AgentPluginVersionUpsertBulk) SetParsedMeta(v types.PluginParsedMeta) *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.SetParsedMeta(v) + }) +} + +// UpdateParsedMeta sets the "parsed_meta" field to the value that was provided on create. +func (u *AgentPluginVersionUpsertBulk) UpdateParsedMeta() *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.UpdateParsedMeta() + }) +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (u *AgentPluginVersionUpsertBulk) ClearParsedMeta() *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.ClearParsedMeta() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentPluginVersionUpsertBulk) SetCreatedAt(v time.Time) *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentPluginVersionUpsertBulk) UpdateCreatedAt() *AgentPluginVersionUpsertBulk { + return u.Update(func(s *AgentPluginVersionUpsert) { + s.UpdateCreatedAt() + }) +} + +// Exec executes the query. +func (u *AgentPluginVersionUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentPluginVersionCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentPluginVersionCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentPluginVersionUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentpluginversion_delete.go b/backend/db/agentpluginversion_delete.go new file mode 100644 index 00000000..98698f05 --- /dev/null +++ b/backend/db/agentpluginversion_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" +) + +// AgentPluginVersionDelete is the builder for deleting a AgentPluginVersion entity. +type AgentPluginVersionDelete struct { + config + hooks []Hook + mutation *AgentPluginVersionMutation +} + +// Where appends a list predicates to the AgentPluginVersionDelete builder. +func (_d *AgentPluginVersionDelete) Where(ps ...predicate.AgentPluginVersion) *AgentPluginVersionDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *AgentPluginVersionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentPluginVersionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *AgentPluginVersionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(agentpluginversion.Table, sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// AgentPluginVersionDeleteOne is the builder for deleting a single AgentPluginVersion entity. +type AgentPluginVersionDeleteOne struct { + _d *AgentPluginVersionDelete +} + +// Where appends a list predicates to the AgentPluginVersionDelete builder. +func (_d *AgentPluginVersionDeleteOne) Where(ps ...predicate.AgentPluginVersion) *AgentPluginVersionDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *AgentPluginVersionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{agentpluginversion.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentPluginVersionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentpluginversion_query.go b/backend/db/agentpluginversion_query.go new file mode 100644 index 00000000..0d30e26f --- /dev/null +++ b/backend/db/agentpluginversion_query.go @@ -0,0 +1,657 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentPluginVersionQuery is the builder for querying AgentPluginVersion entities. +type AgentPluginVersionQuery struct { + config + ctx *QueryContext + order []agentpluginversion.OrderOption + inters []Interceptor + predicates []predicate.AgentPluginVersion + withPlugin *AgentPluginQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the AgentPluginVersionQuery builder. +func (_q *AgentPluginVersionQuery) Where(ps ...predicate.AgentPluginVersion) *AgentPluginVersionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *AgentPluginVersionQuery) Limit(limit int) *AgentPluginVersionQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *AgentPluginVersionQuery) Offset(offset int) *AgentPluginVersionQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *AgentPluginVersionQuery) Unique(unique bool) *AgentPluginVersionQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *AgentPluginVersionQuery) Order(o ...agentpluginversion.OrderOption) *AgentPluginVersionQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryPlugin chains the current query on the "plugin" edge. +func (_q *AgentPluginVersionQuery) QueryPlugin() *AgentPluginQuery { + query := (&AgentPluginClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(agentpluginversion.Table, agentpluginversion.FieldID, selector), + sqlgraph.To(agentplugin.Table, agentplugin.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, agentpluginversion.PluginTable, agentpluginversion.PluginColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first AgentPluginVersion entity from the query. +// Returns a *NotFoundError when no AgentPluginVersion was found. +func (_q *AgentPluginVersionQuery) First(ctx context.Context) (*AgentPluginVersion, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{agentpluginversion.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *AgentPluginVersionQuery) FirstX(ctx context.Context) *AgentPluginVersion { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first AgentPluginVersion ID from the query. +// Returns a *NotFoundError when no AgentPluginVersion ID was found. +func (_q *AgentPluginVersionQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{agentpluginversion.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *AgentPluginVersionQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single AgentPluginVersion entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one AgentPluginVersion entity is found. +// Returns a *NotFoundError when no AgentPluginVersion entities are found. +func (_q *AgentPluginVersionQuery) Only(ctx context.Context) (*AgentPluginVersion, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{agentpluginversion.Label} + default: + return nil, &NotSingularError{agentpluginversion.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *AgentPluginVersionQuery) OnlyX(ctx context.Context) *AgentPluginVersion { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only AgentPluginVersion ID in the query. +// Returns a *NotSingularError when more than one AgentPluginVersion ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *AgentPluginVersionQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{agentpluginversion.Label} + default: + err = &NotSingularError{agentpluginversion.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *AgentPluginVersionQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of AgentPluginVersions. +func (_q *AgentPluginVersionQuery) All(ctx context.Context) ([]*AgentPluginVersion, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*AgentPluginVersion, *AgentPluginVersionQuery]() + return withInterceptors[[]*AgentPluginVersion](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *AgentPluginVersionQuery) AllX(ctx context.Context) []*AgentPluginVersion { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of AgentPluginVersion IDs. +func (_q *AgentPluginVersionQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(agentpluginversion.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *AgentPluginVersionQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *AgentPluginVersionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*AgentPluginVersionQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *AgentPluginVersionQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *AgentPluginVersionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *AgentPluginVersionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AgentPluginVersionQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *AgentPluginVersionQuery) Clone() *AgentPluginVersionQuery { + if _q == nil { + return nil + } + return &AgentPluginVersionQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]agentpluginversion.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.AgentPluginVersion{}, _q.predicates...), + withPlugin: _q.withPlugin.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithPlugin tells the query-builder to eager-load the nodes that are connected to +// the "plugin" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentPluginVersionQuery) WithPlugin(opts ...func(*AgentPluginQuery)) *AgentPluginVersionQuery { + query := (&AgentPluginClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withPlugin = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// ResourceID uuid.UUID `json:"resource_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.AgentPluginVersion.Query(). +// GroupBy(agentpluginversion.FieldResourceID). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (_q *AgentPluginVersionQuery) GroupBy(field string, fields ...string) *AgentPluginVersionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &AgentPluginVersionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = agentpluginversion.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// ResourceID uuid.UUID `json:"resource_id,omitempty"` +// } +// +// client.AgentPluginVersion.Query(). +// Select(agentpluginversion.FieldResourceID). +// Scan(ctx, &v) +func (_q *AgentPluginVersionQuery) Select(fields ...string) *AgentPluginVersionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &AgentPluginVersionSelect{AgentPluginVersionQuery: _q} + sbuild.label = agentpluginversion.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AgentPluginVersionSelect configured with the given aggregations. +func (_q *AgentPluginVersionQuery) Aggregate(fns ...AggregateFunc) *AgentPluginVersionSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *AgentPluginVersionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !agentpluginversion.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *AgentPluginVersionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AgentPluginVersion, error) { + var ( + nodes = []*AgentPluginVersion{} + _spec = _q.querySpec() + loadedTypes = [1]bool{ + _q.withPlugin != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*AgentPluginVersion).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &AgentPluginVersion{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withPlugin; query != nil { + if err := _q.loadPlugin(ctx, query, nodes, nil, + func(n *AgentPluginVersion, e *AgentPlugin) { n.Edges.Plugin = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *AgentPluginVersionQuery) loadPlugin(ctx context.Context, query *AgentPluginQuery, nodes []*AgentPluginVersion, init func(*AgentPluginVersion), assign func(*AgentPluginVersion, *AgentPlugin)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*AgentPluginVersion) + for i := range nodes { + fk := nodes[i].ResourceID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(agentplugin.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "resource_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *AgentPluginVersionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *AgentPluginVersionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(agentpluginversion.Table, agentpluginversion.Columns, sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentpluginversion.FieldID) + for i := range fields { + if fields[i] != agentpluginversion.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withPlugin != nil { + _spec.Node.AddColumnOnce(agentpluginversion.FieldResourceID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *AgentPluginVersionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(agentpluginversion.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = agentpluginversion.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *AgentPluginVersionQuery) ForUpdate(opts ...sql.LockOption) *AgentPluginVersionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *AgentPluginVersionQuery) ForShare(opts ...sql.LockOption) *AgentPluginVersionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *AgentPluginVersionQuery) Modify(modifiers ...func(s *sql.Selector)) *AgentPluginVersionSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// AgentPluginVersionGroupBy is the group-by builder for AgentPluginVersion entities. +type AgentPluginVersionGroupBy struct { + selector + build *AgentPluginVersionQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *AgentPluginVersionGroupBy) Aggregate(fns ...AggregateFunc) *AgentPluginVersionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *AgentPluginVersionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentPluginVersionQuery, *AgentPluginVersionGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *AgentPluginVersionGroupBy) sqlScan(ctx context.Context, root *AgentPluginVersionQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// AgentPluginVersionSelect is the builder for selecting fields of AgentPluginVersion entities. +type AgentPluginVersionSelect struct { + *AgentPluginVersionQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *AgentPluginVersionSelect) Aggregate(fns ...AggregateFunc) *AgentPluginVersionSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *AgentPluginVersionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentPluginVersionQuery, *AgentPluginVersionSelect](ctx, _s.AgentPluginVersionQuery, _s, _s.inters, v) +} + +func (_s *AgentPluginVersionSelect) sqlScan(ctx context.Context, root *AgentPluginVersionQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *AgentPluginVersionSelect) Modify(modifiers ...func(s *sql.Selector)) *AgentPluginVersionSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/backend/db/agentpluginversion_update.go b/backend/db/agentpluginversion_update.go new file mode 100644 index 00000000..19ace884 --- /dev/null +++ b/backend/db/agentpluginversion_update.go @@ -0,0 +1,511 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentPluginVersionUpdate is the builder for updating AgentPluginVersion entities. +type AgentPluginVersionUpdate struct { + config + hooks []Hook + mutation *AgentPluginVersionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the AgentPluginVersionUpdate builder. +func (_u *AgentPluginVersionUpdate) Where(ps ...predicate.AgentPluginVersion) *AgentPluginVersionUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetResourceID sets the "resource_id" field. +func (_u *AgentPluginVersionUpdate) SetResourceID(v uuid.UUID) *AgentPluginVersionUpdate { + _u.mutation.SetResourceID(v) + return _u +} + +// SetNillableResourceID sets the "resource_id" field if the given value is not nil. +func (_u *AgentPluginVersionUpdate) SetNillableResourceID(v *uuid.UUID) *AgentPluginVersionUpdate { + if v != nil { + _u.SetResourceID(*v) + } + return _u +} + +// SetVersion sets the "version" field. +func (_u *AgentPluginVersionUpdate) SetVersion(v string) *AgentPluginVersionUpdate { + _u.mutation.SetVersion(v) + return _u +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (_u *AgentPluginVersionUpdate) SetNillableVersion(v *string) *AgentPluginVersionUpdate { + if v != nil { + _u.SetVersion(*v) + } + return _u +} + +// SetS3Key sets the "s3_key" field. +func (_u *AgentPluginVersionUpdate) SetS3Key(v string) *AgentPluginVersionUpdate { + _u.mutation.SetS3Key(v) + return _u +} + +// SetNillableS3Key sets the "s3_key" field if the given value is not nil. +func (_u *AgentPluginVersionUpdate) SetNillableS3Key(v *string) *AgentPluginVersionUpdate { + if v != nil { + _u.SetS3Key(*v) + } + return _u +} + +// SetParsedMeta sets the "parsed_meta" field. +func (_u *AgentPluginVersionUpdate) SetParsedMeta(v types.PluginParsedMeta) *AgentPluginVersionUpdate { + _u.mutation.SetParsedMeta(v) + return _u +} + +// SetNillableParsedMeta sets the "parsed_meta" field if the given value is not nil. +func (_u *AgentPluginVersionUpdate) SetNillableParsedMeta(v *types.PluginParsedMeta) *AgentPluginVersionUpdate { + if v != nil { + _u.SetParsedMeta(*v) + } + return _u +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (_u *AgentPluginVersionUpdate) ClearParsedMeta() *AgentPluginVersionUpdate { + _u.mutation.ClearParsedMeta() + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentPluginVersionUpdate) SetCreatedAt(v time.Time) *AgentPluginVersionUpdate { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentPluginVersionUpdate) SetNillableCreatedAt(v *time.Time) *AgentPluginVersionUpdate { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetPluginID sets the "plugin" edge to the AgentPlugin entity by ID. +func (_u *AgentPluginVersionUpdate) SetPluginID(id uuid.UUID) *AgentPluginVersionUpdate { + _u.mutation.SetPluginID(id) + return _u +} + +// SetPlugin sets the "plugin" edge to the AgentPlugin entity. +func (_u *AgentPluginVersionUpdate) SetPlugin(v *AgentPlugin) *AgentPluginVersionUpdate { + return _u.SetPluginID(v.ID) +} + +// Mutation returns the AgentPluginVersionMutation object of the builder. +func (_u *AgentPluginVersionUpdate) Mutation() *AgentPluginVersionMutation { + return _u.mutation +} + +// ClearPlugin clears the "plugin" edge to the AgentPlugin entity. +func (_u *AgentPluginVersionUpdate) ClearPlugin() *AgentPluginVersionUpdate { + _u.mutation.ClearPlugin() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AgentPluginVersionUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentPluginVersionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AgentPluginVersionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentPluginVersionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentPluginVersionUpdate) check() error { + if v, ok := _u.mutation.Version(); ok { + if err := agentpluginversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "AgentPluginVersion.version": %w`, err)} + } + } + if v, ok := _u.mutation.S3Key(); ok { + if err := agentpluginversion.S3KeyValidator(v); err != nil { + return &ValidationError{Name: "s3_key", err: fmt.Errorf(`db: validator failed for field "AgentPluginVersion.s3_key": %w`, err)} + } + } + if _u.mutation.PluginCleared() && len(_u.mutation.PluginIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentPluginVersion.plugin"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentPluginVersionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentPluginVersionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentPluginVersionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentpluginversion.Table, agentpluginversion.Columns, sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Version(); ok { + _spec.SetField(agentpluginversion.FieldVersion, field.TypeString, value) + } + if value, ok := _u.mutation.S3Key(); ok { + _spec.SetField(agentpluginversion.FieldS3Key, field.TypeString, value) + } + if value, ok := _u.mutation.ParsedMeta(); ok { + _spec.SetField(agentpluginversion.FieldParsedMeta, field.TypeJSON, value) + } + if _u.mutation.ParsedMetaCleared() { + _spec.ClearField(agentpluginversion.FieldParsedMeta, field.TypeJSON) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentpluginversion.FieldCreatedAt, field.TypeTime, value) + } + if _u.mutation.PluginCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentpluginversion.PluginTable, + Columns: []string{agentpluginversion.PluginColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PluginIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentpluginversion.PluginTable, + Columns: []string{agentpluginversion.PluginColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentpluginversion.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AgentPluginVersionUpdateOne is the builder for updating a single AgentPluginVersion entity. +type AgentPluginVersionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AgentPluginVersionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetResourceID sets the "resource_id" field. +func (_u *AgentPluginVersionUpdateOne) SetResourceID(v uuid.UUID) *AgentPluginVersionUpdateOne { + _u.mutation.SetResourceID(v) + return _u +} + +// SetNillableResourceID sets the "resource_id" field if the given value is not nil. +func (_u *AgentPluginVersionUpdateOne) SetNillableResourceID(v *uuid.UUID) *AgentPluginVersionUpdateOne { + if v != nil { + _u.SetResourceID(*v) + } + return _u +} + +// SetVersion sets the "version" field. +func (_u *AgentPluginVersionUpdateOne) SetVersion(v string) *AgentPluginVersionUpdateOne { + _u.mutation.SetVersion(v) + return _u +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (_u *AgentPluginVersionUpdateOne) SetNillableVersion(v *string) *AgentPluginVersionUpdateOne { + if v != nil { + _u.SetVersion(*v) + } + return _u +} + +// SetS3Key sets the "s3_key" field. +func (_u *AgentPluginVersionUpdateOne) SetS3Key(v string) *AgentPluginVersionUpdateOne { + _u.mutation.SetS3Key(v) + return _u +} + +// SetNillableS3Key sets the "s3_key" field if the given value is not nil. +func (_u *AgentPluginVersionUpdateOne) SetNillableS3Key(v *string) *AgentPluginVersionUpdateOne { + if v != nil { + _u.SetS3Key(*v) + } + return _u +} + +// SetParsedMeta sets the "parsed_meta" field. +func (_u *AgentPluginVersionUpdateOne) SetParsedMeta(v types.PluginParsedMeta) *AgentPluginVersionUpdateOne { + _u.mutation.SetParsedMeta(v) + return _u +} + +// SetNillableParsedMeta sets the "parsed_meta" field if the given value is not nil. +func (_u *AgentPluginVersionUpdateOne) SetNillableParsedMeta(v *types.PluginParsedMeta) *AgentPluginVersionUpdateOne { + if v != nil { + _u.SetParsedMeta(*v) + } + return _u +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (_u *AgentPluginVersionUpdateOne) ClearParsedMeta() *AgentPluginVersionUpdateOne { + _u.mutation.ClearParsedMeta() + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentPluginVersionUpdateOne) SetCreatedAt(v time.Time) *AgentPluginVersionUpdateOne { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentPluginVersionUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentPluginVersionUpdateOne { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetPluginID sets the "plugin" edge to the AgentPlugin entity by ID. +func (_u *AgentPluginVersionUpdateOne) SetPluginID(id uuid.UUID) *AgentPluginVersionUpdateOne { + _u.mutation.SetPluginID(id) + return _u +} + +// SetPlugin sets the "plugin" edge to the AgentPlugin entity. +func (_u *AgentPluginVersionUpdateOne) SetPlugin(v *AgentPlugin) *AgentPluginVersionUpdateOne { + return _u.SetPluginID(v.ID) +} + +// Mutation returns the AgentPluginVersionMutation object of the builder. +func (_u *AgentPluginVersionUpdateOne) Mutation() *AgentPluginVersionMutation { + return _u.mutation +} + +// ClearPlugin clears the "plugin" edge to the AgentPlugin entity. +func (_u *AgentPluginVersionUpdateOne) ClearPlugin() *AgentPluginVersionUpdateOne { + _u.mutation.ClearPlugin() + return _u +} + +// Where appends a list predicates to the AgentPluginVersionUpdate builder. +func (_u *AgentPluginVersionUpdateOne) Where(ps ...predicate.AgentPluginVersion) *AgentPluginVersionUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *AgentPluginVersionUpdateOne) Select(field string, fields ...string) *AgentPluginVersionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated AgentPluginVersion entity. +func (_u *AgentPluginVersionUpdateOne) Save(ctx context.Context) (*AgentPluginVersion, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentPluginVersionUpdateOne) SaveX(ctx context.Context) *AgentPluginVersion { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AgentPluginVersionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentPluginVersionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentPluginVersionUpdateOne) check() error { + if v, ok := _u.mutation.Version(); ok { + if err := agentpluginversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "AgentPluginVersion.version": %w`, err)} + } + } + if v, ok := _u.mutation.S3Key(); ok { + if err := agentpluginversion.S3KeyValidator(v); err != nil { + return &ValidationError{Name: "s3_key", err: fmt.Errorf(`db: validator failed for field "AgentPluginVersion.s3_key": %w`, err)} + } + } + if _u.mutation.PluginCleared() && len(_u.mutation.PluginIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentPluginVersion.plugin"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentPluginVersionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentPluginVersionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentPluginVersionUpdateOne) sqlSave(ctx context.Context) (_node *AgentPluginVersion, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentpluginversion.Table, agentpluginversion.Columns, sqlgraph.NewFieldSpec(agentpluginversion.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentPluginVersion.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentpluginversion.FieldID) + for _, f := range fields { + if !agentpluginversion.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != agentpluginversion.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Version(); ok { + _spec.SetField(agentpluginversion.FieldVersion, field.TypeString, value) + } + if value, ok := _u.mutation.S3Key(); ok { + _spec.SetField(agentpluginversion.FieldS3Key, field.TypeString, value) + } + if value, ok := _u.mutation.ParsedMeta(); ok { + _spec.SetField(agentpluginversion.FieldParsedMeta, field.TypeJSON, value) + } + if _u.mutation.ParsedMetaCleared() { + _spec.ClearField(agentpluginversion.FieldParsedMeta, field.TypeJSON) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentpluginversion.FieldCreatedAt, field.TypeTime, value) + } + if _u.mutation.PluginCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentpluginversion.PluginTable, + Columns: []string{agentpluginversion.PluginColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PluginIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentpluginversion.PluginTable, + Columns: []string{agentpluginversion.PluginColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentplugin.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &AgentPluginVersion{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentpluginversion.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/db/agentrule.go b/backend/db/agentrule.go new file mode 100644 index 00000000..aa6a98ec --- /dev/null +++ b/backend/db/agentrule.go @@ -0,0 +1,228 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/google/uuid" +) + +// AgentRule is the model entity for the AgentRule schema. +type AgentRule struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // ScopeType holds the value of the "scope_type" field. + ScopeType agentrule.ScopeType `json:"scope_type,omitempty"` + // ScopeID holds the value of the "scope_id" field. + ScopeID string `json:"scope_id,omitempty"` + // CreatedBy holds the value of the "created_by" field. + CreatedBy uuid.UUID `json:"created_by,omitempty"` + // ActiveVersionID holds the value of the "active_version_id" field. + ActiveVersionID *uuid.UUID `json:"active_version_id,omitempty"` + // IsDeleted holds the value of the "is_deleted" field. + IsDeleted bool `json:"is_deleted,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the AgentRuleQuery when eager-loading is set. + Edges AgentRuleEdges `json:"edges"` + selectValues sql.SelectValues +} + +// AgentRuleEdges holds the relations/edges for other nodes in the graph. +type AgentRuleEdges struct { + // Versions holds the value of the versions edge. + Versions []*AgentRuleVersion `json:"versions,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// VersionsOrErr returns the Versions value or an error if the edge +// was not loaded in eager-loading. +func (e AgentRuleEdges) VersionsOrErr() ([]*AgentRuleVersion, error) { + if e.loadedTypes[0] { + return e.Versions, nil + } + return nil, &NotLoadedError{edge: "versions"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*AgentRule) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case agentrule.FieldActiveVersionID: + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + case agentrule.FieldIsDeleted: + values[i] = new(sql.NullBool) + case agentrule.FieldName, agentrule.FieldDescription, agentrule.FieldScopeType, agentrule.FieldScopeID: + values[i] = new(sql.NullString) + case agentrule.FieldCreatedAt, agentrule.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case agentrule.FieldID, agentrule.FieldCreatedBy: + values[i] = new(uuid.UUID) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the AgentRule fields. +func (_m *AgentRule) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case agentrule.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case agentrule.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case agentrule.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case agentrule.FieldScopeType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope_type", values[i]) + } else if value.Valid { + _m.ScopeType = agentrule.ScopeType(value.String) + } + case agentrule.FieldScopeID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope_id", values[i]) + } else if value.Valid { + _m.ScopeID = value.String + } + case agentrule.FieldCreatedBy: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field created_by", values[i]) + } else if value != nil { + _m.CreatedBy = *value + } + case agentrule.FieldActiveVersionID: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field active_version_id", values[i]) + } else if value.Valid { + _m.ActiveVersionID = new(uuid.UUID) + *_m.ActiveVersionID = *value.S.(*uuid.UUID) + } + case agentrule.FieldIsDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_deleted", values[i]) + } else if value.Valid { + _m.IsDeleted = value.Bool + } + case agentrule.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case agentrule.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the AgentRule. +// This includes values selected through modifiers, order, etc. +func (_m *AgentRule) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryVersions queries the "versions" edge of the AgentRule entity. +func (_m *AgentRule) QueryVersions() *AgentRuleVersionQuery { + return NewAgentRuleClient(_m.config).QueryVersions(_m) +} + +// Update returns a builder for updating this AgentRule. +// Note that you need to call AgentRule.Unwrap() before calling this method if this AgentRule +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *AgentRule) Update() *AgentRuleUpdateOne { + return NewAgentRuleClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the AgentRule entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *AgentRule) Unwrap() *AgentRule { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("db: AgentRule is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *AgentRule) String() string { + var builder strings.Builder + builder.WriteString("AgentRule(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteString(", ") + builder.WriteString("scope_type=") + builder.WriteString(fmt.Sprintf("%v", _m.ScopeType)) + builder.WriteString(", ") + builder.WriteString("scope_id=") + builder.WriteString(_m.ScopeID) + builder.WriteString(", ") + builder.WriteString("created_by=") + builder.WriteString(fmt.Sprintf("%v", _m.CreatedBy)) + builder.WriteString(", ") + if v := _m.ActiveVersionID; v != nil { + builder.WriteString("active_version_id=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + builder.WriteString("is_deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.IsDeleted)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// AgentRules is a parsable slice of AgentRule. +type AgentRules []*AgentRule diff --git a/backend/db/agentrule/agentrule.go b/backend/db/agentrule/agentrule.go new file mode 100644 index 00000000..8dbd29e2 --- /dev/null +++ b/backend/db/agentrule/agentrule.go @@ -0,0 +1,188 @@ +// Code generated by ent, DO NOT EDIT. + +package agentrule + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the agentrule type in the database. + Label = "agent_rule" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldScopeType holds the string denoting the scope_type field in the database. + FieldScopeType = "scope_type" + // FieldScopeID holds the string denoting the scope_id field in the database. + FieldScopeID = "scope_id" + // FieldCreatedBy holds the string denoting the created_by field in the database. + FieldCreatedBy = "created_by" + // FieldActiveVersionID holds the string denoting the active_version_id field in the database. + FieldActiveVersionID = "active_version_id" + // FieldIsDeleted holds the string denoting the is_deleted field in the database. + FieldIsDeleted = "is_deleted" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // EdgeVersions holds the string denoting the versions edge name in mutations. + EdgeVersions = "versions" + // Table holds the table name of the agentrule in the database. + Table = "agent_rules" + // VersionsTable is the table that holds the versions relation/edge. + VersionsTable = "agent_rule_versions" + // VersionsInverseTable is the table name for the AgentRuleVersion entity. + // It exists in this package in order to avoid circular dependency with the "agentruleversion" package. + VersionsInverseTable = "agent_rule_versions" + // VersionsColumn is the table column denoting the versions relation/edge. + VersionsColumn = "rule_id" +) + +// Columns holds all SQL columns for agentrule fields. +var Columns = []string{ + FieldID, + FieldName, + FieldDescription, + FieldScopeType, + FieldScopeID, + FieldCreatedBy, + FieldActiveVersionID, + FieldIsDeleted, + FieldCreatedAt, + FieldUpdatedAt, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultScopeID holds the default value on creation for the "scope_id" field. + DefaultScopeID string + // DefaultIsDeleted holds the default value on creation for the "is_deleted" field. + DefaultIsDeleted bool + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// ScopeType defines the type for the "scope_type" enum field. +type ScopeType string + +// ScopeTypeGlobal is the default value of the ScopeType enum. +const DefaultScopeType = ScopeTypeGlobal + +// ScopeType values. +const ( + ScopeTypeGlobal ScopeType = "global" +) + +func (st ScopeType) String() string { + return string(st) +} + +// ScopeTypeValidator is a validator for the "scope_type" field enum values. It is called by the builders before save. +func ScopeTypeValidator(st ScopeType) error { + switch st { + case ScopeTypeGlobal: + return nil + default: + return fmt.Errorf("agentrule: invalid enum value for scope_type field: %q", st) + } +} + +// OrderOption defines the ordering options for the AgentRule queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByScopeType orders the results by the scope_type field. +func ByScopeType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScopeType, opts...).ToFunc() +} + +// ByScopeID orders the results by the scope_id field. +func ByScopeID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScopeID, opts...).ToFunc() +} + +// ByCreatedBy orders the results by the created_by field. +func ByCreatedBy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedBy, opts...).ToFunc() +} + +// ByActiveVersionID orders the results by the active_version_id field. +func ByActiveVersionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldActiveVersionID, opts...).ToFunc() +} + +// ByIsDeleted orders the results by the is_deleted field. +func ByIsDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsDeleted, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByVersionsCount orders the results by versions count. +func ByVersionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newVersionsStep(), opts...) + } +} + +// ByVersions orders the results by versions terms. +func ByVersions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newVersionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newVersionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(VersionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, VersionsTable, VersionsColumn), + ) +} diff --git a/backend/db/agentrule/where.go b/backend/db/agentrule/where.go new file mode 100644 index 00000000..d12fcb91 --- /dev/null +++ b/backend/db/agentrule/where.go @@ -0,0 +1,540 @@ +// Code generated by ent, DO NOT EDIT. + +package agentrule + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLTE(FieldID, id)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldName, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldDescription, v)) +} + +// ScopeID applies equality check predicate on the "scope_id" field. It's identical to ScopeIDEQ. +func ScopeID(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldScopeID, v)) +} + +// CreatedBy applies equality check predicate on the "created_by" field. It's identical to CreatedByEQ. +func CreatedBy(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldCreatedBy, v)) +} + +// ActiveVersionID applies equality check predicate on the "active_version_id" field. It's identical to ActiveVersionIDEQ. +func ActiveVersionID(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldActiveVersionID, v)) +} + +// IsDeleted applies equality check predicate on the "is_deleted" field. It's identical to IsDeletedEQ. +func IsDeleted(v bool) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldIsDeleted, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldContainsFold(FieldName, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.AgentRule { + return predicate.AgentRule(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldContainsFold(FieldDescription, v)) +} + +// ScopeTypeEQ applies the EQ predicate on the "scope_type" field. +func ScopeTypeEQ(v ScopeType) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldScopeType, v)) +} + +// ScopeTypeNEQ applies the NEQ predicate on the "scope_type" field. +func ScopeTypeNEQ(v ScopeType) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNEQ(FieldScopeType, v)) +} + +// ScopeTypeIn applies the In predicate on the "scope_type" field. +func ScopeTypeIn(vs ...ScopeType) predicate.AgentRule { + return predicate.AgentRule(sql.FieldIn(FieldScopeType, vs...)) +} + +// ScopeTypeNotIn applies the NotIn predicate on the "scope_type" field. +func ScopeTypeNotIn(vs ...ScopeType) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotIn(FieldScopeType, vs...)) +} + +// ScopeIDEQ applies the EQ predicate on the "scope_id" field. +func ScopeIDEQ(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldScopeID, v)) +} + +// ScopeIDNEQ applies the NEQ predicate on the "scope_id" field. +func ScopeIDNEQ(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNEQ(FieldScopeID, v)) +} + +// ScopeIDIn applies the In predicate on the "scope_id" field. +func ScopeIDIn(vs ...string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldIn(FieldScopeID, vs...)) +} + +// ScopeIDNotIn applies the NotIn predicate on the "scope_id" field. +func ScopeIDNotIn(vs ...string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotIn(FieldScopeID, vs...)) +} + +// ScopeIDGT applies the GT predicate on the "scope_id" field. +func ScopeIDGT(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGT(FieldScopeID, v)) +} + +// ScopeIDGTE applies the GTE predicate on the "scope_id" field. +func ScopeIDGTE(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGTE(FieldScopeID, v)) +} + +// ScopeIDLT applies the LT predicate on the "scope_id" field. +func ScopeIDLT(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLT(FieldScopeID, v)) +} + +// ScopeIDLTE applies the LTE predicate on the "scope_id" field. +func ScopeIDLTE(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLTE(FieldScopeID, v)) +} + +// ScopeIDContains applies the Contains predicate on the "scope_id" field. +func ScopeIDContains(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldContains(FieldScopeID, v)) +} + +// ScopeIDHasPrefix applies the HasPrefix predicate on the "scope_id" field. +func ScopeIDHasPrefix(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldHasPrefix(FieldScopeID, v)) +} + +// ScopeIDHasSuffix applies the HasSuffix predicate on the "scope_id" field. +func ScopeIDHasSuffix(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldHasSuffix(FieldScopeID, v)) +} + +// ScopeIDEqualFold applies the EqualFold predicate on the "scope_id" field. +func ScopeIDEqualFold(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEqualFold(FieldScopeID, v)) +} + +// ScopeIDContainsFold applies the ContainsFold predicate on the "scope_id" field. +func ScopeIDContainsFold(v string) predicate.AgentRule { + return predicate.AgentRule(sql.FieldContainsFold(FieldScopeID, v)) +} + +// CreatedByEQ applies the EQ predicate on the "created_by" field. +func CreatedByEQ(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldCreatedBy, v)) +} + +// CreatedByNEQ applies the NEQ predicate on the "created_by" field. +func CreatedByNEQ(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNEQ(FieldCreatedBy, v)) +} + +// CreatedByIn applies the In predicate on the "created_by" field. +func CreatedByIn(vs ...uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldIn(FieldCreatedBy, vs...)) +} + +// CreatedByNotIn applies the NotIn predicate on the "created_by" field. +func CreatedByNotIn(vs ...uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotIn(FieldCreatedBy, vs...)) +} + +// CreatedByGT applies the GT predicate on the "created_by" field. +func CreatedByGT(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGT(FieldCreatedBy, v)) +} + +// CreatedByGTE applies the GTE predicate on the "created_by" field. +func CreatedByGTE(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGTE(FieldCreatedBy, v)) +} + +// CreatedByLT applies the LT predicate on the "created_by" field. +func CreatedByLT(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLT(FieldCreatedBy, v)) +} + +// CreatedByLTE applies the LTE predicate on the "created_by" field. +func CreatedByLTE(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLTE(FieldCreatedBy, v)) +} + +// ActiveVersionIDEQ applies the EQ predicate on the "active_version_id" field. +func ActiveVersionIDEQ(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldActiveVersionID, v)) +} + +// ActiveVersionIDNEQ applies the NEQ predicate on the "active_version_id" field. +func ActiveVersionIDNEQ(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNEQ(FieldActiveVersionID, v)) +} + +// ActiveVersionIDIn applies the In predicate on the "active_version_id" field. +func ActiveVersionIDIn(vs ...uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldIn(FieldActiveVersionID, vs...)) +} + +// ActiveVersionIDNotIn applies the NotIn predicate on the "active_version_id" field. +func ActiveVersionIDNotIn(vs ...uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotIn(FieldActiveVersionID, vs...)) +} + +// ActiveVersionIDGT applies the GT predicate on the "active_version_id" field. +func ActiveVersionIDGT(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGT(FieldActiveVersionID, v)) +} + +// ActiveVersionIDGTE applies the GTE predicate on the "active_version_id" field. +func ActiveVersionIDGTE(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGTE(FieldActiveVersionID, v)) +} + +// ActiveVersionIDLT applies the LT predicate on the "active_version_id" field. +func ActiveVersionIDLT(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLT(FieldActiveVersionID, v)) +} + +// ActiveVersionIDLTE applies the LTE predicate on the "active_version_id" field. +func ActiveVersionIDLTE(v uuid.UUID) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLTE(FieldActiveVersionID, v)) +} + +// ActiveVersionIDIsNil applies the IsNil predicate on the "active_version_id" field. +func ActiveVersionIDIsNil() predicate.AgentRule { + return predicate.AgentRule(sql.FieldIsNull(FieldActiveVersionID)) +} + +// ActiveVersionIDNotNil applies the NotNil predicate on the "active_version_id" field. +func ActiveVersionIDNotNil() predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotNull(FieldActiveVersionID)) +} + +// IsDeletedEQ applies the EQ predicate on the "is_deleted" field. +func IsDeletedEQ(v bool) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldIsDeleted, v)) +} + +// IsDeletedNEQ applies the NEQ predicate on the "is_deleted" field. +func IsDeletedNEQ(v bool) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNEQ(FieldIsDeleted, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.AgentRule { + return predicate.AgentRule(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// HasVersions applies the HasEdge predicate on the "versions" edge. +func HasVersions() predicate.AgentRule { + return predicate.AgentRule(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, VersionsTable, VersionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasVersionsWith applies the HasEdge predicate on the "versions" edge with a given conditions (other predicates). +func HasVersionsWith(preds ...predicate.AgentRuleVersion) predicate.AgentRule { + return predicate.AgentRule(func(s *sql.Selector) { + step := newVersionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.AgentRule) predicate.AgentRule { + return predicate.AgentRule(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.AgentRule) predicate.AgentRule { + return predicate.AgentRule(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.AgentRule) predicate.AgentRule { + return predicate.AgentRule(sql.NotPredicates(p)) +} diff --git a/backend/db/agentrule_create.go b/backend/db/agentrule_create.go new file mode 100644 index 00000000..638c0ca7 --- /dev/null +++ b/backend/db/agentrule_create.go @@ -0,0 +1,1085 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/google/uuid" +) + +// AgentRuleCreate is the builder for creating a AgentRule entity. +type AgentRuleCreate struct { + config + mutation *AgentRuleMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetName sets the "name" field. +func (_c *AgentRuleCreate) SetName(v string) *AgentRuleCreate { + _c.mutation.SetName(v) + return _c +} + +// SetDescription sets the "description" field. +func (_c *AgentRuleCreate) SetDescription(v string) *AgentRuleCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *AgentRuleCreate) SetNillableDescription(v *string) *AgentRuleCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetScopeType sets the "scope_type" field. +func (_c *AgentRuleCreate) SetScopeType(v agentrule.ScopeType) *AgentRuleCreate { + _c.mutation.SetScopeType(v) + return _c +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_c *AgentRuleCreate) SetNillableScopeType(v *agentrule.ScopeType) *AgentRuleCreate { + if v != nil { + _c.SetScopeType(*v) + } + return _c +} + +// SetScopeID sets the "scope_id" field. +func (_c *AgentRuleCreate) SetScopeID(v string) *AgentRuleCreate { + _c.mutation.SetScopeID(v) + return _c +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_c *AgentRuleCreate) SetNillableScopeID(v *string) *AgentRuleCreate { + if v != nil { + _c.SetScopeID(*v) + } + return _c +} + +// SetCreatedBy sets the "created_by" field. +func (_c *AgentRuleCreate) SetCreatedBy(v uuid.UUID) *AgentRuleCreate { + _c.mutation.SetCreatedBy(v) + return _c +} + +// SetActiveVersionID sets the "active_version_id" field. +func (_c *AgentRuleCreate) SetActiveVersionID(v uuid.UUID) *AgentRuleCreate { + _c.mutation.SetActiveVersionID(v) + return _c +} + +// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil. +func (_c *AgentRuleCreate) SetNillableActiveVersionID(v *uuid.UUID) *AgentRuleCreate { + if v != nil { + _c.SetActiveVersionID(*v) + } + return _c +} + +// SetIsDeleted sets the "is_deleted" field. +func (_c *AgentRuleCreate) SetIsDeleted(v bool) *AgentRuleCreate { + _c.mutation.SetIsDeleted(v) + return _c +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_c *AgentRuleCreate) SetNillableIsDeleted(v *bool) *AgentRuleCreate { + if v != nil { + _c.SetIsDeleted(*v) + } + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AgentRuleCreate) SetCreatedAt(v time.Time) *AgentRuleCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AgentRuleCreate) SetNillableCreatedAt(v *time.Time) *AgentRuleCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *AgentRuleCreate) SetUpdatedAt(v time.Time) *AgentRuleCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *AgentRuleCreate) SetNillableUpdatedAt(v *time.Time) *AgentRuleCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AgentRuleCreate) SetID(v uuid.UUID) *AgentRuleCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AgentRuleCreate) SetNillableID(v *uuid.UUID) *AgentRuleCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// AddVersionIDs adds the "versions" edge to the AgentRuleVersion entity by IDs. +func (_c *AgentRuleCreate) AddVersionIDs(ids ...uuid.UUID) *AgentRuleCreate { + _c.mutation.AddVersionIDs(ids...) + return _c +} + +// AddVersions adds the "versions" edges to the AgentRuleVersion entity. +func (_c *AgentRuleCreate) AddVersions(v ...*AgentRuleVersion) *AgentRuleCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddVersionIDs(ids...) +} + +// Mutation returns the AgentRuleMutation object of the builder. +func (_c *AgentRuleCreate) Mutation() *AgentRuleMutation { + return _c.mutation +} + +// Save creates the AgentRule in the database. +func (_c *AgentRuleCreate) Save(ctx context.Context) (*AgentRule, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AgentRuleCreate) SaveX(ctx context.Context) *AgentRule { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentRuleCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentRuleCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AgentRuleCreate) defaults() { + if _, ok := _c.mutation.ScopeType(); !ok { + v := agentrule.DefaultScopeType + _c.mutation.SetScopeType(v) + } + if _, ok := _c.mutation.ScopeID(); !ok { + v := agentrule.DefaultScopeID + _c.mutation.SetScopeID(v) + } + if _, ok := _c.mutation.IsDeleted(); !ok { + v := agentrule.DefaultIsDeleted + _c.mutation.SetIsDeleted(v) + } + if _, ok := _c.mutation.CreatedAt(); !ok { + v := agentrule.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := agentrule.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := agentrule.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AgentRuleCreate) check() error { + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`db: missing required field "AgentRule.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := agentrule.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentRule.name": %w`, err)} + } + } + if _, ok := _c.mutation.ScopeType(); !ok { + return &ValidationError{Name: "scope_type", err: errors.New(`db: missing required field "AgentRule.scope_type"`)} + } + if v, ok := _c.mutation.ScopeType(); ok { + if err := agentrule.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentRule.scope_type": %w`, err)} + } + } + if _, ok := _c.mutation.ScopeID(); !ok { + return &ValidationError{Name: "scope_id", err: errors.New(`db: missing required field "AgentRule.scope_id"`)} + } + if _, ok := _c.mutation.CreatedBy(); !ok { + return &ValidationError{Name: "created_by", err: errors.New(`db: missing required field "AgentRule.created_by"`)} + } + if _, ok := _c.mutation.IsDeleted(); !ok { + return &ValidationError{Name: "is_deleted", err: errors.New(`db: missing required field "AgentRule.is_deleted"`)} + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentRule.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "AgentRule.updated_at"`)} + } + return nil +} + +func (_c *AgentRuleCreate) sqlSave(ctx context.Context) (*AgentRule, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AgentRuleCreate) createSpec() (*AgentRule, *sqlgraph.CreateSpec) { + var ( + _node = &AgentRule{config: _c.config} + _spec = sqlgraph.NewCreateSpec(agentrule.Table, sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID)) + ) + _spec.OnConflict = _c.conflict + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(agentrule.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(agentrule.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := _c.mutation.ScopeType(); ok { + _spec.SetField(agentrule.FieldScopeType, field.TypeEnum, value) + _node.ScopeType = value + } + if value, ok := _c.mutation.ScopeID(); ok { + _spec.SetField(agentrule.FieldScopeID, field.TypeString, value) + _node.ScopeID = value + } + if value, ok := _c.mutation.CreatedBy(); ok { + _spec.SetField(agentrule.FieldCreatedBy, field.TypeUUID, value) + _node.CreatedBy = value + } + if value, ok := _c.mutation.ActiveVersionID(); ok { + _spec.SetField(agentrule.FieldActiveVersionID, field.TypeUUID, value) + _node.ActiveVersionID = &value + } + if value, ok := _c.mutation.IsDeleted(); ok { + _spec.SetField(agentrule.FieldIsDeleted, field.TypeBool, value) + _node.IsDeleted = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(agentrule.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(agentrule.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if nodes := _c.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentrule.VersionsTable, + Columns: []string{agentrule.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentRule.Create(). +// SetName(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentRuleUpsert) { +// SetName(v+v). +// }). +// Exec(ctx) +func (_c *AgentRuleCreate) OnConflict(opts ...sql.ConflictOption) *AgentRuleUpsertOne { + _c.conflict = opts + return &AgentRuleUpsertOne{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentRule.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentRuleCreate) OnConflictColumns(columns ...string) *AgentRuleUpsertOne { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentRuleUpsertOne{ + create: _c, + } +} + +type ( + // AgentRuleUpsertOne is the builder for "upsert"-ing + // one AgentRule node. + AgentRuleUpsertOne struct { + create *AgentRuleCreate + } + + // AgentRuleUpsert is the "OnConflict" setter. + AgentRuleUpsert struct { + *sql.UpdateSet + } +) + +// SetName sets the "name" field. +func (u *AgentRuleUpsert) SetName(v string) *AgentRuleUpsert { + u.Set(agentrule.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentRuleUpsert) UpdateName() *AgentRuleUpsert { + u.SetExcluded(agentrule.FieldName) + return u +} + +// SetDescription sets the "description" field. +func (u *AgentRuleUpsert) SetDescription(v string) *AgentRuleUpsert { + u.Set(agentrule.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *AgentRuleUpsert) UpdateDescription() *AgentRuleUpsert { + u.SetExcluded(agentrule.FieldDescription) + return u +} + +// ClearDescription clears the value of the "description" field. +func (u *AgentRuleUpsert) ClearDescription() *AgentRuleUpsert { + u.SetNull(agentrule.FieldDescription) + return u +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentRuleUpsert) SetScopeType(v agentrule.ScopeType) *AgentRuleUpsert { + u.Set(agentrule.FieldScopeType, v) + return u +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentRuleUpsert) UpdateScopeType() *AgentRuleUpsert { + u.SetExcluded(agentrule.FieldScopeType) + return u +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentRuleUpsert) SetScopeID(v string) *AgentRuleUpsert { + u.Set(agentrule.FieldScopeID, v) + return u +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentRuleUpsert) UpdateScopeID() *AgentRuleUpsert { + u.SetExcluded(agentrule.FieldScopeID) + return u +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentRuleUpsert) SetCreatedBy(v uuid.UUID) *AgentRuleUpsert { + u.Set(agentrule.FieldCreatedBy, v) + return u +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentRuleUpsert) UpdateCreatedBy() *AgentRuleUpsert { + u.SetExcluded(agentrule.FieldCreatedBy) + return u +} + +// SetActiveVersionID sets the "active_version_id" field. +func (u *AgentRuleUpsert) SetActiveVersionID(v uuid.UUID) *AgentRuleUpsert { + u.Set(agentrule.FieldActiveVersionID, v) + return u +} + +// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create. +func (u *AgentRuleUpsert) UpdateActiveVersionID() *AgentRuleUpsert { + u.SetExcluded(agentrule.FieldActiveVersionID) + return u +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (u *AgentRuleUpsert) ClearActiveVersionID() *AgentRuleUpsert { + u.SetNull(agentrule.FieldActiveVersionID) + return u +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentRuleUpsert) SetIsDeleted(v bool) *AgentRuleUpsert { + u.Set(agentrule.FieldIsDeleted, v) + return u +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentRuleUpsert) UpdateIsDeleted() *AgentRuleUpsert { + u.SetExcluded(agentrule.FieldIsDeleted) + return u +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentRuleUpsert) SetCreatedAt(v time.Time) *AgentRuleUpsert { + u.Set(agentrule.FieldCreatedAt, v) + return u +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentRuleUpsert) UpdateCreatedAt() *AgentRuleUpsert { + u.SetExcluded(agentrule.FieldCreatedAt) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentRuleUpsert) SetUpdatedAt(v time.Time) *AgentRuleUpsert { + u.Set(agentrule.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentRuleUpsert) UpdateUpdatedAt() *AgentRuleUpsert { + u.SetExcluded(agentrule.FieldUpdatedAt) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.AgentRule.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentrule.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentRuleUpsertOne) UpdateNewValues() *AgentRuleUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(agentrule.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentRule.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentRuleUpsertOne) Ignore() *AgentRuleUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentRuleUpsertOne) DoNothing() *AgentRuleUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentRuleCreate.OnConflict +// documentation for more info. +func (u *AgentRuleUpsertOne) Update(set func(*AgentRuleUpsert)) *AgentRuleUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentRuleUpsert{UpdateSet: update}) + })) + return u +} + +// SetName sets the "name" field. +func (u *AgentRuleUpsertOne) SetName(v string) *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentRuleUpsertOne) UpdateName() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *AgentRuleUpsertOne) SetDescription(v string) *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *AgentRuleUpsertOne) UpdateDescription() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *AgentRuleUpsertOne) ClearDescription() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.ClearDescription() + }) +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentRuleUpsertOne) SetScopeType(v agentrule.ScopeType) *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.SetScopeType(v) + }) +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentRuleUpsertOne) UpdateScopeType() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateScopeType() + }) +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentRuleUpsertOne) SetScopeID(v string) *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.SetScopeID(v) + }) +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentRuleUpsertOne) UpdateScopeID() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateScopeID() + }) +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentRuleUpsertOne) SetCreatedBy(v uuid.UUID) *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.SetCreatedBy(v) + }) +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentRuleUpsertOne) UpdateCreatedBy() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateCreatedBy() + }) +} + +// SetActiveVersionID sets the "active_version_id" field. +func (u *AgentRuleUpsertOne) SetActiveVersionID(v uuid.UUID) *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.SetActiveVersionID(v) + }) +} + +// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create. +func (u *AgentRuleUpsertOne) UpdateActiveVersionID() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateActiveVersionID() + }) +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (u *AgentRuleUpsertOne) ClearActiveVersionID() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.ClearActiveVersionID() + }) +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentRuleUpsertOne) SetIsDeleted(v bool) *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.SetIsDeleted(v) + }) +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentRuleUpsertOne) UpdateIsDeleted() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateIsDeleted() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentRuleUpsertOne) SetCreatedAt(v time.Time) *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentRuleUpsertOne) UpdateCreatedAt() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentRuleUpsertOne) SetUpdatedAt(v time.Time) *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentRuleUpsertOne) UpdateUpdatedAt() *AgentRuleUpsertOne { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentRuleUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentRuleCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentRuleUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *AgentRuleUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: AgentRuleUpsertOne.ID is not supported by MySQL driver. Use AgentRuleUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *AgentRuleUpsertOne) IDX(ctx context.Context) uuid.UUID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// AgentRuleCreateBulk is the builder for creating many AgentRule entities in bulk. +type AgentRuleCreateBulk struct { + config + err error + builders []*AgentRuleCreate + conflict []sql.ConflictOption +} + +// Save creates the AgentRule entities in the database. +func (_c *AgentRuleCreateBulk) Save(ctx context.Context) ([]*AgentRule, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*AgentRule, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AgentRuleMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = _c.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AgentRuleCreateBulk) SaveX(ctx context.Context) []*AgentRule { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentRuleCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentRuleCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentRule.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentRuleUpsert) { +// SetName(v+v). +// }). +// Exec(ctx) +func (_c *AgentRuleCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentRuleUpsertBulk { + _c.conflict = opts + return &AgentRuleUpsertBulk{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentRule.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentRuleCreateBulk) OnConflictColumns(columns ...string) *AgentRuleUpsertBulk { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentRuleUpsertBulk{ + create: _c, + } +} + +// AgentRuleUpsertBulk is the builder for "upsert"-ing +// a bulk of AgentRule nodes. +type AgentRuleUpsertBulk struct { + create *AgentRuleCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.AgentRule.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentrule.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentRuleUpsertBulk) UpdateNewValues() *AgentRuleUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(agentrule.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentRule.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentRuleUpsertBulk) Ignore() *AgentRuleUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentRuleUpsertBulk) DoNothing() *AgentRuleUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentRuleCreateBulk.OnConflict +// documentation for more info. +func (u *AgentRuleUpsertBulk) Update(set func(*AgentRuleUpsert)) *AgentRuleUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentRuleUpsert{UpdateSet: update}) + })) + return u +} + +// SetName sets the "name" field. +func (u *AgentRuleUpsertBulk) SetName(v string) *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentRuleUpsertBulk) UpdateName() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *AgentRuleUpsertBulk) SetDescription(v string) *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *AgentRuleUpsertBulk) UpdateDescription() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *AgentRuleUpsertBulk) ClearDescription() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.ClearDescription() + }) +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentRuleUpsertBulk) SetScopeType(v agentrule.ScopeType) *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.SetScopeType(v) + }) +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentRuleUpsertBulk) UpdateScopeType() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateScopeType() + }) +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentRuleUpsertBulk) SetScopeID(v string) *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.SetScopeID(v) + }) +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentRuleUpsertBulk) UpdateScopeID() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateScopeID() + }) +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentRuleUpsertBulk) SetCreatedBy(v uuid.UUID) *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.SetCreatedBy(v) + }) +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentRuleUpsertBulk) UpdateCreatedBy() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateCreatedBy() + }) +} + +// SetActiveVersionID sets the "active_version_id" field. +func (u *AgentRuleUpsertBulk) SetActiveVersionID(v uuid.UUID) *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.SetActiveVersionID(v) + }) +} + +// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create. +func (u *AgentRuleUpsertBulk) UpdateActiveVersionID() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateActiveVersionID() + }) +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (u *AgentRuleUpsertBulk) ClearActiveVersionID() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.ClearActiveVersionID() + }) +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentRuleUpsertBulk) SetIsDeleted(v bool) *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.SetIsDeleted(v) + }) +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentRuleUpsertBulk) UpdateIsDeleted() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateIsDeleted() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentRuleUpsertBulk) SetCreatedAt(v time.Time) *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentRuleUpsertBulk) UpdateCreatedAt() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentRuleUpsertBulk) SetUpdatedAt(v time.Time) *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentRuleUpsertBulk) UpdateUpdatedAt() *AgentRuleUpsertBulk { + return u.Update(func(s *AgentRuleUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentRuleUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentRuleCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentRuleCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentRuleUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/teamskill_delete.go b/backend/db/agentrule_delete.go similarity index 54% rename from backend/db/teamskill_delete.go rename to backend/db/agentrule_delete.go index 7c09d011..8401bce9 100644 --- a/backend/db/teamskill_delete.go +++ b/backend/db/agentrule_delete.go @@ -8,30 +8,30 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" ) -// TeamSkillDelete is the builder for deleting a TeamSkill entity. -type TeamSkillDelete struct { +// AgentRuleDelete is the builder for deleting a AgentRule entity. +type AgentRuleDelete struct { config hooks []Hook - mutation *TeamSkillMutation + mutation *AgentRuleMutation } -// Where appends a list predicates to the TeamSkillDelete builder. -func (_d *TeamSkillDelete) Where(ps ...predicate.TeamSkill) *TeamSkillDelete { +// Where appends a list predicates to the AgentRuleDelete builder. +func (_d *AgentRuleDelete) Where(ps ...predicate.AgentRule) *AgentRuleDelete { _d.mutation.Where(ps...) return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (_d *TeamSkillDelete) Exec(ctx context.Context) (int, error) { +func (_d *AgentRuleDelete) Exec(ctx context.Context) (int, error) { return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (_d *TeamSkillDelete) ExecX(ctx context.Context) int { +func (_d *AgentRuleDelete) ExecX(ctx context.Context) int { n, err := _d.Exec(ctx) if err != nil { panic(err) @@ -39,8 +39,8 @@ func (_d *TeamSkillDelete) ExecX(ctx context.Context) int { return n } -func (_d *TeamSkillDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(teamskill.Table, sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID)) +func (_d *AgentRuleDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(agentrule.Table, sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID)) if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -56,32 +56,32 @@ func (_d *TeamSkillDelete) sqlExec(ctx context.Context) (int, error) { return affected, err } -// TeamSkillDeleteOne is the builder for deleting a single TeamSkill entity. -type TeamSkillDeleteOne struct { - _d *TeamSkillDelete +// AgentRuleDeleteOne is the builder for deleting a single AgentRule entity. +type AgentRuleDeleteOne struct { + _d *AgentRuleDelete } -// Where appends a list predicates to the TeamSkillDelete builder. -func (_d *TeamSkillDeleteOne) Where(ps ...predicate.TeamSkill) *TeamSkillDeleteOne { +// Where appends a list predicates to the AgentRuleDelete builder. +func (_d *AgentRuleDeleteOne) Where(ps ...predicate.AgentRule) *AgentRuleDeleteOne { _d._d.mutation.Where(ps...) return _d } // Exec executes the deletion query. -func (_d *TeamSkillDeleteOne) Exec(ctx context.Context) error { +func (_d *AgentRuleDeleteOne) Exec(ctx context.Context) error { n, err := _d._d.Exec(ctx) switch { case err != nil: return err case n == 0: - return &NotFoundError{teamskill.Label} + return &NotFoundError{agentrule.Label} default: return nil } } // ExecX is like Exec, but panics if an error occurs. -func (_d *TeamSkillDeleteOne) ExecX(ctx context.Context) { +func (_d *AgentRuleDeleteOne) ExecX(ctx context.Context) { if err := _d.Exec(ctx); err != nil { panic(err) } diff --git a/backend/db/agentrule_query.go b/backend/db/agentrule_query.go new file mode 100644 index 00000000..02535958 --- /dev/null +++ b/backend/db/agentrule_query.go @@ -0,0 +1,657 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentRuleQuery is the builder for querying AgentRule entities. +type AgentRuleQuery struct { + config + ctx *QueryContext + order []agentrule.OrderOption + inters []Interceptor + predicates []predicate.AgentRule + withVersions *AgentRuleVersionQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the AgentRuleQuery builder. +func (_q *AgentRuleQuery) Where(ps ...predicate.AgentRule) *AgentRuleQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *AgentRuleQuery) Limit(limit int) *AgentRuleQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *AgentRuleQuery) Offset(offset int) *AgentRuleQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *AgentRuleQuery) Unique(unique bool) *AgentRuleQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *AgentRuleQuery) Order(o ...agentrule.OrderOption) *AgentRuleQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryVersions chains the current query on the "versions" edge. +func (_q *AgentRuleQuery) QueryVersions() *AgentRuleVersionQuery { + query := (&AgentRuleVersionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(agentrule.Table, agentrule.FieldID, selector), + sqlgraph.To(agentruleversion.Table, agentruleversion.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, agentrule.VersionsTable, agentrule.VersionsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first AgentRule entity from the query. +// Returns a *NotFoundError when no AgentRule was found. +func (_q *AgentRuleQuery) First(ctx context.Context) (*AgentRule, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{agentrule.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *AgentRuleQuery) FirstX(ctx context.Context) *AgentRule { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first AgentRule ID from the query. +// Returns a *NotFoundError when no AgentRule ID was found. +func (_q *AgentRuleQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{agentrule.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *AgentRuleQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single AgentRule entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one AgentRule entity is found. +// Returns a *NotFoundError when no AgentRule entities are found. +func (_q *AgentRuleQuery) Only(ctx context.Context) (*AgentRule, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{agentrule.Label} + default: + return nil, &NotSingularError{agentrule.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *AgentRuleQuery) OnlyX(ctx context.Context) *AgentRule { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only AgentRule ID in the query. +// Returns a *NotSingularError when more than one AgentRule ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *AgentRuleQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{agentrule.Label} + default: + err = &NotSingularError{agentrule.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *AgentRuleQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of AgentRules. +func (_q *AgentRuleQuery) All(ctx context.Context) ([]*AgentRule, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*AgentRule, *AgentRuleQuery]() + return withInterceptors[[]*AgentRule](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *AgentRuleQuery) AllX(ctx context.Context) []*AgentRule { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of AgentRule IDs. +func (_q *AgentRuleQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(agentrule.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *AgentRuleQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *AgentRuleQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*AgentRuleQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *AgentRuleQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *AgentRuleQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *AgentRuleQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AgentRuleQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *AgentRuleQuery) Clone() *AgentRuleQuery { + if _q == nil { + return nil + } + return &AgentRuleQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]agentrule.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.AgentRule{}, _q.predicates...), + withVersions: _q.withVersions.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithVersions tells the query-builder to eager-load the nodes that are connected to +// the "versions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentRuleQuery) WithVersions(opts ...func(*AgentRuleVersionQuery)) *AgentRuleQuery { + query := (&AgentRuleVersionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withVersions = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Name string `json:"name,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.AgentRule.Query(). +// GroupBy(agentrule.FieldName). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (_q *AgentRuleQuery) GroupBy(field string, fields ...string) *AgentRuleGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &AgentRuleGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = agentrule.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Name string `json:"name,omitempty"` +// } +// +// client.AgentRule.Query(). +// Select(agentrule.FieldName). +// Scan(ctx, &v) +func (_q *AgentRuleQuery) Select(fields ...string) *AgentRuleSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &AgentRuleSelect{AgentRuleQuery: _q} + sbuild.label = agentrule.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AgentRuleSelect configured with the given aggregations. +func (_q *AgentRuleQuery) Aggregate(fns ...AggregateFunc) *AgentRuleSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *AgentRuleQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !agentrule.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *AgentRuleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AgentRule, error) { + var ( + nodes = []*AgentRule{} + _spec = _q.querySpec() + loadedTypes = [1]bool{ + _q.withVersions != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*AgentRule).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &AgentRule{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withVersions; query != nil { + if err := _q.loadVersions(ctx, query, nodes, + func(n *AgentRule) { n.Edges.Versions = []*AgentRuleVersion{} }, + func(n *AgentRule, e *AgentRuleVersion) { n.Edges.Versions = append(n.Edges.Versions, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *AgentRuleQuery) loadVersions(ctx context.Context, query *AgentRuleVersionQuery, nodes []*AgentRule, init func(*AgentRule), assign func(*AgentRule, *AgentRuleVersion)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*AgentRule) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(agentruleversion.FieldRuleID) + } + query.Where(predicate.AgentRuleVersion(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(agentrule.VersionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.RuleID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "rule_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *AgentRuleQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *AgentRuleQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(agentrule.Table, agentrule.Columns, sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentrule.FieldID) + for i := range fields { + if fields[i] != agentrule.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *AgentRuleQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(agentrule.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = agentrule.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *AgentRuleQuery) ForUpdate(opts ...sql.LockOption) *AgentRuleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *AgentRuleQuery) ForShare(opts ...sql.LockOption) *AgentRuleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *AgentRuleQuery) Modify(modifiers ...func(s *sql.Selector)) *AgentRuleSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// AgentRuleGroupBy is the group-by builder for AgentRule entities. +type AgentRuleGroupBy struct { + selector + build *AgentRuleQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *AgentRuleGroupBy) Aggregate(fns ...AggregateFunc) *AgentRuleGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *AgentRuleGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentRuleQuery, *AgentRuleGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *AgentRuleGroupBy) sqlScan(ctx context.Context, root *AgentRuleQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// AgentRuleSelect is the builder for selecting fields of AgentRule entities. +type AgentRuleSelect struct { + *AgentRuleQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *AgentRuleSelect) Aggregate(fns ...AggregateFunc) *AgentRuleSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *AgentRuleSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentRuleQuery, *AgentRuleSelect](ctx, _s.AgentRuleQuery, _s, _s.inters, v) +} + +func (_s *AgentRuleSelect) sqlScan(ctx context.Context, root *AgentRuleQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *AgentRuleSelect) Modify(modifiers ...func(s *sql.Selector)) *AgentRuleSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/backend/db/agentrule_update.go b/backend/db/agentrule_update.go new file mode 100644 index 00000000..9ed5d1aa --- /dev/null +++ b/backend/db/agentrule_update.go @@ -0,0 +1,736 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentRuleUpdate is the builder for updating AgentRule entities. +type AgentRuleUpdate struct { + config + hooks []Hook + mutation *AgentRuleMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the AgentRuleUpdate builder. +func (_u *AgentRuleUpdate) Where(ps ...predicate.AgentRule) *AgentRuleUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetName sets the "name" field. +func (_u *AgentRuleUpdate) SetName(v string) *AgentRuleUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *AgentRuleUpdate) SetNillableName(v *string) *AgentRuleUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *AgentRuleUpdate) SetDescription(v string) *AgentRuleUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *AgentRuleUpdate) SetNillableDescription(v *string) *AgentRuleUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *AgentRuleUpdate) ClearDescription() *AgentRuleUpdate { + _u.mutation.ClearDescription() + return _u +} + +// SetScopeType sets the "scope_type" field. +func (_u *AgentRuleUpdate) SetScopeType(v agentrule.ScopeType) *AgentRuleUpdate { + _u.mutation.SetScopeType(v) + return _u +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_u *AgentRuleUpdate) SetNillableScopeType(v *agentrule.ScopeType) *AgentRuleUpdate { + if v != nil { + _u.SetScopeType(*v) + } + return _u +} + +// SetScopeID sets the "scope_id" field. +func (_u *AgentRuleUpdate) SetScopeID(v string) *AgentRuleUpdate { + _u.mutation.SetScopeID(v) + return _u +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_u *AgentRuleUpdate) SetNillableScopeID(v *string) *AgentRuleUpdate { + if v != nil { + _u.SetScopeID(*v) + } + return _u +} + +// SetCreatedBy sets the "created_by" field. +func (_u *AgentRuleUpdate) SetCreatedBy(v uuid.UUID) *AgentRuleUpdate { + _u.mutation.SetCreatedBy(v) + return _u +} + +// SetNillableCreatedBy sets the "created_by" field if the given value is not nil. +func (_u *AgentRuleUpdate) SetNillableCreatedBy(v *uuid.UUID) *AgentRuleUpdate { + if v != nil { + _u.SetCreatedBy(*v) + } + return _u +} + +// SetActiveVersionID sets the "active_version_id" field. +func (_u *AgentRuleUpdate) SetActiveVersionID(v uuid.UUID) *AgentRuleUpdate { + _u.mutation.SetActiveVersionID(v) + return _u +} + +// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil. +func (_u *AgentRuleUpdate) SetNillableActiveVersionID(v *uuid.UUID) *AgentRuleUpdate { + if v != nil { + _u.SetActiveVersionID(*v) + } + return _u +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (_u *AgentRuleUpdate) ClearActiveVersionID() *AgentRuleUpdate { + _u.mutation.ClearActiveVersionID() + return _u +} + +// SetIsDeleted sets the "is_deleted" field. +func (_u *AgentRuleUpdate) SetIsDeleted(v bool) *AgentRuleUpdate { + _u.mutation.SetIsDeleted(v) + return _u +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_u *AgentRuleUpdate) SetNillableIsDeleted(v *bool) *AgentRuleUpdate { + if v != nil { + _u.SetIsDeleted(*v) + } + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentRuleUpdate) SetCreatedAt(v time.Time) *AgentRuleUpdate { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentRuleUpdate) SetNillableCreatedAt(v *time.Time) *AgentRuleUpdate { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentRuleUpdate) SetUpdatedAt(v time.Time) *AgentRuleUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// AddVersionIDs adds the "versions" edge to the AgentRuleVersion entity by IDs. +func (_u *AgentRuleUpdate) AddVersionIDs(ids ...uuid.UUID) *AgentRuleUpdate { + _u.mutation.AddVersionIDs(ids...) + return _u +} + +// AddVersions adds the "versions" edges to the AgentRuleVersion entity. +func (_u *AgentRuleUpdate) AddVersions(v ...*AgentRuleVersion) *AgentRuleUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddVersionIDs(ids...) +} + +// Mutation returns the AgentRuleMutation object of the builder. +func (_u *AgentRuleUpdate) Mutation() *AgentRuleMutation { + return _u.mutation +} + +// ClearVersions clears all "versions" edges to the AgentRuleVersion entity. +func (_u *AgentRuleUpdate) ClearVersions() *AgentRuleUpdate { + _u.mutation.ClearVersions() + return _u +} + +// RemoveVersionIDs removes the "versions" edge to AgentRuleVersion entities by IDs. +func (_u *AgentRuleUpdate) RemoveVersionIDs(ids ...uuid.UUID) *AgentRuleUpdate { + _u.mutation.RemoveVersionIDs(ids...) + return _u +} + +// RemoveVersions removes "versions" edges to AgentRuleVersion entities. +func (_u *AgentRuleUpdate) RemoveVersions(v ...*AgentRuleVersion) *AgentRuleUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveVersionIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AgentRuleUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentRuleUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AgentRuleUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentRuleUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentRuleUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentrule.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentRuleUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := agentrule.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentRule.name": %w`, err)} + } + } + if v, ok := _u.mutation.ScopeType(); ok { + if err := agentrule.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentRule.scope_type": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentRuleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentRuleUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentRuleUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentrule.Table, agentrule.Columns, sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(agentrule.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(agentrule.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(agentrule.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.ScopeType(); ok { + _spec.SetField(agentrule.FieldScopeType, field.TypeEnum, value) + } + if value, ok := _u.mutation.ScopeID(); ok { + _spec.SetField(agentrule.FieldScopeID, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedBy(); ok { + _spec.SetField(agentrule.FieldCreatedBy, field.TypeUUID, value) + } + if value, ok := _u.mutation.ActiveVersionID(); ok { + _spec.SetField(agentrule.FieldActiveVersionID, field.TypeUUID, value) + } + if _u.mutation.ActiveVersionIDCleared() { + _spec.ClearField(agentrule.FieldActiveVersionID, field.TypeUUID) + } + if value, ok := _u.mutation.IsDeleted(); ok { + _spec.SetField(agentrule.FieldIsDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentrule.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentrule.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentrule.VersionsTable, + Columns: []string{agentrule.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedVersionsIDs(); len(nodes) > 0 && !_u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentrule.VersionsTable, + Columns: []string{agentrule.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentrule.VersionsTable, + Columns: []string{agentrule.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentrule.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AgentRuleUpdateOne is the builder for updating a single AgentRule entity. +type AgentRuleUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AgentRuleMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetName sets the "name" field. +func (_u *AgentRuleUpdateOne) SetName(v string) *AgentRuleUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *AgentRuleUpdateOne) SetNillableName(v *string) *AgentRuleUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *AgentRuleUpdateOne) SetDescription(v string) *AgentRuleUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *AgentRuleUpdateOne) SetNillableDescription(v *string) *AgentRuleUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *AgentRuleUpdateOne) ClearDescription() *AgentRuleUpdateOne { + _u.mutation.ClearDescription() + return _u +} + +// SetScopeType sets the "scope_type" field. +func (_u *AgentRuleUpdateOne) SetScopeType(v agentrule.ScopeType) *AgentRuleUpdateOne { + _u.mutation.SetScopeType(v) + return _u +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_u *AgentRuleUpdateOne) SetNillableScopeType(v *agentrule.ScopeType) *AgentRuleUpdateOne { + if v != nil { + _u.SetScopeType(*v) + } + return _u +} + +// SetScopeID sets the "scope_id" field. +func (_u *AgentRuleUpdateOne) SetScopeID(v string) *AgentRuleUpdateOne { + _u.mutation.SetScopeID(v) + return _u +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_u *AgentRuleUpdateOne) SetNillableScopeID(v *string) *AgentRuleUpdateOne { + if v != nil { + _u.SetScopeID(*v) + } + return _u +} + +// SetCreatedBy sets the "created_by" field. +func (_u *AgentRuleUpdateOne) SetCreatedBy(v uuid.UUID) *AgentRuleUpdateOne { + _u.mutation.SetCreatedBy(v) + return _u +} + +// SetNillableCreatedBy sets the "created_by" field if the given value is not nil. +func (_u *AgentRuleUpdateOne) SetNillableCreatedBy(v *uuid.UUID) *AgentRuleUpdateOne { + if v != nil { + _u.SetCreatedBy(*v) + } + return _u +} + +// SetActiveVersionID sets the "active_version_id" field. +func (_u *AgentRuleUpdateOne) SetActiveVersionID(v uuid.UUID) *AgentRuleUpdateOne { + _u.mutation.SetActiveVersionID(v) + return _u +} + +// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil. +func (_u *AgentRuleUpdateOne) SetNillableActiveVersionID(v *uuid.UUID) *AgentRuleUpdateOne { + if v != nil { + _u.SetActiveVersionID(*v) + } + return _u +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (_u *AgentRuleUpdateOne) ClearActiveVersionID() *AgentRuleUpdateOne { + _u.mutation.ClearActiveVersionID() + return _u +} + +// SetIsDeleted sets the "is_deleted" field. +func (_u *AgentRuleUpdateOne) SetIsDeleted(v bool) *AgentRuleUpdateOne { + _u.mutation.SetIsDeleted(v) + return _u +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_u *AgentRuleUpdateOne) SetNillableIsDeleted(v *bool) *AgentRuleUpdateOne { + if v != nil { + _u.SetIsDeleted(*v) + } + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentRuleUpdateOne) SetCreatedAt(v time.Time) *AgentRuleUpdateOne { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentRuleUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentRuleUpdateOne { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentRuleUpdateOne) SetUpdatedAt(v time.Time) *AgentRuleUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// AddVersionIDs adds the "versions" edge to the AgentRuleVersion entity by IDs. +func (_u *AgentRuleUpdateOne) AddVersionIDs(ids ...uuid.UUID) *AgentRuleUpdateOne { + _u.mutation.AddVersionIDs(ids...) + return _u +} + +// AddVersions adds the "versions" edges to the AgentRuleVersion entity. +func (_u *AgentRuleUpdateOne) AddVersions(v ...*AgentRuleVersion) *AgentRuleUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddVersionIDs(ids...) +} + +// Mutation returns the AgentRuleMutation object of the builder. +func (_u *AgentRuleUpdateOne) Mutation() *AgentRuleMutation { + return _u.mutation +} + +// ClearVersions clears all "versions" edges to the AgentRuleVersion entity. +func (_u *AgentRuleUpdateOne) ClearVersions() *AgentRuleUpdateOne { + _u.mutation.ClearVersions() + return _u +} + +// RemoveVersionIDs removes the "versions" edge to AgentRuleVersion entities by IDs. +func (_u *AgentRuleUpdateOne) RemoveVersionIDs(ids ...uuid.UUID) *AgentRuleUpdateOne { + _u.mutation.RemoveVersionIDs(ids...) + return _u +} + +// RemoveVersions removes "versions" edges to AgentRuleVersion entities. +func (_u *AgentRuleUpdateOne) RemoveVersions(v ...*AgentRuleVersion) *AgentRuleUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveVersionIDs(ids...) +} + +// Where appends a list predicates to the AgentRuleUpdate builder. +func (_u *AgentRuleUpdateOne) Where(ps ...predicate.AgentRule) *AgentRuleUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *AgentRuleUpdateOne) Select(field string, fields ...string) *AgentRuleUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated AgentRule entity. +func (_u *AgentRuleUpdateOne) Save(ctx context.Context) (*AgentRule, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentRuleUpdateOne) SaveX(ctx context.Context) *AgentRule { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AgentRuleUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentRuleUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentRuleUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentrule.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentRuleUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := agentrule.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentRule.name": %w`, err)} + } + } + if v, ok := _u.mutation.ScopeType(); ok { + if err := agentrule.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentRule.scope_type": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentRuleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentRuleUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentRuleUpdateOne) sqlSave(ctx context.Context) (_node *AgentRule, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentrule.Table, agentrule.Columns, sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentRule.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentrule.FieldID) + for _, f := range fields { + if !agentrule.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != agentrule.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(agentrule.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(agentrule.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(agentrule.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.ScopeType(); ok { + _spec.SetField(agentrule.FieldScopeType, field.TypeEnum, value) + } + if value, ok := _u.mutation.ScopeID(); ok { + _spec.SetField(agentrule.FieldScopeID, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedBy(); ok { + _spec.SetField(agentrule.FieldCreatedBy, field.TypeUUID, value) + } + if value, ok := _u.mutation.ActiveVersionID(); ok { + _spec.SetField(agentrule.FieldActiveVersionID, field.TypeUUID, value) + } + if _u.mutation.ActiveVersionIDCleared() { + _spec.ClearField(agentrule.FieldActiveVersionID, field.TypeUUID) + } + if value, ok := _u.mutation.IsDeleted(); ok { + _spec.SetField(agentrule.FieldIsDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentrule.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentrule.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentrule.VersionsTable, + Columns: []string{agentrule.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedVersionsIDs(); len(nodes) > 0 && !_u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentrule.VersionsTable, + Columns: []string{agentrule.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentrule.VersionsTable, + Columns: []string{agentrule.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &AgentRule{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentrule.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/db/agentruleversion.go b/backend/db/agentruleversion.go new file mode 100644 index 00000000..74fc5a4e --- /dev/null +++ b/backend/db/agentruleversion.go @@ -0,0 +1,169 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/google/uuid" +) + +// AgentRuleVersion is the model entity for the AgentRuleVersion schema. +type AgentRuleVersion struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // RuleID holds the value of the "rule_id" field. + RuleID uuid.UUID `json:"rule_id,omitempty"` + // Version holds the value of the "version" field. + Version string `json:"version,omitempty"` + // Content holds the value of the "content" field. + Content string `json:"content,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the AgentRuleVersionQuery when eager-loading is set. + Edges AgentRuleVersionEdges `json:"edges"` + selectValues sql.SelectValues +} + +// AgentRuleVersionEdges holds the relations/edges for other nodes in the graph. +type AgentRuleVersionEdges struct { + // Rule holds the value of the rule edge. + Rule *AgentRule `json:"rule,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// RuleOrErr returns the Rule value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e AgentRuleVersionEdges) RuleOrErr() (*AgentRule, error) { + if e.Rule != nil { + return e.Rule, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: agentrule.Label} + } + return nil, &NotLoadedError{edge: "rule"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*AgentRuleVersion) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case agentruleversion.FieldVersion, agentruleversion.FieldContent: + values[i] = new(sql.NullString) + case agentruleversion.FieldCreatedAt: + values[i] = new(sql.NullTime) + case agentruleversion.FieldID, agentruleversion.FieldRuleID: + values[i] = new(uuid.UUID) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the AgentRuleVersion fields. +func (_m *AgentRuleVersion) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case agentruleversion.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case agentruleversion.FieldRuleID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field rule_id", values[i]) + } else if value != nil { + _m.RuleID = *value + } + case agentruleversion.FieldVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version", values[i]) + } else if value.Valid { + _m.Version = value.String + } + case agentruleversion.FieldContent: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field content", values[i]) + } else if value.Valid { + _m.Content = value.String + } + case agentruleversion.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the AgentRuleVersion. +// This includes values selected through modifiers, order, etc. +func (_m *AgentRuleVersion) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryRule queries the "rule" edge of the AgentRuleVersion entity. +func (_m *AgentRuleVersion) QueryRule() *AgentRuleQuery { + return NewAgentRuleVersionClient(_m.config).QueryRule(_m) +} + +// Update returns a builder for updating this AgentRuleVersion. +// Note that you need to call AgentRuleVersion.Unwrap() before calling this method if this AgentRuleVersion +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *AgentRuleVersion) Update() *AgentRuleVersionUpdateOne { + return NewAgentRuleVersionClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the AgentRuleVersion entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *AgentRuleVersion) Unwrap() *AgentRuleVersion { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("db: AgentRuleVersion is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *AgentRuleVersion) String() string { + var builder strings.Builder + builder.WriteString("AgentRuleVersion(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("rule_id=") + builder.WriteString(fmt.Sprintf("%v", _m.RuleID)) + builder.WriteString(", ") + builder.WriteString("version=") + builder.WriteString(_m.Version) + builder.WriteString(", ") + builder.WriteString("content=") + builder.WriteString(_m.Content) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// AgentRuleVersions is a parsable slice of AgentRuleVersion. +type AgentRuleVersions []*AgentRuleVersion diff --git a/backend/db/agentruleversion/agentruleversion.go b/backend/db/agentruleversion/agentruleversion.go new file mode 100644 index 00000000..27005303 --- /dev/null +++ b/backend/db/agentruleversion/agentruleversion.go @@ -0,0 +1,107 @@ +// Code generated by ent, DO NOT EDIT. + +package agentruleversion + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the agentruleversion type in the database. + Label = "agent_rule_version" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldRuleID holds the string denoting the rule_id field in the database. + FieldRuleID = "rule_id" + // FieldVersion holds the string denoting the version field in the database. + FieldVersion = "version" + // FieldContent holds the string denoting the content field in the database. + FieldContent = "content" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // EdgeRule holds the string denoting the rule edge name in mutations. + EdgeRule = "rule" + // Table holds the table name of the agentruleversion in the database. + Table = "agent_rule_versions" + // RuleTable is the table that holds the rule relation/edge. + RuleTable = "agent_rule_versions" + // RuleInverseTable is the table name for the AgentRule entity. + // It exists in this package in order to avoid circular dependency with the "agentrule" package. + RuleInverseTable = "agent_rules" + // RuleColumn is the table column denoting the rule relation/edge. + RuleColumn = "rule_id" +) + +// Columns holds all SQL columns for agentruleversion fields. +var Columns = []string{ + FieldID, + FieldRuleID, + FieldVersion, + FieldContent, + FieldCreatedAt, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // VersionValidator is a validator for the "version" field. It is called by the builders before save. + VersionValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// OrderOption defines the ordering options for the AgentRuleVersion queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByRuleID orders the results by the rule_id field. +func ByRuleID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRuleID, opts...).ToFunc() +} + +// ByVersion orders the results by the version field. +func ByVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersion, opts...).ToFunc() +} + +// ByContent orders the results by the content field. +func ByContent(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldContent, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByRuleField orders the results by rule field. +func ByRuleField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRuleStep(), sql.OrderByField(field, opts...)) + } +} +func newRuleStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RuleInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, RuleTable, RuleColumn), + ) +} diff --git a/backend/db/agentruleversion/where.go b/backend/db/agentruleversion/where.go new file mode 100644 index 00000000..47cb7814 --- /dev/null +++ b/backend/db/agentruleversion/where.go @@ -0,0 +1,305 @@ +// Code generated by ent, DO NOT EDIT. + +package agentruleversion + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldLTE(FieldID, id)) +} + +// RuleID applies equality check predicate on the "rule_id" field. It's identical to RuleIDEQ. +func RuleID(v uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEQ(FieldRuleID, v)) +} + +// Version applies equality check predicate on the "version" field. It's identical to VersionEQ. +func Version(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEQ(FieldVersion, v)) +} + +// Content applies equality check predicate on the "content" field. It's identical to ContentEQ. +func Content(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEQ(FieldContent, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEQ(FieldCreatedAt, v)) +} + +// RuleIDEQ applies the EQ predicate on the "rule_id" field. +func RuleIDEQ(v uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEQ(FieldRuleID, v)) +} + +// RuleIDNEQ applies the NEQ predicate on the "rule_id" field. +func RuleIDNEQ(v uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldNEQ(FieldRuleID, v)) +} + +// RuleIDIn applies the In predicate on the "rule_id" field. +func RuleIDIn(vs ...uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldIn(FieldRuleID, vs...)) +} + +// RuleIDNotIn applies the NotIn predicate on the "rule_id" field. +func RuleIDNotIn(vs ...uuid.UUID) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldNotIn(FieldRuleID, vs...)) +} + +// VersionEQ applies the EQ predicate on the "version" field. +func VersionEQ(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEQ(FieldVersion, v)) +} + +// VersionNEQ applies the NEQ predicate on the "version" field. +func VersionNEQ(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldNEQ(FieldVersion, v)) +} + +// VersionIn applies the In predicate on the "version" field. +func VersionIn(vs ...string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldIn(FieldVersion, vs...)) +} + +// VersionNotIn applies the NotIn predicate on the "version" field. +func VersionNotIn(vs ...string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldNotIn(FieldVersion, vs...)) +} + +// VersionGT applies the GT predicate on the "version" field. +func VersionGT(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldGT(FieldVersion, v)) +} + +// VersionGTE applies the GTE predicate on the "version" field. +func VersionGTE(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldGTE(FieldVersion, v)) +} + +// VersionLT applies the LT predicate on the "version" field. +func VersionLT(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldLT(FieldVersion, v)) +} + +// VersionLTE applies the LTE predicate on the "version" field. +func VersionLTE(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldLTE(FieldVersion, v)) +} + +// VersionContains applies the Contains predicate on the "version" field. +func VersionContains(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldContains(FieldVersion, v)) +} + +// VersionHasPrefix applies the HasPrefix predicate on the "version" field. +func VersionHasPrefix(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldHasPrefix(FieldVersion, v)) +} + +// VersionHasSuffix applies the HasSuffix predicate on the "version" field. +func VersionHasSuffix(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldHasSuffix(FieldVersion, v)) +} + +// VersionEqualFold applies the EqualFold predicate on the "version" field. +func VersionEqualFold(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEqualFold(FieldVersion, v)) +} + +// VersionContainsFold applies the ContainsFold predicate on the "version" field. +func VersionContainsFold(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldContainsFold(FieldVersion, v)) +} + +// ContentEQ applies the EQ predicate on the "content" field. +func ContentEQ(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEQ(FieldContent, v)) +} + +// ContentNEQ applies the NEQ predicate on the "content" field. +func ContentNEQ(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldNEQ(FieldContent, v)) +} + +// ContentIn applies the In predicate on the "content" field. +func ContentIn(vs ...string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldIn(FieldContent, vs...)) +} + +// ContentNotIn applies the NotIn predicate on the "content" field. +func ContentNotIn(vs ...string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldNotIn(FieldContent, vs...)) +} + +// ContentGT applies the GT predicate on the "content" field. +func ContentGT(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldGT(FieldContent, v)) +} + +// ContentGTE applies the GTE predicate on the "content" field. +func ContentGTE(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldGTE(FieldContent, v)) +} + +// ContentLT applies the LT predicate on the "content" field. +func ContentLT(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldLT(FieldContent, v)) +} + +// ContentLTE applies the LTE predicate on the "content" field. +func ContentLTE(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldLTE(FieldContent, v)) +} + +// ContentContains applies the Contains predicate on the "content" field. +func ContentContains(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldContains(FieldContent, v)) +} + +// ContentHasPrefix applies the HasPrefix predicate on the "content" field. +func ContentHasPrefix(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldHasPrefix(FieldContent, v)) +} + +// ContentHasSuffix applies the HasSuffix predicate on the "content" field. +func ContentHasSuffix(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldHasSuffix(FieldContent, v)) +} + +// ContentEqualFold applies the EqualFold predicate on the "content" field. +func ContentEqualFold(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEqualFold(FieldContent, v)) +} + +// ContentContainsFold applies the ContainsFold predicate on the "content" field. +func ContentContainsFold(v string) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldContainsFold(FieldContent, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.FieldLTE(FieldCreatedAt, v)) +} + +// HasRule applies the HasEdge predicate on the "rule" edge. +func HasRule() predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, RuleTable, RuleColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRuleWith applies the HasEdge predicate on the "rule" edge with a given conditions (other predicates). +func HasRuleWith(preds ...predicate.AgentRule) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(func(s *sql.Selector) { + step := newRuleStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.AgentRuleVersion) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.AgentRuleVersion) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.AgentRuleVersion) predicate.AgentRuleVersion { + return predicate.AgentRuleVersion(sql.NotPredicates(p)) +} diff --git a/backend/db/agentruleversion_create.go b/backend/db/agentruleversion_create.go new file mode 100644 index 00000000..cf065c6c --- /dev/null +++ b/backend/db/agentruleversion_create.go @@ -0,0 +1,707 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/google/uuid" +) + +// AgentRuleVersionCreate is the builder for creating a AgentRuleVersion entity. +type AgentRuleVersionCreate struct { + config + mutation *AgentRuleVersionMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetRuleID sets the "rule_id" field. +func (_c *AgentRuleVersionCreate) SetRuleID(v uuid.UUID) *AgentRuleVersionCreate { + _c.mutation.SetRuleID(v) + return _c +} + +// SetVersion sets the "version" field. +func (_c *AgentRuleVersionCreate) SetVersion(v string) *AgentRuleVersionCreate { + _c.mutation.SetVersion(v) + return _c +} + +// SetContent sets the "content" field. +func (_c *AgentRuleVersionCreate) SetContent(v string) *AgentRuleVersionCreate { + _c.mutation.SetContent(v) + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AgentRuleVersionCreate) SetCreatedAt(v time.Time) *AgentRuleVersionCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AgentRuleVersionCreate) SetNillableCreatedAt(v *time.Time) *AgentRuleVersionCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AgentRuleVersionCreate) SetID(v uuid.UUID) *AgentRuleVersionCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AgentRuleVersionCreate) SetNillableID(v *uuid.UUID) *AgentRuleVersionCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetRule sets the "rule" edge to the AgentRule entity. +func (_c *AgentRuleVersionCreate) SetRule(v *AgentRule) *AgentRuleVersionCreate { + return _c.SetRuleID(v.ID) +} + +// Mutation returns the AgentRuleVersionMutation object of the builder. +func (_c *AgentRuleVersionCreate) Mutation() *AgentRuleVersionMutation { + return _c.mutation +} + +// Save creates the AgentRuleVersion in the database. +func (_c *AgentRuleVersionCreate) Save(ctx context.Context) (*AgentRuleVersion, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AgentRuleVersionCreate) SaveX(ctx context.Context) *AgentRuleVersion { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentRuleVersionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentRuleVersionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AgentRuleVersionCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := agentruleversion.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := agentruleversion.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AgentRuleVersionCreate) check() error { + if _, ok := _c.mutation.RuleID(); !ok { + return &ValidationError{Name: "rule_id", err: errors.New(`db: missing required field "AgentRuleVersion.rule_id"`)} + } + if _, ok := _c.mutation.Version(); !ok { + return &ValidationError{Name: "version", err: errors.New(`db: missing required field "AgentRuleVersion.version"`)} + } + if v, ok := _c.mutation.Version(); ok { + if err := agentruleversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "AgentRuleVersion.version": %w`, err)} + } + } + if _, ok := _c.mutation.Content(); !ok { + return &ValidationError{Name: "content", err: errors.New(`db: missing required field "AgentRuleVersion.content"`)} + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentRuleVersion.created_at"`)} + } + if len(_c.mutation.RuleIDs()) == 0 { + return &ValidationError{Name: "rule", err: errors.New(`db: missing required edge "AgentRuleVersion.rule"`)} + } + return nil +} + +func (_c *AgentRuleVersionCreate) sqlSave(ctx context.Context) (*AgentRuleVersion, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AgentRuleVersionCreate) createSpec() (*AgentRuleVersion, *sqlgraph.CreateSpec) { + var ( + _node = &AgentRuleVersion{config: _c.config} + _spec = sqlgraph.NewCreateSpec(agentruleversion.Table, sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID)) + ) + _spec.OnConflict = _c.conflict + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.Version(); ok { + _spec.SetField(agentruleversion.FieldVersion, field.TypeString, value) + _node.Version = value + } + if value, ok := _c.mutation.Content(); ok { + _spec.SetField(agentruleversion.FieldContent, field.TypeString, value) + _node.Content = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(agentruleversion.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if nodes := _c.mutation.RuleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentruleversion.RuleTable, + Columns: []string{agentruleversion.RuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.RuleID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentRuleVersion.Create(). +// SetRuleID(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentRuleVersionUpsert) { +// SetRuleID(v+v). +// }). +// Exec(ctx) +func (_c *AgentRuleVersionCreate) OnConflict(opts ...sql.ConflictOption) *AgentRuleVersionUpsertOne { + _c.conflict = opts + return &AgentRuleVersionUpsertOne{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentRuleVersion.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentRuleVersionCreate) OnConflictColumns(columns ...string) *AgentRuleVersionUpsertOne { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentRuleVersionUpsertOne{ + create: _c, + } +} + +type ( + // AgentRuleVersionUpsertOne is the builder for "upsert"-ing + // one AgentRuleVersion node. + AgentRuleVersionUpsertOne struct { + create *AgentRuleVersionCreate + } + + // AgentRuleVersionUpsert is the "OnConflict" setter. + AgentRuleVersionUpsert struct { + *sql.UpdateSet + } +) + +// SetRuleID sets the "rule_id" field. +func (u *AgentRuleVersionUpsert) SetRuleID(v uuid.UUID) *AgentRuleVersionUpsert { + u.Set(agentruleversion.FieldRuleID, v) + return u +} + +// UpdateRuleID sets the "rule_id" field to the value that was provided on create. +func (u *AgentRuleVersionUpsert) UpdateRuleID() *AgentRuleVersionUpsert { + u.SetExcluded(agentruleversion.FieldRuleID) + return u +} + +// SetVersion sets the "version" field. +func (u *AgentRuleVersionUpsert) SetVersion(v string) *AgentRuleVersionUpsert { + u.Set(agentruleversion.FieldVersion, v) + return u +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *AgentRuleVersionUpsert) UpdateVersion() *AgentRuleVersionUpsert { + u.SetExcluded(agentruleversion.FieldVersion) + return u +} + +// SetContent sets the "content" field. +func (u *AgentRuleVersionUpsert) SetContent(v string) *AgentRuleVersionUpsert { + u.Set(agentruleversion.FieldContent, v) + return u +} + +// UpdateContent sets the "content" field to the value that was provided on create. +func (u *AgentRuleVersionUpsert) UpdateContent() *AgentRuleVersionUpsert { + u.SetExcluded(agentruleversion.FieldContent) + return u +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentRuleVersionUpsert) SetCreatedAt(v time.Time) *AgentRuleVersionUpsert { + u.Set(agentruleversion.FieldCreatedAt, v) + return u +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentRuleVersionUpsert) UpdateCreatedAt() *AgentRuleVersionUpsert { + u.SetExcluded(agentruleversion.FieldCreatedAt) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.AgentRuleVersion.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentruleversion.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentRuleVersionUpsertOne) UpdateNewValues() *AgentRuleVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(agentruleversion.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentRuleVersion.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentRuleVersionUpsertOne) Ignore() *AgentRuleVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentRuleVersionUpsertOne) DoNothing() *AgentRuleVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentRuleVersionCreate.OnConflict +// documentation for more info. +func (u *AgentRuleVersionUpsertOne) Update(set func(*AgentRuleVersionUpsert)) *AgentRuleVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentRuleVersionUpsert{UpdateSet: update}) + })) + return u +} + +// SetRuleID sets the "rule_id" field. +func (u *AgentRuleVersionUpsertOne) SetRuleID(v uuid.UUID) *AgentRuleVersionUpsertOne { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.SetRuleID(v) + }) +} + +// UpdateRuleID sets the "rule_id" field to the value that was provided on create. +func (u *AgentRuleVersionUpsertOne) UpdateRuleID() *AgentRuleVersionUpsertOne { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.UpdateRuleID() + }) +} + +// SetVersion sets the "version" field. +func (u *AgentRuleVersionUpsertOne) SetVersion(v string) *AgentRuleVersionUpsertOne { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *AgentRuleVersionUpsertOne) UpdateVersion() *AgentRuleVersionUpsertOne { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.UpdateVersion() + }) +} + +// SetContent sets the "content" field. +func (u *AgentRuleVersionUpsertOne) SetContent(v string) *AgentRuleVersionUpsertOne { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.SetContent(v) + }) +} + +// UpdateContent sets the "content" field to the value that was provided on create. +func (u *AgentRuleVersionUpsertOne) UpdateContent() *AgentRuleVersionUpsertOne { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.UpdateContent() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentRuleVersionUpsertOne) SetCreatedAt(v time.Time) *AgentRuleVersionUpsertOne { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentRuleVersionUpsertOne) UpdateCreatedAt() *AgentRuleVersionUpsertOne { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.UpdateCreatedAt() + }) +} + +// Exec executes the query. +func (u *AgentRuleVersionUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentRuleVersionCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentRuleVersionUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *AgentRuleVersionUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: AgentRuleVersionUpsertOne.ID is not supported by MySQL driver. Use AgentRuleVersionUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *AgentRuleVersionUpsertOne) IDX(ctx context.Context) uuid.UUID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// AgentRuleVersionCreateBulk is the builder for creating many AgentRuleVersion entities in bulk. +type AgentRuleVersionCreateBulk struct { + config + err error + builders []*AgentRuleVersionCreate + conflict []sql.ConflictOption +} + +// Save creates the AgentRuleVersion entities in the database. +func (_c *AgentRuleVersionCreateBulk) Save(ctx context.Context) ([]*AgentRuleVersion, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*AgentRuleVersion, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AgentRuleVersionMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = _c.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AgentRuleVersionCreateBulk) SaveX(ctx context.Context) []*AgentRuleVersion { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentRuleVersionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentRuleVersionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentRuleVersion.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentRuleVersionUpsert) { +// SetRuleID(v+v). +// }). +// Exec(ctx) +func (_c *AgentRuleVersionCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentRuleVersionUpsertBulk { + _c.conflict = opts + return &AgentRuleVersionUpsertBulk{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentRuleVersion.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentRuleVersionCreateBulk) OnConflictColumns(columns ...string) *AgentRuleVersionUpsertBulk { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentRuleVersionUpsertBulk{ + create: _c, + } +} + +// AgentRuleVersionUpsertBulk is the builder for "upsert"-ing +// a bulk of AgentRuleVersion nodes. +type AgentRuleVersionUpsertBulk struct { + create *AgentRuleVersionCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.AgentRuleVersion.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentruleversion.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentRuleVersionUpsertBulk) UpdateNewValues() *AgentRuleVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(agentruleversion.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentRuleVersion.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentRuleVersionUpsertBulk) Ignore() *AgentRuleVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentRuleVersionUpsertBulk) DoNothing() *AgentRuleVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentRuleVersionCreateBulk.OnConflict +// documentation for more info. +func (u *AgentRuleVersionUpsertBulk) Update(set func(*AgentRuleVersionUpsert)) *AgentRuleVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentRuleVersionUpsert{UpdateSet: update}) + })) + return u +} + +// SetRuleID sets the "rule_id" field. +func (u *AgentRuleVersionUpsertBulk) SetRuleID(v uuid.UUID) *AgentRuleVersionUpsertBulk { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.SetRuleID(v) + }) +} + +// UpdateRuleID sets the "rule_id" field to the value that was provided on create. +func (u *AgentRuleVersionUpsertBulk) UpdateRuleID() *AgentRuleVersionUpsertBulk { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.UpdateRuleID() + }) +} + +// SetVersion sets the "version" field. +func (u *AgentRuleVersionUpsertBulk) SetVersion(v string) *AgentRuleVersionUpsertBulk { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *AgentRuleVersionUpsertBulk) UpdateVersion() *AgentRuleVersionUpsertBulk { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.UpdateVersion() + }) +} + +// SetContent sets the "content" field. +func (u *AgentRuleVersionUpsertBulk) SetContent(v string) *AgentRuleVersionUpsertBulk { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.SetContent(v) + }) +} + +// UpdateContent sets the "content" field to the value that was provided on create. +func (u *AgentRuleVersionUpsertBulk) UpdateContent() *AgentRuleVersionUpsertBulk { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.UpdateContent() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentRuleVersionUpsertBulk) SetCreatedAt(v time.Time) *AgentRuleVersionUpsertBulk { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentRuleVersionUpsertBulk) UpdateCreatedAt() *AgentRuleVersionUpsertBulk { + return u.Update(func(s *AgentRuleVersionUpsert) { + s.UpdateCreatedAt() + }) +} + +// Exec executes the query. +func (u *AgentRuleVersionUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentRuleVersionCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentRuleVersionCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentRuleVersionUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentruleversion_delete.go b/backend/db/agentruleversion_delete.go new file mode 100644 index 00000000..50a13378 --- /dev/null +++ b/backend/db/agentruleversion_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" +) + +// AgentRuleVersionDelete is the builder for deleting a AgentRuleVersion entity. +type AgentRuleVersionDelete struct { + config + hooks []Hook + mutation *AgentRuleVersionMutation +} + +// Where appends a list predicates to the AgentRuleVersionDelete builder. +func (_d *AgentRuleVersionDelete) Where(ps ...predicate.AgentRuleVersion) *AgentRuleVersionDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *AgentRuleVersionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentRuleVersionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *AgentRuleVersionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(agentruleversion.Table, sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// AgentRuleVersionDeleteOne is the builder for deleting a single AgentRuleVersion entity. +type AgentRuleVersionDeleteOne struct { + _d *AgentRuleVersionDelete +} + +// Where appends a list predicates to the AgentRuleVersionDelete builder. +func (_d *AgentRuleVersionDeleteOne) Where(ps ...predicate.AgentRuleVersion) *AgentRuleVersionDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *AgentRuleVersionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{agentruleversion.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentRuleVersionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentruleversion_query.go b/backend/db/agentruleversion_query.go new file mode 100644 index 00000000..7a0ba010 --- /dev/null +++ b/backend/db/agentruleversion_query.go @@ -0,0 +1,657 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentRuleVersionQuery is the builder for querying AgentRuleVersion entities. +type AgentRuleVersionQuery struct { + config + ctx *QueryContext + order []agentruleversion.OrderOption + inters []Interceptor + predicates []predicate.AgentRuleVersion + withRule *AgentRuleQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the AgentRuleVersionQuery builder. +func (_q *AgentRuleVersionQuery) Where(ps ...predicate.AgentRuleVersion) *AgentRuleVersionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *AgentRuleVersionQuery) Limit(limit int) *AgentRuleVersionQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *AgentRuleVersionQuery) Offset(offset int) *AgentRuleVersionQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *AgentRuleVersionQuery) Unique(unique bool) *AgentRuleVersionQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *AgentRuleVersionQuery) Order(o ...agentruleversion.OrderOption) *AgentRuleVersionQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryRule chains the current query on the "rule" edge. +func (_q *AgentRuleVersionQuery) QueryRule() *AgentRuleQuery { + query := (&AgentRuleClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(agentruleversion.Table, agentruleversion.FieldID, selector), + sqlgraph.To(agentrule.Table, agentrule.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, agentruleversion.RuleTable, agentruleversion.RuleColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first AgentRuleVersion entity from the query. +// Returns a *NotFoundError when no AgentRuleVersion was found. +func (_q *AgentRuleVersionQuery) First(ctx context.Context) (*AgentRuleVersion, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{agentruleversion.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *AgentRuleVersionQuery) FirstX(ctx context.Context) *AgentRuleVersion { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first AgentRuleVersion ID from the query. +// Returns a *NotFoundError when no AgentRuleVersion ID was found. +func (_q *AgentRuleVersionQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{agentruleversion.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *AgentRuleVersionQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single AgentRuleVersion entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one AgentRuleVersion entity is found. +// Returns a *NotFoundError when no AgentRuleVersion entities are found. +func (_q *AgentRuleVersionQuery) Only(ctx context.Context) (*AgentRuleVersion, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{agentruleversion.Label} + default: + return nil, &NotSingularError{agentruleversion.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *AgentRuleVersionQuery) OnlyX(ctx context.Context) *AgentRuleVersion { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only AgentRuleVersion ID in the query. +// Returns a *NotSingularError when more than one AgentRuleVersion ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *AgentRuleVersionQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{agentruleversion.Label} + default: + err = &NotSingularError{agentruleversion.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *AgentRuleVersionQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of AgentRuleVersions. +func (_q *AgentRuleVersionQuery) All(ctx context.Context) ([]*AgentRuleVersion, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*AgentRuleVersion, *AgentRuleVersionQuery]() + return withInterceptors[[]*AgentRuleVersion](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *AgentRuleVersionQuery) AllX(ctx context.Context) []*AgentRuleVersion { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of AgentRuleVersion IDs. +func (_q *AgentRuleVersionQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(agentruleversion.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *AgentRuleVersionQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *AgentRuleVersionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*AgentRuleVersionQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *AgentRuleVersionQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *AgentRuleVersionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *AgentRuleVersionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AgentRuleVersionQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *AgentRuleVersionQuery) Clone() *AgentRuleVersionQuery { + if _q == nil { + return nil + } + return &AgentRuleVersionQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]agentruleversion.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.AgentRuleVersion{}, _q.predicates...), + withRule: _q.withRule.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithRule tells the query-builder to eager-load the nodes that are connected to +// the "rule" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentRuleVersionQuery) WithRule(opts ...func(*AgentRuleQuery)) *AgentRuleVersionQuery { + query := (&AgentRuleClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRule = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// RuleID uuid.UUID `json:"rule_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.AgentRuleVersion.Query(). +// GroupBy(agentruleversion.FieldRuleID). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (_q *AgentRuleVersionQuery) GroupBy(field string, fields ...string) *AgentRuleVersionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &AgentRuleVersionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = agentruleversion.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// RuleID uuid.UUID `json:"rule_id,omitempty"` +// } +// +// client.AgentRuleVersion.Query(). +// Select(agentruleversion.FieldRuleID). +// Scan(ctx, &v) +func (_q *AgentRuleVersionQuery) Select(fields ...string) *AgentRuleVersionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &AgentRuleVersionSelect{AgentRuleVersionQuery: _q} + sbuild.label = agentruleversion.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AgentRuleVersionSelect configured with the given aggregations. +func (_q *AgentRuleVersionQuery) Aggregate(fns ...AggregateFunc) *AgentRuleVersionSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *AgentRuleVersionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !agentruleversion.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *AgentRuleVersionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AgentRuleVersion, error) { + var ( + nodes = []*AgentRuleVersion{} + _spec = _q.querySpec() + loadedTypes = [1]bool{ + _q.withRule != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*AgentRuleVersion).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &AgentRuleVersion{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withRule; query != nil { + if err := _q.loadRule(ctx, query, nodes, nil, + func(n *AgentRuleVersion, e *AgentRule) { n.Edges.Rule = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *AgentRuleVersionQuery) loadRule(ctx context.Context, query *AgentRuleQuery, nodes []*AgentRuleVersion, init func(*AgentRuleVersion), assign func(*AgentRuleVersion, *AgentRule)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*AgentRuleVersion) + for i := range nodes { + fk := nodes[i].RuleID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(agentrule.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "rule_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *AgentRuleVersionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *AgentRuleVersionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(agentruleversion.Table, agentruleversion.Columns, sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentruleversion.FieldID) + for i := range fields { + if fields[i] != agentruleversion.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withRule != nil { + _spec.Node.AddColumnOnce(agentruleversion.FieldRuleID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *AgentRuleVersionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(agentruleversion.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = agentruleversion.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *AgentRuleVersionQuery) ForUpdate(opts ...sql.LockOption) *AgentRuleVersionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *AgentRuleVersionQuery) ForShare(opts ...sql.LockOption) *AgentRuleVersionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *AgentRuleVersionQuery) Modify(modifiers ...func(s *sql.Selector)) *AgentRuleVersionSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// AgentRuleVersionGroupBy is the group-by builder for AgentRuleVersion entities. +type AgentRuleVersionGroupBy struct { + selector + build *AgentRuleVersionQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *AgentRuleVersionGroupBy) Aggregate(fns ...AggregateFunc) *AgentRuleVersionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *AgentRuleVersionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentRuleVersionQuery, *AgentRuleVersionGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *AgentRuleVersionGroupBy) sqlScan(ctx context.Context, root *AgentRuleVersionQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// AgentRuleVersionSelect is the builder for selecting fields of AgentRuleVersion entities. +type AgentRuleVersionSelect struct { + *AgentRuleVersionQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *AgentRuleVersionSelect) Aggregate(fns ...AggregateFunc) *AgentRuleVersionSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *AgentRuleVersionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentRuleVersionQuery, *AgentRuleVersionSelect](ctx, _s.AgentRuleVersionQuery, _s, _s.inters, v) +} + +func (_s *AgentRuleVersionSelect) sqlScan(ctx context.Context, root *AgentRuleVersionQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *AgentRuleVersionSelect) Modify(modifiers ...func(s *sql.Selector)) *AgentRuleVersionSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/backend/db/agentruleversion_update.go b/backend/db/agentruleversion_update.go new file mode 100644 index 00000000..91222d08 --- /dev/null +++ b/backend/db/agentruleversion_update.go @@ -0,0 +1,436 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentRuleVersionUpdate is the builder for updating AgentRuleVersion entities. +type AgentRuleVersionUpdate struct { + config + hooks []Hook + mutation *AgentRuleVersionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the AgentRuleVersionUpdate builder. +func (_u *AgentRuleVersionUpdate) Where(ps ...predicate.AgentRuleVersion) *AgentRuleVersionUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetRuleID sets the "rule_id" field. +func (_u *AgentRuleVersionUpdate) SetRuleID(v uuid.UUID) *AgentRuleVersionUpdate { + _u.mutation.SetRuleID(v) + return _u +} + +// SetNillableRuleID sets the "rule_id" field if the given value is not nil. +func (_u *AgentRuleVersionUpdate) SetNillableRuleID(v *uuid.UUID) *AgentRuleVersionUpdate { + if v != nil { + _u.SetRuleID(*v) + } + return _u +} + +// SetVersion sets the "version" field. +func (_u *AgentRuleVersionUpdate) SetVersion(v string) *AgentRuleVersionUpdate { + _u.mutation.SetVersion(v) + return _u +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (_u *AgentRuleVersionUpdate) SetNillableVersion(v *string) *AgentRuleVersionUpdate { + if v != nil { + _u.SetVersion(*v) + } + return _u +} + +// SetContent sets the "content" field. +func (_u *AgentRuleVersionUpdate) SetContent(v string) *AgentRuleVersionUpdate { + _u.mutation.SetContent(v) + return _u +} + +// SetNillableContent sets the "content" field if the given value is not nil. +func (_u *AgentRuleVersionUpdate) SetNillableContent(v *string) *AgentRuleVersionUpdate { + if v != nil { + _u.SetContent(*v) + } + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentRuleVersionUpdate) SetCreatedAt(v time.Time) *AgentRuleVersionUpdate { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentRuleVersionUpdate) SetNillableCreatedAt(v *time.Time) *AgentRuleVersionUpdate { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetRule sets the "rule" edge to the AgentRule entity. +func (_u *AgentRuleVersionUpdate) SetRule(v *AgentRule) *AgentRuleVersionUpdate { + return _u.SetRuleID(v.ID) +} + +// Mutation returns the AgentRuleVersionMutation object of the builder. +func (_u *AgentRuleVersionUpdate) Mutation() *AgentRuleVersionMutation { + return _u.mutation +} + +// ClearRule clears the "rule" edge to the AgentRule entity. +func (_u *AgentRuleVersionUpdate) ClearRule() *AgentRuleVersionUpdate { + _u.mutation.ClearRule() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AgentRuleVersionUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentRuleVersionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AgentRuleVersionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentRuleVersionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentRuleVersionUpdate) check() error { + if v, ok := _u.mutation.Version(); ok { + if err := agentruleversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "AgentRuleVersion.version": %w`, err)} + } + } + if _u.mutation.RuleCleared() && len(_u.mutation.RuleIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentRuleVersion.rule"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentRuleVersionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentRuleVersionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentRuleVersionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentruleversion.Table, agentruleversion.Columns, sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Version(); ok { + _spec.SetField(agentruleversion.FieldVersion, field.TypeString, value) + } + if value, ok := _u.mutation.Content(); ok { + _spec.SetField(agentruleversion.FieldContent, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentruleversion.FieldCreatedAt, field.TypeTime, value) + } + if _u.mutation.RuleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentruleversion.RuleTable, + Columns: []string{agentruleversion.RuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RuleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentruleversion.RuleTable, + Columns: []string{agentruleversion.RuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentruleversion.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AgentRuleVersionUpdateOne is the builder for updating a single AgentRuleVersion entity. +type AgentRuleVersionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AgentRuleVersionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetRuleID sets the "rule_id" field. +func (_u *AgentRuleVersionUpdateOne) SetRuleID(v uuid.UUID) *AgentRuleVersionUpdateOne { + _u.mutation.SetRuleID(v) + return _u +} + +// SetNillableRuleID sets the "rule_id" field if the given value is not nil. +func (_u *AgentRuleVersionUpdateOne) SetNillableRuleID(v *uuid.UUID) *AgentRuleVersionUpdateOne { + if v != nil { + _u.SetRuleID(*v) + } + return _u +} + +// SetVersion sets the "version" field. +func (_u *AgentRuleVersionUpdateOne) SetVersion(v string) *AgentRuleVersionUpdateOne { + _u.mutation.SetVersion(v) + return _u +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (_u *AgentRuleVersionUpdateOne) SetNillableVersion(v *string) *AgentRuleVersionUpdateOne { + if v != nil { + _u.SetVersion(*v) + } + return _u +} + +// SetContent sets the "content" field. +func (_u *AgentRuleVersionUpdateOne) SetContent(v string) *AgentRuleVersionUpdateOne { + _u.mutation.SetContent(v) + return _u +} + +// SetNillableContent sets the "content" field if the given value is not nil. +func (_u *AgentRuleVersionUpdateOne) SetNillableContent(v *string) *AgentRuleVersionUpdateOne { + if v != nil { + _u.SetContent(*v) + } + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentRuleVersionUpdateOne) SetCreatedAt(v time.Time) *AgentRuleVersionUpdateOne { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentRuleVersionUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentRuleVersionUpdateOne { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetRule sets the "rule" edge to the AgentRule entity. +func (_u *AgentRuleVersionUpdateOne) SetRule(v *AgentRule) *AgentRuleVersionUpdateOne { + return _u.SetRuleID(v.ID) +} + +// Mutation returns the AgentRuleVersionMutation object of the builder. +func (_u *AgentRuleVersionUpdateOne) Mutation() *AgentRuleVersionMutation { + return _u.mutation +} + +// ClearRule clears the "rule" edge to the AgentRule entity. +func (_u *AgentRuleVersionUpdateOne) ClearRule() *AgentRuleVersionUpdateOne { + _u.mutation.ClearRule() + return _u +} + +// Where appends a list predicates to the AgentRuleVersionUpdate builder. +func (_u *AgentRuleVersionUpdateOne) Where(ps ...predicate.AgentRuleVersion) *AgentRuleVersionUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *AgentRuleVersionUpdateOne) Select(field string, fields ...string) *AgentRuleVersionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated AgentRuleVersion entity. +func (_u *AgentRuleVersionUpdateOne) Save(ctx context.Context) (*AgentRuleVersion, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentRuleVersionUpdateOne) SaveX(ctx context.Context) *AgentRuleVersion { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AgentRuleVersionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentRuleVersionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentRuleVersionUpdateOne) check() error { + if v, ok := _u.mutation.Version(); ok { + if err := agentruleversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "AgentRuleVersion.version": %w`, err)} + } + } + if _u.mutation.RuleCleared() && len(_u.mutation.RuleIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentRuleVersion.rule"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentRuleVersionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentRuleVersionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentRuleVersionUpdateOne) sqlSave(ctx context.Context) (_node *AgentRuleVersion, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentruleversion.Table, agentruleversion.Columns, sqlgraph.NewFieldSpec(agentruleversion.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentRuleVersion.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentruleversion.FieldID) + for _, f := range fields { + if !agentruleversion.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != agentruleversion.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Version(); ok { + _spec.SetField(agentruleversion.FieldVersion, field.TypeString, value) + } + if value, ok := _u.mutation.Content(); ok { + _spec.SetField(agentruleversion.FieldContent, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentruleversion.FieldCreatedAt, field.TypeTime, value) + } + if _u.mutation.RuleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentruleversion.RuleTable, + Columns: []string{agentruleversion.RuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RuleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentruleversion.RuleTable, + Columns: []string{agentruleversion.RuleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentrule.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &AgentRuleVersion{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentruleversion.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/db/agentskill.go b/backend/db/agentskill.go new file mode 100644 index 00000000..5e940643 --- /dev/null +++ b/backend/db/agentskill.go @@ -0,0 +1,335 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/google/uuid" +) + +// AgentSkill is the model entity for the AgentSkill schema. +type AgentSkill struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // RepoID holds the value of the "repo_id" field. + RepoID uuid.UUID `json:"repo_id,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description string `json:"description,omitempty"` + // ScopeType holds the value of the "scope_type" field. + ScopeType agentskill.ScopeType `json:"scope_type,omitempty"` + // ScopeID holds the value of the "scope_id" field. + ScopeID string `json:"scope_id,omitempty"` + // CreatedBy holds the value of the "created_by" field. + CreatedBy uuid.UUID `json:"created_by,omitempty"` + // ActiveVersionID holds the value of the "active_version_id" field. + ActiveVersionID *uuid.UUID `json:"active_version_id,omitempty"` + // IsForceDelivery holds the value of the "is_force_delivery" field. + IsForceDelivery bool `json:"is_force_delivery,omitempty"` + // IsOrphan holds the value of the "is_orphan" field. + IsOrphan bool `json:"is_orphan,omitempty"` + // IsDeleted holds the value of the "is_deleted" field. + IsDeleted bool `json:"is_deleted,omitempty"` + // Enabled holds the value of the "enabled" field. + Enabled bool `json:"enabled,omitempty"` + // ExtensionPackageID holds the value of the "extension_package_id" field. + ExtensionPackageID *string `json:"extension_package_id,omitempty"` + // AdminDescription holds the value of the "admin_description" field. + AdminDescription *string `json:"admin_description,omitempty"` + // AdminTags holds the value of the "admin_tags" field. + AdminTags []string `json:"admin_tags,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the AgentSkillQuery when eager-loading is set. + Edges AgentSkillEdges `json:"edges"` + selectValues sql.SelectValues +} + +// AgentSkillEdges holds the relations/edges for other nodes in the graph. +type AgentSkillEdges struct { + // Repo holds the value of the repo edge. + Repo *AgentSkillRepo `json:"repo,omitempty"` + // Versions holds the value of the versions edge. + Versions []*AgentSkillVersion `json:"versions,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// RepoOrErr returns the Repo value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e AgentSkillEdges) RepoOrErr() (*AgentSkillRepo, error) { + if e.Repo != nil { + return e.Repo, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: agentskillrepo.Label} + } + return nil, &NotLoadedError{edge: "repo"} +} + +// VersionsOrErr returns the Versions value or an error if the edge +// was not loaded in eager-loading. +func (e AgentSkillEdges) VersionsOrErr() ([]*AgentSkillVersion, error) { + if e.loadedTypes[1] { + return e.Versions, nil + } + return nil, &NotLoadedError{edge: "versions"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*AgentSkill) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case agentskill.FieldActiveVersionID: + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + case agentskill.FieldAdminTags: + values[i] = new([]byte) + case agentskill.FieldIsForceDelivery, agentskill.FieldIsOrphan, agentskill.FieldIsDeleted, agentskill.FieldEnabled: + values[i] = new(sql.NullBool) + case agentskill.FieldName, agentskill.FieldDescription, agentskill.FieldScopeType, agentskill.FieldScopeID, agentskill.FieldExtensionPackageID, agentskill.FieldAdminDescription: + values[i] = new(sql.NullString) + case agentskill.FieldCreatedAt, agentskill.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case agentskill.FieldID, agentskill.FieldRepoID, agentskill.FieldCreatedBy: + values[i] = new(uuid.UUID) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the AgentSkill fields. +func (_m *AgentSkill) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case agentskill.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case agentskill.FieldRepoID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field repo_id", values[i]) + } else if value != nil { + _m.RepoID = *value + } + case agentskill.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case agentskill.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case agentskill.FieldScopeType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope_type", values[i]) + } else if value.Valid { + _m.ScopeType = agentskill.ScopeType(value.String) + } + case agentskill.FieldScopeID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope_id", values[i]) + } else if value.Valid { + _m.ScopeID = value.String + } + case agentskill.FieldCreatedBy: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field created_by", values[i]) + } else if value != nil { + _m.CreatedBy = *value + } + case agentskill.FieldActiveVersionID: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field active_version_id", values[i]) + } else if value.Valid { + _m.ActiveVersionID = new(uuid.UUID) + *_m.ActiveVersionID = *value.S.(*uuid.UUID) + } + case agentskill.FieldIsForceDelivery: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_force_delivery", values[i]) + } else if value.Valid { + _m.IsForceDelivery = value.Bool + } + case agentskill.FieldIsOrphan: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_orphan", values[i]) + } else if value.Valid { + _m.IsOrphan = value.Bool + } + case agentskill.FieldIsDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_deleted", values[i]) + } else if value.Valid { + _m.IsDeleted = value.Bool + } + case agentskill.FieldEnabled: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field enabled", values[i]) + } else if value.Valid { + _m.Enabled = value.Bool + } + case agentskill.FieldExtensionPackageID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field extension_package_id", values[i]) + } else if value.Valid { + _m.ExtensionPackageID = new(string) + *_m.ExtensionPackageID = value.String + } + case agentskill.FieldAdminDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field admin_description", values[i]) + } else if value.Valid { + _m.AdminDescription = new(string) + *_m.AdminDescription = value.String + } + case agentskill.FieldAdminTags: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field admin_tags", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.AdminTags); err != nil { + return fmt.Errorf("unmarshal field admin_tags: %w", err) + } + } + case agentskill.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case agentskill.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the AgentSkill. +// This includes values selected through modifiers, order, etc. +func (_m *AgentSkill) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryRepo queries the "repo" edge of the AgentSkill entity. +func (_m *AgentSkill) QueryRepo() *AgentSkillRepoQuery { + return NewAgentSkillClient(_m.config).QueryRepo(_m) +} + +// QueryVersions queries the "versions" edge of the AgentSkill entity. +func (_m *AgentSkill) QueryVersions() *AgentSkillVersionQuery { + return NewAgentSkillClient(_m.config).QueryVersions(_m) +} + +// Update returns a builder for updating this AgentSkill. +// Note that you need to call AgentSkill.Unwrap() before calling this method if this AgentSkill +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *AgentSkill) Update() *AgentSkillUpdateOne { + return NewAgentSkillClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the AgentSkill entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *AgentSkill) Unwrap() *AgentSkill { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("db: AgentSkill is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *AgentSkill) String() string { + var builder strings.Builder + builder.WriteString("AgentSkill(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("repo_id=") + builder.WriteString(fmt.Sprintf("%v", _m.RepoID)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteString(", ") + builder.WriteString("scope_type=") + builder.WriteString(fmt.Sprintf("%v", _m.ScopeType)) + builder.WriteString(", ") + builder.WriteString("scope_id=") + builder.WriteString(_m.ScopeID) + builder.WriteString(", ") + builder.WriteString("created_by=") + builder.WriteString(fmt.Sprintf("%v", _m.CreatedBy)) + builder.WriteString(", ") + if v := _m.ActiveVersionID; v != nil { + builder.WriteString("active_version_id=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + builder.WriteString("is_force_delivery=") + builder.WriteString(fmt.Sprintf("%v", _m.IsForceDelivery)) + builder.WriteString(", ") + builder.WriteString("is_orphan=") + builder.WriteString(fmt.Sprintf("%v", _m.IsOrphan)) + builder.WriteString(", ") + builder.WriteString("is_deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.IsDeleted)) + builder.WriteString(", ") + builder.WriteString("enabled=") + builder.WriteString(fmt.Sprintf("%v", _m.Enabled)) + builder.WriteString(", ") + if v := _m.ExtensionPackageID; v != nil { + builder.WriteString("extension_package_id=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.AdminDescription; v != nil { + builder.WriteString("admin_description=") + builder.WriteString(*v) + } + builder.WriteString(", ") + builder.WriteString("admin_tags=") + builder.WriteString(fmt.Sprintf("%v", _m.AdminTags)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// AgentSkills is a parsable slice of AgentSkill. +type AgentSkills []*AgentSkill diff --git a/backend/db/agentskill/agentskill.go b/backend/db/agentskill/agentskill.go new file mode 100644 index 00000000..4e3a18ce --- /dev/null +++ b/backend/db/agentskill/agentskill.go @@ -0,0 +1,270 @@ +// Code generated by ent, DO NOT EDIT. + +package agentskill + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the agentskill type in the database. + Label = "agent_skill" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldRepoID holds the string denoting the repo_id field in the database. + FieldRepoID = "repo_id" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldScopeType holds the string denoting the scope_type field in the database. + FieldScopeType = "scope_type" + // FieldScopeID holds the string denoting the scope_id field in the database. + FieldScopeID = "scope_id" + // FieldCreatedBy holds the string denoting the created_by field in the database. + FieldCreatedBy = "created_by" + // FieldActiveVersionID holds the string denoting the active_version_id field in the database. + FieldActiveVersionID = "active_version_id" + // FieldIsForceDelivery holds the string denoting the is_force_delivery field in the database. + FieldIsForceDelivery = "is_force_delivery" + // FieldIsOrphan holds the string denoting the is_orphan field in the database. + FieldIsOrphan = "is_orphan" + // FieldIsDeleted holds the string denoting the is_deleted field in the database. + FieldIsDeleted = "is_deleted" + // FieldEnabled holds the string denoting the enabled field in the database. + FieldEnabled = "enabled" + // FieldExtensionPackageID holds the string denoting the extension_package_id field in the database. + FieldExtensionPackageID = "extension_package_id" + // FieldAdminDescription holds the string denoting the admin_description field in the database. + FieldAdminDescription = "admin_description" + // FieldAdminTags holds the string denoting the admin_tags field in the database. + FieldAdminTags = "admin_tags" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // EdgeRepo holds the string denoting the repo edge name in mutations. + EdgeRepo = "repo" + // EdgeVersions holds the string denoting the versions edge name in mutations. + EdgeVersions = "versions" + // Table holds the table name of the agentskill in the database. + Table = "agent_skills" + // RepoTable is the table that holds the repo relation/edge. + RepoTable = "agent_skills" + // RepoInverseTable is the table name for the AgentSkillRepo entity. + // It exists in this package in order to avoid circular dependency with the "agentskillrepo" package. + RepoInverseTable = "agent_skill_repos" + // RepoColumn is the table column denoting the repo relation/edge. + RepoColumn = "repo_id" + // VersionsTable is the table that holds the versions relation/edge. + VersionsTable = "agent_skill_versions" + // VersionsInverseTable is the table name for the AgentSkillVersion entity. + // It exists in this package in order to avoid circular dependency with the "agentskillversion" package. + VersionsInverseTable = "agent_skill_versions" + // VersionsColumn is the table column denoting the versions relation/edge. + VersionsColumn = "resource_id" +) + +// Columns holds all SQL columns for agentskill fields. +var Columns = []string{ + FieldID, + FieldRepoID, + FieldName, + FieldDescription, + FieldScopeType, + FieldScopeID, + FieldCreatedBy, + FieldActiveVersionID, + FieldIsForceDelivery, + FieldIsOrphan, + FieldIsDeleted, + FieldEnabled, + FieldExtensionPackageID, + FieldAdminDescription, + FieldAdminTags, + FieldCreatedAt, + FieldUpdatedAt, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultScopeID holds the default value on creation for the "scope_id" field. + DefaultScopeID string + // DefaultIsForceDelivery holds the default value on creation for the "is_force_delivery" field. + DefaultIsForceDelivery bool + // DefaultIsOrphan holds the default value on creation for the "is_orphan" field. + DefaultIsOrphan bool + // DefaultIsDeleted holds the default value on creation for the "is_deleted" field. + DefaultIsDeleted bool + // DefaultEnabled holds the default value on creation for the "enabled" field. + DefaultEnabled bool + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// ScopeType defines the type for the "scope_type" enum field. +type ScopeType string + +// ScopeTypeGlobal is the default value of the ScopeType enum. +const DefaultScopeType = ScopeTypeGlobal + +// ScopeType values. +const ( + ScopeTypeGlobal ScopeType = "global" + ScopeTypeTeam ScopeType = "team" + ScopeTypeUser ScopeType = "user" +) + +func (st ScopeType) String() string { + return string(st) +} + +// ScopeTypeValidator is a validator for the "scope_type" field enum values. It is called by the builders before save. +func ScopeTypeValidator(st ScopeType) error { + switch st { + case ScopeTypeGlobal, ScopeTypeTeam, ScopeTypeUser: + return nil + default: + return fmt.Errorf("agentskill: invalid enum value for scope_type field: %q", st) + } +} + +// OrderOption defines the ordering options for the AgentSkill queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByRepoID orders the results by the repo_id field. +func ByRepoID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRepoID, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByScopeType orders the results by the scope_type field. +func ByScopeType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScopeType, opts...).ToFunc() +} + +// ByScopeID orders the results by the scope_id field. +func ByScopeID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScopeID, opts...).ToFunc() +} + +// ByCreatedBy orders the results by the created_by field. +func ByCreatedBy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedBy, opts...).ToFunc() +} + +// ByActiveVersionID orders the results by the active_version_id field. +func ByActiveVersionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldActiveVersionID, opts...).ToFunc() +} + +// ByIsForceDelivery orders the results by the is_force_delivery field. +func ByIsForceDelivery(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsForceDelivery, opts...).ToFunc() +} + +// ByIsOrphan orders the results by the is_orphan field. +func ByIsOrphan(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsOrphan, opts...).ToFunc() +} + +// ByIsDeleted orders the results by the is_deleted field. +func ByIsDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsDeleted, opts...).ToFunc() +} + +// ByEnabled orders the results by the enabled field. +func ByEnabled(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEnabled, opts...).ToFunc() +} + +// ByExtensionPackageID orders the results by the extension_package_id field. +func ByExtensionPackageID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldExtensionPackageID, opts...).ToFunc() +} + +// ByAdminDescription orders the results by the admin_description field. +func ByAdminDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAdminDescription, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByRepoField orders the results by repo field. +func ByRepoField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRepoStep(), sql.OrderByField(field, opts...)) + } +} + +// ByVersionsCount orders the results by versions count. +func ByVersionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newVersionsStep(), opts...) + } +} + +// ByVersions orders the results by versions terms. +func ByVersions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newVersionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newRepoStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RepoInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, RepoTable, RepoColumn), + ) +} +func newVersionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(VersionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, VersionsTable, VersionsColumn), + ) +} diff --git a/backend/db/agentskill/where.go b/backend/db/agentskill/where.go new file mode 100644 index 00000000..c0013988 --- /dev/null +++ b/backend/db/agentskill/where.go @@ -0,0 +1,803 @@ +// Code generated by ent, DO NOT EDIT. + +package agentskill + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLTE(FieldID, id)) +} + +// RepoID applies equality check predicate on the "repo_id" field. It's identical to RepoIDEQ. +func RepoID(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldRepoID, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldName, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldDescription, v)) +} + +// ScopeID applies equality check predicate on the "scope_id" field. It's identical to ScopeIDEQ. +func ScopeID(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldScopeID, v)) +} + +// CreatedBy applies equality check predicate on the "created_by" field. It's identical to CreatedByEQ. +func CreatedBy(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldCreatedBy, v)) +} + +// ActiveVersionID applies equality check predicate on the "active_version_id" field. It's identical to ActiveVersionIDEQ. +func ActiveVersionID(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldActiveVersionID, v)) +} + +// IsForceDelivery applies equality check predicate on the "is_force_delivery" field. It's identical to IsForceDeliveryEQ. +func IsForceDelivery(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldIsForceDelivery, v)) +} + +// IsOrphan applies equality check predicate on the "is_orphan" field. It's identical to IsOrphanEQ. +func IsOrphan(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldIsOrphan, v)) +} + +// IsDeleted applies equality check predicate on the "is_deleted" field. It's identical to IsDeletedEQ. +func IsDeleted(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldIsDeleted, v)) +} + +// Enabled applies equality check predicate on the "enabled" field. It's identical to EnabledEQ. +func Enabled(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldEnabled, v)) +} + +// ExtensionPackageID applies equality check predicate on the "extension_package_id" field. It's identical to ExtensionPackageIDEQ. +func ExtensionPackageID(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldExtensionPackageID, v)) +} + +// AdminDescription applies equality check predicate on the "admin_description" field. It's identical to AdminDescriptionEQ. +func AdminDescription(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldAdminDescription, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// RepoIDEQ applies the EQ predicate on the "repo_id" field. +func RepoIDEQ(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldRepoID, v)) +} + +// RepoIDNEQ applies the NEQ predicate on the "repo_id" field. +func RepoIDNEQ(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldRepoID, v)) +} + +// RepoIDIn applies the In predicate on the "repo_id" field. +func RepoIDIn(vs ...uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldRepoID, vs...)) +} + +// RepoIDNotIn applies the NotIn predicate on the "repo_id" field. +func RepoIDNotIn(vs ...uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldRepoID, vs...)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldContainsFold(FieldName, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldContainsFold(FieldDescription, v)) +} + +// ScopeTypeEQ applies the EQ predicate on the "scope_type" field. +func ScopeTypeEQ(v ScopeType) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldScopeType, v)) +} + +// ScopeTypeNEQ applies the NEQ predicate on the "scope_type" field. +func ScopeTypeNEQ(v ScopeType) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldScopeType, v)) +} + +// ScopeTypeIn applies the In predicate on the "scope_type" field. +func ScopeTypeIn(vs ...ScopeType) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldScopeType, vs...)) +} + +// ScopeTypeNotIn applies the NotIn predicate on the "scope_type" field. +func ScopeTypeNotIn(vs ...ScopeType) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldScopeType, vs...)) +} + +// ScopeIDEQ applies the EQ predicate on the "scope_id" field. +func ScopeIDEQ(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldScopeID, v)) +} + +// ScopeIDNEQ applies the NEQ predicate on the "scope_id" field. +func ScopeIDNEQ(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldScopeID, v)) +} + +// ScopeIDIn applies the In predicate on the "scope_id" field. +func ScopeIDIn(vs ...string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldScopeID, vs...)) +} + +// ScopeIDNotIn applies the NotIn predicate on the "scope_id" field. +func ScopeIDNotIn(vs ...string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldScopeID, vs...)) +} + +// ScopeIDGT applies the GT predicate on the "scope_id" field. +func ScopeIDGT(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGT(FieldScopeID, v)) +} + +// ScopeIDGTE applies the GTE predicate on the "scope_id" field. +func ScopeIDGTE(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGTE(FieldScopeID, v)) +} + +// ScopeIDLT applies the LT predicate on the "scope_id" field. +func ScopeIDLT(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLT(FieldScopeID, v)) +} + +// ScopeIDLTE applies the LTE predicate on the "scope_id" field. +func ScopeIDLTE(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLTE(FieldScopeID, v)) +} + +// ScopeIDContains applies the Contains predicate on the "scope_id" field. +func ScopeIDContains(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldContains(FieldScopeID, v)) +} + +// ScopeIDHasPrefix applies the HasPrefix predicate on the "scope_id" field. +func ScopeIDHasPrefix(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldHasPrefix(FieldScopeID, v)) +} + +// ScopeIDHasSuffix applies the HasSuffix predicate on the "scope_id" field. +func ScopeIDHasSuffix(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldHasSuffix(FieldScopeID, v)) +} + +// ScopeIDEqualFold applies the EqualFold predicate on the "scope_id" field. +func ScopeIDEqualFold(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEqualFold(FieldScopeID, v)) +} + +// ScopeIDContainsFold applies the ContainsFold predicate on the "scope_id" field. +func ScopeIDContainsFold(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldContainsFold(FieldScopeID, v)) +} + +// CreatedByEQ applies the EQ predicate on the "created_by" field. +func CreatedByEQ(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldCreatedBy, v)) +} + +// CreatedByNEQ applies the NEQ predicate on the "created_by" field. +func CreatedByNEQ(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldCreatedBy, v)) +} + +// CreatedByIn applies the In predicate on the "created_by" field. +func CreatedByIn(vs ...uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldCreatedBy, vs...)) +} + +// CreatedByNotIn applies the NotIn predicate on the "created_by" field. +func CreatedByNotIn(vs ...uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldCreatedBy, vs...)) +} + +// CreatedByGT applies the GT predicate on the "created_by" field. +func CreatedByGT(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGT(FieldCreatedBy, v)) +} + +// CreatedByGTE applies the GTE predicate on the "created_by" field. +func CreatedByGTE(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGTE(FieldCreatedBy, v)) +} + +// CreatedByLT applies the LT predicate on the "created_by" field. +func CreatedByLT(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLT(FieldCreatedBy, v)) +} + +// CreatedByLTE applies the LTE predicate on the "created_by" field. +func CreatedByLTE(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLTE(FieldCreatedBy, v)) +} + +// ActiveVersionIDEQ applies the EQ predicate on the "active_version_id" field. +func ActiveVersionIDEQ(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldActiveVersionID, v)) +} + +// ActiveVersionIDNEQ applies the NEQ predicate on the "active_version_id" field. +func ActiveVersionIDNEQ(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldActiveVersionID, v)) +} + +// ActiveVersionIDIn applies the In predicate on the "active_version_id" field. +func ActiveVersionIDIn(vs ...uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldActiveVersionID, vs...)) +} + +// ActiveVersionIDNotIn applies the NotIn predicate on the "active_version_id" field. +func ActiveVersionIDNotIn(vs ...uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldActiveVersionID, vs...)) +} + +// ActiveVersionIDGT applies the GT predicate on the "active_version_id" field. +func ActiveVersionIDGT(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGT(FieldActiveVersionID, v)) +} + +// ActiveVersionIDGTE applies the GTE predicate on the "active_version_id" field. +func ActiveVersionIDGTE(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGTE(FieldActiveVersionID, v)) +} + +// ActiveVersionIDLT applies the LT predicate on the "active_version_id" field. +func ActiveVersionIDLT(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLT(FieldActiveVersionID, v)) +} + +// ActiveVersionIDLTE applies the LTE predicate on the "active_version_id" field. +func ActiveVersionIDLTE(v uuid.UUID) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLTE(FieldActiveVersionID, v)) +} + +// ActiveVersionIDIsNil applies the IsNil predicate on the "active_version_id" field. +func ActiveVersionIDIsNil() predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIsNull(FieldActiveVersionID)) +} + +// ActiveVersionIDNotNil applies the NotNil predicate on the "active_version_id" field. +func ActiveVersionIDNotNil() predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotNull(FieldActiveVersionID)) +} + +// IsForceDeliveryEQ applies the EQ predicate on the "is_force_delivery" field. +func IsForceDeliveryEQ(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldIsForceDelivery, v)) +} + +// IsForceDeliveryNEQ applies the NEQ predicate on the "is_force_delivery" field. +func IsForceDeliveryNEQ(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldIsForceDelivery, v)) +} + +// IsOrphanEQ applies the EQ predicate on the "is_orphan" field. +func IsOrphanEQ(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldIsOrphan, v)) +} + +// IsOrphanNEQ applies the NEQ predicate on the "is_orphan" field. +func IsOrphanNEQ(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldIsOrphan, v)) +} + +// IsDeletedEQ applies the EQ predicate on the "is_deleted" field. +func IsDeletedEQ(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldIsDeleted, v)) +} + +// IsDeletedNEQ applies the NEQ predicate on the "is_deleted" field. +func IsDeletedNEQ(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldIsDeleted, v)) +} + +// EnabledEQ applies the EQ predicate on the "enabled" field. +func EnabledEQ(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldEnabled, v)) +} + +// EnabledNEQ applies the NEQ predicate on the "enabled" field. +func EnabledNEQ(v bool) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldEnabled, v)) +} + +// ExtensionPackageIDEQ applies the EQ predicate on the "extension_package_id" field. +func ExtensionPackageIDEQ(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldExtensionPackageID, v)) +} + +// ExtensionPackageIDNEQ applies the NEQ predicate on the "extension_package_id" field. +func ExtensionPackageIDNEQ(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldExtensionPackageID, v)) +} + +// ExtensionPackageIDIn applies the In predicate on the "extension_package_id" field. +func ExtensionPackageIDIn(vs ...string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldExtensionPackageID, vs...)) +} + +// ExtensionPackageIDNotIn applies the NotIn predicate on the "extension_package_id" field. +func ExtensionPackageIDNotIn(vs ...string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldExtensionPackageID, vs...)) +} + +// ExtensionPackageIDGT applies the GT predicate on the "extension_package_id" field. +func ExtensionPackageIDGT(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGT(FieldExtensionPackageID, v)) +} + +// ExtensionPackageIDGTE applies the GTE predicate on the "extension_package_id" field. +func ExtensionPackageIDGTE(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGTE(FieldExtensionPackageID, v)) +} + +// ExtensionPackageIDLT applies the LT predicate on the "extension_package_id" field. +func ExtensionPackageIDLT(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLT(FieldExtensionPackageID, v)) +} + +// ExtensionPackageIDLTE applies the LTE predicate on the "extension_package_id" field. +func ExtensionPackageIDLTE(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLTE(FieldExtensionPackageID, v)) +} + +// ExtensionPackageIDContains applies the Contains predicate on the "extension_package_id" field. +func ExtensionPackageIDContains(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldContains(FieldExtensionPackageID, v)) +} + +// ExtensionPackageIDHasPrefix applies the HasPrefix predicate on the "extension_package_id" field. +func ExtensionPackageIDHasPrefix(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldHasPrefix(FieldExtensionPackageID, v)) +} + +// ExtensionPackageIDHasSuffix applies the HasSuffix predicate on the "extension_package_id" field. +func ExtensionPackageIDHasSuffix(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldHasSuffix(FieldExtensionPackageID, v)) +} + +// ExtensionPackageIDIsNil applies the IsNil predicate on the "extension_package_id" field. +func ExtensionPackageIDIsNil() predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIsNull(FieldExtensionPackageID)) +} + +// ExtensionPackageIDNotNil applies the NotNil predicate on the "extension_package_id" field. +func ExtensionPackageIDNotNil() predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotNull(FieldExtensionPackageID)) +} + +// ExtensionPackageIDEqualFold applies the EqualFold predicate on the "extension_package_id" field. +func ExtensionPackageIDEqualFold(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEqualFold(FieldExtensionPackageID, v)) +} + +// ExtensionPackageIDContainsFold applies the ContainsFold predicate on the "extension_package_id" field. +func ExtensionPackageIDContainsFold(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldContainsFold(FieldExtensionPackageID, v)) +} + +// AdminDescriptionEQ applies the EQ predicate on the "admin_description" field. +func AdminDescriptionEQ(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldAdminDescription, v)) +} + +// AdminDescriptionNEQ applies the NEQ predicate on the "admin_description" field. +func AdminDescriptionNEQ(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldAdminDescription, v)) +} + +// AdminDescriptionIn applies the In predicate on the "admin_description" field. +func AdminDescriptionIn(vs ...string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldAdminDescription, vs...)) +} + +// AdminDescriptionNotIn applies the NotIn predicate on the "admin_description" field. +func AdminDescriptionNotIn(vs ...string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldAdminDescription, vs...)) +} + +// AdminDescriptionGT applies the GT predicate on the "admin_description" field. +func AdminDescriptionGT(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGT(FieldAdminDescription, v)) +} + +// AdminDescriptionGTE applies the GTE predicate on the "admin_description" field. +func AdminDescriptionGTE(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGTE(FieldAdminDescription, v)) +} + +// AdminDescriptionLT applies the LT predicate on the "admin_description" field. +func AdminDescriptionLT(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLT(FieldAdminDescription, v)) +} + +// AdminDescriptionLTE applies the LTE predicate on the "admin_description" field. +func AdminDescriptionLTE(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLTE(FieldAdminDescription, v)) +} + +// AdminDescriptionContains applies the Contains predicate on the "admin_description" field. +func AdminDescriptionContains(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldContains(FieldAdminDescription, v)) +} + +// AdminDescriptionHasPrefix applies the HasPrefix predicate on the "admin_description" field. +func AdminDescriptionHasPrefix(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldHasPrefix(FieldAdminDescription, v)) +} + +// AdminDescriptionHasSuffix applies the HasSuffix predicate on the "admin_description" field. +func AdminDescriptionHasSuffix(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldHasSuffix(FieldAdminDescription, v)) +} + +// AdminDescriptionIsNil applies the IsNil predicate on the "admin_description" field. +func AdminDescriptionIsNil() predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIsNull(FieldAdminDescription)) +} + +// AdminDescriptionNotNil applies the NotNil predicate on the "admin_description" field. +func AdminDescriptionNotNil() predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotNull(FieldAdminDescription)) +} + +// AdminDescriptionEqualFold applies the EqualFold predicate on the "admin_description" field. +func AdminDescriptionEqualFold(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEqualFold(FieldAdminDescription, v)) +} + +// AdminDescriptionContainsFold applies the ContainsFold predicate on the "admin_description" field. +func AdminDescriptionContainsFold(v string) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldContainsFold(FieldAdminDescription, v)) +} + +// AdminTagsIsNil applies the IsNil predicate on the "admin_tags" field. +func AdminTagsIsNil() predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIsNull(FieldAdminTags)) +} + +// AdminTagsNotNil applies the NotNil predicate on the "admin_tags" field. +func AdminTagsNotNil() predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotNull(FieldAdminTags)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.AgentSkill { + return predicate.AgentSkill(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// HasRepo applies the HasEdge predicate on the "repo" edge. +func HasRepo() predicate.AgentSkill { + return predicate.AgentSkill(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, RepoTable, RepoColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRepoWith applies the HasEdge predicate on the "repo" edge with a given conditions (other predicates). +func HasRepoWith(preds ...predicate.AgentSkillRepo) predicate.AgentSkill { + return predicate.AgentSkill(func(s *sql.Selector) { + step := newRepoStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasVersions applies the HasEdge predicate on the "versions" edge. +func HasVersions() predicate.AgentSkill { + return predicate.AgentSkill(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, VersionsTable, VersionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasVersionsWith applies the HasEdge predicate on the "versions" edge with a given conditions (other predicates). +func HasVersionsWith(preds ...predicate.AgentSkillVersion) predicate.AgentSkill { + return predicate.AgentSkill(func(s *sql.Selector) { + step := newVersionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.AgentSkill) predicate.AgentSkill { + return predicate.AgentSkill(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.AgentSkill) predicate.AgentSkill { + return predicate.AgentSkill(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.AgentSkill) predicate.AgentSkill { + return predicate.AgentSkill(sql.NotPredicates(p)) +} diff --git a/backend/db/agentskill_create.go b/backend/db/agentskill_create.go new file mode 100644 index 00000000..eb5aff13 --- /dev/null +++ b/backend/db/agentskill_create.go @@ -0,0 +1,1581 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/google/uuid" +) + +// AgentSkillCreate is the builder for creating a AgentSkill entity. +type AgentSkillCreate struct { + config + mutation *AgentSkillMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetRepoID sets the "repo_id" field. +func (_c *AgentSkillCreate) SetRepoID(v uuid.UUID) *AgentSkillCreate { + _c.mutation.SetRepoID(v) + return _c +} + +// SetName sets the "name" field. +func (_c *AgentSkillCreate) SetName(v string) *AgentSkillCreate { + _c.mutation.SetName(v) + return _c +} + +// SetDescription sets the "description" field. +func (_c *AgentSkillCreate) SetDescription(v string) *AgentSkillCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableDescription(v *string) *AgentSkillCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetScopeType sets the "scope_type" field. +func (_c *AgentSkillCreate) SetScopeType(v agentskill.ScopeType) *AgentSkillCreate { + _c.mutation.SetScopeType(v) + return _c +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableScopeType(v *agentskill.ScopeType) *AgentSkillCreate { + if v != nil { + _c.SetScopeType(*v) + } + return _c +} + +// SetScopeID sets the "scope_id" field. +func (_c *AgentSkillCreate) SetScopeID(v string) *AgentSkillCreate { + _c.mutation.SetScopeID(v) + return _c +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableScopeID(v *string) *AgentSkillCreate { + if v != nil { + _c.SetScopeID(*v) + } + return _c +} + +// SetCreatedBy sets the "created_by" field. +func (_c *AgentSkillCreate) SetCreatedBy(v uuid.UUID) *AgentSkillCreate { + _c.mutation.SetCreatedBy(v) + return _c +} + +// SetActiveVersionID sets the "active_version_id" field. +func (_c *AgentSkillCreate) SetActiveVersionID(v uuid.UUID) *AgentSkillCreate { + _c.mutation.SetActiveVersionID(v) + return _c +} + +// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableActiveVersionID(v *uuid.UUID) *AgentSkillCreate { + if v != nil { + _c.SetActiveVersionID(*v) + } + return _c +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (_c *AgentSkillCreate) SetIsForceDelivery(v bool) *AgentSkillCreate { + _c.mutation.SetIsForceDelivery(v) + return _c +} + +// SetNillableIsForceDelivery sets the "is_force_delivery" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableIsForceDelivery(v *bool) *AgentSkillCreate { + if v != nil { + _c.SetIsForceDelivery(*v) + } + return _c +} + +// SetIsOrphan sets the "is_orphan" field. +func (_c *AgentSkillCreate) SetIsOrphan(v bool) *AgentSkillCreate { + _c.mutation.SetIsOrphan(v) + return _c +} + +// SetNillableIsOrphan sets the "is_orphan" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableIsOrphan(v *bool) *AgentSkillCreate { + if v != nil { + _c.SetIsOrphan(*v) + } + return _c +} + +// SetIsDeleted sets the "is_deleted" field. +func (_c *AgentSkillCreate) SetIsDeleted(v bool) *AgentSkillCreate { + _c.mutation.SetIsDeleted(v) + return _c +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableIsDeleted(v *bool) *AgentSkillCreate { + if v != nil { + _c.SetIsDeleted(*v) + } + return _c +} + +// SetEnabled sets the "enabled" field. +func (_c *AgentSkillCreate) SetEnabled(v bool) *AgentSkillCreate { + _c.mutation.SetEnabled(v) + return _c +} + +// SetNillableEnabled sets the "enabled" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableEnabled(v *bool) *AgentSkillCreate { + if v != nil { + _c.SetEnabled(*v) + } + return _c +} + +// SetExtensionPackageID sets the "extension_package_id" field. +func (_c *AgentSkillCreate) SetExtensionPackageID(v string) *AgentSkillCreate { + _c.mutation.SetExtensionPackageID(v) + return _c +} + +// SetNillableExtensionPackageID sets the "extension_package_id" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableExtensionPackageID(v *string) *AgentSkillCreate { + if v != nil { + _c.SetExtensionPackageID(*v) + } + return _c +} + +// SetAdminDescription sets the "admin_description" field. +func (_c *AgentSkillCreate) SetAdminDescription(v string) *AgentSkillCreate { + _c.mutation.SetAdminDescription(v) + return _c +} + +// SetNillableAdminDescription sets the "admin_description" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableAdminDescription(v *string) *AgentSkillCreate { + if v != nil { + _c.SetAdminDescription(*v) + } + return _c +} + +// SetAdminTags sets the "admin_tags" field. +func (_c *AgentSkillCreate) SetAdminTags(v []string) *AgentSkillCreate { + _c.mutation.SetAdminTags(v) + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AgentSkillCreate) SetCreatedAt(v time.Time) *AgentSkillCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableCreatedAt(v *time.Time) *AgentSkillCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *AgentSkillCreate) SetUpdatedAt(v time.Time) *AgentSkillCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableUpdatedAt(v *time.Time) *AgentSkillCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AgentSkillCreate) SetID(v uuid.UUID) *AgentSkillCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AgentSkillCreate) SetNillableID(v *uuid.UUID) *AgentSkillCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetRepo sets the "repo" edge to the AgentSkillRepo entity. +func (_c *AgentSkillCreate) SetRepo(v *AgentSkillRepo) *AgentSkillCreate { + return _c.SetRepoID(v.ID) +} + +// AddVersionIDs adds the "versions" edge to the AgentSkillVersion entity by IDs. +func (_c *AgentSkillCreate) AddVersionIDs(ids ...uuid.UUID) *AgentSkillCreate { + _c.mutation.AddVersionIDs(ids...) + return _c +} + +// AddVersions adds the "versions" edges to the AgentSkillVersion entity. +func (_c *AgentSkillCreate) AddVersions(v ...*AgentSkillVersion) *AgentSkillCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddVersionIDs(ids...) +} + +// Mutation returns the AgentSkillMutation object of the builder. +func (_c *AgentSkillCreate) Mutation() *AgentSkillMutation { + return _c.mutation +} + +// Save creates the AgentSkill in the database. +func (_c *AgentSkillCreate) Save(ctx context.Context) (*AgentSkill, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AgentSkillCreate) SaveX(ctx context.Context) *AgentSkill { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentSkillCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentSkillCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AgentSkillCreate) defaults() { + if _, ok := _c.mutation.ScopeType(); !ok { + v := agentskill.DefaultScopeType + _c.mutation.SetScopeType(v) + } + if _, ok := _c.mutation.ScopeID(); !ok { + v := agentskill.DefaultScopeID + _c.mutation.SetScopeID(v) + } + if _, ok := _c.mutation.IsForceDelivery(); !ok { + v := agentskill.DefaultIsForceDelivery + _c.mutation.SetIsForceDelivery(v) + } + if _, ok := _c.mutation.IsOrphan(); !ok { + v := agentskill.DefaultIsOrphan + _c.mutation.SetIsOrphan(v) + } + if _, ok := _c.mutation.IsDeleted(); !ok { + v := agentskill.DefaultIsDeleted + _c.mutation.SetIsDeleted(v) + } + if _, ok := _c.mutation.Enabled(); !ok { + v := agentskill.DefaultEnabled + _c.mutation.SetEnabled(v) + } + if _, ok := _c.mutation.CreatedAt(); !ok { + v := agentskill.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := agentskill.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := agentskill.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AgentSkillCreate) check() error { + if _, ok := _c.mutation.RepoID(); !ok { + return &ValidationError{Name: "repo_id", err: errors.New(`db: missing required field "AgentSkill.repo_id"`)} + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`db: missing required field "AgentSkill.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := agentskill.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentSkill.name": %w`, err)} + } + } + if _, ok := _c.mutation.ScopeType(); !ok { + return &ValidationError{Name: "scope_type", err: errors.New(`db: missing required field "AgentSkill.scope_type"`)} + } + if v, ok := _c.mutation.ScopeType(); ok { + if err := agentskill.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentSkill.scope_type": %w`, err)} + } + } + if _, ok := _c.mutation.ScopeID(); !ok { + return &ValidationError{Name: "scope_id", err: errors.New(`db: missing required field "AgentSkill.scope_id"`)} + } + if _, ok := _c.mutation.CreatedBy(); !ok { + return &ValidationError{Name: "created_by", err: errors.New(`db: missing required field "AgentSkill.created_by"`)} + } + if _, ok := _c.mutation.IsForceDelivery(); !ok { + return &ValidationError{Name: "is_force_delivery", err: errors.New(`db: missing required field "AgentSkill.is_force_delivery"`)} + } + if _, ok := _c.mutation.IsOrphan(); !ok { + return &ValidationError{Name: "is_orphan", err: errors.New(`db: missing required field "AgentSkill.is_orphan"`)} + } + if _, ok := _c.mutation.IsDeleted(); !ok { + return &ValidationError{Name: "is_deleted", err: errors.New(`db: missing required field "AgentSkill.is_deleted"`)} + } + if _, ok := _c.mutation.Enabled(); !ok { + return &ValidationError{Name: "enabled", err: errors.New(`db: missing required field "AgentSkill.enabled"`)} + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentSkill.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "AgentSkill.updated_at"`)} + } + if len(_c.mutation.RepoIDs()) == 0 { + return &ValidationError{Name: "repo", err: errors.New(`db: missing required edge "AgentSkill.repo"`)} + } + return nil +} + +func (_c *AgentSkillCreate) sqlSave(ctx context.Context) (*AgentSkill, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AgentSkillCreate) createSpec() (*AgentSkill, *sqlgraph.CreateSpec) { + var ( + _node = &AgentSkill{config: _c.config} + _spec = sqlgraph.NewCreateSpec(agentskill.Table, sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID)) + ) + _spec.OnConflict = _c.conflict + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(agentskill.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(agentskill.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := _c.mutation.ScopeType(); ok { + _spec.SetField(agentskill.FieldScopeType, field.TypeEnum, value) + _node.ScopeType = value + } + if value, ok := _c.mutation.ScopeID(); ok { + _spec.SetField(agentskill.FieldScopeID, field.TypeString, value) + _node.ScopeID = value + } + if value, ok := _c.mutation.CreatedBy(); ok { + _spec.SetField(agentskill.FieldCreatedBy, field.TypeUUID, value) + _node.CreatedBy = value + } + if value, ok := _c.mutation.ActiveVersionID(); ok { + _spec.SetField(agentskill.FieldActiveVersionID, field.TypeUUID, value) + _node.ActiveVersionID = &value + } + if value, ok := _c.mutation.IsForceDelivery(); ok { + _spec.SetField(agentskill.FieldIsForceDelivery, field.TypeBool, value) + _node.IsForceDelivery = value + } + if value, ok := _c.mutation.IsOrphan(); ok { + _spec.SetField(agentskill.FieldIsOrphan, field.TypeBool, value) + _node.IsOrphan = value + } + if value, ok := _c.mutation.IsDeleted(); ok { + _spec.SetField(agentskill.FieldIsDeleted, field.TypeBool, value) + _node.IsDeleted = value + } + if value, ok := _c.mutation.Enabled(); ok { + _spec.SetField(agentskill.FieldEnabled, field.TypeBool, value) + _node.Enabled = value + } + if value, ok := _c.mutation.ExtensionPackageID(); ok { + _spec.SetField(agentskill.FieldExtensionPackageID, field.TypeString, value) + _node.ExtensionPackageID = &value + } + if value, ok := _c.mutation.AdminDescription(); ok { + _spec.SetField(agentskill.FieldAdminDescription, field.TypeString, value) + _node.AdminDescription = &value + } + if value, ok := _c.mutation.AdminTags(); ok { + _spec.SetField(agentskill.FieldAdminTags, field.TypeJSON, value) + _node.AdminTags = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(agentskill.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(agentskill.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if nodes := _c.mutation.RepoIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentskill.RepoTable, + Columns: []string{agentskill.RepoColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.RepoID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskill.VersionsTable, + Columns: []string{agentskill.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentSkill.Create(). +// SetRepoID(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentSkillUpsert) { +// SetRepoID(v+v). +// }). +// Exec(ctx) +func (_c *AgentSkillCreate) OnConflict(opts ...sql.ConflictOption) *AgentSkillUpsertOne { + _c.conflict = opts + return &AgentSkillUpsertOne{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentSkill.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentSkillCreate) OnConflictColumns(columns ...string) *AgentSkillUpsertOne { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentSkillUpsertOne{ + create: _c, + } +} + +type ( + // AgentSkillUpsertOne is the builder for "upsert"-ing + // one AgentSkill node. + AgentSkillUpsertOne struct { + create *AgentSkillCreate + } + + // AgentSkillUpsert is the "OnConflict" setter. + AgentSkillUpsert struct { + *sql.UpdateSet + } +) + +// SetRepoID sets the "repo_id" field. +func (u *AgentSkillUpsert) SetRepoID(v uuid.UUID) *AgentSkillUpsert { + u.Set(agentskill.FieldRepoID, v) + return u +} + +// UpdateRepoID sets the "repo_id" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateRepoID() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldRepoID) + return u +} + +// SetName sets the "name" field. +func (u *AgentSkillUpsert) SetName(v string) *AgentSkillUpsert { + u.Set(agentskill.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateName() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldName) + return u +} + +// SetDescription sets the "description" field. +func (u *AgentSkillUpsert) SetDescription(v string) *AgentSkillUpsert { + u.Set(agentskill.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateDescription() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldDescription) + return u +} + +// ClearDescription clears the value of the "description" field. +func (u *AgentSkillUpsert) ClearDescription() *AgentSkillUpsert { + u.SetNull(agentskill.FieldDescription) + return u +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentSkillUpsert) SetScopeType(v agentskill.ScopeType) *AgentSkillUpsert { + u.Set(agentskill.FieldScopeType, v) + return u +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateScopeType() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldScopeType) + return u +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentSkillUpsert) SetScopeID(v string) *AgentSkillUpsert { + u.Set(agentskill.FieldScopeID, v) + return u +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateScopeID() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldScopeID) + return u +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentSkillUpsert) SetCreatedBy(v uuid.UUID) *AgentSkillUpsert { + u.Set(agentskill.FieldCreatedBy, v) + return u +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateCreatedBy() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldCreatedBy) + return u +} + +// SetActiveVersionID sets the "active_version_id" field. +func (u *AgentSkillUpsert) SetActiveVersionID(v uuid.UUID) *AgentSkillUpsert { + u.Set(agentskill.FieldActiveVersionID, v) + return u +} + +// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateActiveVersionID() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldActiveVersionID) + return u +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (u *AgentSkillUpsert) ClearActiveVersionID() *AgentSkillUpsert { + u.SetNull(agentskill.FieldActiveVersionID) + return u +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (u *AgentSkillUpsert) SetIsForceDelivery(v bool) *AgentSkillUpsert { + u.Set(agentskill.FieldIsForceDelivery, v) + return u +} + +// UpdateIsForceDelivery sets the "is_force_delivery" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateIsForceDelivery() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldIsForceDelivery) + return u +} + +// SetIsOrphan sets the "is_orphan" field. +func (u *AgentSkillUpsert) SetIsOrphan(v bool) *AgentSkillUpsert { + u.Set(agentskill.FieldIsOrphan, v) + return u +} + +// UpdateIsOrphan sets the "is_orphan" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateIsOrphan() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldIsOrphan) + return u +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentSkillUpsert) SetIsDeleted(v bool) *AgentSkillUpsert { + u.Set(agentskill.FieldIsDeleted, v) + return u +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateIsDeleted() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldIsDeleted) + return u +} + +// SetEnabled sets the "enabled" field. +func (u *AgentSkillUpsert) SetEnabled(v bool) *AgentSkillUpsert { + u.Set(agentskill.FieldEnabled, v) + return u +} + +// UpdateEnabled sets the "enabled" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateEnabled() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldEnabled) + return u +} + +// SetExtensionPackageID sets the "extension_package_id" field. +func (u *AgentSkillUpsert) SetExtensionPackageID(v string) *AgentSkillUpsert { + u.Set(agentskill.FieldExtensionPackageID, v) + return u +} + +// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateExtensionPackageID() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldExtensionPackageID) + return u +} + +// ClearExtensionPackageID clears the value of the "extension_package_id" field. +func (u *AgentSkillUpsert) ClearExtensionPackageID() *AgentSkillUpsert { + u.SetNull(agentskill.FieldExtensionPackageID) + return u +} + +// SetAdminDescription sets the "admin_description" field. +func (u *AgentSkillUpsert) SetAdminDescription(v string) *AgentSkillUpsert { + u.Set(agentskill.FieldAdminDescription, v) + return u +} + +// UpdateAdminDescription sets the "admin_description" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateAdminDescription() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldAdminDescription) + return u +} + +// ClearAdminDescription clears the value of the "admin_description" field. +func (u *AgentSkillUpsert) ClearAdminDescription() *AgentSkillUpsert { + u.SetNull(agentskill.FieldAdminDescription) + return u +} + +// SetAdminTags sets the "admin_tags" field. +func (u *AgentSkillUpsert) SetAdminTags(v []string) *AgentSkillUpsert { + u.Set(agentskill.FieldAdminTags, v) + return u +} + +// UpdateAdminTags sets the "admin_tags" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateAdminTags() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldAdminTags) + return u +} + +// ClearAdminTags clears the value of the "admin_tags" field. +func (u *AgentSkillUpsert) ClearAdminTags() *AgentSkillUpsert { + u.SetNull(agentskill.FieldAdminTags) + return u +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSkillUpsert) SetCreatedAt(v time.Time) *AgentSkillUpsert { + u.Set(agentskill.FieldCreatedAt, v) + return u +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateCreatedAt() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldCreatedAt) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentSkillUpsert) SetUpdatedAt(v time.Time) *AgentSkillUpsert { + u.Set(agentskill.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentSkillUpsert) UpdateUpdatedAt() *AgentSkillUpsert { + u.SetExcluded(agentskill.FieldUpdatedAt) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.AgentSkill.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentskill.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentSkillUpsertOne) UpdateNewValues() *AgentSkillUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(agentskill.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentSkill.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentSkillUpsertOne) Ignore() *AgentSkillUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentSkillUpsertOne) DoNothing() *AgentSkillUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentSkillCreate.OnConflict +// documentation for more info. +func (u *AgentSkillUpsertOne) Update(set func(*AgentSkillUpsert)) *AgentSkillUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentSkillUpsert{UpdateSet: update}) + })) + return u +} + +// SetRepoID sets the "repo_id" field. +func (u *AgentSkillUpsertOne) SetRepoID(v uuid.UUID) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetRepoID(v) + }) +} + +// UpdateRepoID sets the "repo_id" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateRepoID() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateRepoID() + }) +} + +// SetName sets the "name" field. +func (u *AgentSkillUpsertOne) SetName(v string) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateName() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *AgentSkillUpsertOne) SetDescription(v string) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateDescription() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *AgentSkillUpsertOne) ClearDescription() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.ClearDescription() + }) +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentSkillUpsertOne) SetScopeType(v agentskill.ScopeType) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetScopeType(v) + }) +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateScopeType() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateScopeType() + }) +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentSkillUpsertOne) SetScopeID(v string) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetScopeID(v) + }) +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateScopeID() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateScopeID() + }) +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentSkillUpsertOne) SetCreatedBy(v uuid.UUID) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetCreatedBy(v) + }) +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateCreatedBy() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateCreatedBy() + }) +} + +// SetActiveVersionID sets the "active_version_id" field. +func (u *AgentSkillUpsertOne) SetActiveVersionID(v uuid.UUID) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetActiveVersionID(v) + }) +} + +// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateActiveVersionID() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateActiveVersionID() + }) +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (u *AgentSkillUpsertOne) ClearActiveVersionID() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.ClearActiveVersionID() + }) +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (u *AgentSkillUpsertOne) SetIsForceDelivery(v bool) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetIsForceDelivery(v) + }) +} + +// UpdateIsForceDelivery sets the "is_force_delivery" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateIsForceDelivery() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateIsForceDelivery() + }) +} + +// SetIsOrphan sets the "is_orphan" field. +func (u *AgentSkillUpsertOne) SetIsOrphan(v bool) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetIsOrphan(v) + }) +} + +// UpdateIsOrphan sets the "is_orphan" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateIsOrphan() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateIsOrphan() + }) +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentSkillUpsertOne) SetIsDeleted(v bool) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetIsDeleted(v) + }) +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateIsDeleted() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateIsDeleted() + }) +} + +// SetEnabled sets the "enabled" field. +func (u *AgentSkillUpsertOne) SetEnabled(v bool) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetEnabled(v) + }) +} + +// UpdateEnabled sets the "enabled" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateEnabled() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateEnabled() + }) +} + +// SetExtensionPackageID sets the "extension_package_id" field. +func (u *AgentSkillUpsertOne) SetExtensionPackageID(v string) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetExtensionPackageID(v) + }) +} + +// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateExtensionPackageID() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateExtensionPackageID() + }) +} + +// ClearExtensionPackageID clears the value of the "extension_package_id" field. +func (u *AgentSkillUpsertOne) ClearExtensionPackageID() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.ClearExtensionPackageID() + }) +} + +// SetAdminDescription sets the "admin_description" field. +func (u *AgentSkillUpsertOne) SetAdminDescription(v string) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetAdminDescription(v) + }) +} + +// UpdateAdminDescription sets the "admin_description" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateAdminDescription() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateAdminDescription() + }) +} + +// ClearAdminDescription clears the value of the "admin_description" field. +func (u *AgentSkillUpsertOne) ClearAdminDescription() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.ClearAdminDescription() + }) +} + +// SetAdminTags sets the "admin_tags" field. +func (u *AgentSkillUpsertOne) SetAdminTags(v []string) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetAdminTags(v) + }) +} + +// UpdateAdminTags sets the "admin_tags" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateAdminTags() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateAdminTags() + }) +} + +// ClearAdminTags clears the value of the "admin_tags" field. +func (u *AgentSkillUpsertOne) ClearAdminTags() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.ClearAdminTags() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSkillUpsertOne) SetCreatedAt(v time.Time) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateCreatedAt() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentSkillUpsertOne) SetUpdatedAt(v time.Time) *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentSkillUpsertOne) UpdateUpdatedAt() *AgentSkillUpsertOne { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentSkillUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentSkillCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentSkillUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *AgentSkillUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: AgentSkillUpsertOne.ID is not supported by MySQL driver. Use AgentSkillUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *AgentSkillUpsertOne) IDX(ctx context.Context) uuid.UUID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// AgentSkillCreateBulk is the builder for creating many AgentSkill entities in bulk. +type AgentSkillCreateBulk struct { + config + err error + builders []*AgentSkillCreate + conflict []sql.ConflictOption +} + +// Save creates the AgentSkill entities in the database. +func (_c *AgentSkillCreateBulk) Save(ctx context.Context) ([]*AgentSkill, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*AgentSkill, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AgentSkillMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = _c.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AgentSkillCreateBulk) SaveX(ctx context.Context) []*AgentSkill { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentSkillCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentSkillCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentSkill.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentSkillUpsert) { +// SetRepoID(v+v). +// }). +// Exec(ctx) +func (_c *AgentSkillCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentSkillUpsertBulk { + _c.conflict = opts + return &AgentSkillUpsertBulk{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentSkill.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentSkillCreateBulk) OnConflictColumns(columns ...string) *AgentSkillUpsertBulk { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentSkillUpsertBulk{ + create: _c, + } +} + +// AgentSkillUpsertBulk is the builder for "upsert"-ing +// a bulk of AgentSkill nodes. +type AgentSkillUpsertBulk struct { + create *AgentSkillCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.AgentSkill.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentskill.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentSkillUpsertBulk) UpdateNewValues() *AgentSkillUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(agentskill.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentSkill.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentSkillUpsertBulk) Ignore() *AgentSkillUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentSkillUpsertBulk) DoNothing() *AgentSkillUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentSkillCreateBulk.OnConflict +// documentation for more info. +func (u *AgentSkillUpsertBulk) Update(set func(*AgentSkillUpsert)) *AgentSkillUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentSkillUpsert{UpdateSet: update}) + })) + return u +} + +// SetRepoID sets the "repo_id" field. +func (u *AgentSkillUpsertBulk) SetRepoID(v uuid.UUID) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetRepoID(v) + }) +} + +// UpdateRepoID sets the "repo_id" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateRepoID() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateRepoID() + }) +} + +// SetName sets the "name" field. +func (u *AgentSkillUpsertBulk) SetName(v string) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateName() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *AgentSkillUpsertBulk) SetDescription(v string) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateDescription() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *AgentSkillUpsertBulk) ClearDescription() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.ClearDescription() + }) +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentSkillUpsertBulk) SetScopeType(v agentskill.ScopeType) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetScopeType(v) + }) +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateScopeType() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateScopeType() + }) +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentSkillUpsertBulk) SetScopeID(v string) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetScopeID(v) + }) +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateScopeID() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateScopeID() + }) +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentSkillUpsertBulk) SetCreatedBy(v uuid.UUID) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetCreatedBy(v) + }) +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateCreatedBy() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateCreatedBy() + }) +} + +// SetActiveVersionID sets the "active_version_id" field. +func (u *AgentSkillUpsertBulk) SetActiveVersionID(v uuid.UUID) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetActiveVersionID(v) + }) +} + +// UpdateActiveVersionID sets the "active_version_id" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateActiveVersionID() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateActiveVersionID() + }) +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (u *AgentSkillUpsertBulk) ClearActiveVersionID() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.ClearActiveVersionID() + }) +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (u *AgentSkillUpsertBulk) SetIsForceDelivery(v bool) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetIsForceDelivery(v) + }) +} + +// UpdateIsForceDelivery sets the "is_force_delivery" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateIsForceDelivery() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateIsForceDelivery() + }) +} + +// SetIsOrphan sets the "is_orphan" field. +func (u *AgentSkillUpsertBulk) SetIsOrphan(v bool) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetIsOrphan(v) + }) +} + +// UpdateIsOrphan sets the "is_orphan" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateIsOrphan() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateIsOrphan() + }) +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentSkillUpsertBulk) SetIsDeleted(v bool) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetIsDeleted(v) + }) +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateIsDeleted() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateIsDeleted() + }) +} + +// SetEnabled sets the "enabled" field. +func (u *AgentSkillUpsertBulk) SetEnabled(v bool) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetEnabled(v) + }) +} + +// UpdateEnabled sets the "enabled" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateEnabled() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateEnabled() + }) +} + +// SetExtensionPackageID sets the "extension_package_id" field. +func (u *AgentSkillUpsertBulk) SetExtensionPackageID(v string) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetExtensionPackageID(v) + }) +} + +// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateExtensionPackageID() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateExtensionPackageID() + }) +} + +// ClearExtensionPackageID clears the value of the "extension_package_id" field. +func (u *AgentSkillUpsertBulk) ClearExtensionPackageID() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.ClearExtensionPackageID() + }) +} + +// SetAdminDescription sets the "admin_description" field. +func (u *AgentSkillUpsertBulk) SetAdminDescription(v string) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetAdminDescription(v) + }) +} + +// UpdateAdminDescription sets the "admin_description" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateAdminDescription() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateAdminDescription() + }) +} + +// ClearAdminDescription clears the value of the "admin_description" field. +func (u *AgentSkillUpsertBulk) ClearAdminDescription() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.ClearAdminDescription() + }) +} + +// SetAdminTags sets the "admin_tags" field. +func (u *AgentSkillUpsertBulk) SetAdminTags(v []string) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetAdminTags(v) + }) +} + +// UpdateAdminTags sets the "admin_tags" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateAdminTags() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateAdminTags() + }) +} + +// ClearAdminTags clears the value of the "admin_tags" field. +func (u *AgentSkillUpsertBulk) ClearAdminTags() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.ClearAdminTags() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSkillUpsertBulk) SetCreatedAt(v time.Time) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateCreatedAt() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentSkillUpsertBulk) SetUpdatedAt(v time.Time) *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentSkillUpsertBulk) UpdateUpdatedAt() *AgentSkillUpsertBulk { + return u.Update(func(s *AgentSkillUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentSkillUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentSkillCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentSkillCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentSkillUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/skill_delete.go b/backend/db/agentskill_delete.go similarity index 53% rename from backend/db/skill_delete.go rename to backend/db/agentskill_delete.go index 68880562..39d5784a 100644 --- a/backend/db/skill_delete.go +++ b/backend/db/agentskill_delete.go @@ -8,30 +8,30 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" ) -// SkillDelete is the builder for deleting a Skill entity. -type SkillDelete struct { +// AgentSkillDelete is the builder for deleting a AgentSkill entity. +type AgentSkillDelete struct { config hooks []Hook - mutation *SkillMutation + mutation *AgentSkillMutation } -// Where appends a list predicates to the SkillDelete builder. -func (_d *SkillDelete) Where(ps ...predicate.Skill) *SkillDelete { +// Where appends a list predicates to the AgentSkillDelete builder. +func (_d *AgentSkillDelete) Where(ps ...predicate.AgentSkill) *AgentSkillDelete { _d.mutation.Where(ps...) return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (_d *SkillDelete) Exec(ctx context.Context) (int, error) { +func (_d *AgentSkillDelete) Exec(ctx context.Context) (int, error) { return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (_d *SkillDelete) ExecX(ctx context.Context) int { +func (_d *AgentSkillDelete) ExecX(ctx context.Context) int { n, err := _d.Exec(ctx) if err != nil { panic(err) @@ -39,8 +39,8 @@ func (_d *SkillDelete) ExecX(ctx context.Context) int { return n } -func (_d *SkillDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(skill.Table, sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID)) +func (_d *AgentSkillDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(agentskill.Table, sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID)) if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -56,32 +56,32 @@ func (_d *SkillDelete) sqlExec(ctx context.Context) (int, error) { return affected, err } -// SkillDeleteOne is the builder for deleting a single Skill entity. -type SkillDeleteOne struct { - _d *SkillDelete +// AgentSkillDeleteOne is the builder for deleting a single AgentSkill entity. +type AgentSkillDeleteOne struct { + _d *AgentSkillDelete } -// Where appends a list predicates to the SkillDelete builder. -func (_d *SkillDeleteOne) Where(ps ...predicate.Skill) *SkillDeleteOne { +// Where appends a list predicates to the AgentSkillDelete builder. +func (_d *AgentSkillDeleteOne) Where(ps ...predicate.AgentSkill) *AgentSkillDeleteOne { _d._d.mutation.Where(ps...) return _d } // Exec executes the deletion query. -func (_d *SkillDeleteOne) Exec(ctx context.Context) error { +func (_d *AgentSkillDeleteOne) Exec(ctx context.Context) error { n, err := _d._d.Exec(ctx) switch { case err != nil: return err case n == 0: - return &NotFoundError{skill.Label} + return &NotFoundError{agentskill.Label} default: return nil } } // ExecX is like Exec, but panics if an error occurs. -func (_d *SkillDeleteOne) ExecX(ctx context.Context) { +func (_d *AgentSkillDeleteOne) ExecX(ctx context.Context) { if err := _d.Exec(ctx); err != nil { panic(err) } diff --git a/backend/db/agentskill_query.go b/backend/db/agentskill_query.go new file mode 100644 index 00000000..40bc8be9 --- /dev/null +++ b/backend/db/agentskill_query.go @@ -0,0 +1,732 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentSkillQuery is the builder for querying AgentSkill entities. +type AgentSkillQuery struct { + config + ctx *QueryContext + order []agentskill.OrderOption + inters []Interceptor + predicates []predicate.AgentSkill + withRepo *AgentSkillRepoQuery + withVersions *AgentSkillVersionQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the AgentSkillQuery builder. +func (_q *AgentSkillQuery) Where(ps ...predicate.AgentSkill) *AgentSkillQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *AgentSkillQuery) Limit(limit int) *AgentSkillQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *AgentSkillQuery) Offset(offset int) *AgentSkillQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *AgentSkillQuery) Unique(unique bool) *AgentSkillQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *AgentSkillQuery) Order(o ...agentskill.OrderOption) *AgentSkillQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryRepo chains the current query on the "repo" edge. +func (_q *AgentSkillQuery) QueryRepo() *AgentSkillRepoQuery { + query := (&AgentSkillRepoClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(agentskill.Table, agentskill.FieldID, selector), + sqlgraph.To(agentskillrepo.Table, agentskillrepo.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, agentskill.RepoTable, agentskill.RepoColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryVersions chains the current query on the "versions" edge. +func (_q *AgentSkillQuery) QueryVersions() *AgentSkillVersionQuery { + query := (&AgentSkillVersionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(agentskill.Table, agentskill.FieldID, selector), + sqlgraph.To(agentskillversion.Table, agentskillversion.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, agentskill.VersionsTable, agentskill.VersionsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first AgentSkill entity from the query. +// Returns a *NotFoundError when no AgentSkill was found. +func (_q *AgentSkillQuery) First(ctx context.Context) (*AgentSkill, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{agentskill.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *AgentSkillQuery) FirstX(ctx context.Context) *AgentSkill { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first AgentSkill ID from the query. +// Returns a *NotFoundError when no AgentSkill ID was found. +func (_q *AgentSkillQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{agentskill.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *AgentSkillQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single AgentSkill entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one AgentSkill entity is found. +// Returns a *NotFoundError when no AgentSkill entities are found. +func (_q *AgentSkillQuery) Only(ctx context.Context) (*AgentSkill, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{agentskill.Label} + default: + return nil, &NotSingularError{agentskill.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *AgentSkillQuery) OnlyX(ctx context.Context) *AgentSkill { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only AgentSkill ID in the query. +// Returns a *NotSingularError when more than one AgentSkill ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *AgentSkillQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{agentskill.Label} + default: + err = &NotSingularError{agentskill.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *AgentSkillQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of AgentSkills. +func (_q *AgentSkillQuery) All(ctx context.Context) ([]*AgentSkill, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*AgentSkill, *AgentSkillQuery]() + return withInterceptors[[]*AgentSkill](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *AgentSkillQuery) AllX(ctx context.Context) []*AgentSkill { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of AgentSkill IDs. +func (_q *AgentSkillQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(agentskill.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *AgentSkillQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *AgentSkillQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*AgentSkillQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *AgentSkillQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *AgentSkillQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *AgentSkillQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AgentSkillQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *AgentSkillQuery) Clone() *AgentSkillQuery { + if _q == nil { + return nil + } + return &AgentSkillQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]agentskill.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.AgentSkill{}, _q.predicates...), + withRepo: _q.withRepo.Clone(), + withVersions: _q.withVersions.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithRepo tells the query-builder to eager-load the nodes that are connected to +// the "repo" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentSkillQuery) WithRepo(opts ...func(*AgentSkillRepoQuery)) *AgentSkillQuery { + query := (&AgentSkillRepoClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRepo = query + return _q +} + +// WithVersions tells the query-builder to eager-load the nodes that are connected to +// the "versions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentSkillQuery) WithVersions(opts ...func(*AgentSkillVersionQuery)) *AgentSkillQuery { + query := (&AgentSkillVersionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withVersions = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// RepoID uuid.UUID `json:"repo_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.AgentSkill.Query(). +// GroupBy(agentskill.FieldRepoID). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (_q *AgentSkillQuery) GroupBy(field string, fields ...string) *AgentSkillGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &AgentSkillGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = agentskill.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// RepoID uuid.UUID `json:"repo_id,omitempty"` +// } +// +// client.AgentSkill.Query(). +// Select(agentskill.FieldRepoID). +// Scan(ctx, &v) +func (_q *AgentSkillQuery) Select(fields ...string) *AgentSkillSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &AgentSkillSelect{AgentSkillQuery: _q} + sbuild.label = agentskill.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AgentSkillSelect configured with the given aggregations. +func (_q *AgentSkillQuery) Aggregate(fns ...AggregateFunc) *AgentSkillSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *AgentSkillQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !agentskill.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *AgentSkillQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AgentSkill, error) { + var ( + nodes = []*AgentSkill{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withRepo != nil, + _q.withVersions != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*AgentSkill).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &AgentSkill{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withRepo; query != nil { + if err := _q.loadRepo(ctx, query, nodes, nil, + func(n *AgentSkill, e *AgentSkillRepo) { n.Edges.Repo = e }); err != nil { + return nil, err + } + } + if query := _q.withVersions; query != nil { + if err := _q.loadVersions(ctx, query, nodes, + func(n *AgentSkill) { n.Edges.Versions = []*AgentSkillVersion{} }, + func(n *AgentSkill, e *AgentSkillVersion) { n.Edges.Versions = append(n.Edges.Versions, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *AgentSkillQuery) loadRepo(ctx context.Context, query *AgentSkillRepoQuery, nodes []*AgentSkill, init func(*AgentSkill), assign func(*AgentSkill, *AgentSkillRepo)) error { + ids := make([]uuid.UUID, 0, len(nodes)) + nodeids := make(map[uuid.UUID][]*AgentSkill) + for i := range nodes { + fk := nodes[i].RepoID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(agentskillrepo.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "repo_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *AgentSkillQuery) loadVersions(ctx context.Context, query *AgentSkillVersionQuery, nodes []*AgentSkill, init func(*AgentSkill), assign func(*AgentSkill, *AgentSkillVersion)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*AgentSkill) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(agentskillversion.FieldResourceID) + } + query.Where(predicate.AgentSkillVersion(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(agentskill.VersionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ResourceID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "resource_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *AgentSkillQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *AgentSkillQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(agentskill.Table, agentskill.Columns, sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentskill.FieldID) + for i := range fields { + if fields[i] != agentskill.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withRepo != nil { + _spec.Node.AddColumnOnce(agentskill.FieldRepoID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *AgentSkillQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(agentskill.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = agentskill.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *AgentSkillQuery) ForUpdate(opts ...sql.LockOption) *AgentSkillQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *AgentSkillQuery) ForShare(opts ...sql.LockOption) *AgentSkillQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *AgentSkillQuery) Modify(modifiers ...func(s *sql.Selector)) *AgentSkillSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// AgentSkillGroupBy is the group-by builder for AgentSkill entities. +type AgentSkillGroupBy struct { + selector + build *AgentSkillQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *AgentSkillGroupBy) Aggregate(fns ...AggregateFunc) *AgentSkillGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *AgentSkillGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentSkillQuery, *AgentSkillGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *AgentSkillGroupBy) sqlScan(ctx context.Context, root *AgentSkillQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// AgentSkillSelect is the builder for selecting fields of AgentSkill entities. +type AgentSkillSelect struct { + *AgentSkillQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *AgentSkillSelect) Aggregate(fns ...AggregateFunc) *AgentSkillSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *AgentSkillSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentSkillQuery, *AgentSkillSelect](ctx, _s.AgentSkillQuery, _s, _s.inters, v) +} + +func (_s *AgentSkillSelect) sqlScan(ctx context.Context, root *AgentSkillQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *AgentSkillSelect) Modify(modifiers ...func(s *sql.Selector)) *AgentSkillSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/backend/db/agentskill_update.go b/backend/db/agentskill_update.go new file mode 100644 index 00000000..957c9145 --- /dev/null +++ b/backend/db/agentskill_update.go @@ -0,0 +1,1116 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/dialect/sql/sqljson" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentSkillUpdate is the builder for updating AgentSkill entities. +type AgentSkillUpdate struct { + config + hooks []Hook + mutation *AgentSkillMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the AgentSkillUpdate builder. +func (_u *AgentSkillUpdate) Where(ps ...predicate.AgentSkill) *AgentSkillUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetRepoID sets the "repo_id" field. +func (_u *AgentSkillUpdate) SetRepoID(v uuid.UUID) *AgentSkillUpdate { + _u.mutation.SetRepoID(v) + return _u +} + +// SetNillableRepoID sets the "repo_id" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableRepoID(v *uuid.UUID) *AgentSkillUpdate { + if v != nil { + _u.SetRepoID(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *AgentSkillUpdate) SetName(v string) *AgentSkillUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableName(v *string) *AgentSkillUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *AgentSkillUpdate) SetDescription(v string) *AgentSkillUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableDescription(v *string) *AgentSkillUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *AgentSkillUpdate) ClearDescription() *AgentSkillUpdate { + _u.mutation.ClearDescription() + return _u +} + +// SetScopeType sets the "scope_type" field. +func (_u *AgentSkillUpdate) SetScopeType(v agentskill.ScopeType) *AgentSkillUpdate { + _u.mutation.SetScopeType(v) + return _u +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableScopeType(v *agentskill.ScopeType) *AgentSkillUpdate { + if v != nil { + _u.SetScopeType(*v) + } + return _u +} + +// SetScopeID sets the "scope_id" field. +func (_u *AgentSkillUpdate) SetScopeID(v string) *AgentSkillUpdate { + _u.mutation.SetScopeID(v) + return _u +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableScopeID(v *string) *AgentSkillUpdate { + if v != nil { + _u.SetScopeID(*v) + } + return _u +} + +// SetCreatedBy sets the "created_by" field. +func (_u *AgentSkillUpdate) SetCreatedBy(v uuid.UUID) *AgentSkillUpdate { + _u.mutation.SetCreatedBy(v) + return _u +} + +// SetNillableCreatedBy sets the "created_by" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableCreatedBy(v *uuid.UUID) *AgentSkillUpdate { + if v != nil { + _u.SetCreatedBy(*v) + } + return _u +} + +// SetActiveVersionID sets the "active_version_id" field. +func (_u *AgentSkillUpdate) SetActiveVersionID(v uuid.UUID) *AgentSkillUpdate { + _u.mutation.SetActiveVersionID(v) + return _u +} + +// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableActiveVersionID(v *uuid.UUID) *AgentSkillUpdate { + if v != nil { + _u.SetActiveVersionID(*v) + } + return _u +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (_u *AgentSkillUpdate) ClearActiveVersionID() *AgentSkillUpdate { + _u.mutation.ClearActiveVersionID() + return _u +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (_u *AgentSkillUpdate) SetIsForceDelivery(v bool) *AgentSkillUpdate { + _u.mutation.SetIsForceDelivery(v) + return _u +} + +// SetNillableIsForceDelivery sets the "is_force_delivery" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableIsForceDelivery(v *bool) *AgentSkillUpdate { + if v != nil { + _u.SetIsForceDelivery(*v) + } + return _u +} + +// SetIsOrphan sets the "is_orphan" field. +func (_u *AgentSkillUpdate) SetIsOrphan(v bool) *AgentSkillUpdate { + _u.mutation.SetIsOrphan(v) + return _u +} + +// SetNillableIsOrphan sets the "is_orphan" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableIsOrphan(v *bool) *AgentSkillUpdate { + if v != nil { + _u.SetIsOrphan(*v) + } + return _u +} + +// SetIsDeleted sets the "is_deleted" field. +func (_u *AgentSkillUpdate) SetIsDeleted(v bool) *AgentSkillUpdate { + _u.mutation.SetIsDeleted(v) + return _u +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableIsDeleted(v *bool) *AgentSkillUpdate { + if v != nil { + _u.SetIsDeleted(*v) + } + return _u +} + +// SetEnabled sets the "enabled" field. +func (_u *AgentSkillUpdate) SetEnabled(v bool) *AgentSkillUpdate { + _u.mutation.SetEnabled(v) + return _u +} + +// SetNillableEnabled sets the "enabled" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableEnabled(v *bool) *AgentSkillUpdate { + if v != nil { + _u.SetEnabled(*v) + } + return _u +} + +// SetExtensionPackageID sets the "extension_package_id" field. +func (_u *AgentSkillUpdate) SetExtensionPackageID(v string) *AgentSkillUpdate { + _u.mutation.SetExtensionPackageID(v) + return _u +} + +// SetNillableExtensionPackageID sets the "extension_package_id" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableExtensionPackageID(v *string) *AgentSkillUpdate { + if v != nil { + _u.SetExtensionPackageID(*v) + } + return _u +} + +// ClearExtensionPackageID clears the value of the "extension_package_id" field. +func (_u *AgentSkillUpdate) ClearExtensionPackageID() *AgentSkillUpdate { + _u.mutation.ClearExtensionPackageID() + return _u +} + +// SetAdminDescription sets the "admin_description" field. +func (_u *AgentSkillUpdate) SetAdminDescription(v string) *AgentSkillUpdate { + _u.mutation.SetAdminDescription(v) + return _u +} + +// SetNillableAdminDescription sets the "admin_description" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableAdminDescription(v *string) *AgentSkillUpdate { + if v != nil { + _u.SetAdminDescription(*v) + } + return _u +} + +// ClearAdminDescription clears the value of the "admin_description" field. +func (_u *AgentSkillUpdate) ClearAdminDescription() *AgentSkillUpdate { + _u.mutation.ClearAdminDescription() + return _u +} + +// SetAdminTags sets the "admin_tags" field. +func (_u *AgentSkillUpdate) SetAdminTags(v []string) *AgentSkillUpdate { + _u.mutation.SetAdminTags(v) + return _u +} + +// AppendAdminTags appends value to the "admin_tags" field. +func (_u *AgentSkillUpdate) AppendAdminTags(v []string) *AgentSkillUpdate { + _u.mutation.AppendAdminTags(v) + return _u +} + +// ClearAdminTags clears the value of the "admin_tags" field. +func (_u *AgentSkillUpdate) ClearAdminTags() *AgentSkillUpdate { + _u.mutation.ClearAdminTags() + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentSkillUpdate) SetCreatedAt(v time.Time) *AgentSkillUpdate { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentSkillUpdate) SetNillableCreatedAt(v *time.Time) *AgentSkillUpdate { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentSkillUpdate) SetUpdatedAt(v time.Time) *AgentSkillUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetRepo sets the "repo" edge to the AgentSkillRepo entity. +func (_u *AgentSkillUpdate) SetRepo(v *AgentSkillRepo) *AgentSkillUpdate { + return _u.SetRepoID(v.ID) +} + +// AddVersionIDs adds the "versions" edge to the AgentSkillVersion entity by IDs. +func (_u *AgentSkillUpdate) AddVersionIDs(ids ...uuid.UUID) *AgentSkillUpdate { + _u.mutation.AddVersionIDs(ids...) + return _u +} + +// AddVersions adds the "versions" edges to the AgentSkillVersion entity. +func (_u *AgentSkillUpdate) AddVersions(v ...*AgentSkillVersion) *AgentSkillUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddVersionIDs(ids...) +} + +// Mutation returns the AgentSkillMutation object of the builder. +func (_u *AgentSkillUpdate) Mutation() *AgentSkillMutation { + return _u.mutation +} + +// ClearRepo clears the "repo" edge to the AgentSkillRepo entity. +func (_u *AgentSkillUpdate) ClearRepo() *AgentSkillUpdate { + _u.mutation.ClearRepo() + return _u +} + +// ClearVersions clears all "versions" edges to the AgentSkillVersion entity. +func (_u *AgentSkillUpdate) ClearVersions() *AgentSkillUpdate { + _u.mutation.ClearVersions() + return _u +} + +// RemoveVersionIDs removes the "versions" edge to AgentSkillVersion entities by IDs. +func (_u *AgentSkillUpdate) RemoveVersionIDs(ids ...uuid.UUID) *AgentSkillUpdate { + _u.mutation.RemoveVersionIDs(ids...) + return _u +} + +// RemoveVersions removes "versions" edges to AgentSkillVersion entities. +func (_u *AgentSkillUpdate) RemoveVersions(v ...*AgentSkillVersion) *AgentSkillUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveVersionIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AgentSkillUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentSkillUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AgentSkillUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentSkillUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentSkillUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentskill.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentSkillUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := agentskill.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentSkill.name": %w`, err)} + } + } + if v, ok := _u.mutation.ScopeType(); ok { + if err := agentskill.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentSkill.scope_type": %w`, err)} + } + } + if _u.mutation.RepoCleared() && len(_u.mutation.RepoIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentSkill.repo"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentSkillUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentSkillUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentskill.Table, agentskill.Columns, sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(agentskill.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(agentskill.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(agentskill.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.ScopeType(); ok { + _spec.SetField(agentskill.FieldScopeType, field.TypeEnum, value) + } + if value, ok := _u.mutation.ScopeID(); ok { + _spec.SetField(agentskill.FieldScopeID, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedBy(); ok { + _spec.SetField(agentskill.FieldCreatedBy, field.TypeUUID, value) + } + if value, ok := _u.mutation.ActiveVersionID(); ok { + _spec.SetField(agentskill.FieldActiveVersionID, field.TypeUUID, value) + } + if _u.mutation.ActiveVersionIDCleared() { + _spec.ClearField(agentskill.FieldActiveVersionID, field.TypeUUID) + } + if value, ok := _u.mutation.IsForceDelivery(); ok { + _spec.SetField(agentskill.FieldIsForceDelivery, field.TypeBool, value) + } + if value, ok := _u.mutation.IsOrphan(); ok { + _spec.SetField(agentskill.FieldIsOrphan, field.TypeBool, value) + } + if value, ok := _u.mutation.IsDeleted(); ok { + _spec.SetField(agentskill.FieldIsDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.Enabled(); ok { + _spec.SetField(agentskill.FieldEnabled, field.TypeBool, value) + } + if value, ok := _u.mutation.ExtensionPackageID(); ok { + _spec.SetField(agentskill.FieldExtensionPackageID, field.TypeString, value) + } + if _u.mutation.ExtensionPackageIDCleared() { + _spec.ClearField(agentskill.FieldExtensionPackageID, field.TypeString) + } + if value, ok := _u.mutation.AdminDescription(); ok { + _spec.SetField(agentskill.FieldAdminDescription, field.TypeString, value) + } + if _u.mutation.AdminDescriptionCleared() { + _spec.ClearField(agentskill.FieldAdminDescription, field.TypeString) + } + if value, ok := _u.mutation.AdminTags(); ok { + _spec.SetField(agentskill.FieldAdminTags, field.TypeJSON, value) + } + if value, ok := _u.mutation.AppendedAdminTags(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, agentskill.FieldAdminTags, value) + }) + } + if _u.mutation.AdminTagsCleared() { + _spec.ClearField(agentskill.FieldAdminTags, field.TypeJSON) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentskill.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentskill.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.RepoCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentskill.RepoTable, + Columns: []string{agentskill.RepoColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RepoIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentskill.RepoTable, + Columns: []string{agentskill.RepoColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskill.VersionsTable, + Columns: []string{agentskill.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedVersionsIDs(); len(nodes) > 0 && !_u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskill.VersionsTable, + Columns: []string{agentskill.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskill.VersionsTable, + Columns: []string{agentskill.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentskill.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AgentSkillUpdateOne is the builder for updating a single AgentSkill entity. +type AgentSkillUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AgentSkillMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetRepoID sets the "repo_id" field. +func (_u *AgentSkillUpdateOne) SetRepoID(v uuid.UUID) *AgentSkillUpdateOne { + _u.mutation.SetRepoID(v) + return _u +} + +// SetNillableRepoID sets the "repo_id" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableRepoID(v *uuid.UUID) *AgentSkillUpdateOne { + if v != nil { + _u.SetRepoID(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *AgentSkillUpdateOne) SetName(v string) *AgentSkillUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableName(v *string) *AgentSkillUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *AgentSkillUpdateOne) SetDescription(v string) *AgentSkillUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableDescription(v *string) *AgentSkillUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *AgentSkillUpdateOne) ClearDescription() *AgentSkillUpdateOne { + _u.mutation.ClearDescription() + return _u +} + +// SetScopeType sets the "scope_type" field. +func (_u *AgentSkillUpdateOne) SetScopeType(v agentskill.ScopeType) *AgentSkillUpdateOne { + _u.mutation.SetScopeType(v) + return _u +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableScopeType(v *agentskill.ScopeType) *AgentSkillUpdateOne { + if v != nil { + _u.SetScopeType(*v) + } + return _u +} + +// SetScopeID sets the "scope_id" field. +func (_u *AgentSkillUpdateOne) SetScopeID(v string) *AgentSkillUpdateOne { + _u.mutation.SetScopeID(v) + return _u +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableScopeID(v *string) *AgentSkillUpdateOne { + if v != nil { + _u.SetScopeID(*v) + } + return _u +} + +// SetCreatedBy sets the "created_by" field. +func (_u *AgentSkillUpdateOne) SetCreatedBy(v uuid.UUID) *AgentSkillUpdateOne { + _u.mutation.SetCreatedBy(v) + return _u +} + +// SetNillableCreatedBy sets the "created_by" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableCreatedBy(v *uuid.UUID) *AgentSkillUpdateOne { + if v != nil { + _u.SetCreatedBy(*v) + } + return _u +} + +// SetActiveVersionID sets the "active_version_id" field. +func (_u *AgentSkillUpdateOne) SetActiveVersionID(v uuid.UUID) *AgentSkillUpdateOne { + _u.mutation.SetActiveVersionID(v) + return _u +} + +// SetNillableActiveVersionID sets the "active_version_id" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableActiveVersionID(v *uuid.UUID) *AgentSkillUpdateOne { + if v != nil { + _u.SetActiveVersionID(*v) + } + return _u +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (_u *AgentSkillUpdateOne) ClearActiveVersionID() *AgentSkillUpdateOne { + _u.mutation.ClearActiveVersionID() + return _u +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (_u *AgentSkillUpdateOne) SetIsForceDelivery(v bool) *AgentSkillUpdateOne { + _u.mutation.SetIsForceDelivery(v) + return _u +} + +// SetNillableIsForceDelivery sets the "is_force_delivery" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableIsForceDelivery(v *bool) *AgentSkillUpdateOne { + if v != nil { + _u.SetIsForceDelivery(*v) + } + return _u +} + +// SetIsOrphan sets the "is_orphan" field. +func (_u *AgentSkillUpdateOne) SetIsOrphan(v bool) *AgentSkillUpdateOne { + _u.mutation.SetIsOrphan(v) + return _u +} + +// SetNillableIsOrphan sets the "is_orphan" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableIsOrphan(v *bool) *AgentSkillUpdateOne { + if v != nil { + _u.SetIsOrphan(*v) + } + return _u +} + +// SetIsDeleted sets the "is_deleted" field. +func (_u *AgentSkillUpdateOne) SetIsDeleted(v bool) *AgentSkillUpdateOne { + _u.mutation.SetIsDeleted(v) + return _u +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableIsDeleted(v *bool) *AgentSkillUpdateOne { + if v != nil { + _u.SetIsDeleted(*v) + } + return _u +} + +// SetEnabled sets the "enabled" field. +func (_u *AgentSkillUpdateOne) SetEnabled(v bool) *AgentSkillUpdateOne { + _u.mutation.SetEnabled(v) + return _u +} + +// SetNillableEnabled sets the "enabled" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableEnabled(v *bool) *AgentSkillUpdateOne { + if v != nil { + _u.SetEnabled(*v) + } + return _u +} + +// SetExtensionPackageID sets the "extension_package_id" field. +func (_u *AgentSkillUpdateOne) SetExtensionPackageID(v string) *AgentSkillUpdateOne { + _u.mutation.SetExtensionPackageID(v) + return _u +} + +// SetNillableExtensionPackageID sets the "extension_package_id" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableExtensionPackageID(v *string) *AgentSkillUpdateOne { + if v != nil { + _u.SetExtensionPackageID(*v) + } + return _u +} + +// ClearExtensionPackageID clears the value of the "extension_package_id" field. +func (_u *AgentSkillUpdateOne) ClearExtensionPackageID() *AgentSkillUpdateOne { + _u.mutation.ClearExtensionPackageID() + return _u +} + +// SetAdminDescription sets the "admin_description" field. +func (_u *AgentSkillUpdateOne) SetAdminDescription(v string) *AgentSkillUpdateOne { + _u.mutation.SetAdminDescription(v) + return _u +} + +// SetNillableAdminDescription sets the "admin_description" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableAdminDescription(v *string) *AgentSkillUpdateOne { + if v != nil { + _u.SetAdminDescription(*v) + } + return _u +} + +// ClearAdminDescription clears the value of the "admin_description" field. +func (_u *AgentSkillUpdateOne) ClearAdminDescription() *AgentSkillUpdateOne { + _u.mutation.ClearAdminDescription() + return _u +} + +// SetAdminTags sets the "admin_tags" field. +func (_u *AgentSkillUpdateOne) SetAdminTags(v []string) *AgentSkillUpdateOne { + _u.mutation.SetAdminTags(v) + return _u +} + +// AppendAdminTags appends value to the "admin_tags" field. +func (_u *AgentSkillUpdateOne) AppendAdminTags(v []string) *AgentSkillUpdateOne { + _u.mutation.AppendAdminTags(v) + return _u +} + +// ClearAdminTags clears the value of the "admin_tags" field. +func (_u *AgentSkillUpdateOne) ClearAdminTags() *AgentSkillUpdateOne { + _u.mutation.ClearAdminTags() + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentSkillUpdateOne) SetCreatedAt(v time.Time) *AgentSkillUpdateOne { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentSkillUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentSkillUpdateOne { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentSkillUpdateOne) SetUpdatedAt(v time.Time) *AgentSkillUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetRepo sets the "repo" edge to the AgentSkillRepo entity. +func (_u *AgentSkillUpdateOne) SetRepo(v *AgentSkillRepo) *AgentSkillUpdateOne { + return _u.SetRepoID(v.ID) +} + +// AddVersionIDs adds the "versions" edge to the AgentSkillVersion entity by IDs. +func (_u *AgentSkillUpdateOne) AddVersionIDs(ids ...uuid.UUID) *AgentSkillUpdateOne { + _u.mutation.AddVersionIDs(ids...) + return _u +} + +// AddVersions adds the "versions" edges to the AgentSkillVersion entity. +func (_u *AgentSkillUpdateOne) AddVersions(v ...*AgentSkillVersion) *AgentSkillUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddVersionIDs(ids...) +} + +// Mutation returns the AgentSkillMutation object of the builder. +func (_u *AgentSkillUpdateOne) Mutation() *AgentSkillMutation { + return _u.mutation +} + +// ClearRepo clears the "repo" edge to the AgentSkillRepo entity. +func (_u *AgentSkillUpdateOne) ClearRepo() *AgentSkillUpdateOne { + _u.mutation.ClearRepo() + return _u +} + +// ClearVersions clears all "versions" edges to the AgentSkillVersion entity. +func (_u *AgentSkillUpdateOne) ClearVersions() *AgentSkillUpdateOne { + _u.mutation.ClearVersions() + return _u +} + +// RemoveVersionIDs removes the "versions" edge to AgentSkillVersion entities by IDs. +func (_u *AgentSkillUpdateOne) RemoveVersionIDs(ids ...uuid.UUID) *AgentSkillUpdateOne { + _u.mutation.RemoveVersionIDs(ids...) + return _u +} + +// RemoveVersions removes "versions" edges to AgentSkillVersion entities. +func (_u *AgentSkillUpdateOne) RemoveVersions(v ...*AgentSkillVersion) *AgentSkillUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveVersionIDs(ids...) +} + +// Where appends a list predicates to the AgentSkillUpdate builder. +func (_u *AgentSkillUpdateOne) Where(ps ...predicate.AgentSkill) *AgentSkillUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *AgentSkillUpdateOne) Select(field string, fields ...string) *AgentSkillUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated AgentSkill entity. +func (_u *AgentSkillUpdateOne) Save(ctx context.Context) (*AgentSkill, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentSkillUpdateOne) SaveX(ctx context.Context) *AgentSkill { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AgentSkillUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentSkillUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentSkillUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentskill.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentSkillUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := agentskill.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentSkill.name": %w`, err)} + } + } + if v, ok := _u.mutation.ScopeType(); ok { + if err := agentskill.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentSkill.scope_type": %w`, err)} + } + } + if _u.mutation.RepoCleared() && len(_u.mutation.RepoIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentSkill.repo"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentSkillUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentSkillUpdateOne) sqlSave(ctx context.Context) (_node *AgentSkill, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentskill.Table, agentskill.Columns, sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentSkill.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentskill.FieldID) + for _, f := range fields { + if !agentskill.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != agentskill.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(agentskill.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(agentskill.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(agentskill.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.ScopeType(); ok { + _spec.SetField(agentskill.FieldScopeType, field.TypeEnum, value) + } + if value, ok := _u.mutation.ScopeID(); ok { + _spec.SetField(agentskill.FieldScopeID, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedBy(); ok { + _spec.SetField(agentskill.FieldCreatedBy, field.TypeUUID, value) + } + if value, ok := _u.mutation.ActiveVersionID(); ok { + _spec.SetField(agentskill.FieldActiveVersionID, field.TypeUUID, value) + } + if _u.mutation.ActiveVersionIDCleared() { + _spec.ClearField(agentskill.FieldActiveVersionID, field.TypeUUID) + } + if value, ok := _u.mutation.IsForceDelivery(); ok { + _spec.SetField(agentskill.FieldIsForceDelivery, field.TypeBool, value) + } + if value, ok := _u.mutation.IsOrphan(); ok { + _spec.SetField(agentskill.FieldIsOrphan, field.TypeBool, value) + } + if value, ok := _u.mutation.IsDeleted(); ok { + _spec.SetField(agentskill.FieldIsDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.Enabled(); ok { + _spec.SetField(agentskill.FieldEnabled, field.TypeBool, value) + } + if value, ok := _u.mutation.ExtensionPackageID(); ok { + _spec.SetField(agentskill.FieldExtensionPackageID, field.TypeString, value) + } + if _u.mutation.ExtensionPackageIDCleared() { + _spec.ClearField(agentskill.FieldExtensionPackageID, field.TypeString) + } + if value, ok := _u.mutation.AdminDescription(); ok { + _spec.SetField(agentskill.FieldAdminDescription, field.TypeString, value) + } + if _u.mutation.AdminDescriptionCleared() { + _spec.ClearField(agentskill.FieldAdminDescription, field.TypeString) + } + if value, ok := _u.mutation.AdminTags(); ok { + _spec.SetField(agentskill.FieldAdminTags, field.TypeJSON, value) + } + if value, ok := _u.mutation.AppendedAdminTags(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, agentskill.FieldAdminTags, value) + }) + } + if _u.mutation.AdminTagsCleared() { + _spec.ClearField(agentskill.FieldAdminTags, field.TypeJSON) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentskill.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentskill.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.RepoCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentskill.RepoTable, + Columns: []string{agentskill.RepoColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RepoIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentskill.RepoTable, + Columns: []string{agentskill.RepoColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskill.VersionsTable, + Columns: []string{agentskill.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedVersionsIDs(); len(nodes) > 0 && !_u.mutation.VersionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskill.VersionsTable, + Columns: []string{agentskill.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.VersionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskill.VersionsTable, + Columns: []string{agentskill.VersionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &AgentSkill{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentskill.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/db/teamgroupskill.go b/backend/db/agentskillgroupbinding.go similarity index 59% rename from backend/db/teamgroupskill.go rename to backend/db/agentskillgroupbinding.go index 33e0fb07..51449f4d 100644 --- a/backend/db/teamgroupskill.go +++ b/backend/db/agentskillgroupbinding.go @@ -9,70 +9,70 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/chaitin/MonkeyCode/backend/db/skill" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/google/uuid" ) -// TeamGroupSkill is the model entity for the TeamGroupSkill schema. -type TeamGroupSkill struct { +// AgentSkillGroupBinding is the model entity for the AgentSkillGroupBinding schema. +type AgentSkillGroupBinding struct { config `json:"-"` // ID of the ent. ID uuid.UUID `json:"id,omitempty"` - // GroupID holds the value of the "group_id" field. - GroupID uuid.UUID `json:"group_id,omitempty"` // SkillID holds the value of the "skill_id" field. SkillID uuid.UUID `json:"skill_id,omitempty"` + // GroupID holds the value of the "group_id" field. + GroupID uuid.UUID `json:"group_id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the TeamGroupSkillQuery when eager-loading is set. - Edges TeamGroupSkillEdges `json:"edges"` + // The values are being populated by the AgentSkillGroupBindingQuery when eager-loading is set. + Edges AgentSkillGroupBindingEdges `json:"edges"` selectValues sql.SelectValues } -// TeamGroupSkillEdges holds the relations/edges for other nodes in the graph. -type TeamGroupSkillEdges struct { +// AgentSkillGroupBindingEdges holds the relations/edges for other nodes in the graph. +type AgentSkillGroupBindingEdges struct { + // Skill holds the value of the skill edge. + Skill *AgentSkill `json:"skill,omitempty"` // Group holds the value of the group edge. Group *TeamGroup `json:"group,omitempty"` - // Skill holds the value of the skill edge. - Skill *Skill `json:"skill,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [2]bool } -// GroupOrErr returns the Group value or an error if the edge +// SkillOrErr returns the Skill value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e TeamGroupSkillEdges) GroupOrErr() (*TeamGroup, error) { - if e.Group != nil { - return e.Group, nil +func (e AgentSkillGroupBindingEdges) SkillOrErr() (*AgentSkill, error) { + if e.Skill != nil { + return e.Skill, nil } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: teamgroup.Label} + return nil, &NotFoundError{label: agentskill.Label} } - return nil, &NotLoadedError{edge: "group"} + return nil, &NotLoadedError{edge: "skill"} } -// SkillOrErr returns the Skill value or an error if the edge +// GroupOrErr returns the Group value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. -func (e TeamGroupSkillEdges) SkillOrErr() (*Skill, error) { - if e.Skill != nil { - return e.Skill, nil +func (e AgentSkillGroupBindingEdges) GroupOrErr() (*TeamGroup, error) { + if e.Group != nil { + return e.Group, nil } else if e.loadedTypes[1] { - return nil, &NotFoundError{label: skill.Label} + return nil, &NotFoundError{label: teamgroup.Label} } - return nil, &NotLoadedError{edge: "skill"} + return nil, &NotLoadedError{edge: "group"} } // scanValues returns the types for scanning values from sql.Rows. -func (*TeamGroupSkill) scanValues(columns []string) ([]any, error) { +func (*AgentSkillGroupBinding) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case teamgroupskill.FieldCreatedAt: + case agentskillgroupbinding.FieldCreatedAt: values[i] = new(sql.NullTime) - case teamgroupskill.FieldID, teamgroupskill.FieldGroupID, teamgroupskill.FieldSkillID: + case agentskillgroupbinding.FieldID, agentskillgroupbinding.FieldSkillID, agentskillgroupbinding.FieldGroupID: values[i] = new(uuid.UUID) default: values[i] = new(sql.UnknownType) @@ -82,32 +82,32 @@ func (*TeamGroupSkill) scanValues(columns []string) ([]any, error) { } // assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the TeamGroupSkill fields. -func (_m *TeamGroupSkill) assignValues(columns []string, values []any) error { +// to the AgentSkillGroupBinding fields. +func (_m *AgentSkillGroupBinding) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } for i := range columns { switch columns[i] { - case teamgroupskill.FieldID: + case agentskillgroupbinding.FieldID: if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field id", values[i]) } else if value != nil { _m.ID = *value } - case teamgroupskill.FieldGroupID: + case agentskillgroupbinding.FieldSkillID: if value, ok := values[i].(*uuid.UUID); !ok { - return fmt.Errorf("unexpected type %T for field group_id", values[i]) + return fmt.Errorf("unexpected type %T for field skill_id", values[i]) } else if value != nil { - _m.GroupID = *value + _m.SkillID = *value } - case teamgroupskill.FieldSkillID: + case agentskillgroupbinding.FieldGroupID: if value, ok := values[i].(*uuid.UUID); !ok { - return fmt.Errorf("unexpected type %T for field skill_id", values[i]) + return fmt.Errorf("unexpected type %T for field group_id", values[i]) } else if value != nil { - _m.SkillID = *value + _m.GroupID = *value } - case teamgroupskill.FieldCreatedAt: + case agentskillgroupbinding.FieldCreatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field created_at", values[i]) } else if value.Valid { @@ -120,56 +120,56 @@ func (_m *TeamGroupSkill) assignValues(columns []string, values []any) error { return nil } -// Value returns the ent.Value that was dynamically selected and assigned to the TeamGroupSkill. +// Value returns the ent.Value that was dynamically selected and assigned to the AgentSkillGroupBinding. // This includes values selected through modifiers, order, etc. -func (_m *TeamGroupSkill) Value(name string) (ent.Value, error) { +func (_m *AgentSkillGroupBinding) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } -// QueryGroup queries the "group" edge of the TeamGroupSkill entity. -func (_m *TeamGroupSkill) QueryGroup() *TeamGroupQuery { - return NewTeamGroupSkillClient(_m.config).QueryGroup(_m) +// QuerySkill queries the "skill" edge of the AgentSkillGroupBinding entity. +func (_m *AgentSkillGroupBinding) QuerySkill() *AgentSkillQuery { + return NewAgentSkillGroupBindingClient(_m.config).QuerySkill(_m) } -// QuerySkill queries the "skill" edge of the TeamGroupSkill entity. -func (_m *TeamGroupSkill) QuerySkill() *SkillQuery { - return NewTeamGroupSkillClient(_m.config).QuerySkill(_m) +// QueryGroup queries the "group" edge of the AgentSkillGroupBinding entity. +func (_m *AgentSkillGroupBinding) QueryGroup() *TeamGroupQuery { + return NewAgentSkillGroupBindingClient(_m.config).QueryGroup(_m) } -// Update returns a builder for updating this TeamGroupSkill. -// Note that you need to call TeamGroupSkill.Unwrap() before calling this method if this TeamGroupSkill +// Update returns a builder for updating this AgentSkillGroupBinding. +// Note that you need to call AgentSkillGroupBinding.Unwrap() before calling this method if this AgentSkillGroupBinding // was returned from a transaction, and the transaction was committed or rolled back. -func (_m *TeamGroupSkill) Update() *TeamGroupSkillUpdateOne { - return NewTeamGroupSkillClient(_m.config).UpdateOne(_m) +func (_m *AgentSkillGroupBinding) Update() *AgentSkillGroupBindingUpdateOne { + return NewAgentSkillGroupBindingClient(_m.config).UpdateOne(_m) } -// Unwrap unwraps the TeamGroupSkill entity that was returned from a transaction after it was closed, +// Unwrap unwraps the AgentSkillGroupBinding entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (_m *TeamGroupSkill) Unwrap() *TeamGroupSkill { +func (_m *AgentSkillGroupBinding) Unwrap() *AgentSkillGroupBinding { _tx, ok := _m.config.driver.(*txDriver) if !ok { - panic("db: TeamGroupSkill is not a transactional entity") + panic("db: AgentSkillGroupBinding is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. -func (_m *TeamGroupSkill) String() string { +func (_m *AgentSkillGroupBinding) String() string { var builder strings.Builder - builder.WriteString("TeamGroupSkill(") + builder.WriteString("AgentSkillGroupBinding(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - builder.WriteString("group_id=") - builder.WriteString(fmt.Sprintf("%v", _m.GroupID)) - builder.WriteString(", ") builder.WriteString("skill_id=") builder.WriteString(fmt.Sprintf("%v", _m.SkillID)) builder.WriteString(", ") + builder.WriteString("group_id=") + builder.WriteString(fmt.Sprintf("%v", _m.GroupID)) + builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } -// TeamGroupSkills is a parsable slice of TeamGroupSkill. -type TeamGroupSkills []*TeamGroupSkill +// AgentSkillGroupBindings is a parsable slice of AgentSkillGroupBinding. +type AgentSkillGroupBindings []*AgentSkillGroupBinding diff --git a/backend/db/teamgroupskill/teamgroupskill.go b/backend/db/agentskillgroupbinding/agentskillgroupbinding.go similarity index 81% rename from backend/db/teamgroupskill/teamgroupskill.go rename to backend/db/agentskillgroupbinding/agentskillgroupbinding.go index 6b2b17fc..1e37b77d 100644 --- a/backend/db/teamgroupskill/teamgroupskill.go +++ b/backend/db/agentskillgroupbinding/agentskillgroupbinding.go @@ -1,52 +1,53 @@ // Code generated by ent, DO NOT EDIT. -package teamgroupskill +package agentskillgroupbinding import ( "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" ) const ( - // Label holds the string label denoting the teamgroupskill type in the database. - Label = "team_group_skill" + // Label holds the string label denoting the agentskillgroupbinding type in the database. + Label = "agent_skill_group_binding" // FieldID holds the string denoting the id field in the database. FieldID = "id" - // FieldGroupID holds the string denoting the group_id field in the database. - FieldGroupID = "group_id" // FieldSkillID holds the string denoting the skill_id field in the database. FieldSkillID = "skill_id" + // FieldGroupID holds the string denoting the group_id field in the database. + FieldGroupID = "group_id" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" - // EdgeGroup holds the string denoting the group edge name in mutations. - EdgeGroup = "group" // EdgeSkill holds the string denoting the skill edge name in mutations. EdgeSkill = "skill" - // Table holds the table name of the teamgroupskill in the database. - Table = "team_group_skills" + // EdgeGroup holds the string denoting the group edge name in mutations. + EdgeGroup = "group" + // Table holds the table name of the agentskillgroupbinding in the database. + Table = "agent_skill_group_bindings" + // SkillTable is the table that holds the skill relation/edge. + SkillTable = "agent_skill_group_bindings" + // SkillInverseTable is the table name for the AgentSkill entity. + // It exists in this package in order to avoid circular dependency with the "agentskill" package. + SkillInverseTable = "agent_skills" + // SkillColumn is the table column denoting the skill relation/edge. + SkillColumn = "skill_id" // GroupTable is the table that holds the group relation/edge. - GroupTable = "team_group_skills" + GroupTable = "agent_skill_group_bindings" // GroupInverseTable is the table name for the TeamGroup entity. // It exists in this package in order to avoid circular dependency with the "teamgroup" package. GroupInverseTable = "team_groups" // GroupColumn is the table column denoting the group relation/edge. GroupColumn = "group_id" - // SkillTable is the table that holds the skill relation/edge. - SkillTable = "team_group_skills" - // SkillInverseTable is the table name for the Skill entity. - // It exists in this package in order to avoid circular dependency with the "skill" package. - SkillInverseTable = "skills" - // SkillColumn is the table column denoting the skill relation/edge. - SkillColumn = "skill_id" ) -// Columns holds all SQL columns for teamgroupskill fields. +// Columns holds all SQL columns for agentskillgroupbinding fields. var Columns = []string{ FieldID, - FieldGroupID, FieldSkillID, + FieldGroupID, FieldCreatedAt, } @@ -63,9 +64,11 @@ func ValidColumn(column string) bool { var ( // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID ) -// OrderOption defines the ordering options for the TeamGroupSkill queries. +// OrderOption defines the ordering options for the AgentSkillGroupBinding queries. type OrderOption func(*sql.Selector) // ByID orders the results by the id field. @@ -73,45 +76,45 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } -// ByGroupID orders the results by the group_id field. -func ByGroupID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldGroupID, opts...).ToFunc() -} - // BySkillID orders the results by the skill_id field. func BySkillID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSkillID, opts...).ToFunc() } +// ByGroupID orders the results by the group_id field. +func ByGroupID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGroupID, opts...).ToFunc() +} + // ByCreatedAt orders the results by the created_at field. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() } -// ByGroupField orders the results by group field. -func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption { +// BySkillField orders the results by skill field. +func BySkillField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newGroupStep(), sql.OrderByField(field, opts...)) + sqlgraph.OrderByNeighborTerms(s, newSkillStep(), sql.OrderByField(field, opts...)) } } -// BySkillField orders the results by skill field. -func BySkillField(field string, opts ...sql.OrderTermOption) OrderOption { +// ByGroupField orders the results by group field. +func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSkillStep(), sql.OrderByField(field, opts...)) + sqlgraph.OrderByNeighborTerms(s, newGroupStep(), sql.OrderByField(field, opts...)) } } -func newGroupStep() *sqlgraph.Step { +func newSkillStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(GroupInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, GroupTable, GroupColumn), + sqlgraph.To(SkillInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, SkillTable, SkillColumn), ) } -func newSkillStep() *sqlgraph.Step { +func newGroupStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(SkillInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, SkillTable, SkillColumn), + sqlgraph.To(GroupInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, GroupTable, GroupColumn), ) } diff --git a/backend/db/agentskillgroupbinding/where.go b/backend/db/agentskillgroupbinding/where.go new file mode 100644 index 00000000..e0b45f8e --- /dev/null +++ b/backend/db/agentskillgroupbinding/where.go @@ -0,0 +1,213 @@ +// Code generated by ent, DO NOT EDIT. + +package agentskillgroupbinding + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldLTE(FieldID, id)) +} + +// SkillID applies equality check predicate on the "skill_id" field. It's identical to SkillIDEQ. +func SkillID(v uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldEQ(FieldSkillID, v)) +} + +// GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ. +func GroupID(v uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldEQ(FieldGroupID, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldEQ(FieldCreatedAt, v)) +} + +// SkillIDEQ applies the EQ predicate on the "skill_id" field. +func SkillIDEQ(v uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldEQ(FieldSkillID, v)) +} + +// SkillIDNEQ applies the NEQ predicate on the "skill_id" field. +func SkillIDNEQ(v uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldNEQ(FieldSkillID, v)) +} + +// SkillIDIn applies the In predicate on the "skill_id" field. +func SkillIDIn(vs ...uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldIn(FieldSkillID, vs...)) +} + +// SkillIDNotIn applies the NotIn predicate on the "skill_id" field. +func SkillIDNotIn(vs ...uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldNotIn(FieldSkillID, vs...)) +} + +// GroupIDEQ applies the EQ predicate on the "group_id" field. +func GroupIDEQ(v uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldEQ(FieldGroupID, v)) +} + +// GroupIDNEQ applies the NEQ predicate on the "group_id" field. +func GroupIDNEQ(v uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldNEQ(FieldGroupID, v)) +} + +// GroupIDIn applies the In predicate on the "group_id" field. +func GroupIDIn(vs ...uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldIn(FieldGroupID, vs...)) +} + +// GroupIDNotIn applies the NotIn predicate on the "group_id" field. +func GroupIDNotIn(vs ...uuid.UUID) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldNotIn(FieldGroupID, vs...)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.FieldLTE(FieldCreatedAt, v)) +} + +// HasSkill applies the HasEdge predicate on the "skill" edge. +func HasSkill() predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, SkillTable, SkillColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSkillWith applies the HasEdge predicate on the "skill" edge with a given conditions (other predicates). +func HasSkillWith(preds ...predicate.AgentSkill) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(func(s *sql.Selector) { + step := newSkillStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasGroup applies the HasEdge predicate on the "group" edge. +func HasGroup() predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, GroupTable, GroupColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates). +func HasGroupWith(preds ...predicate.TeamGroup) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(func(s *sql.Selector) { + step := newGroupStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.AgentSkillGroupBinding) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.AgentSkillGroupBinding) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.AgentSkillGroupBinding) predicate.AgentSkillGroupBinding { + return predicate.AgentSkillGroupBinding(sql.NotPredicates(p)) +} diff --git a/backend/db/teamgroupskill_create.go b/backend/db/agentskillgroupbinding_create.go similarity index 53% rename from backend/db/teamgroupskill_create.go rename to backend/db/agentskillgroupbinding_create.go index 13347fda..00b690f7 100644 --- a/backend/db/teamgroupskill_create.go +++ b/backend/db/agentskillgroupbinding_create.go @@ -12,40 +12,40 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/chaitin/MonkeyCode/backend/db/skill" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/google/uuid" ) -// TeamGroupSkillCreate is the builder for creating a TeamGroupSkill entity. -type TeamGroupSkillCreate struct { +// AgentSkillGroupBindingCreate is the builder for creating a AgentSkillGroupBinding entity. +type AgentSkillGroupBindingCreate struct { config - mutation *TeamGroupSkillMutation + mutation *AgentSkillGroupBindingMutation hooks []Hook conflict []sql.ConflictOption } -// SetGroupID sets the "group_id" field. -func (_c *TeamGroupSkillCreate) SetGroupID(v uuid.UUID) *TeamGroupSkillCreate { - _c.mutation.SetGroupID(v) +// SetSkillID sets the "skill_id" field. +func (_c *AgentSkillGroupBindingCreate) SetSkillID(v uuid.UUID) *AgentSkillGroupBindingCreate { + _c.mutation.SetSkillID(v) return _c } -// SetSkillID sets the "skill_id" field. -func (_c *TeamGroupSkillCreate) SetSkillID(v uuid.UUID) *TeamGroupSkillCreate { - _c.mutation.SetSkillID(v) +// SetGroupID sets the "group_id" field. +func (_c *AgentSkillGroupBindingCreate) SetGroupID(v uuid.UUID) *AgentSkillGroupBindingCreate { + _c.mutation.SetGroupID(v) return _c } // SetCreatedAt sets the "created_at" field. -func (_c *TeamGroupSkillCreate) SetCreatedAt(v time.Time) *TeamGroupSkillCreate { +func (_c *AgentSkillGroupBindingCreate) SetCreatedAt(v time.Time) *AgentSkillGroupBindingCreate { _c.mutation.SetCreatedAt(v) return _c } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (_c *TeamGroupSkillCreate) SetNillableCreatedAt(v *time.Time) *TeamGroupSkillCreate { +func (_c *AgentSkillGroupBindingCreate) SetNillableCreatedAt(v *time.Time) *AgentSkillGroupBindingCreate { if v != nil { _c.SetCreatedAt(*v) } @@ -53,34 +53,42 @@ func (_c *TeamGroupSkillCreate) SetNillableCreatedAt(v *time.Time) *TeamGroupSki } // SetID sets the "id" field. -func (_c *TeamGroupSkillCreate) SetID(v uuid.UUID) *TeamGroupSkillCreate { +func (_c *AgentSkillGroupBindingCreate) SetID(v uuid.UUID) *AgentSkillGroupBindingCreate { _c.mutation.SetID(v) return _c } -// SetGroup sets the "group" edge to the TeamGroup entity. -func (_c *TeamGroupSkillCreate) SetGroup(v *TeamGroup) *TeamGroupSkillCreate { - return _c.SetGroupID(v.ID) +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AgentSkillGroupBindingCreate) SetNillableID(v *uuid.UUID) *AgentSkillGroupBindingCreate { + if v != nil { + _c.SetID(*v) + } + return _c } -// SetSkill sets the "skill" edge to the Skill entity. -func (_c *TeamGroupSkillCreate) SetSkill(v *Skill) *TeamGroupSkillCreate { +// SetSkill sets the "skill" edge to the AgentSkill entity. +func (_c *AgentSkillGroupBindingCreate) SetSkill(v *AgentSkill) *AgentSkillGroupBindingCreate { return _c.SetSkillID(v.ID) } -// Mutation returns the TeamGroupSkillMutation object of the builder. -func (_c *TeamGroupSkillCreate) Mutation() *TeamGroupSkillMutation { +// SetGroup sets the "group" edge to the TeamGroup entity. +func (_c *AgentSkillGroupBindingCreate) SetGroup(v *TeamGroup) *AgentSkillGroupBindingCreate { + return _c.SetGroupID(v.ID) +} + +// Mutation returns the AgentSkillGroupBindingMutation object of the builder. +func (_c *AgentSkillGroupBindingCreate) Mutation() *AgentSkillGroupBindingMutation { return _c.mutation } -// Save creates the TeamGroupSkill in the database. -func (_c *TeamGroupSkillCreate) Save(ctx context.Context) (*TeamGroupSkill, error) { +// Save creates the AgentSkillGroupBinding in the database. +func (_c *AgentSkillGroupBindingCreate) Save(ctx context.Context) (*AgentSkillGroupBinding, error) { _c.defaults() return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (_c *TeamGroupSkillCreate) SaveX(ctx context.Context) *TeamGroupSkill { +func (_c *AgentSkillGroupBindingCreate) SaveX(ctx context.Context) *AgentSkillGroupBinding { v, err := _c.Save(ctx) if err != nil { panic(err) @@ -89,47 +97,51 @@ func (_c *TeamGroupSkillCreate) SaveX(ctx context.Context) *TeamGroupSkill { } // Exec executes the query. -func (_c *TeamGroupSkillCreate) Exec(ctx context.Context) error { +func (_c *AgentSkillGroupBindingCreate) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (_c *TeamGroupSkillCreate) ExecX(ctx context.Context) { +func (_c *AgentSkillGroupBindingCreate) ExecX(ctx context.Context) { if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (_c *TeamGroupSkillCreate) defaults() { +func (_c *AgentSkillGroupBindingCreate) defaults() { if _, ok := _c.mutation.CreatedAt(); !ok { - v := teamgroupskill.DefaultCreatedAt() + v := agentskillgroupbinding.DefaultCreatedAt() _c.mutation.SetCreatedAt(v) } + if _, ok := _c.mutation.ID(); !ok { + v := agentskillgroupbinding.DefaultID() + _c.mutation.SetID(v) + } } // check runs all checks and user-defined validators on the builder. -func (_c *TeamGroupSkillCreate) check() error { - if _, ok := _c.mutation.GroupID(); !ok { - return &ValidationError{Name: "group_id", err: errors.New(`db: missing required field "TeamGroupSkill.group_id"`)} - } +func (_c *AgentSkillGroupBindingCreate) check() error { if _, ok := _c.mutation.SkillID(); !ok { - return &ValidationError{Name: "skill_id", err: errors.New(`db: missing required field "TeamGroupSkill.skill_id"`)} + return &ValidationError{Name: "skill_id", err: errors.New(`db: missing required field "AgentSkillGroupBinding.skill_id"`)} } - if _, ok := _c.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "TeamGroupSkill.created_at"`)} + if _, ok := _c.mutation.GroupID(); !ok { + return &ValidationError{Name: "group_id", err: errors.New(`db: missing required field "AgentSkillGroupBinding.group_id"`)} } - if len(_c.mutation.GroupIDs()) == 0 { - return &ValidationError{Name: "group", err: errors.New(`db: missing required edge "TeamGroupSkill.group"`)} + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentSkillGroupBinding.created_at"`)} } if len(_c.mutation.SkillIDs()) == 0 { - return &ValidationError{Name: "skill", err: errors.New(`db: missing required edge "TeamGroupSkill.skill"`)} + return &ValidationError{Name: "skill", err: errors.New(`db: missing required edge "AgentSkillGroupBinding.skill"`)} + } + if len(_c.mutation.GroupIDs()) == 0 { + return &ValidationError{Name: "group", err: errors.New(`db: missing required edge "AgentSkillGroupBinding.group"`)} } return nil } -func (_c *TeamGroupSkillCreate) sqlSave(ctx context.Context) (*TeamGroupSkill, error) { +func (_c *AgentSkillGroupBindingCreate) sqlSave(ctx context.Context) (*AgentSkillGroupBinding, error) { if err := _c.check(); err != nil { return nil, err } @@ -152,10 +164,10 @@ func (_c *TeamGroupSkillCreate) sqlSave(ctx context.Context) (*TeamGroupSkill, e return _node, nil } -func (_c *TeamGroupSkillCreate) createSpec() (*TeamGroupSkill, *sqlgraph.CreateSpec) { +func (_c *AgentSkillGroupBindingCreate) createSpec() (*AgentSkillGroupBinding, *sqlgraph.CreateSpec) { var ( - _node = &TeamGroupSkill{config: _c.config} - _spec = sqlgraph.NewCreateSpec(teamgroupskill.Table, sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID)) + _node = &AgentSkillGroupBinding{config: _c.config} + _spec = sqlgraph.NewCreateSpec(agentskillgroupbinding.Table, sqlgraph.NewFieldSpec(agentskillgroupbinding.FieldID, field.TypeUUID)) ) _spec.OnConflict = _c.conflict if id, ok := _c.mutation.ID(); ok { @@ -163,41 +175,41 @@ func (_c *TeamGroupSkillCreate) createSpec() (*TeamGroupSkill, *sqlgraph.CreateS _spec.ID.Value = &id } if value, ok := _c.mutation.CreatedAt(); ok { - _spec.SetField(teamgroupskill.FieldCreatedAt, field.TypeTime, value) + _spec.SetField(agentskillgroupbinding.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } - if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 { + if nodes := _c.mutation.SkillIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: teamgroupskill.GroupTable, - Columns: []string{teamgroupskill.GroupColumn}, + Table: agentskillgroupbinding.SkillTable, + Columns: []string{agentskillgroupbinding.SkillColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.GroupID = nodes[0] + _node.SkillID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.SkillIDs(); len(nodes) > 0 { + if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: teamgroupskill.SkillTable, - Columns: []string{teamgroupskill.SkillColumn}, + Table: agentskillgroupbinding.GroupTable, + Columns: []string{agentskillgroupbinding.GroupColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.SkillID = nodes[0] + _node.GroupID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } return _node, _spec @@ -206,8 +218,8 @@ func (_c *TeamGroupSkillCreate) createSpec() (*TeamGroupSkill, *sqlgraph.CreateS // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // -// client.TeamGroupSkill.Create(). -// SetGroupID(v). +// client.AgentSkillGroupBinding.Create(). +// SetSkillID(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -215,13 +227,13 @@ func (_c *TeamGroupSkillCreate) createSpec() (*TeamGroupSkill, *sqlgraph.CreateS // ). // // Override some of the fields with custom // // update values. -// Update(func(u *ent.TeamGroupSkillUpsert) { -// SetGroupID(v+v). +// Update(func(u *ent.AgentSkillGroupBindingUpsert) { +// SetSkillID(v+v). // }). // Exec(ctx) -func (_c *TeamGroupSkillCreate) OnConflict(opts ...sql.ConflictOption) *TeamGroupSkillUpsertOne { +func (_c *AgentSkillGroupBindingCreate) OnConflict(opts ...sql.ConflictOption) *AgentSkillGroupBindingUpsertOne { _c.conflict = opts - return &TeamGroupSkillUpsertOne{ + return &AgentSkillGroupBindingUpsertOne{ create: _c, } } @@ -229,81 +241,81 @@ func (_c *TeamGroupSkillCreate) OnConflict(opts ...sql.ConflictOption) *TeamGrou // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // -// client.TeamGroupSkill.Create(). +// client.AgentSkillGroupBinding.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) -func (_c *TeamGroupSkillCreate) OnConflictColumns(columns ...string) *TeamGroupSkillUpsertOne { +func (_c *AgentSkillGroupBindingCreate) OnConflictColumns(columns ...string) *AgentSkillGroupBindingUpsertOne { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) - return &TeamGroupSkillUpsertOne{ + return &AgentSkillGroupBindingUpsertOne{ create: _c, } } type ( - // TeamGroupSkillUpsertOne is the builder for "upsert"-ing - // one TeamGroupSkill node. - TeamGroupSkillUpsertOne struct { - create *TeamGroupSkillCreate + // AgentSkillGroupBindingUpsertOne is the builder for "upsert"-ing + // one AgentSkillGroupBinding node. + AgentSkillGroupBindingUpsertOne struct { + create *AgentSkillGroupBindingCreate } - // TeamGroupSkillUpsert is the "OnConflict" setter. - TeamGroupSkillUpsert struct { + // AgentSkillGroupBindingUpsert is the "OnConflict" setter. + AgentSkillGroupBindingUpsert struct { *sql.UpdateSet } ) -// SetGroupID sets the "group_id" field. -func (u *TeamGroupSkillUpsert) SetGroupID(v uuid.UUID) *TeamGroupSkillUpsert { - u.Set(teamgroupskill.FieldGroupID, v) +// SetSkillID sets the "skill_id" field. +func (u *AgentSkillGroupBindingUpsert) SetSkillID(v uuid.UUID) *AgentSkillGroupBindingUpsert { + u.Set(agentskillgroupbinding.FieldSkillID, v) return u } -// UpdateGroupID sets the "group_id" field to the value that was provided on create. -func (u *TeamGroupSkillUpsert) UpdateGroupID() *TeamGroupSkillUpsert { - u.SetExcluded(teamgroupskill.FieldGroupID) +// UpdateSkillID sets the "skill_id" field to the value that was provided on create. +func (u *AgentSkillGroupBindingUpsert) UpdateSkillID() *AgentSkillGroupBindingUpsert { + u.SetExcluded(agentskillgroupbinding.FieldSkillID) return u } -// SetSkillID sets the "skill_id" field. -func (u *TeamGroupSkillUpsert) SetSkillID(v uuid.UUID) *TeamGroupSkillUpsert { - u.Set(teamgroupskill.FieldSkillID, v) +// SetGroupID sets the "group_id" field. +func (u *AgentSkillGroupBindingUpsert) SetGroupID(v uuid.UUID) *AgentSkillGroupBindingUpsert { + u.Set(agentskillgroupbinding.FieldGroupID, v) return u } -// UpdateSkillID sets the "skill_id" field to the value that was provided on create. -func (u *TeamGroupSkillUpsert) UpdateSkillID() *TeamGroupSkillUpsert { - u.SetExcluded(teamgroupskill.FieldSkillID) +// UpdateGroupID sets the "group_id" field to the value that was provided on create. +func (u *AgentSkillGroupBindingUpsert) UpdateGroupID() *AgentSkillGroupBindingUpsert { + u.SetExcluded(agentskillgroupbinding.FieldGroupID) return u } // SetCreatedAt sets the "created_at" field. -func (u *TeamGroupSkillUpsert) SetCreatedAt(v time.Time) *TeamGroupSkillUpsert { - u.Set(teamgroupskill.FieldCreatedAt, v) +func (u *AgentSkillGroupBindingUpsert) SetCreatedAt(v time.Time) *AgentSkillGroupBindingUpsert { + u.Set(agentskillgroupbinding.FieldCreatedAt, v) return u } // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. -func (u *TeamGroupSkillUpsert) UpdateCreatedAt() *TeamGroupSkillUpsert { - u.SetExcluded(teamgroupskill.FieldCreatedAt) +func (u *AgentSkillGroupBindingUpsert) UpdateCreatedAt() *AgentSkillGroupBindingUpsert { + u.SetExcluded(agentskillgroupbinding.FieldCreatedAt) return u } // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // -// client.TeamGroupSkill.Create(). +// client.AgentSkillGroupBinding.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { -// u.SetIgnore(teamgroupskill.FieldID) +// u.SetIgnore(agentskillgroupbinding.FieldID) // }), // ). // Exec(ctx) -func (u *TeamGroupSkillUpsertOne) UpdateNewValues() *TeamGroupSkillUpsertOne { +func (u *AgentSkillGroupBindingUpsertOne) UpdateNewValues() *AgentSkillGroupBindingUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { if _, exists := u.create.mutation.ID(); exists { - s.SetIgnore(teamgroupskill.FieldID) + s.SetIgnore(agentskillgroupbinding.FieldID) } })) return u @@ -312,93 +324,93 @@ func (u *TeamGroupSkillUpsertOne) UpdateNewValues() *TeamGroupSkillUpsertOne { // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // -// client.TeamGroupSkill.Create(). +// client.AgentSkillGroupBinding.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) -func (u *TeamGroupSkillUpsertOne) Ignore() *TeamGroupSkillUpsertOne { +func (u *AgentSkillGroupBindingUpsertOne) Ignore() *AgentSkillGroupBindingUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. -func (u *TeamGroupSkillUpsertOne) DoNothing() *TeamGroupSkillUpsertOne { +func (u *AgentSkillGroupBindingUpsertOne) DoNothing() *AgentSkillGroupBindingUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } -// Update allows overriding fields `UPDATE` values. See the TeamGroupSkillCreate.OnConflict +// Update allows overriding fields `UPDATE` values. See the AgentSkillGroupBindingCreate.OnConflict // documentation for more info. -func (u *TeamGroupSkillUpsertOne) Update(set func(*TeamGroupSkillUpsert)) *TeamGroupSkillUpsertOne { +func (u *AgentSkillGroupBindingUpsertOne) Update(set func(*AgentSkillGroupBindingUpsert)) *AgentSkillGroupBindingUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&TeamGroupSkillUpsert{UpdateSet: update}) + set(&AgentSkillGroupBindingUpsert{UpdateSet: update}) })) return u } -// SetGroupID sets the "group_id" field. -func (u *TeamGroupSkillUpsertOne) SetGroupID(v uuid.UUID) *TeamGroupSkillUpsertOne { - return u.Update(func(s *TeamGroupSkillUpsert) { - s.SetGroupID(v) +// SetSkillID sets the "skill_id" field. +func (u *AgentSkillGroupBindingUpsertOne) SetSkillID(v uuid.UUID) *AgentSkillGroupBindingUpsertOne { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { + s.SetSkillID(v) }) } -// UpdateGroupID sets the "group_id" field to the value that was provided on create. -func (u *TeamGroupSkillUpsertOne) UpdateGroupID() *TeamGroupSkillUpsertOne { - return u.Update(func(s *TeamGroupSkillUpsert) { - s.UpdateGroupID() +// UpdateSkillID sets the "skill_id" field to the value that was provided on create. +func (u *AgentSkillGroupBindingUpsertOne) UpdateSkillID() *AgentSkillGroupBindingUpsertOne { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { + s.UpdateSkillID() }) } -// SetSkillID sets the "skill_id" field. -func (u *TeamGroupSkillUpsertOne) SetSkillID(v uuid.UUID) *TeamGroupSkillUpsertOne { - return u.Update(func(s *TeamGroupSkillUpsert) { - s.SetSkillID(v) +// SetGroupID sets the "group_id" field. +func (u *AgentSkillGroupBindingUpsertOne) SetGroupID(v uuid.UUID) *AgentSkillGroupBindingUpsertOne { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { + s.SetGroupID(v) }) } -// UpdateSkillID sets the "skill_id" field to the value that was provided on create. -func (u *TeamGroupSkillUpsertOne) UpdateSkillID() *TeamGroupSkillUpsertOne { - return u.Update(func(s *TeamGroupSkillUpsert) { - s.UpdateSkillID() +// UpdateGroupID sets the "group_id" field to the value that was provided on create. +func (u *AgentSkillGroupBindingUpsertOne) UpdateGroupID() *AgentSkillGroupBindingUpsertOne { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { + s.UpdateGroupID() }) } // SetCreatedAt sets the "created_at" field. -func (u *TeamGroupSkillUpsertOne) SetCreatedAt(v time.Time) *TeamGroupSkillUpsertOne { - return u.Update(func(s *TeamGroupSkillUpsert) { +func (u *AgentSkillGroupBindingUpsertOne) SetCreatedAt(v time.Time) *AgentSkillGroupBindingUpsertOne { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { s.SetCreatedAt(v) }) } // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. -func (u *TeamGroupSkillUpsertOne) UpdateCreatedAt() *TeamGroupSkillUpsertOne { - return u.Update(func(s *TeamGroupSkillUpsert) { +func (u *AgentSkillGroupBindingUpsertOne) UpdateCreatedAt() *AgentSkillGroupBindingUpsertOne { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { s.UpdateCreatedAt() }) } // Exec executes the query. -func (u *TeamGroupSkillUpsertOne) Exec(ctx context.Context) error { +func (u *AgentSkillGroupBindingUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { - return errors.New("db: missing options for TeamGroupSkillCreate.OnConflict") + return errors.New("db: missing options for AgentSkillGroupBindingCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. -func (u *TeamGroupSkillUpsertOne) ExecX(ctx context.Context) { +func (u *AgentSkillGroupBindingUpsertOne) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } } // Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *TeamGroupSkillUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { +func (u *AgentSkillGroupBindingUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { if u.create.driver.Dialect() == dialect.MySQL { // In case of "ON CONFLICT", there is no way to get back non-numeric ID // fields from the database since MySQL does not support the RETURNING clause. - return id, errors.New("db: TeamGroupSkillUpsertOne.ID is not supported by MySQL driver. Use TeamGroupSkillUpsertOne.Exec instead") + return id, errors.New("db: AgentSkillGroupBindingUpsertOne.ID is not supported by MySQL driver. Use AgentSkillGroupBindingUpsertOne.Exec instead") } node, err := u.create.Save(ctx) if err != nil { @@ -408,7 +420,7 @@ func (u *TeamGroupSkillUpsertOne) ID(ctx context.Context) (id uuid.UUID, err err } // IDX is like ID, but panics if an error occurs. -func (u *TeamGroupSkillUpsertOne) IDX(ctx context.Context) uuid.UUID { +func (u *AgentSkillGroupBindingUpsertOne) IDX(ctx context.Context) uuid.UUID { id, err := u.ID(ctx) if err != nil { panic(err) @@ -416,28 +428,28 @@ func (u *TeamGroupSkillUpsertOne) IDX(ctx context.Context) uuid.UUID { return id } -// TeamGroupSkillCreateBulk is the builder for creating many TeamGroupSkill entities in bulk. -type TeamGroupSkillCreateBulk struct { +// AgentSkillGroupBindingCreateBulk is the builder for creating many AgentSkillGroupBinding entities in bulk. +type AgentSkillGroupBindingCreateBulk struct { config err error - builders []*TeamGroupSkillCreate + builders []*AgentSkillGroupBindingCreate conflict []sql.ConflictOption } -// Save creates the TeamGroupSkill entities in the database. -func (_c *TeamGroupSkillCreateBulk) Save(ctx context.Context) ([]*TeamGroupSkill, error) { +// Save creates the AgentSkillGroupBinding entities in the database. +func (_c *AgentSkillGroupBindingCreateBulk) Save(ctx context.Context) ([]*AgentSkillGroupBinding, error) { if _c.err != nil { return nil, _c.err } specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*TeamGroupSkill, len(_c.builders)) + nodes := make([]*AgentSkillGroupBinding, len(_c.builders)) mutators := make([]Mutator, len(_c.builders)) for i := range _c.builders { func(i int, root context.Context) { builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*TeamGroupSkillMutation) + mutation, ok := m.(*AgentSkillGroupBindingMutation) if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } @@ -481,7 +493,7 @@ func (_c *TeamGroupSkillCreateBulk) Save(ctx context.Context) ([]*TeamGroupSkill } // SaveX is like Save, but panics if an error occurs. -func (_c *TeamGroupSkillCreateBulk) SaveX(ctx context.Context) []*TeamGroupSkill { +func (_c *AgentSkillGroupBindingCreateBulk) SaveX(ctx context.Context) []*AgentSkillGroupBinding { v, err := _c.Save(ctx) if err != nil { panic(err) @@ -490,13 +502,13 @@ func (_c *TeamGroupSkillCreateBulk) SaveX(ctx context.Context) []*TeamGroupSkill } // Exec executes the query. -func (_c *TeamGroupSkillCreateBulk) Exec(ctx context.Context) error { +func (_c *AgentSkillGroupBindingCreateBulk) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (_c *TeamGroupSkillCreateBulk) ExecX(ctx context.Context) { +func (_c *AgentSkillGroupBindingCreateBulk) ExecX(ctx context.Context) { if err := _c.Exec(ctx); err != nil { panic(err) } @@ -505,7 +517,7 @@ func (_c *TeamGroupSkillCreateBulk) ExecX(ctx context.Context) { // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // -// client.TeamGroupSkill.CreateBulk(builders...). +// client.AgentSkillGroupBinding.CreateBulk(builders...). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -513,13 +525,13 @@ func (_c *TeamGroupSkillCreateBulk) ExecX(ctx context.Context) { // ). // // Override some of the fields with custom // // update values. -// Update(func(u *ent.TeamGroupSkillUpsert) { -// SetGroupID(v+v). +// Update(func(u *ent.AgentSkillGroupBindingUpsert) { +// SetSkillID(v+v). // }). // Exec(ctx) -func (_c *TeamGroupSkillCreateBulk) OnConflict(opts ...sql.ConflictOption) *TeamGroupSkillUpsertBulk { +func (_c *AgentSkillGroupBindingCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentSkillGroupBindingUpsertBulk { _c.conflict = opts - return &TeamGroupSkillUpsertBulk{ + return &AgentSkillGroupBindingUpsertBulk{ create: _c, } } @@ -527,39 +539,39 @@ func (_c *TeamGroupSkillCreateBulk) OnConflict(opts ...sql.ConflictOption) *Team // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // -// client.TeamGroupSkill.Create(). +// client.AgentSkillGroupBinding.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) -func (_c *TeamGroupSkillCreateBulk) OnConflictColumns(columns ...string) *TeamGroupSkillUpsertBulk { +func (_c *AgentSkillGroupBindingCreateBulk) OnConflictColumns(columns ...string) *AgentSkillGroupBindingUpsertBulk { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) - return &TeamGroupSkillUpsertBulk{ + return &AgentSkillGroupBindingUpsertBulk{ create: _c, } } -// TeamGroupSkillUpsertBulk is the builder for "upsert"-ing -// a bulk of TeamGroupSkill nodes. -type TeamGroupSkillUpsertBulk struct { - create *TeamGroupSkillCreateBulk +// AgentSkillGroupBindingUpsertBulk is the builder for "upsert"-ing +// a bulk of AgentSkillGroupBinding nodes. +type AgentSkillGroupBindingUpsertBulk struct { + create *AgentSkillGroupBindingCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // -// client.TeamGroupSkill.Create(). +// client.AgentSkillGroupBinding.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { -// u.SetIgnore(teamgroupskill.FieldID) +// u.SetIgnore(agentskillgroupbinding.FieldID) // }), // ). // Exec(ctx) -func (u *TeamGroupSkillUpsertBulk) UpdateNewValues() *TeamGroupSkillUpsertBulk { +func (u *AgentSkillGroupBindingUpsertBulk) UpdateNewValues() *AgentSkillGroupBindingUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { for _, b := range u.create.builders { if _, exists := b.mutation.ID(); exists { - s.SetIgnore(teamgroupskill.FieldID) + s.SetIgnore(agentskillgroupbinding.FieldID) } } })) @@ -569,90 +581,90 @@ func (u *TeamGroupSkillUpsertBulk) UpdateNewValues() *TeamGroupSkillUpsertBulk { // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // -// client.TeamGroupSkill.Create(). +// client.AgentSkillGroupBinding.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) -func (u *TeamGroupSkillUpsertBulk) Ignore() *TeamGroupSkillUpsertBulk { +func (u *AgentSkillGroupBindingUpsertBulk) Ignore() *AgentSkillGroupBindingUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. -func (u *TeamGroupSkillUpsertBulk) DoNothing() *TeamGroupSkillUpsertBulk { +func (u *AgentSkillGroupBindingUpsertBulk) DoNothing() *AgentSkillGroupBindingUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } -// Update allows overriding fields `UPDATE` values. See the TeamGroupSkillCreateBulk.OnConflict +// Update allows overriding fields `UPDATE` values. See the AgentSkillGroupBindingCreateBulk.OnConflict // documentation for more info. -func (u *TeamGroupSkillUpsertBulk) Update(set func(*TeamGroupSkillUpsert)) *TeamGroupSkillUpsertBulk { +func (u *AgentSkillGroupBindingUpsertBulk) Update(set func(*AgentSkillGroupBindingUpsert)) *AgentSkillGroupBindingUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&TeamGroupSkillUpsert{UpdateSet: update}) + set(&AgentSkillGroupBindingUpsert{UpdateSet: update}) })) return u } -// SetGroupID sets the "group_id" field. -func (u *TeamGroupSkillUpsertBulk) SetGroupID(v uuid.UUID) *TeamGroupSkillUpsertBulk { - return u.Update(func(s *TeamGroupSkillUpsert) { - s.SetGroupID(v) +// SetSkillID sets the "skill_id" field. +func (u *AgentSkillGroupBindingUpsertBulk) SetSkillID(v uuid.UUID) *AgentSkillGroupBindingUpsertBulk { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { + s.SetSkillID(v) }) } -// UpdateGroupID sets the "group_id" field to the value that was provided on create. -func (u *TeamGroupSkillUpsertBulk) UpdateGroupID() *TeamGroupSkillUpsertBulk { - return u.Update(func(s *TeamGroupSkillUpsert) { - s.UpdateGroupID() +// UpdateSkillID sets the "skill_id" field to the value that was provided on create. +func (u *AgentSkillGroupBindingUpsertBulk) UpdateSkillID() *AgentSkillGroupBindingUpsertBulk { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { + s.UpdateSkillID() }) } -// SetSkillID sets the "skill_id" field. -func (u *TeamGroupSkillUpsertBulk) SetSkillID(v uuid.UUID) *TeamGroupSkillUpsertBulk { - return u.Update(func(s *TeamGroupSkillUpsert) { - s.SetSkillID(v) +// SetGroupID sets the "group_id" field. +func (u *AgentSkillGroupBindingUpsertBulk) SetGroupID(v uuid.UUID) *AgentSkillGroupBindingUpsertBulk { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { + s.SetGroupID(v) }) } -// UpdateSkillID sets the "skill_id" field to the value that was provided on create. -func (u *TeamGroupSkillUpsertBulk) UpdateSkillID() *TeamGroupSkillUpsertBulk { - return u.Update(func(s *TeamGroupSkillUpsert) { - s.UpdateSkillID() +// UpdateGroupID sets the "group_id" field to the value that was provided on create. +func (u *AgentSkillGroupBindingUpsertBulk) UpdateGroupID() *AgentSkillGroupBindingUpsertBulk { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { + s.UpdateGroupID() }) } // SetCreatedAt sets the "created_at" field. -func (u *TeamGroupSkillUpsertBulk) SetCreatedAt(v time.Time) *TeamGroupSkillUpsertBulk { - return u.Update(func(s *TeamGroupSkillUpsert) { +func (u *AgentSkillGroupBindingUpsertBulk) SetCreatedAt(v time.Time) *AgentSkillGroupBindingUpsertBulk { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { s.SetCreatedAt(v) }) } // UpdateCreatedAt sets the "created_at" field to the value that was provided on create. -func (u *TeamGroupSkillUpsertBulk) UpdateCreatedAt() *TeamGroupSkillUpsertBulk { - return u.Update(func(s *TeamGroupSkillUpsert) { +func (u *AgentSkillGroupBindingUpsertBulk) UpdateCreatedAt() *AgentSkillGroupBindingUpsertBulk { + return u.Update(func(s *AgentSkillGroupBindingUpsert) { s.UpdateCreatedAt() }) } // Exec executes the query. -func (u *TeamGroupSkillUpsertBulk) Exec(ctx context.Context) error { +func (u *AgentSkillGroupBindingUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { return u.create.err } for i, b := range u.create.builders { if len(b.conflict) != 0 { - return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the TeamGroupSkillCreateBulk instead", i) + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentSkillGroupBindingCreateBulk instead", i) } } if len(u.create.conflict) == 0 { - return errors.New("db: missing options for TeamGroupSkillCreateBulk.OnConflict") + return errors.New("db: missing options for AgentSkillGroupBindingCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. -func (u *TeamGroupSkillUpsertBulk) ExecX(ctx context.Context) { +func (u *AgentSkillGroupBindingUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } diff --git a/backend/db/agentskillgroupbinding_delete.go b/backend/db/agentskillgroupbinding_delete.go new file mode 100644 index 00000000..aa0c72b3 --- /dev/null +++ b/backend/db/agentskillgroupbinding_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" + "github.com/chaitin/MonkeyCode/backend/db/predicate" +) + +// AgentSkillGroupBindingDelete is the builder for deleting a AgentSkillGroupBinding entity. +type AgentSkillGroupBindingDelete struct { + config + hooks []Hook + mutation *AgentSkillGroupBindingMutation +} + +// Where appends a list predicates to the AgentSkillGroupBindingDelete builder. +func (_d *AgentSkillGroupBindingDelete) Where(ps ...predicate.AgentSkillGroupBinding) *AgentSkillGroupBindingDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *AgentSkillGroupBindingDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentSkillGroupBindingDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *AgentSkillGroupBindingDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(agentskillgroupbinding.Table, sqlgraph.NewFieldSpec(agentskillgroupbinding.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// AgentSkillGroupBindingDeleteOne is the builder for deleting a single AgentSkillGroupBinding entity. +type AgentSkillGroupBindingDeleteOne struct { + _d *AgentSkillGroupBindingDelete +} + +// Where appends a list predicates to the AgentSkillGroupBindingDelete builder. +func (_d *AgentSkillGroupBindingDeleteOne) Where(ps ...predicate.AgentSkillGroupBinding) *AgentSkillGroupBindingDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *AgentSkillGroupBindingDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{agentskillgroupbinding.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentSkillGroupBindingDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/teamgroupskill_query.go b/backend/db/agentskillgroupbinding_query.go similarity index 58% rename from backend/db/teamgroupskill_query.go rename to backend/db/agentskillgroupbinding_query.go index 4f7b0b1a..22da23cc 100644 --- a/backend/db/teamgroupskill_query.go +++ b/backend/db/agentskillgroupbinding_query.go @@ -12,62 +12,62 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/google/uuid" ) -// TeamGroupSkillQuery is the builder for querying TeamGroupSkill entities. -type TeamGroupSkillQuery struct { +// AgentSkillGroupBindingQuery is the builder for querying AgentSkillGroupBinding entities. +type AgentSkillGroupBindingQuery struct { config ctx *QueryContext - order []teamgroupskill.OrderOption + order []agentskillgroupbinding.OrderOption inters []Interceptor - predicates []predicate.TeamGroupSkill + predicates []predicate.AgentSkillGroupBinding + withSkill *AgentSkillQuery withGroup *TeamGroupQuery - withSkill *SkillQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) } -// Where adds a new predicate for the TeamGroupSkillQuery builder. -func (_q *TeamGroupSkillQuery) Where(ps ...predicate.TeamGroupSkill) *TeamGroupSkillQuery { +// Where adds a new predicate for the AgentSkillGroupBindingQuery builder. +func (_q *AgentSkillGroupBindingQuery) Where(ps ...predicate.AgentSkillGroupBinding) *AgentSkillGroupBindingQuery { _q.predicates = append(_q.predicates, ps...) return _q } // Limit the number of records to be returned by this query. -func (_q *TeamGroupSkillQuery) Limit(limit int) *TeamGroupSkillQuery { +func (_q *AgentSkillGroupBindingQuery) Limit(limit int) *AgentSkillGroupBindingQuery { _q.ctx.Limit = &limit return _q } // Offset to start from. -func (_q *TeamGroupSkillQuery) Offset(offset int) *TeamGroupSkillQuery { +func (_q *AgentSkillGroupBindingQuery) Offset(offset int) *AgentSkillGroupBindingQuery { _q.ctx.Offset = &offset return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (_q *TeamGroupSkillQuery) Unique(unique bool) *TeamGroupSkillQuery { +func (_q *AgentSkillGroupBindingQuery) Unique(unique bool) *AgentSkillGroupBindingQuery { _q.ctx.Unique = &unique return _q } // Order specifies how the records should be ordered. -func (_q *TeamGroupSkillQuery) Order(o ...teamgroupskill.OrderOption) *TeamGroupSkillQuery { +func (_q *AgentSkillGroupBindingQuery) Order(o ...agentskillgroupbinding.OrderOption) *AgentSkillGroupBindingQuery { _q.order = append(_q.order, o...) return _q } -// QueryGroup chains the current query on the "group" edge. -func (_q *TeamGroupSkillQuery) QueryGroup() *TeamGroupQuery { - query := (&TeamGroupClient{config: _q.config}).Query() +// QuerySkill chains the current query on the "skill" edge. +func (_q *AgentSkillGroupBindingQuery) QuerySkill() *AgentSkillQuery { + query := (&AgentSkillClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err @@ -77,9 +77,9 @@ func (_q *TeamGroupSkillQuery) QueryGroup() *TeamGroupQuery { return nil, err } step := sqlgraph.NewStep( - sqlgraph.From(teamgroupskill.Table, teamgroupskill.FieldID, selector), - sqlgraph.To(teamgroup.Table, teamgroup.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, teamgroupskill.GroupTable, teamgroupskill.GroupColumn), + sqlgraph.From(agentskillgroupbinding.Table, agentskillgroupbinding.FieldID, selector), + sqlgraph.To(agentskill.Table, agentskill.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, agentskillgroupbinding.SkillTable, agentskillgroupbinding.SkillColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -87,9 +87,9 @@ func (_q *TeamGroupSkillQuery) QueryGroup() *TeamGroupQuery { return query } -// QuerySkill chains the current query on the "skill" edge. -func (_q *TeamGroupSkillQuery) QuerySkill() *SkillQuery { - query := (&SkillClient{config: _q.config}).Query() +// QueryGroup chains the current query on the "group" edge. +func (_q *AgentSkillGroupBindingQuery) QueryGroup() *TeamGroupQuery { + query := (&TeamGroupClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err @@ -99,9 +99,9 @@ func (_q *TeamGroupSkillQuery) QuerySkill() *SkillQuery { return nil, err } step := sqlgraph.NewStep( - sqlgraph.From(teamgroupskill.Table, teamgroupskill.FieldID, selector), - sqlgraph.To(skill.Table, skill.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, teamgroupskill.SkillTable, teamgroupskill.SkillColumn), + sqlgraph.From(agentskillgroupbinding.Table, agentskillgroupbinding.FieldID, selector), + sqlgraph.To(teamgroup.Table, teamgroup.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, agentskillgroupbinding.GroupTable, agentskillgroupbinding.GroupColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -109,21 +109,21 @@ func (_q *TeamGroupSkillQuery) QuerySkill() *SkillQuery { return query } -// First returns the first TeamGroupSkill entity from the query. -// Returns a *NotFoundError when no TeamGroupSkill was found. -func (_q *TeamGroupSkillQuery) First(ctx context.Context) (*TeamGroupSkill, error) { +// First returns the first AgentSkillGroupBinding entity from the query. +// Returns a *NotFoundError when no AgentSkillGroupBinding was found. +func (_q *AgentSkillGroupBindingQuery) First(ctx context.Context) (*AgentSkillGroupBinding, error) { nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } if len(nodes) == 0 { - return nil, &NotFoundError{teamgroupskill.Label} + return nil, &NotFoundError{agentskillgroupbinding.Label} } return nodes[0], nil } // FirstX is like First, but panics if an error occurs. -func (_q *TeamGroupSkillQuery) FirstX(ctx context.Context) *TeamGroupSkill { +func (_q *AgentSkillGroupBindingQuery) FirstX(ctx context.Context) *AgentSkillGroupBinding { node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -131,22 +131,22 @@ func (_q *TeamGroupSkillQuery) FirstX(ctx context.Context) *TeamGroupSkill { return node } -// FirstID returns the first TeamGroupSkill ID from the query. -// Returns a *NotFoundError when no TeamGroupSkill ID was found. -func (_q *TeamGroupSkillQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { +// FirstID returns the first AgentSkillGroupBinding ID from the query. +// Returns a *NotFoundError when no AgentSkillGroupBinding ID was found. +func (_q *AgentSkillGroupBindingQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { - err = &NotFoundError{teamgroupskill.Label} + err = &NotFoundError{agentskillgroupbinding.Label} return } return ids[0], nil } // FirstIDX is like FirstID, but panics if an error occurs. -func (_q *TeamGroupSkillQuery) FirstIDX(ctx context.Context) uuid.UUID { +func (_q *AgentSkillGroupBindingQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -154,10 +154,10 @@ func (_q *TeamGroupSkillQuery) FirstIDX(ctx context.Context) uuid.UUID { return id } -// Only returns a single TeamGroupSkill entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one TeamGroupSkill entity is found. -// Returns a *NotFoundError when no TeamGroupSkill entities are found. -func (_q *TeamGroupSkillQuery) Only(ctx context.Context) (*TeamGroupSkill, error) { +// Only returns a single AgentSkillGroupBinding entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one AgentSkillGroupBinding entity is found. +// Returns a *NotFoundError when no AgentSkillGroupBinding entities are found. +func (_q *AgentSkillGroupBindingQuery) Only(ctx context.Context) (*AgentSkillGroupBinding, error) { nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err @@ -166,14 +166,14 @@ func (_q *TeamGroupSkillQuery) Only(ctx context.Context) (*TeamGroupSkill, error case 1: return nodes[0], nil case 0: - return nil, &NotFoundError{teamgroupskill.Label} + return nil, &NotFoundError{agentskillgroupbinding.Label} default: - return nil, &NotSingularError{teamgroupskill.Label} + return nil, &NotSingularError{agentskillgroupbinding.Label} } } // OnlyX is like Only, but panics if an error occurs. -func (_q *TeamGroupSkillQuery) OnlyX(ctx context.Context) *TeamGroupSkill { +func (_q *AgentSkillGroupBindingQuery) OnlyX(ctx context.Context) *AgentSkillGroupBinding { node, err := _q.Only(ctx) if err != nil { panic(err) @@ -181,10 +181,10 @@ func (_q *TeamGroupSkillQuery) OnlyX(ctx context.Context) *TeamGroupSkill { return node } -// OnlyID is like Only, but returns the only TeamGroupSkill ID in the query. -// Returns a *NotSingularError when more than one TeamGroupSkill ID is found. +// OnlyID is like Only, but returns the only AgentSkillGroupBinding ID in the query. +// Returns a *NotSingularError when more than one AgentSkillGroupBinding ID is found. // Returns a *NotFoundError when no entities are found. -func (_q *TeamGroupSkillQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { +func (_q *AgentSkillGroupBindingQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return @@ -193,15 +193,15 @@ func (_q *TeamGroupSkillQuery) OnlyID(ctx context.Context) (id uuid.UUID, err er case 1: id = ids[0] case 0: - err = &NotFoundError{teamgroupskill.Label} + err = &NotFoundError{agentskillgroupbinding.Label} default: - err = &NotSingularError{teamgroupskill.Label} + err = &NotSingularError{agentskillgroupbinding.Label} } return } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *TeamGroupSkillQuery) OnlyIDX(ctx context.Context) uuid.UUID { +func (_q *AgentSkillGroupBindingQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := _q.OnlyID(ctx) if err != nil { panic(err) @@ -209,18 +209,18 @@ func (_q *TeamGroupSkillQuery) OnlyIDX(ctx context.Context) uuid.UUID { return id } -// All executes the query and returns a list of TeamGroupSkills. -func (_q *TeamGroupSkillQuery) All(ctx context.Context) ([]*TeamGroupSkill, error) { +// All executes the query and returns a list of AgentSkillGroupBindings. +func (_q *AgentSkillGroupBindingQuery) All(ctx context.Context) ([]*AgentSkillGroupBinding, error) { ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) if err := _q.prepareQuery(ctx); err != nil { return nil, err } - qr := querierAll[[]*TeamGroupSkill, *TeamGroupSkillQuery]() - return withInterceptors[[]*TeamGroupSkill](ctx, _q, qr, _q.inters) + qr := querierAll[[]*AgentSkillGroupBinding, *AgentSkillGroupBindingQuery]() + return withInterceptors[[]*AgentSkillGroupBinding](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (_q *TeamGroupSkillQuery) AllX(ctx context.Context) []*TeamGroupSkill { +func (_q *AgentSkillGroupBindingQuery) AllX(ctx context.Context) []*AgentSkillGroupBinding { nodes, err := _q.All(ctx) if err != nil { panic(err) @@ -228,20 +228,20 @@ func (_q *TeamGroupSkillQuery) AllX(ctx context.Context) []*TeamGroupSkill { return nodes } -// IDs executes the query and returns a list of TeamGroupSkill IDs. -func (_q *TeamGroupSkillQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { +// IDs executes the query and returns a list of AgentSkillGroupBinding IDs. +func (_q *AgentSkillGroupBindingQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if _q.ctx.Unique == nil && _q.path != nil { _q.Unique(true) } ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(teamgroupskill.FieldID).Scan(ctx, &ids); err != nil { + if err = _q.Select(agentskillgroupbinding.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (_q *TeamGroupSkillQuery) IDsX(ctx context.Context) []uuid.UUID { +func (_q *AgentSkillGroupBindingQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := _q.IDs(ctx) if err != nil { panic(err) @@ -250,16 +250,16 @@ func (_q *TeamGroupSkillQuery) IDsX(ctx context.Context) []uuid.UUID { } // Count returns the count of the given query. -func (_q *TeamGroupSkillQuery) Count(ctx context.Context) (int, error) { +func (_q *AgentSkillGroupBindingQuery) Count(ctx context.Context) (int, error) { ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, _q, querierCount[*TeamGroupSkillQuery](), _q.inters) + return withInterceptors[int](ctx, _q, querierCount[*AgentSkillGroupBindingQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (_q *TeamGroupSkillQuery) CountX(ctx context.Context) int { +func (_q *AgentSkillGroupBindingQuery) CountX(ctx context.Context) int { count, err := _q.Count(ctx) if err != nil { panic(err) @@ -268,7 +268,7 @@ func (_q *TeamGroupSkillQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (_q *TeamGroupSkillQuery) Exist(ctx context.Context) (bool, error) { +func (_q *AgentSkillGroupBindingQuery) Exist(ctx context.Context) (bool, error) { ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) switch _, err := _q.FirstID(ctx); { case IsNotFound(err): @@ -281,7 +281,7 @@ func (_q *TeamGroupSkillQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (_q *TeamGroupSkillQuery) ExistX(ctx context.Context) bool { +func (_q *AgentSkillGroupBindingQuery) ExistX(ctx context.Context) bool { exist, err := _q.Exist(ctx) if err != nil { panic(err) @@ -289,20 +289,20 @@ func (_q *TeamGroupSkillQuery) ExistX(ctx context.Context) bool { return exist } -// Clone returns a duplicate of the TeamGroupSkillQuery builder, including all associated steps. It can be +// Clone returns a duplicate of the AgentSkillGroupBindingQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (_q *TeamGroupSkillQuery) Clone() *TeamGroupSkillQuery { +func (_q *AgentSkillGroupBindingQuery) Clone() *AgentSkillGroupBindingQuery { if _q == nil { return nil } - return &TeamGroupSkillQuery{ + return &AgentSkillGroupBindingQuery{ config: _q.config, ctx: _q.ctx.Clone(), - order: append([]teamgroupskill.OrderOption{}, _q.order...), + order: append([]agentskillgroupbinding.OrderOption{}, _q.order...), inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.TeamGroupSkill{}, _q.predicates...), - withGroup: _q.withGroup.Clone(), + predicates: append([]predicate.AgentSkillGroupBinding{}, _q.predicates...), withSkill: _q.withSkill.Clone(), + withGroup: _q.withGroup.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, @@ -310,25 +310,25 @@ func (_q *TeamGroupSkillQuery) Clone() *TeamGroupSkillQuery { } } -// WithGroup tells the query-builder to eager-load the nodes that are connected to -// the "group" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *TeamGroupSkillQuery) WithGroup(opts ...func(*TeamGroupQuery)) *TeamGroupSkillQuery { - query := (&TeamGroupClient{config: _q.config}).Query() +// WithSkill tells the query-builder to eager-load the nodes that are connected to +// the "skill" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentSkillGroupBindingQuery) WithSkill(opts ...func(*AgentSkillQuery)) *AgentSkillGroupBindingQuery { + query := (&AgentSkillClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withGroup = query + _q.withSkill = query return _q } -// WithSkill tells the query-builder to eager-load the nodes that are connected to -// the "skill" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *TeamGroupSkillQuery) WithSkill(opts ...func(*SkillQuery)) *TeamGroupSkillQuery { - query := (&SkillClient{config: _q.config}).Query() +// WithGroup tells the query-builder to eager-load the nodes that are connected to +// the "group" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentSkillGroupBindingQuery) WithGroup(opts ...func(*TeamGroupQuery)) *AgentSkillGroupBindingQuery { + query := (&TeamGroupClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withSkill = query + _q.withGroup = query return _q } @@ -338,19 +338,19 @@ func (_q *TeamGroupSkillQuery) WithSkill(opts ...func(*SkillQuery)) *TeamGroupSk // Example: // // var v []struct { -// GroupID uuid.UUID `json:"group_id,omitempty"` +// SkillID uuid.UUID `json:"skill_id,omitempty"` // Count int `json:"count,omitempty"` // } // -// client.TeamGroupSkill.Query(). -// GroupBy(teamgroupskill.FieldGroupID). +// client.AgentSkillGroupBinding.Query(). +// GroupBy(agentskillgroupbinding.FieldSkillID). // Aggregate(db.Count()). // Scan(ctx, &v) -func (_q *TeamGroupSkillQuery) GroupBy(field string, fields ...string) *TeamGroupSkillGroupBy { +func (_q *AgentSkillGroupBindingQuery) GroupBy(field string, fields ...string) *AgentSkillGroupBindingGroupBy { _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &TeamGroupSkillGroupBy{build: _q} + grbuild := &AgentSkillGroupBindingGroupBy{build: _q} grbuild.flds = &_q.ctx.Fields - grbuild.label = teamgroupskill.Label + grbuild.label = agentskillgroupbinding.Label grbuild.scan = grbuild.Scan return grbuild } @@ -361,26 +361,26 @@ func (_q *TeamGroupSkillQuery) GroupBy(field string, fields ...string) *TeamGrou // Example: // // var v []struct { -// GroupID uuid.UUID `json:"group_id,omitempty"` +// SkillID uuid.UUID `json:"skill_id,omitempty"` // } // -// client.TeamGroupSkill.Query(). -// Select(teamgroupskill.FieldGroupID). +// client.AgentSkillGroupBinding.Query(). +// Select(agentskillgroupbinding.FieldSkillID). // Scan(ctx, &v) -func (_q *TeamGroupSkillQuery) Select(fields ...string) *TeamGroupSkillSelect { +func (_q *AgentSkillGroupBindingQuery) Select(fields ...string) *AgentSkillGroupBindingSelect { _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &TeamGroupSkillSelect{TeamGroupSkillQuery: _q} - sbuild.label = teamgroupskill.Label + sbuild := &AgentSkillGroupBindingSelect{AgentSkillGroupBindingQuery: _q} + sbuild.label = agentskillgroupbinding.Label sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } -// Aggregate returns a TeamGroupSkillSelect configured with the given aggregations. -func (_q *TeamGroupSkillQuery) Aggregate(fns ...AggregateFunc) *TeamGroupSkillSelect { +// Aggregate returns a AgentSkillGroupBindingSelect configured with the given aggregations. +func (_q *AgentSkillGroupBindingQuery) Aggregate(fns ...AggregateFunc) *AgentSkillGroupBindingSelect { return _q.Select().Aggregate(fns...) } -func (_q *TeamGroupSkillQuery) prepareQuery(ctx context.Context) error { +func (_q *AgentSkillGroupBindingQuery) prepareQuery(ctx context.Context) error { for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") @@ -392,7 +392,7 @@ func (_q *TeamGroupSkillQuery) prepareQuery(ctx context.Context) error { } } for _, f := range _q.ctx.Fields { - if !teamgroupskill.ValidColumn(f) { + if !agentskillgroupbinding.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} } } @@ -406,20 +406,20 @@ func (_q *TeamGroupSkillQuery) prepareQuery(ctx context.Context) error { return nil } -func (_q *TeamGroupSkillQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*TeamGroupSkill, error) { +func (_q *AgentSkillGroupBindingQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AgentSkillGroupBinding, error) { var ( - nodes = []*TeamGroupSkill{} + nodes = []*AgentSkillGroupBinding{} _spec = _q.querySpec() loadedTypes = [2]bool{ - _q.withGroup != nil, _q.withSkill != nil, + _q.withGroup != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { - return (*TeamGroupSkill).scanValues(nil, columns) + return (*AgentSkillGroupBinding).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &TeamGroupSkill{config: _q.config} + node := &AgentSkillGroupBinding{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) @@ -436,26 +436,26 @@ func (_q *TeamGroupSkillQuery) sqlAll(ctx context.Context, hooks ...queryHook) ( if len(nodes) == 0 { return nodes, nil } - if query := _q.withGroup; query != nil { - if err := _q.loadGroup(ctx, query, nodes, nil, - func(n *TeamGroupSkill, e *TeamGroup) { n.Edges.Group = e }); err != nil { + if query := _q.withSkill; query != nil { + if err := _q.loadSkill(ctx, query, nodes, nil, + func(n *AgentSkillGroupBinding, e *AgentSkill) { n.Edges.Skill = e }); err != nil { return nil, err } } - if query := _q.withSkill; query != nil { - if err := _q.loadSkill(ctx, query, nodes, nil, - func(n *TeamGroupSkill, e *Skill) { n.Edges.Skill = e }); err != nil { + if query := _q.withGroup; query != nil { + if err := _q.loadGroup(ctx, query, nodes, nil, + func(n *AgentSkillGroupBinding, e *TeamGroup) { n.Edges.Group = e }); err != nil { return nil, err } } return nodes, nil } -func (_q *TeamGroupSkillQuery) loadGroup(ctx context.Context, query *TeamGroupQuery, nodes []*TeamGroupSkill, init func(*TeamGroupSkill), assign func(*TeamGroupSkill, *TeamGroup)) error { +func (_q *AgentSkillGroupBindingQuery) loadSkill(ctx context.Context, query *AgentSkillQuery, nodes []*AgentSkillGroupBinding, init func(*AgentSkillGroupBinding), assign func(*AgentSkillGroupBinding, *AgentSkill)) error { ids := make([]uuid.UUID, 0, len(nodes)) - nodeids := make(map[uuid.UUID][]*TeamGroupSkill) + nodeids := make(map[uuid.UUID][]*AgentSkillGroupBinding) for i := range nodes { - fk := nodes[i].GroupID + fk := nodes[i].SkillID if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -464,7 +464,7 @@ func (_q *TeamGroupSkillQuery) loadGroup(ctx context.Context, query *TeamGroupQu if len(ids) == 0 { return nil } - query.Where(teamgroup.IDIn(ids...)) + query.Where(agentskill.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err @@ -472,7 +472,7 @@ func (_q *TeamGroupSkillQuery) loadGroup(ctx context.Context, query *TeamGroupQu for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "group_id" returned %v`, n.ID) + return fmt.Errorf(`unexpected foreign-key "skill_id" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) @@ -480,11 +480,11 @@ func (_q *TeamGroupSkillQuery) loadGroup(ctx context.Context, query *TeamGroupQu } return nil } -func (_q *TeamGroupSkillQuery) loadSkill(ctx context.Context, query *SkillQuery, nodes []*TeamGroupSkill, init func(*TeamGroupSkill), assign func(*TeamGroupSkill, *Skill)) error { +func (_q *AgentSkillGroupBindingQuery) loadGroup(ctx context.Context, query *TeamGroupQuery, nodes []*AgentSkillGroupBinding, init func(*AgentSkillGroupBinding), assign func(*AgentSkillGroupBinding, *TeamGroup)) error { ids := make([]uuid.UUID, 0, len(nodes)) - nodeids := make(map[uuid.UUID][]*TeamGroupSkill) + nodeids := make(map[uuid.UUID][]*AgentSkillGroupBinding) for i := range nodes { - fk := nodes[i].SkillID + fk := nodes[i].GroupID if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -493,7 +493,7 @@ func (_q *TeamGroupSkillQuery) loadSkill(ctx context.Context, query *SkillQuery, if len(ids) == 0 { return nil } - query.Where(skill.IDIn(ids...)) + query.Where(teamgroup.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err @@ -501,7 +501,7 @@ func (_q *TeamGroupSkillQuery) loadSkill(ctx context.Context, query *SkillQuery, for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "skill_id" returned %v`, n.ID) + return fmt.Errorf(`unexpected foreign-key "group_id" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) @@ -510,7 +510,7 @@ func (_q *TeamGroupSkillQuery) loadSkill(ctx context.Context, query *SkillQuery, return nil } -func (_q *TeamGroupSkillQuery) sqlCount(ctx context.Context) (int, error) { +func (_q *AgentSkillGroupBindingQuery) sqlCount(ctx context.Context) (int, error) { _spec := _q.querySpec() if len(_q.modifiers) > 0 { _spec.Modifiers = _q.modifiers @@ -522,8 +522,8 @@ func (_q *TeamGroupSkillQuery) sqlCount(ctx context.Context) (int, error) { return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (_q *TeamGroupSkillQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(teamgroupskill.Table, teamgroupskill.Columns, sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID)) +func (_q *AgentSkillGroupBindingQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(agentskillgroupbinding.Table, agentskillgroupbinding.Columns, sqlgraph.NewFieldSpec(agentskillgroupbinding.FieldID, field.TypeUUID)) _spec.From = _q.sql if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique @@ -532,17 +532,17 @@ func (_q *TeamGroupSkillQuery) querySpec() *sqlgraph.QuerySpec { } if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, teamgroupskill.FieldID) + _spec.Node.Columns = append(_spec.Node.Columns, agentskillgroupbinding.FieldID) for i := range fields { - if fields[i] != teamgroupskill.FieldID { + if fields[i] != agentskillgroupbinding.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if _q.withGroup != nil { - _spec.Node.AddColumnOnce(teamgroupskill.FieldGroupID) - } if _q.withSkill != nil { - _spec.Node.AddColumnOnce(teamgroupskill.FieldSkillID) + _spec.Node.AddColumnOnce(agentskillgroupbinding.FieldSkillID) + } + if _q.withGroup != nil { + _spec.Node.AddColumnOnce(agentskillgroupbinding.FieldGroupID) } } if ps := _q.predicates; len(ps) > 0 { @@ -568,12 +568,12 @@ func (_q *TeamGroupSkillQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (_q *TeamGroupSkillQuery) sqlQuery(ctx context.Context) *sql.Selector { +func (_q *AgentSkillGroupBindingQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(teamgroupskill.Table) + t1 := builder.Table(agentskillgroupbinding.Table) columns := _q.ctx.Fields if len(columns) == 0 { - columns = teamgroupskill.Columns + columns = agentskillgroupbinding.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) if _q.sql != nil { @@ -606,7 +606,7 @@ func (_q *TeamGroupSkillQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (_q *TeamGroupSkillQuery) ForUpdate(opts ...sql.LockOption) *TeamGroupSkillQuery { +func (_q *AgentSkillGroupBindingQuery) ForUpdate(opts ...sql.LockOption) *AgentSkillGroupBindingQuery { if _q.driver.Dialect() == dialect.Postgres { _q.Unique(false) } @@ -619,7 +619,7 @@ func (_q *TeamGroupSkillQuery) ForUpdate(opts ...sql.LockOption) *TeamGroupSkill // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (_q *TeamGroupSkillQuery) ForShare(opts ...sql.LockOption) *TeamGroupSkillQuery { +func (_q *AgentSkillGroupBindingQuery) ForShare(opts ...sql.LockOption) *AgentSkillGroupBindingQuery { if _q.driver.Dialect() == dialect.Postgres { _q.Unique(false) } @@ -630,33 +630,33 @@ func (_q *TeamGroupSkillQuery) ForShare(opts ...sql.LockOption) *TeamGroupSkillQ } // Modify adds a query modifier for attaching custom logic to queries. -func (_q *TeamGroupSkillQuery) Modify(modifiers ...func(s *sql.Selector)) *TeamGroupSkillSelect { +func (_q *AgentSkillGroupBindingQuery) Modify(modifiers ...func(s *sql.Selector)) *AgentSkillGroupBindingSelect { _q.modifiers = append(_q.modifiers, modifiers...) return _q.Select() } -// TeamGroupSkillGroupBy is the group-by builder for TeamGroupSkill entities. -type TeamGroupSkillGroupBy struct { +// AgentSkillGroupBindingGroupBy is the group-by builder for AgentSkillGroupBinding entities. +type AgentSkillGroupBindingGroupBy struct { selector - build *TeamGroupSkillQuery + build *AgentSkillGroupBindingQuery } // Aggregate adds the given aggregation functions to the group-by query. -func (_g *TeamGroupSkillGroupBy) Aggregate(fns ...AggregateFunc) *TeamGroupSkillGroupBy { +func (_g *AgentSkillGroupBindingGroupBy) Aggregate(fns ...AggregateFunc) *AgentSkillGroupBindingGroupBy { _g.fns = append(_g.fns, fns...) return _g } // Scan applies the selector query and scans the result into the given value. -func (_g *TeamGroupSkillGroupBy) Scan(ctx context.Context, v any) error { +func (_g *AgentSkillGroupBindingGroupBy) Scan(ctx context.Context, v any) error { ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*TeamGroupSkillQuery, *TeamGroupSkillGroupBy](ctx, _g.build, _g, _g.build.inters, v) + return scanWithInterceptors[*AgentSkillGroupBindingQuery, *AgentSkillGroupBindingGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (_g *TeamGroupSkillGroupBy) sqlScan(ctx context.Context, root *TeamGroupSkillQuery, v any) error { +func (_g *AgentSkillGroupBindingGroupBy) sqlScan(ctx context.Context, root *AgentSkillGroupBindingQuery, v any) error { selector := root.sqlQuery(ctx).Select() aggregation := make([]string, 0, len(_g.fns)) for _, fn := range _g.fns { @@ -683,28 +683,28 @@ func (_g *TeamGroupSkillGroupBy) sqlScan(ctx context.Context, root *TeamGroupSki return sql.ScanSlice(rows, v) } -// TeamGroupSkillSelect is the builder for selecting fields of TeamGroupSkill entities. -type TeamGroupSkillSelect struct { - *TeamGroupSkillQuery +// AgentSkillGroupBindingSelect is the builder for selecting fields of AgentSkillGroupBinding entities. +type AgentSkillGroupBindingSelect struct { + *AgentSkillGroupBindingQuery selector } // Aggregate adds the given aggregation functions to the selector query. -func (_s *TeamGroupSkillSelect) Aggregate(fns ...AggregateFunc) *TeamGroupSkillSelect { +func (_s *AgentSkillGroupBindingSelect) Aggregate(fns ...AggregateFunc) *AgentSkillGroupBindingSelect { _s.fns = append(_s.fns, fns...) return _s } // Scan applies the selector query and scans the result into the given value. -func (_s *TeamGroupSkillSelect) Scan(ctx context.Context, v any) error { +func (_s *AgentSkillGroupBindingSelect) Scan(ctx context.Context, v any) error { ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*TeamGroupSkillQuery, *TeamGroupSkillSelect](ctx, _s.TeamGroupSkillQuery, _s, _s.inters, v) + return scanWithInterceptors[*AgentSkillGroupBindingQuery, *AgentSkillGroupBindingSelect](ctx, _s.AgentSkillGroupBindingQuery, _s, _s.inters, v) } -func (_s *TeamGroupSkillSelect) sqlScan(ctx context.Context, root *TeamGroupSkillQuery, v any) error { +func (_s *AgentSkillGroupBindingSelect) sqlScan(ctx context.Context, root *AgentSkillGroupBindingQuery, v any) error { selector := root.sqlQuery(ctx) aggregation := make([]string, 0, len(_s.fns)) for _, fn := range _s.fns { @@ -726,7 +726,7 @@ func (_s *TeamGroupSkillSelect) sqlScan(ctx context.Context, root *TeamGroupSkil } // Modify adds a query modifier for attaching custom logic to queries. -func (_s *TeamGroupSkillSelect) Modify(modifiers ...func(s *sql.Selector)) *TeamGroupSkillSelect { +func (_s *AgentSkillGroupBindingSelect) Modify(modifiers ...func(s *sql.Selector)) *AgentSkillGroupBindingSelect { _s.modifiers = append(_s.modifiers, modifiers...) return _s } diff --git a/backend/db/teamgroupskill_update.go b/backend/db/agentskillgroupbinding_update.go similarity index 53% rename from backend/db/teamgroupskill_update.go rename to backend/db/agentskillgroupbinding_update.go index 6efa4fb7..6c837525 100644 --- a/backend/db/teamgroupskill_update.go +++ b/backend/db/agentskillgroupbinding_update.go @@ -11,103 +11,103 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/google/uuid" ) -// TeamGroupSkillUpdate is the builder for updating TeamGroupSkill entities. -type TeamGroupSkillUpdate struct { +// AgentSkillGroupBindingUpdate is the builder for updating AgentSkillGroupBinding entities. +type AgentSkillGroupBindingUpdate struct { config hooks []Hook - mutation *TeamGroupSkillMutation + mutation *AgentSkillGroupBindingMutation modifiers []func(*sql.UpdateBuilder) } -// Where appends a list predicates to the TeamGroupSkillUpdate builder. -func (_u *TeamGroupSkillUpdate) Where(ps ...predicate.TeamGroupSkill) *TeamGroupSkillUpdate { +// Where appends a list predicates to the AgentSkillGroupBindingUpdate builder. +func (_u *AgentSkillGroupBindingUpdate) Where(ps ...predicate.AgentSkillGroupBinding) *AgentSkillGroupBindingUpdate { _u.mutation.Where(ps...) return _u } -// SetGroupID sets the "group_id" field. -func (_u *TeamGroupSkillUpdate) SetGroupID(v uuid.UUID) *TeamGroupSkillUpdate { - _u.mutation.SetGroupID(v) +// SetSkillID sets the "skill_id" field. +func (_u *AgentSkillGroupBindingUpdate) SetSkillID(v uuid.UUID) *AgentSkillGroupBindingUpdate { + _u.mutation.SetSkillID(v) return _u } -// SetNillableGroupID sets the "group_id" field if the given value is not nil. -func (_u *TeamGroupSkillUpdate) SetNillableGroupID(v *uuid.UUID) *TeamGroupSkillUpdate { +// SetNillableSkillID sets the "skill_id" field if the given value is not nil. +func (_u *AgentSkillGroupBindingUpdate) SetNillableSkillID(v *uuid.UUID) *AgentSkillGroupBindingUpdate { if v != nil { - _u.SetGroupID(*v) + _u.SetSkillID(*v) } return _u } -// SetSkillID sets the "skill_id" field. -func (_u *TeamGroupSkillUpdate) SetSkillID(v uuid.UUID) *TeamGroupSkillUpdate { - _u.mutation.SetSkillID(v) +// SetGroupID sets the "group_id" field. +func (_u *AgentSkillGroupBindingUpdate) SetGroupID(v uuid.UUID) *AgentSkillGroupBindingUpdate { + _u.mutation.SetGroupID(v) return _u } -// SetNillableSkillID sets the "skill_id" field if the given value is not nil. -func (_u *TeamGroupSkillUpdate) SetNillableSkillID(v *uuid.UUID) *TeamGroupSkillUpdate { +// SetNillableGroupID sets the "group_id" field if the given value is not nil. +func (_u *AgentSkillGroupBindingUpdate) SetNillableGroupID(v *uuid.UUID) *AgentSkillGroupBindingUpdate { if v != nil { - _u.SetSkillID(*v) + _u.SetGroupID(*v) } return _u } // SetCreatedAt sets the "created_at" field. -func (_u *TeamGroupSkillUpdate) SetCreatedAt(v time.Time) *TeamGroupSkillUpdate { +func (_u *AgentSkillGroupBindingUpdate) SetCreatedAt(v time.Time) *AgentSkillGroupBindingUpdate { _u.mutation.SetCreatedAt(v) return _u } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (_u *TeamGroupSkillUpdate) SetNillableCreatedAt(v *time.Time) *TeamGroupSkillUpdate { +func (_u *AgentSkillGroupBindingUpdate) SetNillableCreatedAt(v *time.Time) *AgentSkillGroupBindingUpdate { if v != nil { _u.SetCreatedAt(*v) } return _u } -// SetGroup sets the "group" edge to the TeamGroup entity. -func (_u *TeamGroupSkillUpdate) SetGroup(v *TeamGroup) *TeamGroupSkillUpdate { - return _u.SetGroupID(v.ID) +// SetSkill sets the "skill" edge to the AgentSkill entity. +func (_u *AgentSkillGroupBindingUpdate) SetSkill(v *AgentSkill) *AgentSkillGroupBindingUpdate { + return _u.SetSkillID(v.ID) } -// SetSkill sets the "skill" edge to the Skill entity. -func (_u *TeamGroupSkillUpdate) SetSkill(v *Skill) *TeamGroupSkillUpdate { - return _u.SetSkillID(v.ID) +// SetGroup sets the "group" edge to the TeamGroup entity. +func (_u *AgentSkillGroupBindingUpdate) SetGroup(v *TeamGroup) *AgentSkillGroupBindingUpdate { + return _u.SetGroupID(v.ID) } -// Mutation returns the TeamGroupSkillMutation object of the builder. -func (_u *TeamGroupSkillUpdate) Mutation() *TeamGroupSkillMutation { +// Mutation returns the AgentSkillGroupBindingMutation object of the builder. +func (_u *AgentSkillGroupBindingUpdate) Mutation() *AgentSkillGroupBindingMutation { return _u.mutation } -// ClearGroup clears the "group" edge to the TeamGroup entity. -func (_u *TeamGroupSkillUpdate) ClearGroup() *TeamGroupSkillUpdate { - _u.mutation.ClearGroup() +// ClearSkill clears the "skill" edge to the AgentSkill entity. +func (_u *AgentSkillGroupBindingUpdate) ClearSkill() *AgentSkillGroupBindingUpdate { + _u.mutation.ClearSkill() return _u } -// ClearSkill clears the "skill" edge to the Skill entity. -func (_u *TeamGroupSkillUpdate) ClearSkill() *TeamGroupSkillUpdate { - _u.mutation.ClearSkill() +// ClearGroup clears the "group" edge to the TeamGroup entity. +func (_u *AgentSkillGroupBindingUpdate) ClearGroup() *AgentSkillGroupBindingUpdate { + _u.mutation.ClearGroup() return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (_u *TeamGroupSkillUpdate) Save(ctx context.Context) (int, error) { +func (_u *AgentSkillGroupBindingUpdate) Save(ctx context.Context) (int, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (_u *TeamGroupSkillUpdate) SaveX(ctx context.Context) int { +func (_u *AgentSkillGroupBindingUpdate) SaveX(ctx context.Context) int { affected, err := _u.Save(ctx) if err != nil { panic(err) @@ -116,40 +116,40 @@ func (_u *TeamGroupSkillUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (_u *TeamGroupSkillUpdate) Exec(ctx context.Context) error { +func (_u *AgentSkillGroupBindingUpdate) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (_u *TeamGroupSkillUpdate) ExecX(ctx context.Context) { +func (_u *AgentSkillGroupBindingUpdate) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (_u *TeamGroupSkillUpdate) check() error { - if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 { - return errors.New(`db: clearing a required unique edge "TeamGroupSkill.group"`) - } +func (_u *AgentSkillGroupBindingUpdate) check() error { if _u.mutation.SkillCleared() && len(_u.mutation.SkillIDs()) > 0 { - return errors.New(`db: clearing a required unique edge "TeamGroupSkill.skill"`) + return errors.New(`db: clearing a required unique edge "AgentSkillGroupBinding.skill"`) + } + if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentSkillGroupBinding.group"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *TeamGroupSkillUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TeamGroupSkillUpdate { +func (_u *AgentSkillGroupBindingUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillGroupBindingUpdate { _u.modifiers = append(_u.modifiers, modifiers...) return _u } -func (_u *TeamGroupSkillUpdate) sqlSave(ctx context.Context) (_node int, err error) { +func (_u *AgentSkillGroupBindingUpdate) sqlSave(ctx context.Context) (_node int, err error) { if err := _u.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(teamgroupskill.Table, teamgroupskill.Columns, sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID)) + _spec := sqlgraph.NewUpdateSpec(agentskillgroupbinding.Table, agentskillgroupbinding.Columns, sqlgraph.NewFieldSpec(agentskillgroupbinding.FieldID, field.TypeUUID)) if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -158,30 +158,30 @@ func (_u *TeamGroupSkillUpdate) sqlSave(ctx context.Context) (_node int, err err } } if value, ok := _u.mutation.CreatedAt(); ok { - _spec.SetField(teamgroupskill.FieldCreatedAt, field.TypeTime, value) + _spec.SetField(agentskillgroupbinding.FieldCreatedAt, field.TypeTime, value) } - if _u.mutation.GroupCleared() { + if _u.mutation.SkillCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: teamgroupskill.GroupTable, - Columns: []string{teamgroupskill.GroupColumn}, + Table: agentskillgroupbinding.SkillTable, + Columns: []string{agentskillgroupbinding.SkillColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 { + if nodes := _u.mutation.SkillIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: teamgroupskill.GroupTable, - Columns: []string{teamgroupskill.GroupColumn}, + Table: agentskillgroupbinding.SkillTable, + Columns: []string{agentskillgroupbinding.SkillColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -189,28 +189,28 @@ func (_u *TeamGroupSkillUpdate) sqlSave(ctx context.Context) (_node int, err err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.SkillCleared() { + if _u.mutation.GroupCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: teamgroupskill.SkillTable, - Columns: []string{teamgroupskill.SkillColumn}, + Table: agentskillgroupbinding.GroupTable, + Columns: []string{agentskillgroupbinding.GroupColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.SkillIDs(); len(nodes) > 0 { + if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: teamgroupskill.SkillTable, - Columns: []string{teamgroupskill.SkillColumn}, + Table: agentskillgroupbinding.GroupTable, + Columns: []string{agentskillgroupbinding.GroupColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -221,7 +221,7 @@ func (_u *TeamGroupSkillUpdate) sqlSave(ctx context.Context) (_node int, err err _spec.AddModifiers(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{teamgroupskill.Label} + err = &NotFoundError{agentskillgroupbinding.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -231,104 +231,104 @@ func (_u *TeamGroupSkillUpdate) sqlSave(ctx context.Context) (_node int, err err return _node, nil } -// TeamGroupSkillUpdateOne is the builder for updating a single TeamGroupSkill entity. -type TeamGroupSkillUpdateOne struct { +// AgentSkillGroupBindingUpdateOne is the builder for updating a single AgentSkillGroupBinding entity. +type AgentSkillGroupBindingUpdateOne struct { config fields []string hooks []Hook - mutation *TeamGroupSkillMutation + mutation *AgentSkillGroupBindingMutation modifiers []func(*sql.UpdateBuilder) } -// SetGroupID sets the "group_id" field. -func (_u *TeamGroupSkillUpdateOne) SetGroupID(v uuid.UUID) *TeamGroupSkillUpdateOne { - _u.mutation.SetGroupID(v) +// SetSkillID sets the "skill_id" field. +func (_u *AgentSkillGroupBindingUpdateOne) SetSkillID(v uuid.UUID) *AgentSkillGroupBindingUpdateOne { + _u.mutation.SetSkillID(v) return _u } -// SetNillableGroupID sets the "group_id" field if the given value is not nil. -func (_u *TeamGroupSkillUpdateOne) SetNillableGroupID(v *uuid.UUID) *TeamGroupSkillUpdateOne { +// SetNillableSkillID sets the "skill_id" field if the given value is not nil. +func (_u *AgentSkillGroupBindingUpdateOne) SetNillableSkillID(v *uuid.UUID) *AgentSkillGroupBindingUpdateOne { if v != nil { - _u.SetGroupID(*v) + _u.SetSkillID(*v) } return _u } -// SetSkillID sets the "skill_id" field. -func (_u *TeamGroupSkillUpdateOne) SetSkillID(v uuid.UUID) *TeamGroupSkillUpdateOne { - _u.mutation.SetSkillID(v) +// SetGroupID sets the "group_id" field. +func (_u *AgentSkillGroupBindingUpdateOne) SetGroupID(v uuid.UUID) *AgentSkillGroupBindingUpdateOne { + _u.mutation.SetGroupID(v) return _u } -// SetNillableSkillID sets the "skill_id" field if the given value is not nil. -func (_u *TeamGroupSkillUpdateOne) SetNillableSkillID(v *uuid.UUID) *TeamGroupSkillUpdateOne { +// SetNillableGroupID sets the "group_id" field if the given value is not nil. +func (_u *AgentSkillGroupBindingUpdateOne) SetNillableGroupID(v *uuid.UUID) *AgentSkillGroupBindingUpdateOne { if v != nil { - _u.SetSkillID(*v) + _u.SetGroupID(*v) } return _u } // SetCreatedAt sets the "created_at" field. -func (_u *TeamGroupSkillUpdateOne) SetCreatedAt(v time.Time) *TeamGroupSkillUpdateOne { +func (_u *AgentSkillGroupBindingUpdateOne) SetCreatedAt(v time.Time) *AgentSkillGroupBindingUpdateOne { _u.mutation.SetCreatedAt(v) return _u } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (_u *TeamGroupSkillUpdateOne) SetNillableCreatedAt(v *time.Time) *TeamGroupSkillUpdateOne { +func (_u *AgentSkillGroupBindingUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentSkillGroupBindingUpdateOne { if v != nil { _u.SetCreatedAt(*v) } return _u } -// SetGroup sets the "group" edge to the TeamGroup entity. -func (_u *TeamGroupSkillUpdateOne) SetGroup(v *TeamGroup) *TeamGroupSkillUpdateOne { - return _u.SetGroupID(v.ID) +// SetSkill sets the "skill" edge to the AgentSkill entity. +func (_u *AgentSkillGroupBindingUpdateOne) SetSkill(v *AgentSkill) *AgentSkillGroupBindingUpdateOne { + return _u.SetSkillID(v.ID) } -// SetSkill sets the "skill" edge to the Skill entity. -func (_u *TeamGroupSkillUpdateOne) SetSkill(v *Skill) *TeamGroupSkillUpdateOne { - return _u.SetSkillID(v.ID) +// SetGroup sets the "group" edge to the TeamGroup entity. +func (_u *AgentSkillGroupBindingUpdateOne) SetGroup(v *TeamGroup) *AgentSkillGroupBindingUpdateOne { + return _u.SetGroupID(v.ID) } -// Mutation returns the TeamGroupSkillMutation object of the builder. -func (_u *TeamGroupSkillUpdateOne) Mutation() *TeamGroupSkillMutation { +// Mutation returns the AgentSkillGroupBindingMutation object of the builder. +func (_u *AgentSkillGroupBindingUpdateOne) Mutation() *AgentSkillGroupBindingMutation { return _u.mutation } -// ClearGroup clears the "group" edge to the TeamGroup entity. -func (_u *TeamGroupSkillUpdateOne) ClearGroup() *TeamGroupSkillUpdateOne { - _u.mutation.ClearGroup() +// ClearSkill clears the "skill" edge to the AgentSkill entity. +func (_u *AgentSkillGroupBindingUpdateOne) ClearSkill() *AgentSkillGroupBindingUpdateOne { + _u.mutation.ClearSkill() return _u } -// ClearSkill clears the "skill" edge to the Skill entity. -func (_u *TeamGroupSkillUpdateOne) ClearSkill() *TeamGroupSkillUpdateOne { - _u.mutation.ClearSkill() +// ClearGroup clears the "group" edge to the TeamGroup entity. +func (_u *AgentSkillGroupBindingUpdateOne) ClearGroup() *AgentSkillGroupBindingUpdateOne { + _u.mutation.ClearGroup() return _u } -// Where appends a list predicates to the TeamGroupSkillUpdate builder. -func (_u *TeamGroupSkillUpdateOne) Where(ps ...predicate.TeamGroupSkill) *TeamGroupSkillUpdateOne { +// Where appends a list predicates to the AgentSkillGroupBindingUpdate builder. +func (_u *AgentSkillGroupBindingUpdateOne) Where(ps ...predicate.AgentSkillGroupBinding) *AgentSkillGroupBindingUpdateOne { _u.mutation.Where(ps...) return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (_u *TeamGroupSkillUpdateOne) Select(field string, fields ...string) *TeamGroupSkillUpdateOne { +func (_u *AgentSkillGroupBindingUpdateOne) Select(field string, fields ...string) *AgentSkillGroupBindingUpdateOne { _u.fields = append([]string{field}, fields...) return _u } -// Save executes the query and returns the updated TeamGroupSkill entity. -func (_u *TeamGroupSkillUpdateOne) Save(ctx context.Context) (*TeamGroupSkill, error) { +// Save executes the query and returns the updated AgentSkillGroupBinding entity. +func (_u *AgentSkillGroupBindingUpdateOne) Save(ctx context.Context) (*AgentSkillGroupBinding, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (_u *TeamGroupSkillUpdateOne) SaveX(ctx context.Context) *TeamGroupSkill { +func (_u *AgentSkillGroupBindingUpdateOne) SaveX(ctx context.Context) *AgentSkillGroupBinding { node, err := _u.Save(ctx) if err != nil { panic(err) @@ -337,53 +337,53 @@ func (_u *TeamGroupSkillUpdateOne) SaveX(ctx context.Context) *TeamGroupSkill { } // Exec executes the query on the entity. -func (_u *TeamGroupSkillUpdateOne) Exec(ctx context.Context) error { +func (_u *AgentSkillGroupBindingUpdateOne) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (_u *TeamGroupSkillUpdateOne) ExecX(ctx context.Context) { +func (_u *AgentSkillGroupBindingUpdateOne) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (_u *TeamGroupSkillUpdateOne) check() error { - if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 { - return errors.New(`db: clearing a required unique edge "TeamGroupSkill.group"`) - } +func (_u *AgentSkillGroupBindingUpdateOne) check() error { if _u.mutation.SkillCleared() && len(_u.mutation.SkillIDs()) > 0 { - return errors.New(`db: clearing a required unique edge "TeamGroupSkill.skill"`) + return errors.New(`db: clearing a required unique edge "AgentSkillGroupBinding.skill"`) + } + if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentSkillGroupBinding.group"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *TeamGroupSkillUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TeamGroupSkillUpdateOne { +func (_u *AgentSkillGroupBindingUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillGroupBindingUpdateOne { _u.modifiers = append(_u.modifiers, modifiers...) return _u } -func (_u *TeamGroupSkillUpdateOne) sqlSave(ctx context.Context) (_node *TeamGroupSkill, err error) { +func (_u *AgentSkillGroupBindingUpdateOne) sqlSave(ctx context.Context) (_node *AgentSkillGroupBinding, err error) { if err := _u.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(teamgroupskill.Table, teamgroupskill.Columns, sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID)) + _spec := sqlgraph.NewUpdateSpec(agentskillgroupbinding.Table, agentskillgroupbinding.Columns, sqlgraph.NewFieldSpec(agentskillgroupbinding.FieldID, field.TypeUUID)) id, ok := _u.mutation.ID() if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "TeamGroupSkill.id" for update`)} + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentSkillGroupBinding.id" for update`)} } _spec.Node.ID.Value = id if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, teamgroupskill.FieldID) + _spec.Node.Columns = append(_spec.Node.Columns, agentskillgroupbinding.FieldID) for _, f := range fields { - if !teamgroupskill.ValidColumn(f) { + if !agentskillgroupbinding.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} } - if f != teamgroupskill.FieldID { + if f != agentskillgroupbinding.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } @@ -396,30 +396,30 @@ func (_u *TeamGroupSkillUpdateOne) sqlSave(ctx context.Context) (_node *TeamGrou } } if value, ok := _u.mutation.CreatedAt(); ok { - _spec.SetField(teamgroupskill.FieldCreatedAt, field.TypeTime, value) + _spec.SetField(agentskillgroupbinding.FieldCreatedAt, field.TypeTime, value) } - if _u.mutation.GroupCleared() { + if _u.mutation.SkillCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: teamgroupskill.GroupTable, - Columns: []string{teamgroupskill.GroupColumn}, + Table: agentskillgroupbinding.SkillTable, + Columns: []string{agentskillgroupbinding.SkillColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 { + if nodes := _u.mutation.SkillIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: teamgroupskill.GroupTable, - Columns: []string{teamgroupskill.GroupColumn}, + Table: agentskillgroupbinding.SkillTable, + Columns: []string{agentskillgroupbinding.SkillColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -427,28 +427,28 @@ func (_u *TeamGroupSkillUpdateOne) sqlSave(ctx context.Context) (_node *TeamGrou } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.SkillCleared() { + if _u.mutation.GroupCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: teamgroupskill.SkillTable, - Columns: []string{teamgroupskill.SkillColumn}, + Table: agentskillgroupbinding.GroupTable, + Columns: []string{agentskillgroupbinding.GroupColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.SkillIDs(); len(nodes) > 0 { + if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, - Table: teamgroupskill.SkillTable, - Columns: []string{teamgroupskill.SkillColumn}, + Table: agentskillgroupbinding.GroupTable, + Columns: []string{agentskillgroupbinding.GroupColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), + IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), }, } for _, k := range nodes { @@ -457,12 +457,12 @@ func (_u *TeamGroupSkillUpdateOne) sqlSave(ctx context.Context) (_node *TeamGrou _spec.Edges.Add = append(_spec.Edges.Add, edge) } _spec.AddModifiers(_u.modifiers...) - _node = &TeamGroupSkill{config: _u.config} + _node = &AgentSkillGroupBinding{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{teamgroupskill.Label} + err = &NotFoundError{agentskillgroupbinding.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } diff --git a/backend/db/agentskillrepo.go b/backend/db/agentskillrepo.go new file mode 100644 index 00000000..39588330 --- /dev/null +++ b/backend/db/agentskillrepo.go @@ -0,0 +1,282 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/google/uuid" +) + +// AgentSkillRepo is the model entity for the AgentSkillRepo schema. +type AgentSkillRepo struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // ScopeType holds the value of the "scope_type" field. + ScopeType agentskillrepo.ScopeType `json:"scope_type,omitempty"` + // ScopeID holds the value of the "scope_id" field. + ScopeID string `json:"scope_id,omitempty"` + // CreatedBy holds the value of the "created_by" field. + CreatedBy uuid.UUID `json:"created_by,omitempty"` + // SourceType holds the value of the "source_type" field. + SourceType agentskillrepo.SourceType `json:"source_type,omitempty"` + // GithubURL holds the value of the "github_url" field. + GithubURL *string `json:"github_url,omitempty"` + // RefType holds the value of the "ref_type" field. + RefType *agentskillrepo.RefType `json:"ref_type,omitempty"` + // RefValue holds the value of the "ref_value" field. + RefValue *string `json:"ref_value,omitempty"` + // LastUploadFilename holds the value of the "last_upload_filename" field. + LastUploadFilename *string `json:"last_upload_filename,omitempty"` + // LastUploadAt holds the value of the "last_upload_at" field. + LastUploadAt *time.Time `json:"last_upload_at,omitempty"` + // IsDeleted holds the value of the "is_deleted" field. + IsDeleted bool `json:"is_deleted,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the AgentSkillRepoQuery when eager-loading is set. + Edges AgentSkillRepoEdges `json:"edges"` + selectValues sql.SelectValues +} + +// AgentSkillRepoEdges holds the relations/edges for other nodes in the graph. +type AgentSkillRepoEdges struct { + // Skills holds the value of the skills edge. + Skills []*AgentSkill `json:"skills,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// SkillsOrErr returns the Skills value or an error if the edge +// was not loaded in eager-loading. +func (e AgentSkillRepoEdges) SkillsOrErr() ([]*AgentSkill, error) { + if e.loadedTypes[0] { + return e.Skills, nil + } + return nil, &NotLoadedError{edge: "skills"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*AgentSkillRepo) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case agentskillrepo.FieldIsDeleted: + values[i] = new(sql.NullBool) + case agentskillrepo.FieldName, agentskillrepo.FieldScopeType, agentskillrepo.FieldScopeID, agentskillrepo.FieldSourceType, agentskillrepo.FieldGithubURL, agentskillrepo.FieldRefType, agentskillrepo.FieldRefValue, agentskillrepo.FieldLastUploadFilename: + values[i] = new(sql.NullString) + case agentskillrepo.FieldLastUploadAt, agentskillrepo.FieldCreatedAt, agentskillrepo.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case agentskillrepo.FieldID, agentskillrepo.FieldCreatedBy: + values[i] = new(uuid.UUID) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the AgentSkillRepo fields. +func (_m *AgentSkillRepo) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case agentskillrepo.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case agentskillrepo.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case agentskillrepo.FieldScopeType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope_type", values[i]) + } else if value.Valid { + _m.ScopeType = agentskillrepo.ScopeType(value.String) + } + case agentskillrepo.FieldScopeID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope_id", values[i]) + } else if value.Valid { + _m.ScopeID = value.String + } + case agentskillrepo.FieldCreatedBy: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field created_by", values[i]) + } else if value != nil { + _m.CreatedBy = *value + } + case agentskillrepo.FieldSourceType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field source_type", values[i]) + } else if value.Valid { + _m.SourceType = agentskillrepo.SourceType(value.String) + } + case agentskillrepo.FieldGithubURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field github_url", values[i]) + } else if value.Valid { + _m.GithubURL = new(string) + *_m.GithubURL = value.String + } + case agentskillrepo.FieldRefType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field ref_type", values[i]) + } else if value.Valid { + _m.RefType = new(agentskillrepo.RefType) + *_m.RefType = agentskillrepo.RefType(value.String) + } + case agentskillrepo.FieldRefValue: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field ref_value", values[i]) + } else if value.Valid { + _m.RefValue = new(string) + *_m.RefValue = value.String + } + case agentskillrepo.FieldLastUploadFilename: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field last_upload_filename", values[i]) + } else if value.Valid { + _m.LastUploadFilename = new(string) + *_m.LastUploadFilename = value.String + } + case agentskillrepo.FieldLastUploadAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_upload_at", values[i]) + } else if value.Valid { + _m.LastUploadAt = new(time.Time) + *_m.LastUploadAt = value.Time + } + case agentskillrepo.FieldIsDeleted: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_deleted", values[i]) + } else if value.Valid { + _m.IsDeleted = value.Bool + } + case agentskillrepo.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case agentskillrepo.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the AgentSkillRepo. +// This includes values selected through modifiers, order, etc. +func (_m *AgentSkillRepo) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QuerySkills queries the "skills" edge of the AgentSkillRepo entity. +func (_m *AgentSkillRepo) QuerySkills() *AgentSkillQuery { + return NewAgentSkillRepoClient(_m.config).QuerySkills(_m) +} + +// Update returns a builder for updating this AgentSkillRepo. +// Note that you need to call AgentSkillRepo.Unwrap() before calling this method if this AgentSkillRepo +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *AgentSkillRepo) Update() *AgentSkillRepoUpdateOne { + return NewAgentSkillRepoClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the AgentSkillRepo entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *AgentSkillRepo) Unwrap() *AgentSkillRepo { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("db: AgentSkillRepo is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *AgentSkillRepo) String() string { + var builder strings.Builder + builder.WriteString("AgentSkillRepo(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("scope_type=") + builder.WriteString(fmt.Sprintf("%v", _m.ScopeType)) + builder.WriteString(", ") + builder.WriteString("scope_id=") + builder.WriteString(_m.ScopeID) + builder.WriteString(", ") + builder.WriteString("created_by=") + builder.WriteString(fmt.Sprintf("%v", _m.CreatedBy)) + builder.WriteString(", ") + builder.WriteString("source_type=") + builder.WriteString(fmt.Sprintf("%v", _m.SourceType)) + builder.WriteString(", ") + if v := _m.GithubURL; v != nil { + builder.WriteString("github_url=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.RefType; v != nil { + builder.WriteString("ref_type=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + if v := _m.RefValue; v != nil { + builder.WriteString("ref_value=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.LastUploadFilename; v != nil { + builder.WriteString("last_upload_filename=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.LastUploadAt; v != nil { + builder.WriteString("last_upload_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("is_deleted=") + builder.WriteString(fmt.Sprintf("%v", _m.IsDeleted)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// AgentSkillRepos is a parsable slice of AgentSkillRepo. +type AgentSkillRepos []*AgentSkillRepo diff --git a/backend/db/agentskillrepo/agentskillrepo.go b/backend/db/agentskillrepo/agentskillrepo.go new file mode 100644 index 00000000..de2b7acd --- /dev/null +++ b/backend/db/agentskillrepo/agentskillrepo.go @@ -0,0 +1,270 @@ +// Code generated by ent, DO NOT EDIT. + +package agentskillrepo + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the agentskillrepo type in the database. + Label = "agent_skill_repo" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldScopeType holds the string denoting the scope_type field in the database. + FieldScopeType = "scope_type" + // FieldScopeID holds the string denoting the scope_id field in the database. + FieldScopeID = "scope_id" + // FieldCreatedBy holds the string denoting the created_by field in the database. + FieldCreatedBy = "created_by" + // FieldSourceType holds the string denoting the source_type field in the database. + FieldSourceType = "source_type" + // FieldGithubURL holds the string denoting the github_url field in the database. + FieldGithubURL = "github_url" + // FieldRefType holds the string denoting the ref_type field in the database. + FieldRefType = "ref_type" + // FieldRefValue holds the string denoting the ref_value field in the database. + FieldRefValue = "ref_value" + // FieldLastUploadFilename holds the string denoting the last_upload_filename field in the database. + FieldLastUploadFilename = "last_upload_filename" + // FieldLastUploadAt holds the string denoting the last_upload_at field in the database. + FieldLastUploadAt = "last_upload_at" + // FieldIsDeleted holds the string denoting the is_deleted field in the database. + FieldIsDeleted = "is_deleted" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // EdgeSkills holds the string denoting the skills edge name in mutations. + EdgeSkills = "skills" + // Table holds the table name of the agentskillrepo in the database. + Table = "agent_skill_repos" + // SkillsTable is the table that holds the skills relation/edge. + SkillsTable = "agent_skills" + // SkillsInverseTable is the table name for the AgentSkill entity. + // It exists in this package in order to avoid circular dependency with the "agentskill" package. + SkillsInverseTable = "agent_skills" + // SkillsColumn is the table column denoting the skills relation/edge. + SkillsColumn = "repo_id" +) + +// Columns holds all SQL columns for agentskillrepo fields. +var Columns = []string{ + FieldID, + FieldName, + FieldScopeType, + FieldScopeID, + FieldCreatedBy, + FieldSourceType, + FieldGithubURL, + FieldRefType, + FieldRefValue, + FieldLastUploadFilename, + FieldLastUploadAt, + FieldIsDeleted, + FieldCreatedAt, + FieldUpdatedAt, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultScopeID holds the default value on creation for the "scope_id" field. + DefaultScopeID string + // DefaultIsDeleted holds the default value on creation for the "is_deleted" field. + DefaultIsDeleted bool + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// ScopeType defines the type for the "scope_type" enum field. +type ScopeType string + +// ScopeTypeGlobal is the default value of the ScopeType enum. +const DefaultScopeType = ScopeTypeGlobal + +// ScopeType values. +const ( + ScopeTypeGlobal ScopeType = "global" + ScopeTypeTeam ScopeType = "team" + ScopeTypeUser ScopeType = "user" +) + +func (st ScopeType) String() string { + return string(st) +} + +// ScopeTypeValidator is a validator for the "scope_type" field enum values. It is called by the builders before save. +func ScopeTypeValidator(st ScopeType) error { + switch st { + case ScopeTypeGlobal, ScopeTypeTeam, ScopeTypeUser: + return nil + default: + return fmt.Errorf("agentskillrepo: invalid enum value for scope_type field: %q", st) + } +} + +// SourceType defines the type for the "source_type" enum field. +type SourceType string + +// SourceType values. +const ( + SourceTypeGithub SourceType = "github" + SourceTypeUpload SourceType = "upload" + SourceTypeBare SourceType = "bare" +) + +func (st SourceType) String() string { + return string(st) +} + +// SourceTypeValidator is a validator for the "source_type" field enum values. It is called by the builders before save. +func SourceTypeValidator(st SourceType) error { + switch st { + case SourceTypeGithub, SourceTypeUpload, SourceTypeBare: + return nil + default: + return fmt.Errorf("agentskillrepo: invalid enum value for source_type field: %q", st) + } +} + +// RefType defines the type for the "ref_type" enum field. +type RefType string + +// RefType values. +const ( + RefTypeBranch RefType = "branch" + RefTypeTag RefType = "tag" + RefTypeCommit RefType = "commit" +) + +func (rt RefType) String() string { + return string(rt) +} + +// RefTypeValidator is a validator for the "ref_type" field enum values. It is called by the builders before save. +func RefTypeValidator(rt RefType) error { + switch rt { + case RefTypeBranch, RefTypeTag, RefTypeCommit: + return nil + default: + return fmt.Errorf("agentskillrepo: invalid enum value for ref_type field: %q", rt) + } +} + +// OrderOption defines the ordering options for the AgentSkillRepo queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByScopeType orders the results by the scope_type field. +func ByScopeType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScopeType, opts...).ToFunc() +} + +// ByScopeID orders the results by the scope_id field. +func ByScopeID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScopeID, opts...).ToFunc() +} + +// ByCreatedBy orders the results by the created_by field. +func ByCreatedBy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedBy, opts...).ToFunc() +} + +// BySourceType orders the results by the source_type field. +func BySourceType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSourceType, opts...).ToFunc() +} + +// ByGithubURL orders the results by the github_url field. +func ByGithubURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGithubURL, opts...).ToFunc() +} + +// ByRefType orders the results by the ref_type field. +func ByRefType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefType, opts...).ToFunc() +} + +// ByRefValue orders the results by the ref_value field. +func ByRefValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefValue, opts...).ToFunc() +} + +// ByLastUploadFilename orders the results by the last_upload_filename field. +func ByLastUploadFilename(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastUploadFilename, opts...).ToFunc() +} + +// ByLastUploadAt orders the results by the last_upload_at field. +func ByLastUploadAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastUploadAt, opts...).ToFunc() +} + +// ByIsDeleted orders the results by the is_deleted field. +func ByIsDeleted(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsDeleted, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// BySkillsCount orders the results by skills count. +func BySkillsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newSkillsStep(), opts...) + } +} + +// BySkills orders the results by skills terms. +func BySkills(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newSkillsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newSkillsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SkillsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, SkillsTable, SkillsColumn), + ) +} diff --git a/backend/db/agentskillrepo/where.go b/backend/db/agentskillrepo/where.go new file mode 100644 index 00000000..abcf625b --- /dev/null +++ b/backend/db/agentskillrepo/where.go @@ -0,0 +1,750 @@ +// Code generated by ent, DO NOT EDIT. + +package agentskillrepo + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLTE(FieldID, id)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldName, v)) +} + +// ScopeID applies equality check predicate on the "scope_id" field. It's identical to ScopeIDEQ. +func ScopeID(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldScopeID, v)) +} + +// CreatedBy applies equality check predicate on the "created_by" field. It's identical to CreatedByEQ. +func CreatedBy(v uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldCreatedBy, v)) +} + +// GithubURL applies equality check predicate on the "github_url" field. It's identical to GithubURLEQ. +func GithubURL(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldGithubURL, v)) +} + +// RefValue applies equality check predicate on the "ref_value" field. It's identical to RefValueEQ. +func RefValue(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldRefValue, v)) +} + +// LastUploadFilename applies equality check predicate on the "last_upload_filename" field. It's identical to LastUploadFilenameEQ. +func LastUploadFilename(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldLastUploadFilename, v)) +} + +// LastUploadAt applies equality check predicate on the "last_upload_at" field. It's identical to LastUploadAtEQ. +func LastUploadAt(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldLastUploadAt, v)) +} + +// IsDeleted applies equality check predicate on the "is_deleted" field. It's identical to IsDeletedEQ. +func IsDeleted(v bool) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldIsDeleted, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldContainsFold(FieldName, v)) +} + +// ScopeTypeEQ applies the EQ predicate on the "scope_type" field. +func ScopeTypeEQ(v ScopeType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldScopeType, v)) +} + +// ScopeTypeNEQ applies the NEQ predicate on the "scope_type" field. +func ScopeTypeNEQ(v ScopeType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldScopeType, v)) +} + +// ScopeTypeIn applies the In predicate on the "scope_type" field. +func ScopeTypeIn(vs ...ScopeType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldScopeType, vs...)) +} + +// ScopeTypeNotIn applies the NotIn predicate on the "scope_type" field. +func ScopeTypeNotIn(vs ...ScopeType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldScopeType, vs...)) +} + +// ScopeIDEQ applies the EQ predicate on the "scope_id" field. +func ScopeIDEQ(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldScopeID, v)) +} + +// ScopeIDNEQ applies the NEQ predicate on the "scope_id" field. +func ScopeIDNEQ(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldScopeID, v)) +} + +// ScopeIDIn applies the In predicate on the "scope_id" field. +func ScopeIDIn(vs ...string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldScopeID, vs...)) +} + +// ScopeIDNotIn applies the NotIn predicate on the "scope_id" field. +func ScopeIDNotIn(vs ...string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldScopeID, vs...)) +} + +// ScopeIDGT applies the GT predicate on the "scope_id" field. +func ScopeIDGT(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGT(FieldScopeID, v)) +} + +// ScopeIDGTE applies the GTE predicate on the "scope_id" field. +func ScopeIDGTE(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGTE(FieldScopeID, v)) +} + +// ScopeIDLT applies the LT predicate on the "scope_id" field. +func ScopeIDLT(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLT(FieldScopeID, v)) +} + +// ScopeIDLTE applies the LTE predicate on the "scope_id" field. +func ScopeIDLTE(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLTE(FieldScopeID, v)) +} + +// ScopeIDContains applies the Contains predicate on the "scope_id" field. +func ScopeIDContains(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldContains(FieldScopeID, v)) +} + +// ScopeIDHasPrefix applies the HasPrefix predicate on the "scope_id" field. +func ScopeIDHasPrefix(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldHasPrefix(FieldScopeID, v)) +} + +// ScopeIDHasSuffix applies the HasSuffix predicate on the "scope_id" field. +func ScopeIDHasSuffix(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldHasSuffix(FieldScopeID, v)) +} + +// ScopeIDEqualFold applies the EqualFold predicate on the "scope_id" field. +func ScopeIDEqualFold(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEqualFold(FieldScopeID, v)) +} + +// ScopeIDContainsFold applies the ContainsFold predicate on the "scope_id" field. +func ScopeIDContainsFold(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldContainsFold(FieldScopeID, v)) +} + +// CreatedByEQ applies the EQ predicate on the "created_by" field. +func CreatedByEQ(v uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldCreatedBy, v)) +} + +// CreatedByNEQ applies the NEQ predicate on the "created_by" field. +func CreatedByNEQ(v uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldCreatedBy, v)) +} + +// CreatedByIn applies the In predicate on the "created_by" field. +func CreatedByIn(vs ...uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldCreatedBy, vs...)) +} + +// CreatedByNotIn applies the NotIn predicate on the "created_by" field. +func CreatedByNotIn(vs ...uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldCreatedBy, vs...)) +} + +// CreatedByGT applies the GT predicate on the "created_by" field. +func CreatedByGT(v uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGT(FieldCreatedBy, v)) +} + +// CreatedByGTE applies the GTE predicate on the "created_by" field. +func CreatedByGTE(v uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGTE(FieldCreatedBy, v)) +} + +// CreatedByLT applies the LT predicate on the "created_by" field. +func CreatedByLT(v uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLT(FieldCreatedBy, v)) +} + +// CreatedByLTE applies the LTE predicate on the "created_by" field. +func CreatedByLTE(v uuid.UUID) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLTE(FieldCreatedBy, v)) +} + +// SourceTypeEQ applies the EQ predicate on the "source_type" field. +func SourceTypeEQ(v SourceType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldSourceType, v)) +} + +// SourceTypeNEQ applies the NEQ predicate on the "source_type" field. +func SourceTypeNEQ(v SourceType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldSourceType, v)) +} + +// SourceTypeIn applies the In predicate on the "source_type" field. +func SourceTypeIn(vs ...SourceType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldSourceType, vs...)) +} + +// SourceTypeNotIn applies the NotIn predicate on the "source_type" field. +func SourceTypeNotIn(vs ...SourceType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldSourceType, vs...)) +} + +// GithubURLEQ applies the EQ predicate on the "github_url" field. +func GithubURLEQ(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldGithubURL, v)) +} + +// GithubURLNEQ applies the NEQ predicate on the "github_url" field. +func GithubURLNEQ(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldGithubURL, v)) +} + +// GithubURLIn applies the In predicate on the "github_url" field. +func GithubURLIn(vs ...string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldGithubURL, vs...)) +} + +// GithubURLNotIn applies the NotIn predicate on the "github_url" field. +func GithubURLNotIn(vs ...string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldGithubURL, vs...)) +} + +// GithubURLGT applies the GT predicate on the "github_url" field. +func GithubURLGT(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGT(FieldGithubURL, v)) +} + +// GithubURLGTE applies the GTE predicate on the "github_url" field. +func GithubURLGTE(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGTE(FieldGithubURL, v)) +} + +// GithubURLLT applies the LT predicate on the "github_url" field. +func GithubURLLT(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLT(FieldGithubURL, v)) +} + +// GithubURLLTE applies the LTE predicate on the "github_url" field. +func GithubURLLTE(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLTE(FieldGithubURL, v)) +} + +// GithubURLContains applies the Contains predicate on the "github_url" field. +func GithubURLContains(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldContains(FieldGithubURL, v)) +} + +// GithubURLHasPrefix applies the HasPrefix predicate on the "github_url" field. +func GithubURLHasPrefix(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldHasPrefix(FieldGithubURL, v)) +} + +// GithubURLHasSuffix applies the HasSuffix predicate on the "github_url" field. +func GithubURLHasSuffix(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldHasSuffix(FieldGithubURL, v)) +} + +// GithubURLIsNil applies the IsNil predicate on the "github_url" field. +func GithubURLIsNil() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIsNull(FieldGithubURL)) +} + +// GithubURLNotNil applies the NotNil predicate on the "github_url" field. +func GithubURLNotNil() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotNull(FieldGithubURL)) +} + +// GithubURLEqualFold applies the EqualFold predicate on the "github_url" field. +func GithubURLEqualFold(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEqualFold(FieldGithubURL, v)) +} + +// GithubURLContainsFold applies the ContainsFold predicate on the "github_url" field. +func GithubURLContainsFold(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldContainsFold(FieldGithubURL, v)) +} + +// RefTypeEQ applies the EQ predicate on the "ref_type" field. +func RefTypeEQ(v RefType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldRefType, v)) +} + +// RefTypeNEQ applies the NEQ predicate on the "ref_type" field. +func RefTypeNEQ(v RefType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldRefType, v)) +} + +// RefTypeIn applies the In predicate on the "ref_type" field. +func RefTypeIn(vs ...RefType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldRefType, vs...)) +} + +// RefTypeNotIn applies the NotIn predicate on the "ref_type" field. +func RefTypeNotIn(vs ...RefType) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldRefType, vs...)) +} + +// RefTypeIsNil applies the IsNil predicate on the "ref_type" field. +func RefTypeIsNil() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIsNull(FieldRefType)) +} + +// RefTypeNotNil applies the NotNil predicate on the "ref_type" field. +func RefTypeNotNil() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotNull(FieldRefType)) +} + +// RefValueEQ applies the EQ predicate on the "ref_value" field. +func RefValueEQ(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldRefValue, v)) +} + +// RefValueNEQ applies the NEQ predicate on the "ref_value" field. +func RefValueNEQ(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldRefValue, v)) +} + +// RefValueIn applies the In predicate on the "ref_value" field. +func RefValueIn(vs ...string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldRefValue, vs...)) +} + +// RefValueNotIn applies the NotIn predicate on the "ref_value" field. +func RefValueNotIn(vs ...string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldRefValue, vs...)) +} + +// RefValueGT applies the GT predicate on the "ref_value" field. +func RefValueGT(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGT(FieldRefValue, v)) +} + +// RefValueGTE applies the GTE predicate on the "ref_value" field. +func RefValueGTE(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGTE(FieldRefValue, v)) +} + +// RefValueLT applies the LT predicate on the "ref_value" field. +func RefValueLT(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLT(FieldRefValue, v)) +} + +// RefValueLTE applies the LTE predicate on the "ref_value" field. +func RefValueLTE(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLTE(FieldRefValue, v)) +} + +// RefValueContains applies the Contains predicate on the "ref_value" field. +func RefValueContains(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldContains(FieldRefValue, v)) +} + +// RefValueHasPrefix applies the HasPrefix predicate on the "ref_value" field. +func RefValueHasPrefix(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldHasPrefix(FieldRefValue, v)) +} + +// RefValueHasSuffix applies the HasSuffix predicate on the "ref_value" field. +func RefValueHasSuffix(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldHasSuffix(FieldRefValue, v)) +} + +// RefValueIsNil applies the IsNil predicate on the "ref_value" field. +func RefValueIsNil() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIsNull(FieldRefValue)) +} + +// RefValueNotNil applies the NotNil predicate on the "ref_value" field. +func RefValueNotNil() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotNull(FieldRefValue)) +} + +// RefValueEqualFold applies the EqualFold predicate on the "ref_value" field. +func RefValueEqualFold(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEqualFold(FieldRefValue, v)) +} + +// RefValueContainsFold applies the ContainsFold predicate on the "ref_value" field. +func RefValueContainsFold(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldContainsFold(FieldRefValue, v)) +} + +// LastUploadFilenameEQ applies the EQ predicate on the "last_upload_filename" field. +func LastUploadFilenameEQ(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameNEQ applies the NEQ predicate on the "last_upload_filename" field. +func LastUploadFilenameNEQ(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameIn applies the In predicate on the "last_upload_filename" field. +func LastUploadFilenameIn(vs ...string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldLastUploadFilename, vs...)) +} + +// LastUploadFilenameNotIn applies the NotIn predicate on the "last_upload_filename" field. +func LastUploadFilenameNotIn(vs ...string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldLastUploadFilename, vs...)) +} + +// LastUploadFilenameGT applies the GT predicate on the "last_upload_filename" field. +func LastUploadFilenameGT(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGT(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameGTE applies the GTE predicate on the "last_upload_filename" field. +func LastUploadFilenameGTE(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGTE(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameLT applies the LT predicate on the "last_upload_filename" field. +func LastUploadFilenameLT(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLT(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameLTE applies the LTE predicate on the "last_upload_filename" field. +func LastUploadFilenameLTE(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLTE(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameContains applies the Contains predicate on the "last_upload_filename" field. +func LastUploadFilenameContains(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldContains(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameHasPrefix applies the HasPrefix predicate on the "last_upload_filename" field. +func LastUploadFilenameHasPrefix(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldHasPrefix(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameHasSuffix applies the HasSuffix predicate on the "last_upload_filename" field. +func LastUploadFilenameHasSuffix(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldHasSuffix(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameIsNil applies the IsNil predicate on the "last_upload_filename" field. +func LastUploadFilenameIsNil() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIsNull(FieldLastUploadFilename)) +} + +// LastUploadFilenameNotNil applies the NotNil predicate on the "last_upload_filename" field. +func LastUploadFilenameNotNil() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotNull(FieldLastUploadFilename)) +} + +// LastUploadFilenameEqualFold applies the EqualFold predicate on the "last_upload_filename" field. +func LastUploadFilenameEqualFold(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEqualFold(FieldLastUploadFilename, v)) +} + +// LastUploadFilenameContainsFold applies the ContainsFold predicate on the "last_upload_filename" field. +func LastUploadFilenameContainsFold(v string) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldContainsFold(FieldLastUploadFilename, v)) +} + +// LastUploadAtEQ applies the EQ predicate on the "last_upload_at" field. +func LastUploadAtEQ(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldLastUploadAt, v)) +} + +// LastUploadAtNEQ applies the NEQ predicate on the "last_upload_at" field. +func LastUploadAtNEQ(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldLastUploadAt, v)) +} + +// LastUploadAtIn applies the In predicate on the "last_upload_at" field. +func LastUploadAtIn(vs ...time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldLastUploadAt, vs...)) +} + +// LastUploadAtNotIn applies the NotIn predicate on the "last_upload_at" field. +func LastUploadAtNotIn(vs ...time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldLastUploadAt, vs...)) +} + +// LastUploadAtGT applies the GT predicate on the "last_upload_at" field. +func LastUploadAtGT(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGT(FieldLastUploadAt, v)) +} + +// LastUploadAtGTE applies the GTE predicate on the "last_upload_at" field. +func LastUploadAtGTE(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGTE(FieldLastUploadAt, v)) +} + +// LastUploadAtLT applies the LT predicate on the "last_upload_at" field. +func LastUploadAtLT(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLT(FieldLastUploadAt, v)) +} + +// LastUploadAtLTE applies the LTE predicate on the "last_upload_at" field. +func LastUploadAtLTE(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLTE(FieldLastUploadAt, v)) +} + +// LastUploadAtIsNil applies the IsNil predicate on the "last_upload_at" field. +func LastUploadAtIsNil() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIsNull(FieldLastUploadAt)) +} + +// LastUploadAtNotNil applies the NotNil predicate on the "last_upload_at" field. +func LastUploadAtNotNil() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotNull(FieldLastUploadAt)) +} + +// IsDeletedEQ applies the EQ predicate on the "is_deleted" field. +func IsDeletedEQ(v bool) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldIsDeleted, v)) +} + +// IsDeletedNEQ applies the NEQ predicate on the "is_deleted" field. +func IsDeletedNEQ(v bool) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldIsDeleted, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// HasSkills applies the HasEdge predicate on the "skills" edge. +func HasSkills() predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, SkillsTable, SkillsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSkillsWith applies the HasEdge predicate on the "skills" edge with a given conditions (other predicates). +func HasSkillsWith(preds ...predicate.AgentSkill) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(func(s *sql.Selector) { + step := newSkillsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.AgentSkillRepo) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.AgentSkillRepo) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.AgentSkillRepo) predicate.AgentSkillRepo { + return predicate.AgentSkillRepo(sql.NotPredicates(p)) +} diff --git a/backend/db/agentskillrepo_create.go b/backend/db/agentskillrepo_create.go new file mode 100644 index 00000000..dbb2ae4a --- /dev/null +++ b/backend/db/agentskillrepo_create.go @@ -0,0 +1,1382 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/google/uuid" +) + +// AgentSkillRepoCreate is the builder for creating a AgentSkillRepo entity. +type AgentSkillRepoCreate struct { + config + mutation *AgentSkillRepoMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetName sets the "name" field. +func (_c *AgentSkillRepoCreate) SetName(v string) *AgentSkillRepoCreate { + _c.mutation.SetName(v) + return _c +} + +// SetScopeType sets the "scope_type" field. +func (_c *AgentSkillRepoCreate) SetScopeType(v agentskillrepo.ScopeType) *AgentSkillRepoCreate { + _c.mutation.SetScopeType(v) + return _c +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableScopeType(v *agentskillrepo.ScopeType) *AgentSkillRepoCreate { + if v != nil { + _c.SetScopeType(*v) + } + return _c +} + +// SetScopeID sets the "scope_id" field. +func (_c *AgentSkillRepoCreate) SetScopeID(v string) *AgentSkillRepoCreate { + _c.mutation.SetScopeID(v) + return _c +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableScopeID(v *string) *AgentSkillRepoCreate { + if v != nil { + _c.SetScopeID(*v) + } + return _c +} + +// SetCreatedBy sets the "created_by" field. +func (_c *AgentSkillRepoCreate) SetCreatedBy(v uuid.UUID) *AgentSkillRepoCreate { + _c.mutation.SetCreatedBy(v) + return _c +} + +// SetSourceType sets the "source_type" field. +func (_c *AgentSkillRepoCreate) SetSourceType(v agentskillrepo.SourceType) *AgentSkillRepoCreate { + _c.mutation.SetSourceType(v) + return _c +} + +// SetGithubURL sets the "github_url" field. +func (_c *AgentSkillRepoCreate) SetGithubURL(v string) *AgentSkillRepoCreate { + _c.mutation.SetGithubURL(v) + return _c +} + +// SetNillableGithubURL sets the "github_url" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableGithubURL(v *string) *AgentSkillRepoCreate { + if v != nil { + _c.SetGithubURL(*v) + } + return _c +} + +// SetRefType sets the "ref_type" field. +func (_c *AgentSkillRepoCreate) SetRefType(v agentskillrepo.RefType) *AgentSkillRepoCreate { + _c.mutation.SetRefType(v) + return _c +} + +// SetNillableRefType sets the "ref_type" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableRefType(v *agentskillrepo.RefType) *AgentSkillRepoCreate { + if v != nil { + _c.SetRefType(*v) + } + return _c +} + +// SetRefValue sets the "ref_value" field. +func (_c *AgentSkillRepoCreate) SetRefValue(v string) *AgentSkillRepoCreate { + _c.mutation.SetRefValue(v) + return _c +} + +// SetNillableRefValue sets the "ref_value" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableRefValue(v *string) *AgentSkillRepoCreate { + if v != nil { + _c.SetRefValue(*v) + } + return _c +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (_c *AgentSkillRepoCreate) SetLastUploadFilename(v string) *AgentSkillRepoCreate { + _c.mutation.SetLastUploadFilename(v) + return _c +} + +// SetNillableLastUploadFilename sets the "last_upload_filename" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableLastUploadFilename(v *string) *AgentSkillRepoCreate { + if v != nil { + _c.SetLastUploadFilename(*v) + } + return _c +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (_c *AgentSkillRepoCreate) SetLastUploadAt(v time.Time) *AgentSkillRepoCreate { + _c.mutation.SetLastUploadAt(v) + return _c +} + +// SetNillableLastUploadAt sets the "last_upload_at" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableLastUploadAt(v *time.Time) *AgentSkillRepoCreate { + if v != nil { + _c.SetLastUploadAt(*v) + } + return _c +} + +// SetIsDeleted sets the "is_deleted" field. +func (_c *AgentSkillRepoCreate) SetIsDeleted(v bool) *AgentSkillRepoCreate { + _c.mutation.SetIsDeleted(v) + return _c +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableIsDeleted(v *bool) *AgentSkillRepoCreate { + if v != nil { + _c.SetIsDeleted(*v) + } + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AgentSkillRepoCreate) SetCreatedAt(v time.Time) *AgentSkillRepoCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableCreatedAt(v *time.Time) *AgentSkillRepoCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *AgentSkillRepoCreate) SetUpdatedAt(v time.Time) *AgentSkillRepoCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableUpdatedAt(v *time.Time) *AgentSkillRepoCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AgentSkillRepoCreate) SetID(v uuid.UUID) *AgentSkillRepoCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AgentSkillRepoCreate) SetNillableID(v *uuid.UUID) *AgentSkillRepoCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// AddSkillIDs adds the "skills" edge to the AgentSkill entity by IDs. +func (_c *AgentSkillRepoCreate) AddSkillIDs(ids ...uuid.UUID) *AgentSkillRepoCreate { + _c.mutation.AddSkillIDs(ids...) + return _c +} + +// AddSkills adds the "skills" edges to the AgentSkill entity. +func (_c *AgentSkillRepoCreate) AddSkills(v ...*AgentSkill) *AgentSkillRepoCreate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddSkillIDs(ids...) +} + +// Mutation returns the AgentSkillRepoMutation object of the builder. +func (_c *AgentSkillRepoCreate) Mutation() *AgentSkillRepoMutation { + return _c.mutation +} + +// Save creates the AgentSkillRepo in the database. +func (_c *AgentSkillRepoCreate) Save(ctx context.Context) (*AgentSkillRepo, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AgentSkillRepoCreate) SaveX(ctx context.Context) *AgentSkillRepo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentSkillRepoCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentSkillRepoCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AgentSkillRepoCreate) defaults() { + if _, ok := _c.mutation.ScopeType(); !ok { + v := agentskillrepo.DefaultScopeType + _c.mutation.SetScopeType(v) + } + if _, ok := _c.mutation.ScopeID(); !ok { + v := agentskillrepo.DefaultScopeID + _c.mutation.SetScopeID(v) + } + if _, ok := _c.mutation.IsDeleted(); !ok { + v := agentskillrepo.DefaultIsDeleted + _c.mutation.SetIsDeleted(v) + } + if _, ok := _c.mutation.CreatedAt(); !ok { + v := agentskillrepo.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := agentskillrepo.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := agentskillrepo.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AgentSkillRepoCreate) check() error { + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`db: missing required field "AgentSkillRepo.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := agentskillrepo.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.name": %w`, err)} + } + } + if _, ok := _c.mutation.ScopeType(); !ok { + return &ValidationError{Name: "scope_type", err: errors.New(`db: missing required field "AgentSkillRepo.scope_type"`)} + } + if v, ok := _c.mutation.ScopeType(); ok { + if err := agentskillrepo.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.scope_type": %w`, err)} + } + } + if _, ok := _c.mutation.ScopeID(); !ok { + return &ValidationError{Name: "scope_id", err: errors.New(`db: missing required field "AgentSkillRepo.scope_id"`)} + } + if _, ok := _c.mutation.CreatedBy(); !ok { + return &ValidationError{Name: "created_by", err: errors.New(`db: missing required field "AgentSkillRepo.created_by"`)} + } + if _, ok := _c.mutation.SourceType(); !ok { + return &ValidationError{Name: "source_type", err: errors.New(`db: missing required field "AgentSkillRepo.source_type"`)} + } + if v, ok := _c.mutation.SourceType(); ok { + if err := agentskillrepo.SourceTypeValidator(v); err != nil { + return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.source_type": %w`, err)} + } + } + if v, ok := _c.mutation.RefType(); ok { + if err := agentskillrepo.RefTypeValidator(v); err != nil { + return &ValidationError{Name: "ref_type", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.ref_type": %w`, err)} + } + } + if _, ok := _c.mutation.IsDeleted(); !ok { + return &ValidationError{Name: "is_deleted", err: errors.New(`db: missing required field "AgentSkillRepo.is_deleted"`)} + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentSkillRepo.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "AgentSkillRepo.updated_at"`)} + } + return nil +} + +func (_c *AgentSkillRepoCreate) sqlSave(ctx context.Context) (*AgentSkillRepo, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AgentSkillRepoCreate) createSpec() (*AgentSkillRepo, *sqlgraph.CreateSpec) { + var ( + _node = &AgentSkillRepo{config: _c.config} + _spec = sqlgraph.NewCreateSpec(agentskillrepo.Table, sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID)) + ) + _spec.OnConflict = _c.conflict + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(agentskillrepo.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.ScopeType(); ok { + _spec.SetField(agentskillrepo.FieldScopeType, field.TypeEnum, value) + _node.ScopeType = value + } + if value, ok := _c.mutation.ScopeID(); ok { + _spec.SetField(agentskillrepo.FieldScopeID, field.TypeString, value) + _node.ScopeID = value + } + if value, ok := _c.mutation.CreatedBy(); ok { + _spec.SetField(agentskillrepo.FieldCreatedBy, field.TypeUUID, value) + _node.CreatedBy = value + } + if value, ok := _c.mutation.SourceType(); ok { + _spec.SetField(agentskillrepo.FieldSourceType, field.TypeEnum, value) + _node.SourceType = value + } + if value, ok := _c.mutation.GithubURL(); ok { + _spec.SetField(agentskillrepo.FieldGithubURL, field.TypeString, value) + _node.GithubURL = &value + } + if value, ok := _c.mutation.RefType(); ok { + _spec.SetField(agentskillrepo.FieldRefType, field.TypeEnum, value) + _node.RefType = &value + } + if value, ok := _c.mutation.RefValue(); ok { + _spec.SetField(agentskillrepo.FieldRefValue, field.TypeString, value) + _node.RefValue = &value + } + if value, ok := _c.mutation.LastUploadFilename(); ok { + _spec.SetField(agentskillrepo.FieldLastUploadFilename, field.TypeString, value) + _node.LastUploadFilename = &value + } + if value, ok := _c.mutation.LastUploadAt(); ok { + _spec.SetField(agentskillrepo.FieldLastUploadAt, field.TypeTime, value) + _node.LastUploadAt = &value + } + if value, ok := _c.mutation.IsDeleted(); ok { + _spec.SetField(agentskillrepo.FieldIsDeleted, field.TypeBool, value) + _node.IsDeleted = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(agentskillrepo.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(agentskillrepo.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if nodes := _c.mutation.SkillsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskillrepo.SkillsTable, + Columns: []string{agentskillrepo.SkillsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentSkillRepo.Create(). +// SetName(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentSkillRepoUpsert) { +// SetName(v+v). +// }). +// Exec(ctx) +func (_c *AgentSkillRepoCreate) OnConflict(opts ...sql.ConflictOption) *AgentSkillRepoUpsertOne { + _c.conflict = opts + return &AgentSkillRepoUpsertOne{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentSkillRepo.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentSkillRepoCreate) OnConflictColumns(columns ...string) *AgentSkillRepoUpsertOne { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentSkillRepoUpsertOne{ + create: _c, + } +} + +type ( + // AgentSkillRepoUpsertOne is the builder for "upsert"-ing + // one AgentSkillRepo node. + AgentSkillRepoUpsertOne struct { + create *AgentSkillRepoCreate + } + + // AgentSkillRepoUpsert is the "OnConflict" setter. + AgentSkillRepoUpsert struct { + *sql.UpdateSet + } +) + +// SetName sets the "name" field. +func (u *AgentSkillRepoUpsert) SetName(v string) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateName() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldName) + return u +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentSkillRepoUpsert) SetScopeType(v agentskillrepo.ScopeType) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldScopeType, v) + return u +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateScopeType() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldScopeType) + return u +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentSkillRepoUpsert) SetScopeID(v string) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldScopeID, v) + return u +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateScopeID() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldScopeID) + return u +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentSkillRepoUpsert) SetCreatedBy(v uuid.UUID) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldCreatedBy, v) + return u +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateCreatedBy() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldCreatedBy) + return u +} + +// SetSourceType sets the "source_type" field. +func (u *AgentSkillRepoUpsert) SetSourceType(v agentskillrepo.SourceType) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldSourceType, v) + return u +} + +// UpdateSourceType sets the "source_type" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateSourceType() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldSourceType) + return u +} + +// SetGithubURL sets the "github_url" field. +func (u *AgentSkillRepoUpsert) SetGithubURL(v string) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldGithubURL, v) + return u +} + +// UpdateGithubURL sets the "github_url" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateGithubURL() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldGithubURL) + return u +} + +// ClearGithubURL clears the value of the "github_url" field. +func (u *AgentSkillRepoUpsert) ClearGithubURL() *AgentSkillRepoUpsert { + u.SetNull(agentskillrepo.FieldGithubURL) + return u +} + +// SetRefType sets the "ref_type" field. +func (u *AgentSkillRepoUpsert) SetRefType(v agentskillrepo.RefType) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldRefType, v) + return u +} + +// UpdateRefType sets the "ref_type" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateRefType() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldRefType) + return u +} + +// ClearRefType clears the value of the "ref_type" field. +func (u *AgentSkillRepoUpsert) ClearRefType() *AgentSkillRepoUpsert { + u.SetNull(agentskillrepo.FieldRefType) + return u +} + +// SetRefValue sets the "ref_value" field. +func (u *AgentSkillRepoUpsert) SetRefValue(v string) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldRefValue, v) + return u +} + +// UpdateRefValue sets the "ref_value" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateRefValue() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldRefValue) + return u +} + +// ClearRefValue clears the value of the "ref_value" field. +func (u *AgentSkillRepoUpsert) ClearRefValue() *AgentSkillRepoUpsert { + u.SetNull(agentskillrepo.FieldRefValue) + return u +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (u *AgentSkillRepoUpsert) SetLastUploadFilename(v string) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldLastUploadFilename, v) + return u +} + +// UpdateLastUploadFilename sets the "last_upload_filename" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateLastUploadFilename() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldLastUploadFilename) + return u +} + +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (u *AgentSkillRepoUpsert) ClearLastUploadFilename() *AgentSkillRepoUpsert { + u.SetNull(agentskillrepo.FieldLastUploadFilename) + return u +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (u *AgentSkillRepoUpsert) SetLastUploadAt(v time.Time) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldLastUploadAt, v) + return u +} + +// UpdateLastUploadAt sets the "last_upload_at" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateLastUploadAt() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldLastUploadAt) + return u +} + +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (u *AgentSkillRepoUpsert) ClearLastUploadAt() *AgentSkillRepoUpsert { + u.SetNull(agentskillrepo.FieldLastUploadAt) + return u +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentSkillRepoUpsert) SetIsDeleted(v bool) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldIsDeleted, v) + return u +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateIsDeleted() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldIsDeleted) + return u +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSkillRepoUpsert) SetCreatedAt(v time.Time) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldCreatedAt, v) + return u +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateCreatedAt() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldCreatedAt) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentSkillRepoUpsert) SetUpdatedAt(v time.Time) *AgentSkillRepoUpsert { + u.Set(agentskillrepo.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentSkillRepoUpsert) UpdateUpdatedAt() *AgentSkillRepoUpsert { + u.SetExcluded(agentskillrepo.FieldUpdatedAt) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.AgentSkillRepo.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentskillrepo.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentSkillRepoUpsertOne) UpdateNewValues() *AgentSkillRepoUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(agentskillrepo.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentSkillRepo.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentSkillRepoUpsertOne) Ignore() *AgentSkillRepoUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentSkillRepoUpsertOne) DoNothing() *AgentSkillRepoUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentSkillRepoCreate.OnConflict +// documentation for more info. +func (u *AgentSkillRepoUpsertOne) Update(set func(*AgentSkillRepoUpsert)) *AgentSkillRepoUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentSkillRepoUpsert{UpdateSet: update}) + })) + return u +} + +// SetName sets the "name" field. +func (u *AgentSkillRepoUpsertOne) SetName(v string) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateName() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateName() + }) +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentSkillRepoUpsertOne) SetScopeType(v agentskillrepo.ScopeType) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetScopeType(v) + }) +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateScopeType() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateScopeType() + }) +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentSkillRepoUpsertOne) SetScopeID(v string) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetScopeID(v) + }) +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateScopeID() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateScopeID() + }) +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentSkillRepoUpsertOne) SetCreatedBy(v uuid.UUID) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetCreatedBy(v) + }) +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateCreatedBy() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateCreatedBy() + }) +} + +// SetSourceType sets the "source_type" field. +func (u *AgentSkillRepoUpsertOne) SetSourceType(v agentskillrepo.SourceType) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetSourceType(v) + }) +} + +// UpdateSourceType sets the "source_type" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateSourceType() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateSourceType() + }) +} + +// SetGithubURL sets the "github_url" field. +func (u *AgentSkillRepoUpsertOne) SetGithubURL(v string) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetGithubURL(v) + }) +} + +// UpdateGithubURL sets the "github_url" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateGithubURL() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateGithubURL() + }) +} + +// ClearGithubURL clears the value of the "github_url" field. +func (u *AgentSkillRepoUpsertOne) ClearGithubURL() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.ClearGithubURL() + }) +} + +// SetRefType sets the "ref_type" field. +func (u *AgentSkillRepoUpsertOne) SetRefType(v agentskillrepo.RefType) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetRefType(v) + }) +} + +// UpdateRefType sets the "ref_type" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateRefType() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateRefType() + }) +} + +// ClearRefType clears the value of the "ref_type" field. +func (u *AgentSkillRepoUpsertOne) ClearRefType() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.ClearRefType() + }) +} + +// SetRefValue sets the "ref_value" field. +func (u *AgentSkillRepoUpsertOne) SetRefValue(v string) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetRefValue(v) + }) +} + +// UpdateRefValue sets the "ref_value" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateRefValue() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateRefValue() + }) +} + +// ClearRefValue clears the value of the "ref_value" field. +func (u *AgentSkillRepoUpsertOne) ClearRefValue() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.ClearRefValue() + }) +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (u *AgentSkillRepoUpsertOne) SetLastUploadFilename(v string) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetLastUploadFilename(v) + }) +} + +// UpdateLastUploadFilename sets the "last_upload_filename" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateLastUploadFilename() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateLastUploadFilename() + }) +} + +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (u *AgentSkillRepoUpsertOne) ClearLastUploadFilename() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.ClearLastUploadFilename() + }) +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (u *AgentSkillRepoUpsertOne) SetLastUploadAt(v time.Time) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetLastUploadAt(v) + }) +} + +// UpdateLastUploadAt sets the "last_upload_at" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateLastUploadAt() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateLastUploadAt() + }) +} + +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (u *AgentSkillRepoUpsertOne) ClearLastUploadAt() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.ClearLastUploadAt() + }) +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentSkillRepoUpsertOne) SetIsDeleted(v bool) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetIsDeleted(v) + }) +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateIsDeleted() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateIsDeleted() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSkillRepoUpsertOne) SetCreatedAt(v time.Time) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateCreatedAt() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentSkillRepoUpsertOne) SetUpdatedAt(v time.Time) *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertOne) UpdateUpdatedAt() *AgentSkillRepoUpsertOne { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentSkillRepoUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentSkillRepoCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentSkillRepoUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *AgentSkillRepoUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: AgentSkillRepoUpsertOne.ID is not supported by MySQL driver. Use AgentSkillRepoUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *AgentSkillRepoUpsertOne) IDX(ctx context.Context) uuid.UUID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// AgentSkillRepoCreateBulk is the builder for creating many AgentSkillRepo entities in bulk. +type AgentSkillRepoCreateBulk struct { + config + err error + builders []*AgentSkillRepoCreate + conflict []sql.ConflictOption +} + +// Save creates the AgentSkillRepo entities in the database. +func (_c *AgentSkillRepoCreateBulk) Save(ctx context.Context) ([]*AgentSkillRepo, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*AgentSkillRepo, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AgentSkillRepoMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = _c.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AgentSkillRepoCreateBulk) SaveX(ctx context.Context) []*AgentSkillRepo { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentSkillRepoCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentSkillRepoCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentSkillRepo.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentSkillRepoUpsert) { +// SetName(v+v). +// }). +// Exec(ctx) +func (_c *AgentSkillRepoCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentSkillRepoUpsertBulk { + _c.conflict = opts + return &AgentSkillRepoUpsertBulk{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentSkillRepo.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentSkillRepoCreateBulk) OnConflictColumns(columns ...string) *AgentSkillRepoUpsertBulk { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentSkillRepoUpsertBulk{ + create: _c, + } +} + +// AgentSkillRepoUpsertBulk is the builder for "upsert"-ing +// a bulk of AgentSkillRepo nodes. +type AgentSkillRepoUpsertBulk struct { + create *AgentSkillRepoCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.AgentSkillRepo.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentskillrepo.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentSkillRepoUpsertBulk) UpdateNewValues() *AgentSkillRepoUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(agentskillrepo.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentSkillRepo.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentSkillRepoUpsertBulk) Ignore() *AgentSkillRepoUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentSkillRepoUpsertBulk) DoNothing() *AgentSkillRepoUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentSkillRepoCreateBulk.OnConflict +// documentation for more info. +func (u *AgentSkillRepoUpsertBulk) Update(set func(*AgentSkillRepoUpsert)) *AgentSkillRepoUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentSkillRepoUpsert{UpdateSet: update}) + })) + return u +} + +// SetName sets the "name" field. +func (u *AgentSkillRepoUpsertBulk) SetName(v string) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateName() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateName() + }) +} + +// SetScopeType sets the "scope_type" field. +func (u *AgentSkillRepoUpsertBulk) SetScopeType(v agentskillrepo.ScopeType) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetScopeType(v) + }) +} + +// UpdateScopeType sets the "scope_type" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateScopeType() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateScopeType() + }) +} + +// SetScopeID sets the "scope_id" field. +func (u *AgentSkillRepoUpsertBulk) SetScopeID(v string) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetScopeID(v) + }) +} + +// UpdateScopeID sets the "scope_id" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateScopeID() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateScopeID() + }) +} + +// SetCreatedBy sets the "created_by" field. +func (u *AgentSkillRepoUpsertBulk) SetCreatedBy(v uuid.UUID) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetCreatedBy(v) + }) +} + +// UpdateCreatedBy sets the "created_by" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateCreatedBy() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateCreatedBy() + }) +} + +// SetSourceType sets the "source_type" field. +func (u *AgentSkillRepoUpsertBulk) SetSourceType(v agentskillrepo.SourceType) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetSourceType(v) + }) +} + +// UpdateSourceType sets the "source_type" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateSourceType() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateSourceType() + }) +} + +// SetGithubURL sets the "github_url" field. +func (u *AgentSkillRepoUpsertBulk) SetGithubURL(v string) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetGithubURL(v) + }) +} + +// UpdateGithubURL sets the "github_url" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateGithubURL() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateGithubURL() + }) +} + +// ClearGithubURL clears the value of the "github_url" field. +func (u *AgentSkillRepoUpsertBulk) ClearGithubURL() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.ClearGithubURL() + }) +} + +// SetRefType sets the "ref_type" field. +func (u *AgentSkillRepoUpsertBulk) SetRefType(v agentskillrepo.RefType) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetRefType(v) + }) +} + +// UpdateRefType sets the "ref_type" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateRefType() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateRefType() + }) +} + +// ClearRefType clears the value of the "ref_type" field. +func (u *AgentSkillRepoUpsertBulk) ClearRefType() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.ClearRefType() + }) +} + +// SetRefValue sets the "ref_value" field. +func (u *AgentSkillRepoUpsertBulk) SetRefValue(v string) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetRefValue(v) + }) +} + +// UpdateRefValue sets the "ref_value" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateRefValue() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateRefValue() + }) +} + +// ClearRefValue clears the value of the "ref_value" field. +func (u *AgentSkillRepoUpsertBulk) ClearRefValue() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.ClearRefValue() + }) +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (u *AgentSkillRepoUpsertBulk) SetLastUploadFilename(v string) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetLastUploadFilename(v) + }) +} + +// UpdateLastUploadFilename sets the "last_upload_filename" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateLastUploadFilename() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateLastUploadFilename() + }) +} + +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (u *AgentSkillRepoUpsertBulk) ClearLastUploadFilename() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.ClearLastUploadFilename() + }) +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (u *AgentSkillRepoUpsertBulk) SetLastUploadAt(v time.Time) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetLastUploadAt(v) + }) +} + +// UpdateLastUploadAt sets the "last_upload_at" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateLastUploadAt() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateLastUploadAt() + }) +} + +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (u *AgentSkillRepoUpsertBulk) ClearLastUploadAt() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.ClearLastUploadAt() + }) +} + +// SetIsDeleted sets the "is_deleted" field. +func (u *AgentSkillRepoUpsertBulk) SetIsDeleted(v bool) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetIsDeleted(v) + }) +} + +// UpdateIsDeleted sets the "is_deleted" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateIsDeleted() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateIsDeleted() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSkillRepoUpsertBulk) SetCreatedAt(v time.Time) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateCreatedAt() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentSkillRepoUpsertBulk) SetUpdatedAt(v time.Time) *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentSkillRepoUpsertBulk) UpdateUpdatedAt() *AgentSkillRepoUpsertBulk { + return u.Update(func(s *AgentSkillRepoUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentSkillRepoUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentSkillRepoCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentSkillRepoCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentSkillRepoUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/teamgroupskill_delete.go b/backend/db/agentskillrepo_delete.go similarity index 52% rename from backend/db/teamgroupskill_delete.go rename to backend/db/agentskillrepo_delete.go index d426033e..6e278b66 100644 --- a/backend/db/teamgroupskill_delete.go +++ b/backend/db/agentskillrepo_delete.go @@ -8,30 +8,30 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" ) -// TeamGroupSkillDelete is the builder for deleting a TeamGroupSkill entity. -type TeamGroupSkillDelete struct { +// AgentSkillRepoDelete is the builder for deleting a AgentSkillRepo entity. +type AgentSkillRepoDelete struct { config hooks []Hook - mutation *TeamGroupSkillMutation + mutation *AgentSkillRepoMutation } -// Where appends a list predicates to the TeamGroupSkillDelete builder. -func (_d *TeamGroupSkillDelete) Where(ps ...predicate.TeamGroupSkill) *TeamGroupSkillDelete { +// Where appends a list predicates to the AgentSkillRepoDelete builder. +func (_d *AgentSkillRepoDelete) Where(ps ...predicate.AgentSkillRepo) *AgentSkillRepoDelete { _d.mutation.Where(ps...) return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (_d *TeamGroupSkillDelete) Exec(ctx context.Context) (int, error) { +func (_d *AgentSkillRepoDelete) Exec(ctx context.Context) (int, error) { return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (_d *TeamGroupSkillDelete) ExecX(ctx context.Context) int { +func (_d *AgentSkillRepoDelete) ExecX(ctx context.Context) int { n, err := _d.Exec(ctx) if err != nil { panic(err) @@ -39,8 +39,8 @@ func (_d *TeamGroupSkillDelete) ExecX(ctx context.Context) int { return n } -func (_d *TeamGroupSkillDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(teamgroupskill.Table, sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID)) +func (_d *AgentSkillRepoDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(agentskillrepo.Table, sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID)) if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -56,32 +56,32 @@ func (_d *TeamGroupSkillDelete) sqlExec(ctx context.Context) (int, error) { return affected, err } -// TeamGroupSkillDeleteOne is the builder for deleting a single TeamGroupSkill entity. -type TeamGroupSkillDeleteOne struct { - _d *TeamGroupSkillDelete +// AgentSkillRepoDeleteOne is the builder for deleting a single AgentSkillRepo entity. +type AgentSkillRepoDeleteOne struct { + _d *AgentSkillRepoDelete } -// Where appends a list predicates to the TeamGroupSkillDelete builder. -func (_d *TeamGroupSkillDeleteOne) Where(ps ...predicate.TeamGroupSkill) *TeamGroupSkillDeleteOne { +// Where appends a list predicates to the AgentSkillRepoDelete builder. +func (_d *AgentSkillRepoDeleteOne) Where(ps ...predicate.AgentSkillRepo) *AgentSkillRepoDeleteOne { _d._d.mutation.Where(ps...) return _d } // Exec executes the deletion query. -func (_d *TeamGroupSkillDeleteOne) Exec(ctx context.Context) error { +func (_d *AgentSkillRepoDeleteOne) Exec(ctx context.Context) error { n, err := _d._d.Exec(ctx) switch { case err != nil: return err case n == 0: - return &NotFoundError{teamgroupskill.Label} + return &NotFoundError{agentskillrepo.Label} default: return nil } } // ExecX is like Exec, but panics if an error occurs. -func (_d *TeamGroupSkillDeleteOne) ExecX(ctx context.Context) { +func (_d *AgentSkillRepoDeleteOne) ExecX(ctx context.Context) { if err := _d.Exec(ctx); err != nil { panic(err) } diff --git a/backend/db/agentskillrepo_query.go b/backend/db/agentskillrepo_query.go new file mode 100644 index 00000000..b85fd0dd --- /dev/null +++ b/backend/db/agentskillrepo_query.go @@ -0,0 +1,657 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentSkillRepoQuery is the builder for querying AgentSkillRepo entities. +type AgentSkillRepoQuery struct { + config + ctx *QueryContext + order []agentskillrepo.OrderOption + inters []Interceptor + predicates []predicate.AgentSkillRepo + withSkills *AgentSkillQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the AgentSkillRepoQuery builder. +func (_q *AgentSkillRepoQuery) Where(ps ...predicate.AgentSkillRepo) *AgentSkillRepoQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *AgentSkillRepoQuery) Limit(limit int) *AgentSkillRepoQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *AgentSkillRepoQuery) Offset(offset int) *AgentSkillRepoQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *AgentSkillRepoQuery) Unique(unique bool) *AgentSkillRepoQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *AgentSkillRepoQuery) Order(o ...agentskillrepo.OrderOption) *AgentSkillRepoQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QuerySkills chains the current query on the "skills" edge. +func (_q *AgentSkillRepoQuery) QuerySkills() *AgentSkillQuery { + query := (&AgentSkillClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(agentskillrepo.Table, agentskillrepo.FieldID, selector), + sqlgraph.To(agentskill.Table, agentskill.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, agentskillrepo.SkillsTable, agentskillrepo.SkillsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first AgentSkillRepo entity from the query. +// Returns a *NotFoundError when no AgentSkillRepo was found. +func (_q *AgentSkillRepoQuery) First(ctx context.Context) (*AgentSkillRepo, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{agentskillrepo.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *AgentSkillRepoQuery) FirstX(ctx context.Context) *AgentSkillRepo { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first AgentSkillRepo ID from the query. +// Returns a *NotFoundError when no AgentSkillRepo ID was found. +func (_q *AgentSkillRepoQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{agentskillrepo.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *AgentSkillRepoQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single AgentSkillRepo entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one AgentSkillRepo entity is found. +// Returns a *NotFoundError when no AgentSkillRepo entities are found. +func (_q *AgentSkillRepoQuery) Only(ctx context.Context) (*AgentSkillRepo, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{agentskillrepo.Label} + default: + return nil, &NotSingularError{agentskillrepo.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *AgentSkillRepoQuery) OnlyX(ctx context.Context) *AgentSkillRepo { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only AgentSkillRepo ID in the query. +// Returns a *NotSingularError when more than one AgentSkillRepo ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *AgentSkillRepoQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{agentskillrepo.Label} + default: + err = &NotSingularError{agentskillrepo.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *AgentSkillRepoQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of AgentSkillRepos. +func (_q *AgentSkillRepoQuery) All(ctx context.Context) ([]*AgentSkillRepo, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*AgentSkillRepo, *AgentSkillRepoQuery]() + return withInterceptors[[]*AgentSkillRepo](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *AgentSkillRepoQuery) AllX(ctx context.Context) []*AgentSkillRepo { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of AgentSkillRepo IDs. +func (_q *AgentSkillRepoQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(agentskillrepo.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *AgentSkillRepoQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *AgentSkillRepoQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*AgentSkillRepoQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *AgentSkillRepoQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *AgentSkillRepoQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *AgentSkillRepoQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AgentSkillRepoQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *AgentSkillRepoQuery) Clone() *AgentSkillRepoQuery { + if _q == nil { + return nil + } + return &AgentSkillRepoQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]agentskillrepo.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.AgentSkillRepo{}, _q.predicates...), + withSkills: _q.withSkills.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithSkills tells the query-builder to eager-load the nodes that are connected to +// the "skills" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AgentSkillRepoQuery) WithSkills(opts ...func(*AgentSkillQuery)) *AgentSkillRepoQuery { + query := (&AgentSkillClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withSkills = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Name string `json:"name,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.AgentSkillRepo.Query(). +// GroupBy(agentskillrepo.FieldName). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (_q *AgentSkillRepoQuery) GroupBy(field string, fields ...string) *AgentSkillRepoGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &AgentSkillRepoGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = agentskillrepo.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Name string `json:"name,omitempty"` +// } +// +// client.AgentSkillRepo.Query(). +// Select(agentskillrepo.FieldName). +// Scan(ctx, &v) +func (_q *AgentSkillRepoQuery) Select(fields ...string) *AgentSkillRepoSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &AgentSkillRepoSelect{AgentSkillRepoQuery: _q} + sbuild.label = agentskillrepo.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AgentSkillRepoSelect configured with the given aggregations. +func (_q *AgentSkillRepoQuery) Aggregate(fns ...AggregateFunc) *AgentSkillRepoSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *AgentSkillRepoQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !agentskillrepo.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *AgentSkillRepoQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AgentSkillRepo, error) { + var ( + nodes = []*AgentSkillRepo{} + _spec = _q.querySpec() + loadedTypes = [1]bool{ + _q.withSkills != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*AgentSkillRepo).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &AgentSkillRepo{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withSkills; query != nil { + if err := _q.loadSkills(ctx, query, nodes, + func(n *AgentSkillRepo) { n.Edges.Skills = []*AgentSkill{} }, + func(n *AgentSkillRepo, e *AgentSkill) { n.Edges.Skills = append(n.Edges.Skills, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *AgentSkillRepoQuery) loadSkills(ctx context.Context, query *AgentSkillQuery, nodes []*AgentSkillRepo, init func(*AgentSkillRepo), assign func(*AgentSkillRepo, *AgentSkill)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uuid.UUID]*AgentSkillRepo) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(agentskill.FieldRepoID) + } + query.Where(predicate.AgentSkill(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(agentskillrepo.SkillsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.RepoID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "repo_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *AgentSkillRepoQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *AgentSkillRepoQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(agentskillrepo.Table, agentskillrepo.Columns, sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentskillrepo.FieldID) + for i := range fields { + if fields[i] != agentskillrepo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *AgentSkillRepoQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(agentskillrepo.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = agentskillrepo.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *AgentSkillRepoQuery) ForUpdate(opts ...sql.LockOption) *AgentSkillRepoQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *AgentSkillRepoQuery) ForShare(opts ...sql.LockOption) *AgentSkillRepoQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *AgentSkillRepoQuery) Modify(modifiers ...func(s *sql.Selector)) *AgentSkillRepoSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// AgentSkillRepoGroupBy is the group-by builder for AgentSkillRepo entities. +type AgentSkillRepoGroupBy struct { + selector + build *AgentSkillRepoQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *AgentSkillRepoGroupBy) Aggregate(fns ...AggregateFunc) *AgentSkillRepoGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *AgentSkillRepoGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentSkillRepoQuery, *AgentSkillRepoGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *AgentSkillRepoGroupBy) sqlScan(ctx context.Context, root *AgentSkillRepoQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// AgentSkillRepoSelect is the builder for selecting fields of AgentSkillRepo entities. +type AgentSkillRepoSelect struct { + *AgentSkillRepoQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *AgentSkillRepoSelect) Aggregate(fns ...AggregateFunc) *AgentSkillRepoSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *AgentSkillRepoSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentSkillRepoQuery, *AgentSkillRepoSelect](ctx, _s.AgentSkillRepoQuery, _s, _s.inters, v) +} + +func (_s *AgentSkillRepoSelect) sqlScan(ctx context.Context, root *AgentSkillRepoQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *AgentSkillRepoSelect) Modify(modifiers ...func(s *sql.Selector)) *AgentSkillRepoSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/backend/db/agentskillrepo_update.go b/backend/db/agentskillrepo_update.go new file mode 100644 index 00000000..1064d49f --- /dev/null +++ b/backend/db/agentskillrepo_update.go @@ -0,0 +1,946 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentSkillRepoUpdate is the builder for updating AgentSkillRepo entities. +type AgentSkillRepoUpdate struct { + config + hooks []Hook + mutation *AgentSkillRepoMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the AgentSkillRepoUpdate builder. +func (_u *AgentSkillRepoUpdate) Where(ps ...predicate.AgentSkillRepo) *AgentSkillRepoUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetName sets the "name" field. +func (_u *AgentSkillRepoUpdate) SetName(v string) *AgentSkillRepoUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableName(v *string) *AgentSkillRepoUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetScopeType sets the "scope_type" field. +func (_u *AgentSkillRepoUpdate) SetScopeType(v agentskillrepo.ScopeType) *AgentSkillRepoUpdate { + _u.mutation.SetScopeType(v) + return _u +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableScopeType(v *agentskillrepo.ScopeType) *AgentSkillRepoUpdate { + if v != nil { + _u.SetScopeType(*v) + } + return _u +} + +// SetScopeID sets the "scope_id" field. +func (_u *AgentSkillRepoUpdate) SetScopeID(v string) *AgentSkillRepoUpdate { + _u.mutation.SetScopeID(v) + return _u +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableScopeID(v *string) *AgentSkillRepoUpdate { + if v != nil { + _u.SetScopeID(*v) + } + return _u +} + +// SetCreatedBy sets the "created_by" field. +func (_u *AgentSkillRepoUpdate) SetCreatedBy(v uuid.UUID) *AgentSkillRepoUpdate { + _u.mutation.SetCreatedBy(v) + return _u +} + +// SetNillableCreatedBy sets the "created_by" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableCreatedBy(v *uuid.UUID) *AgentSkillRepoUpdate { + if v != nil { + _u.SetCreatedBy(*v) + } + return _u +} + +// SetSourceType sets the "source_type" field. +func (_u *AgentSkillRepoUpdate) SetSourceType(v agentskillrepo.SourceType) *AgentSkillRepoUpdate { + _u.mutation.SetSourceType(v) + return _u +} + +// SetNillableSourceType sets the "source_type" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableSourceType(v *agentskillrepo.SourceType) *AgentSkillRepoUpdate { + if v != nil { + _u.SetSourceType(*v) + } + return _u +} + +// SetGithubURL sets the "github_url" field. +func (_u *AgentSkillRepoUpdate) SetGithubURL(v string) *AgentSkillRepoUpdate { + _u.mutation.SetGithubURL(v) + return _u +} + +// SetNillableGithubURL sets the "github_url" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableGithubURL(v *string) *AgentSkillRepoUpdate { + if v != nil { + _u.SetGithubURL(*v) + } + return _u +} + +// ClearGithubURL clears the value of the "github_url" field. +func (_u *AgentSkillRepoUpdate) ClearGithubURL() *AgentSkillRepoUpdate { + _u.mutation.ClearGithubURL() + return _u +} + +// SetRefType sets the "ref_type" field. +func (_u *AgentSkillRepoUpdate) SetRefType(v agentskillrepo.RefType) *AgentSkillRepoUpdate { + _u.mutation.SetRefType(v) + return _u +} + +// SetNillableRefType sets the "ref_type" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableRefType(v *agentskillrepo.RefType) *AgentSkillRepoUpdate { + if v != nil { + _u.SetRefType(*v) + } + return _u +} + +// ClearRefType clears the value of the "ref_type" field. +func (_u *AgentSkillRepoUpdate) ClearRefType() *AgentSkillRepoUpdate { + _u.mutation.ClearRefType() + return _u +} + +// SetRefValue sets the "ref_value" field. +func (_u *AgentSkillRepoUpdate) SetRefValue(v string) *AgentSkillRepoUpdate { + _u.mutation.SetRefValue(v) + return _u +} + +// SetNillableRefValue sets the "ref_value" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableRefValue(v *string) *AgentSkillRepoUpdate { + if v != nil { + _u.SetRefValue(*v) + } + return _u +} + +// ClearRefValue clears the value of the "ref_value" field. +func (_u *AgentSkillRepoUpdate) ClearRefValue() *AgentSkillRepoUpdate { + _u.mutation.ClearRefValue() + return _u +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (_u *AgentSkillRepoUpdate) SetLastUploadFilename(v string) *AgentSkillRepoUpdate { + _u.mutation.SetLastUploadFilename(v) + return _u +} + +// SetNillableLastUploadFilename sets the "last_upload_filename" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableLastUploadFilename(v *string) *AgentSkillRepoUpdate { + if v != nil { + _u.SetLastUploadFilename(*v) + } + return _u +} + +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (_u *AgentSkillRepoUpdate) ClearLastUploadFilename() *AgentSkillRepoUpdate { + _u.mutation.ClearLastUploadFilename() + return _u +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (_u *AgentSkillRepoUpdate) SetLastUploadAt(v time.Time) *AgentSkillRepoUpdate { + _u.mutation.SetLastUploadAt(v) + return _u +} + +// SetNillableLastUploadAt sets the "last_upload_at" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableLastUploadAt(v *time.Time) *AgentSkillRepoUpdate { + if v != nil { + _u.SetLastUploadAt(*v) + } + return _u +} + +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (_u *AgentSkillRepoUpdate) ClearLastUploadAt() *AgentSkillRepoUpdate { + _u.mutation.ClearLastUploadAt() + return _u +} + +// SetIsDeleted sets the "is_deleted" field. +func (_u *AgentSkillRepoUpdate) SetIsDeleted(v bool) *AgentSkillRepoUpdate { + _u.mutation.SetIsDeleted(v) + return _u +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableIsDeleted(v *bool) *AgentSkillRepoUpdate { + if v != nil { + _u.SetIsDeleted(*v) + } + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentSkillRepoUpdate) SetCreatedAt(v time.Time) *AgentSkillRepoUpdate { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentSkillRepoUpdate) SetNillableCreatedAt(v *time.Time) *AgentSkillRepoUpdate { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentSkillRepoUpdate) SetUpdatedAt(v time.Time) *AgentSkillRepoUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// AddSkillIDs adds the "skills" edge to the AgentSkill entity by IDs. +func (_u *AgentSkillRepoUpdate) AddSkillIDs(ids ...uuid.UUID) *AgentSkillRepoUpdate { + _u.mutation.AddSkillIDs(ids...) + return _u +} + +// AddSkills adds the "skills" edges to the AgentSkill entity. +func (_u *AgentSkillRepoUpdate) AddSkills(v ...*AgentSkill) *AgentSkillRepoUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddSkillIDs(ids...) +} + +// Mutation returns the AgentSkillRepoMutation object of the builder. +func (_u *AgentSkillRepoUpdate) Mutation() *AgentSkillRepoMutation { + return _u.mutation +} + +// ClearSkills clears all "skills" edges to the AgentSkill entity. +func (_u *AgentSkillRepoUpdate) ClearSkills() *AgentSkillRepoUpdate { + _u.mutation.ClearSkills() + return _u +} + +// RemoveSkillIDs removes the "skills" edge to AgentSkill entities by IDs. +func (_u *AgentSkillRepoUpdate) RemoveSkillIDs(ids ...uuid.UUID) *AgentSkillRepoUpdate { + _u.mutation.RemoveSkillIDs(ids...) + return _u +} + +// RemoveSkills removes "skills" edges to AgentSkill entities. +func (_u *AgentSkillRepoUpdate) RemoveSkills(v ...*AgentSkill) *AgentSkillRepoUpdate { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveSkillIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AgentSkillRepoUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentSkillRepoUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AgentSkillRepoUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentSkillRepoUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentSkillRepoUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentskillrepo.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentSkillRepoUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := agentskillrepo.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.name": %w`, err)} + } + } + if v, ok := _u.mutation.ScopeType(); ok { + if err := agentskillrepo.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.scope_type": %w`, err)} + } + } + if v, ok := _u.mutation.SourceType(); ok { + if err := agentskillrepo.SourceTypeValidator(v); err != nil { + return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.source_type": %w`, err)} + } + } + if v, ok := _u.mutation.RefType(); ok { + if err := agentskillrepo.RefTypeValidator(v); err != nil { + return &ValidationError{Name: "ref_type", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.ref_type": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentSkillRepoUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillRepoUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentSkillRepoUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentskillrepo.Table, agentskillrepo.Columns, sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(agentskillrepo.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.ScopeType(); ok { + _spec.SetField(agentskillrepo.FieldScopeType, field.TypeEnum, value) + } + if value, ok := _u.mutation.ScopeID(); ok { + _spec.SetField(agentskillrepo.FieldScopeID, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedBy(); ok { + _spec.SetField(agentskillrepo.FieldCreatedBy, field.TypeUUID, value) + } + if value, ok := _u.mutation.SourceType(); ok { + _spec.SetField(agentskillrepo.FieldSourceType, field.TypeEnum, value) + } + if value, ok := _u.mutation.GithubURL(); ok { + _spec.SetField(agentskillrepo.FieldGithubURL, field.TypeString, value) + } + if _u.mutation.GithubURLCleared() { + _spec.ClearField(agentskillrepo.FieldGithubURL, field.TypeString) + } + if value, ok := _u.mutation.RefType(); ok { + _spec.SetField(agentskillrepo.FieldRefType, field.TypeEnum, value) + } + if _u.mutation.RefTypeCleared() { + _spec.ClearField(agentskillrepo.FieldRefType, field.TypeEnum) + } + if value, ok := _u.mutation.RefValue(); ok { + _spec.SetField(agentskillrepo.FieldRefValue, field.TypeString, value) + } + if _u.mutation.RefValueCleared() { + _spec.ClearField(agentskillrepo.FieldRefValue, field.TypeString) + } + if value, ok := _u.mutation.LastUploadFilename(); ok { + _spec.SetField(agentskillrepo.FieldLastUploadFilename, field.TypeString, value) + } + if _u.mutation.LastUploadFilenameCleared() { + _spec.ClearField(agentskillrepo.FieldLastUploadFilename, field.TypeString) + } + if value, ok := _u.mutation.LastUploadAt(); ok { + _spec.SetField(agentskillrepo.FieldLastUploadAt, field.TypeTime, value) + } + if _u.mutation.LastUploadAtCleared() { + _spec.ClearField(agentskillrepo.FieldLastUploadAt, field.TypeTime) + } + if value, ok := _u.mutation.IsDeleted(); ok { + _spec.SetField(agentskillrepo.FieldIsDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentskillrepo.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentskillrepo.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.SkillsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskillrepo.SkillsTable, + Columns: []string{agentskillrepo.SkillsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedSkillsIDs(); len(nodes) > 0 && !_u.mutation.SkillsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskillrepo.SkillsTable, + Columns: []string{agentskillrepo.SkillsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.SkillsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskillrepo.SkillsTable, + Columns: []string{agentskillrepo.SkillsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentskillrepo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AgentSkillRepoUpdateOne is the builder for updating a single AgentSkillRepo entity. +type AgentSkillRepoUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AgentSkillRepoMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetName sets the "name" field. +func (_u *AgentSkillRepoUpdateOne) SetName(v string) *AgentSkillRepoUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableName(v *string) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetScopeType sets the "scope_type" field. +func (_u *AgentSkillRepoUpdateOne) SetScopeType(v agentskillrepo.ScopeType) *AgentSkillRepoUpdateOne { + _u.mutation.SetScopeType(v) + return _u +} + +// SetNillableScopeType sets the "scope_type" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableScopeType(v *agentskillrepo.ScopeType) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetScopeType(*v) + } + return _u +} + +// SetScopeID sets the "scope_id" field. +func (_u *AgentSkillRepoUpdateOne) SetScopeID(v string) *AgentSkillRepoUpdateOne { + _u.mutation.SetScopeID(v) + return _u +} + +// SetNillableScopeID sets the "scope_id" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableScopeID(v *string) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetScopeID(*v) + } + return _u +} + +// SetCreatedBy sets the "created_by" field. +func (_u *AgentSkillRepoUpdateOne) SetCreatedBy(v uuid.UUID) *AgentSkillRepoUpdateOne { + _u.mutation.SetCreatedBy(v) + return _u +} + +// SetNillableCreatedBy sets the "created_by" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableCreatedBy(v *uuid.UUID) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetCreatedBy(*v) + } + return _u +} + +// SetSourceType sets the "source_type" field. +func (_u *AgentSkillRepoUpdateOne) SetSourceType(v agentskillrepo.SourceType) *AgentSkillRepoUpdateOne { + _u.mutation.SetSourceType(v) + return _u +} + +// SetNillableSourceType sets the "source_type" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableSourceType(v *agentskillrepo.SourceType) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetSourceType(*v) + } + return _u +} + +// SetGithubURL sets the "github_url" field. +func (_u *AgentSkillRepoUpdateOne) SetGithubURL(v string) *AgentSkillRepoUpdateOne { + _u.mutation.SetGithubURL(v) + return _u +} + +// SetNillableGithubURL sets the "github_url" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableGithubURL(v *string) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetGithubURL(*v) + } + return _u +} + +// ClearGithubURL clears the value of the "github_url" field. +func (_u *AgentSkillRepoUpdateOne) ClearGithubURL() *AgentSkillRepoUpdateOne { + _u.mutation.ClearGithubURL() + return _u +} + +// SetRefType sets the "ref_type" field. +func (_u *AgentSkillRepoUpdateOne) SetRefType(v agentskillrepo.RefType) *AgentSkillRepoUpdateOne { + _u.mutation.SetRefType(v) + return _u +} + +// SetNillableRefType sets the "ref_type" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableRefType(v *agentskillrepo.RefType) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetRefType(*v) + } + return _u +} + +// ClearRefType clears the value of the "ref_type" field. +func (_u *AgentSkillRepoUpdateOne) ClearRefType() *AgentSkillRepoUpdateOne { + _u.mutation.ClearRefType() + return _u +} + +// SetRefValue sets the "ref_value" field. +func (_u *AgentSkillRepoUpdateOne) SetRefValue(v string) *AgentSkillRepoUpdateOne { + _u.mutation.SetRefValue(v) + return _u +} + +// SetNillableRefValue sets the "ref_value" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableRefValue(v *string) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetRefValue(*v) + } + return _u +} + +// ClearRefValue clears the value of the "ref_value" field. +func (_u *AgentSkillRepoUpdateOne) ClearRefValue() *AgentSkillRepoUpdateOne { + _u.mutation.ClearRefValue() + return _u +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (_u *AgentSkillRepoUpdateOne) SetLastUploadFilename(v string) *AgentSkillRepoUpdateOne { + _u.mutation.SetLastUploadFilename(v) + return _u +} + +// SetNillableLastUploadFilename sets the "last_upload_filename" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableLastUploadFilename(v *string) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetLastUploadFilename(*v) + } + return _u +} + +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (_u *AgentSkillRepoUpdateOne) ClearLastUploadFilename() *AgentSkillRepoUpdateOne { + _u.mutation.ClearLastUploadFilename() + return _u +} + +// SetLastUploadAt sets the "last_upload_at" field. +func (_u *AgentSkillRepoUpdateOne) SetLastUploadAt(v time.Time) *AgentSkillRepoUpdateOne { + _u.mutation.SetLastUploadAt(v) + return _u +} + +// SetNillableLastUploadAt sets the "last_upload_at" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableLastUploadAt(v *time.Time) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetLastUploadAt(*v) + } + return _u +} + +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (_u *AgentSkillRepoUpdateOne) ClearLastUploadAt() *AgentSkillRepoUpdateOne { + _u.mutation.ClearLastUploadAt() + return _u +} + +// SetIsDeleted sets the "is_deleted" field. +func (_u *AgentSkillRepoUpdateOne) SetIsDeleted(v bool) *AgentSkillRepoUpdateOne { + _u.mutation.SetIsDeleted(v) + return _u +} + +// SetNillableIsDeleted sets the "is_deleted" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableIsDeleted(v *bool) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetIsDeleted(*v) + } + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentSkillRepoUpdateOne) SetCreatedAt(v time.Time) *AgentSkillRepoUpdateOne { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentSkillRepoUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentSkillRepoUpdateOne { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentSkillRepoUpdateOne) SetUpdatedAt(v time.Time) *AgentSkillRepoUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// AddSkillIDs adds the "skills" edge to the AgentSkill entity by IDs. +func (_u *AgentSkillRepoUpdateOne) AddSkillIDs(ids ...uuid.UUID) *AgentSkillRepoUpdateOne { + _u.mutation.AddSkillIDs(ids...) + return _u +} + +// AddSkills adds the "skills" edges to the AgentSkill entity. +func (_u *AgentSkillRepoUpdateOne) AddSkills(v ...*AgentSkill) *AgentSkillRepoUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddSkillIDs(ids...) +} + +// Mutation returns the AgentSkillRepoMutation object of the builder. +func (_u *AgentSkillRepoUpdateOne) Mutation() *AgentSkillRepoMutation { + return _u.mutation +} + +// ClearSkills clears all "skills" edges to the AgentSkill entity. +func (_u *AgentSkillRepoUpdateOne) ClearSkills() *AgentSkillRepoUpdateOne { + _u.mutation.ClearSkills() + return _u +} + +// RemoveSkillIDs removes the "skills" edge to AgentSkill entities by IDs. +func (_u *AgentSkillRepoUpdateOne) RemoveSkillIDs(ids ...uuid.UUID) *AgentSkillRepoUpdateOne { + _u.mutation.RemoveSkillIDs(ids...) + return _u +} + +// RemoveSkills removes "skills" edges to AgentSkill entities. +func (_u *AgentSkillRepoUpdateOne) RemoveSkills(v ...*AgentSkill) *AgentSkillRepoUpdateOne { + ids := make([]uuid.UUID, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveSkillIDs(ids...) +} + +// Where appends a list predicates to the AgentSkillRepoUpdate builder. +func (_u *AgentSkillRepoUpdateOne) Where(ps ...predicate.AgentSkillRepo) *AgentSkillRepoUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *AgentSkillRepoUpdateOne) Select(field string, fields ...string) *AgentSkillRepoUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated AgentSkillRepo entity. +func (_u *AgentSkillRepoUpdateOne) Save(ctx context.Context) (*AgentSkillRepo, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentSkillRepoUpdateOne) SaveX(ctx context.Context) *AgentSkillRepo { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AgentSkillRepoUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentSkillRepoUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentSkillRepoUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentskillrepo.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentSkillRepoUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := agentskillrepo.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.name": %w`, err)} + } + } + if v, ok := _u.mutation.ScopeType(); ok { + if err := agentskillrepo.ScopeTypeValidator(v); err != nil { + return &ValidationError{Name: "scope_type", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.scope_type": %w`, err)} + } + } + if v, ok := _u.mutation.SourceType(); ok { + if err := agentskillrepo.SourceTypeValidator(v); err != nil { + return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.source_type": %w`, err)} + } + } + if v, ok := _u.mutation.RefType(); ok { + if err := agentskillrepo.RefTypeValidator(v); err != nil { + return &ValidationError{Name: "ref_type", err: fmt.Errorf(`db: validator failed for field "AgentSkillRepo.ref_type": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentSkillRepoUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillRepoUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentSkillRepoUpdateOne) sqlSave(ctx context.Context) (_node *AgentSkillRepo, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentskillrepo.Table, agentskillrepo.Columns, sqlgraph.NewFieldSpec(agentskillrepo.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentSkillRepo.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentskillrepo.FieldID) + for _, f := range fields { + if !agentskillrepo.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != agentskillrepo.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(agentskillrepo.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.ScopeType(); ok { + _spec.SetField(agentskillrepo.FieldScopeType, field.TypeEnum, value) + } + if value, ok := _u.mutation.ScopeID(); ok { + _spec.SetField(agentskillrepo.FieldScopeID, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedBy(); ok { + _spec.SetField(agentskillrepo.FieldCreatedBy, field.TypeUUID, value) + } + if value, ok := _u.mutation.SourceType(); ok { + _spec.SetField(agentskillrepo.FieldSourceType, field.TypeEnum, value) + } + if value, ok := _u.mutation.GithubURL(); ok { + _spec.SetField(agentskillrepo.FieldGithubURL, field.TypeString, value) + } + if _u.mutation.GithubURLCleared() { + _spec.ClearField(agentskillrepo.FieldGithubURL, field.TypeString) + } + if value, ok := _u.mutation.RefType(); ok { + _spec.SetField(agentskillrepo.FieldRefType, field.TypeEnum, value) + } + if _u.mutation.RefTypeCleared() { + _spec.ClearField(agentskillrepo.FieldRefType, field.TypeEnum) + } + if value, ok := _u.mutation.RefValue(); ok { + _spec.SetField(agentskillrepo.FieldRefValue, field.TypeString, value) + } + if _u.mutation.RefValueCleared() { + _spec.ClearField(agentskillrepo.FieldRefValue, field.TypeString) + } + if value, ok := _u.mutation.LastUploadFilename(); ok { + _spec.SetField(agentskillrepo.FieldLastUploadFilename, field.TypeString, value) + } + if _u.mutation.LastUploadFilenameCleared() { + _spec.ClearField(agentskillrepo.FieldLastUploadFilename, field.TypeString) + } + if value, ok := _u.mutation.LastUploadAt(); ok { + _spec.SetField(agentskillrepo.FieldLastUploadAt, field.TypeTime, value) + } + if _u.mutation.LastUploadAtCleared() { + _spec.ClearField(agentskillrepo.FieldLastUploadAt, field.TypeTime) + } + if value, ok := _u.mutation.IsDeleted(); ok { + _spec.SetField(agentskillrepo.FieldIsDeleted, field.TypeBool, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentskillrepo.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentskillrepo.FieldUpdatedAt, field.TypeTime, value) + } + if _u.mutation.SkillsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskillrepo.SkillsTable, + Columns: []string{agentskillrepo.SkillsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedSkillsIDs(); len(nodes) > 0 && !_u.mutation.SkillsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskillrepo.SkillsTable, + Columns: []string{agentskillrepo.SkillsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.SkillsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: agentskillrepo.SkillsTable, + Columns: []string{agentskillrepo.SkillsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &AgentSkillRepo{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentskillrepo.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/db/agentskillversion.go b/backend/db/agentskillversion.go new file mode 100644 index 00000000..7b35aaf9 --- /dev/null +++ b/backend/db/agentskillversion.go @@ -0,0 +1,186 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentSkillVersion is the model entity for the AgentSkillVersion schema. +type AgentSkillVersion struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // ResourceID holds the value of the "resource_id" field. + ResourceID uuid.UUID `json:"resource_id,omitempty"` + // Version holds the value of the "version" field. + Version string `json:"version,omitempty"` + // S3Key holds the value of the "s3_key" field. + S3Key string `json:"s3_key,omitempty"` + // ParsedMeta holds the value of the "parsed_meta" field. + ParsedMeta types.SkillParsedMeta `json:"parsed_meta,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the AgentSkillVersionQuery when eager-loading is set. + Edges AgentSkillVersionEdges `json:"edges"` + selectValues sql.SelectValues +} + +// AgentSkillVersionEdges holds the relations/edges for other nodes in the graph. +type AgentSkillVersionEdges struct { + // Skill holds the value of the skill edge. + Skill *AgentSkill `json:"skill,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// SkillOrErr returns the Skill value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e AgentSkillVersionEdges) SkillOrErr() (*AgentSkill, error) { + if e.Skill != nil { + return e.Skill, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: agentskill.Label} + } + return nil, &NotLoadedError{edge: "skill"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*AgentSkillVersion) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case agentskillversion.FieldParsedMeta: + values[i] = new([]byte) + case agentskillversion.FieldVersion, agentskillversion.FieldS3Key: + values[i] = new(sql.NullString) + case agentskillversion.FieldCreatedAt: + values[i] = new(sql.NullTime) + case agentskillversion.FieldID, agentskillversion.FieldResourceID: + values[i] = new(uuid.UUID) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the AgentSkillVersion fields. +func (_m *AgentSkillVersion) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case agentskillversion.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case agentskillversion.FieldResourceID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field resource_id", values[i]) + } else if value != nil { + _m.ResourceID = *value + } + case agentskillversion.FieldVersion: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version", values[i]) + } else if value.Valid { + _m.Version = value.String + } + case agentskillversion.FieldS3Key: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field s3_key", values[i]) + } else if value.Valid { + _m.S3Key = value.String + } + case agentskillversion.FieldParsedMeta: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field parsed_meta", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.ParsedMeta); err != nil { + return fmt.Errorf("unmarshal field parsed_meta: %w", err) + } + } + case agentskillversion.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the AgentSkillVersion. +// This includes values selected through modifiers, order, etc. +func (_m *AgentSkillVersion) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QuerySkill queries the "skill" edge of the AgentSkillVersion entity. +func (_m *AgentSkillVersion) QuerySkill() *AgentSkillQuery { + return NewAgentSkillVersionClient(_m.config).QuerySkill(_m) +} + +// Update returns a builder for updating this AgentSkillVersion. +// Note that you need to call AgentSkillVersion.Unwrap() before calling this method if this AgentSkillVersion +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *AgentSkillVersion) Update() *AgentSkillVersionUpdateOne { + return NewAgentSkillVersionClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the AgentSkillVersion entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *AgentSkillVersion) Unwrap() *AgentSkillVersion { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("db: AgentSkillVersion is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *AgentSkillVersion) String() string { + var builder strings.Builder + builder.WriteString("AgentSkillVersion(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("resource_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ResourceID)) + builder.WriteString(", ") + builder.WriteString("version=") + builder.WriteString(_m.Version) + builder.WriteString(", ") + builder.WriteString("s3_key=") + builder.WriteString(_m.S3Key) + builder.WriteString(", ") + builder.WriteString("parsed_meta=") + builder.WriteString(fmt.Sprintf("%v", _m.ParsedMeta)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// AgentSkillVersions is a parsable slice of AgentSkillVersion. +type AgentSkillVersions []*AgentSkillVersion diff --git a/backend/db/agentskillversion/agentskillversion.go b/backend/db/agentskillversion/agentskillversion.go new file mode 100644 index 00000000..b42907ee --- /dev/null +++ b/backend/db/agentskillversion/agentskillversion.go @@ -0,0 +1,112 @@ +// Code generated by ent, DO NOT EDIT. + +package agentskillversion + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the agentskillversion type in the database. + Label = "agent_skill_version" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldResourceID holds the string denoting the resource_id field in the database. + FieldResourceID = "resource_id" + // FieldVersion holds the string denoting the version field in the database. + FieldVersion = "version" + // FieldS3Key holds the string denoting the s3_key field in the database. + FieldS3Key = "s3_key" + // FieldParsedMeta holds the string denoting the parsed_meta field in the database. + FieldParsedMeta = "parsed_meta" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // EdgeSkill holds the string denoting the skill edge name in mutations. + EdgeSkill = "skill" + // Table holds the table name of the agentskillversion in the database. + Table = "agent_skill_versions" + // SkillTable is the table that holds the skill relation/edge. + SkillTable = "agent_skill_versions" + // SkillInverseTable is the table name for the AgentSkill entity. + // It exists in this package in order to avoid circular dependency with the "agentskill" package. + SkillInverseTable = "agent_skills" + // SkillColumn is the table column denoting the skill relation/edge. + SkillColumn = "resource_id" +) + +// Columns holds all SQL columns for agentskillversion fields. +var Columns = []string{ + FieldID, + FieldResourceID, + FieldVersion, + FieldS3Key, + FieldParsedMeta, + FieldCreatedAt, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // VersionValidator is a validator for the "version" field. It is called by the builders before save. + VersionValidator func(string) error + // S3KeyValidator is a validator for the "s3_key" field. It is called by the builders before save. + S3KeyValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// OrderOption defines the ordering options for the AgentSkillVersion queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByResourceID orders the results by the resource_id field. +func ByResourceID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldResourceID, opts...).ToFunc() +} + +// ByVersion orders the results by the version field. +func ByVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersion, opts...).ToFunc() +} + +// ByS3Key orders the results by the s3_key field. +func ByS3Key(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldS3Key, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// BySkillField orders the results by skill field. +func BySkillField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newSkillStep(), sql.OrderByField(field, opts...)) + } +} +func newSkillStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SkillInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, SkillTable, SkillColumn), + ) +} diff --git a/backend/db/agentskillversion/where.go b/backend/db/agentskillversion/where.go new file mode 100644 index 00000000..5034e367 --- /dev/null +++ b/backend/db/agentskillversion/where.go @@ -0,0 +1,315 @@ +// Code generated by ent, DO NOT EDIT. + +package agentskillversion + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldLTE(FieldID, id)) +} + +// ResourceID applies equality check predicate on the "resource_id" field. It's identical to ResourceIDEQ. +func ResourceID(v uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEQ(FieldResourceID, v)) +} + +// Version applies equality check predicate on the "version" field. It's identical to VersionEQ. +func Version(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEQ(FieldVersion, v)) +} + +// S3Key applies equality check predicate on the "s3_key" field. It's identical to S3KeyEQ. +func S3Key(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEQ(FieldS3Key, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEQ(FieldCreatedAt, v)) +} + +// ResourceIDEQ applies the EQ predicate on the "resource_id" field. +func ResourceIDEQ(v uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEQ(FieldResourceID, v)) +} + +// ResourceIDNEQ applies the NEQ predicate on the "resource_id" field. +func ResourceIDNEQ(v uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNEQ(FieldResourceID, v)) +} + +// ResourceIDIn applies the In predicate on the "resource_id" field. +func ResourceIDIn(vs ...uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldIn(FieldResourceID, vs...)) +} + +// ResourceIDNotIn applies the NotIn predicate on the "resource_id" field. +func ResourceIDNotIn(vs ...uuid.UUID) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNotIn(FieldResourceID, vs...)) +} + +// VersionEQ applies the EQ predicate on the "version" field. +func VersionEQ(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEQ(FieldVersion, v)) +} + +// VersionNEQ applies the NEQ predicate on the "version" field. +func VersionNEQ(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNEQ(FieldVersion, v)) +} + +// VersionIn applies the In predicate on the "version" field. +func VersionIn(vs ...string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldIn(FieldVersion, vs...)) +} + +// VersionNotIn applies the NotIn predicate on the "version" field. +func VersionNotIn(vs ...string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNotIn(FieldVersion, vs...)) +} + +// VersionGT applies the GT predicate on the "version" field. +func VersionGT(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldGT(FieldVersion, v)) +} + +// VersionGTE applies the GTE predicate on the "version" field. +func VersionGTE(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldGTE(FieldVersion, v)) +} + +// VersionLT applies the LT predicate on the "version" field. +func VersionLT(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldLT(FieldVersion, v)) +} + +// VersionLTE applies the LTE predicate on the "version" field. +func VersionLTE(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldLTE(FieldVersion, v)) +} + +// VersionContains applies the Contains predicate on the "version" field. +func VersionContains(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldContains(FieldVersion, v)) +} + +// VersionHasPrefix applies the HasPrefix predicate on the "version" field. +func VersionHasPrefix(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldHasPrefix(FieldVersion, v)) +} + +// VersionHasSuffix applies the HasSuffix predicate on the "version" field. +func VersionHasSuffix(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldHasSuffix(FieldVersion, v)) +} + +// VersionEqualFold applies the EqualFold predicate on the "version" field. +func VersionEqualFold(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEqualFold(FieldVersion, v)) +} + +// VersionContainsFold applies the ContainsFold predicate on the "version" field. +func VersionContainsFold(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldContainsFold(FieldVersion, v)) +} + +// S3KeyEQ applies the EQ predicate on the "s3_key" field. +func S3KeyEQ(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEQ(FieldS3Key, v)) +} + +// S3KeyNEQ applies the NEQ predicate on the "s3_key" field. +func S3KeyNEQ(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNEQ(FieldS3Key, v)) +} + +// S3KeyIn applies the In predicate on the "s3_key" field. +func S3KeyIn(vs ...string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldIn(FieldS3Key, vs...)) +} + +// S3KeyNotIn applies the NotIn predicate on the "s3_key" field. +func S3KeyNotIn(vs ...string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNotIn(FieldS3Key, vs...)) +} + +// S3KeyGT applies the GT predicate on the "s3_key" field. +func S3KeyGT(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldGT(FieldS3Key, v)) +} + +// S3KeyGTE applies the GTE predicate on the "s3_key" field. +func S3KeyGTE(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldGTE(FieldS3Key, v)) +} + +// S3KeyLT applies the LT predicate on the "s3_key" field. +func S3KeyLT(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldLT(FieldS3Key, v)) +} + +// S3KeyLTE applies the LTE predicate on the "s3_key" field. +func S3KeyLTE(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldLTE(FieldS3Key, v)) +} + +// S3KeyContains applies the Contains predicate on the "s3_key" field. +func S3KeyContains(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldContains(FieldS3Key, v)) +} + +// S3KeyHasPrefix applies the HasPrefix predicate on the "s3_key" field. +func S3KeyHasPrefix(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldHasPrefix(FieldS3Key, v)) +} + +// S3KeyHasSuffix applies the HasSuffix predicate on the "s3_key" field. +func S3KeyHasSuffix(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldHasSuffix(FieldS3Key, v)) +} + +// S3KeyEqualFold applies the EqualFold predicate on the "s3_key" field. +func S3KeyEqualFold(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEqualFold(FieldS3Key, v)) +} + +// S3KeyContainsFold applies the ContainsFold predicate on the "s3_key" field. +func S3KeyContainsFold(v string) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldContainsFold(FieldS3Key, v)) +} + +// ParsedMetaIsNil applies the IsNil predicate on the "parsed_meta" field. +func ParsedMetaIsNil() predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldIsNull(FieldParsedMeta)) +} + +// ParsedMetaNotNil applies the NotNil predicate on the "parsed_meta" field. +func ParsedMetaNotNil() predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNotNull(FieldParsedMeta)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.FieldLTE(FieldCreatedAt, v)) +} + +// HasSkill applies the HasEdge predicate on the "skill" edge. +func HasSkill() predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, SkillTable, SkillColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSkillWith applies the HasEdge predicate on the "skill" edge with a given conditions (other predicates). +func HasSkillWith(preds ...predicate.AgentSkill) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(func(s *sql.Selector) { + step := newSkillStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.AgentSkillVersion) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.AgentSkillVersion) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.AgentSkillVersion) predicate.AgentSkillVersion { + return predicate.AgentSkillVersion(sql.NotPredicates(p)) +} diff --git a/backend/db/agentskillversion_create.go b/backend/db/agentskillversion_create.go new file mode 100644 index 00000000..b4f612dc --- /dev/null +++ b/backend/db/agentskillversion_create.go @@ -0,0 +1,797 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentSkillVersionCreate is the builder for creating a AgentSkillVersion entity. +type AgentSkillVersionCreate struct { + config + mutation *AgentSkillVersionMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetResourceID sets the "resource_id" field. +func (_c *AgentSkillVersionCreate) SetResourceID(v uuid.UUID) *AgentSkillVersionCreate { + _c.mutation.SetResourceID(v) + return _c +} + +// SetVersion sets the "version" field. +func (_c *AgentSkillVersionCreate) SetVersion(v string) *AgentSkillVersionCreate { + _c.mutation.SetVersion(v) + return _c +} + +// SetS3Key sets the "s3_key" field. +func (_c *AgentSkillVersionCreate) SetS3Key(v string) *AgentSkillVersionCreate { + _c.mutation.SetS3Key(v) + return _c +} + +// SetParsedMeta sets the "parsed_meta" field. +func (_c *AgentSkillVersionCreate) SetParsedMeta(v types.SkillParsedMeta) *AgentSkillVersionCreate { + _c.mutation.SetParsedMeta(v) + return _c +} + +// SetNillableParsedMeta sets the "parsed_meta" field if the given value is not nil. +func (_c *AgentSkillVersionCreate) SetNillableParsedMeta(v *types.SkillParsedMeta) *AgentSkillVersionCreate { + if v != nil { + _c.SetParsedMeta(*v) + } + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AgentSkillVersionCreate) SetCreatedAt(v time.Time) *AgentSkillVersionCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AgentSkillVersionCreate) SetNillableCreatedAt(v *time.Time) *AgentSkillVersionCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AgentSkillVersionCreate) SetID(v uuid.UUID) *AgentSkillVersionCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AgentSkillVersionCreate) SetNillableID(v *uuid.UUID) *AgentSkillVersionCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetSkillID sets the "skill" edge to the AgentSkill entity by ID. +func (_c *AgentSkillVersionCreate) SetSkillID(id uuid.UUID) *AgentSkillVersionCreate { + _c.mutation.SetSkillID(id) + return _c +} + +// SetSkill sets the "skill" edge to the AgentSkill entity. +func (_c *AgentSkillVersionCreate) SetSkill(v *AgentSkill) *AgentSkillVersionCreate { + return _c.SetSkillID(v.ID) +} + +// Mutation returns the AgentSkillVersionMutation object of the builder. +func (_c *AgentSkillVersionCreate) Mutation() *AgentSkillVersionMutation { + return _c.mutation +} + +// Save creates the AgentSkillVersion in the database. +func (_c *AgentSkillVersionCreate) Save(ctx context.Context) (*AgentSkillVersion, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AgentSkillVersionCreate) SaveX(ctx context.Context) *AgentSkillVersion { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentSkillVersionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentSkillVersionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AgentSkillVersionCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := agentskillversion.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := agentskillversion.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AgentSkillVersionCreate) check() error { + if _, ok := _c.mutation.ResourceID(); !ok { + return &ValidationError{Name: "resource_id", err: errors.New(`db: missing required field "AgentSkillVersion.resource_id"`)} + } + if _, ok := _c.mutation.Version(); !ok { + return &ValidationError{Name: "version", err: errors.New(`db: missing required field "AgentSkillVersion.version"`)} + } + if v, ok := _c.mutation.Version(); ok { + if err := agentskillversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "AgentSkillVersion.version": %w`, err)} + } + } + if _, ok := _c.mutation.S3Key(); !ok { + return &ValidationError{Name: "s3_key", err: errors.New(`db: missing required field "AgentSkillVersion.s3_key"`)} + } + if v, ok := _c.mutation.S3Key(); ok { + if err := agentskillversion.S3KeyValidator(v); err != nil { + return &ValidationError{Name: "s3_key", err: fmt.Errorf(`db: validator failed for field "AgentSkillVersion.s3_key": %w`, err)} + } + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentSkillVersion.created_at"`)} + } + if len(_c.mutation.SkillIDs()) == 0 { + return &ValidationError{Name: "skill", err: errors.New(`db: missing required edge "AgentSkillVersion.skill"`)} + } + return nil +} + +func (_c *AgentSkillVersionCreate) sqlSave(ctx context.Context) (*AgentSkillVersion, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AgentSkillVersionCreate) createSpec() (*AgentSkillVersion, *sqlgraph.CreateSpec) { + var ( + _node = &AgentSkillVersion{config: _c.config} + _spec = sqlgraph.NewCreateSpec(agentskillversion.Table, sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID)) + ) + _spec.OnConflict = _c.conflict + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.Version(); ok { + _spec.SetField(agentskillversion.FieldVersion, field.TypeString, value) + _node.Version = value + } + if value, ok := _c.mutation.S3Key(); ok { + _spec.SetField(agentskillversion.FieldS3Key, field.TypeString, value) + _node.S3Key = value + } + if value, ok := _c.mutation.ParsedMeta(); ok { + _spec.SetField(agentskillversion.FieldParsedMeta, field.TypeJSON, value) + _node.ParsedMeta = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(agentskillversion.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if nodes := _c.mutation.SkillIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentskillversion.SkillTable, + Columns: []string{agentskillversion.SkillColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ResourceID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentSkillVersion.Create(). +// SetResourceID(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentSkillVersionUpsert) { +// SetResourceID(v+v). +// }). +// Exec(ctx) +func (_c *AgentSkillVersionCreate) OnConflict(opts ...sql.ConflictOption) *AgentSkillVersionUpsertOne { + _c.conflict = opts + return &AgentSkillVersionUpsertOne{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentSkillVersion.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentSkillVersionCreate) OnConflictColumns(columns ...string) *AgentSkillVersionUpsertOne { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentSkillVersionUpsertOne{ + create: _c, + } +} + +type ( + // AgentSkillVersionUpsertOne is the builder for "upsert"-ing + // one AgentSkillVersion node. + AgentSkillVersionUpsertOne struct { + create *AgentSkillVersionCreate + } + + // AgentSkillVersionUpsert is the "OnConflict" setter. + AgentSkillVersionUpsert struct { + *sql.UpdateSet + } +) + +// SetResourceID sets the "resource_id" field. +func (u *AgentSkillVersionUpsert) SetResourceID(v uuid.UUID) *AgentSkillVersionUpsert { + u.Set(agentskillversion.FieldResourceID, v) + return u +} + +// UpdateResourceID sets the "resource_id" field to the value that was provided on create. +func (u *AgentSkillVersionUpsert) UpdateResourceID() *AgentSkillVersionUpsert { + u.SetExcluded(agentskillversion.FieldResourceID) + return u +} + +// SetVersion sets the "version" field. +func (u *AgentSkillVersionUpsert) SetVersion(v string) *AgentSkillVersionUpsert { + u.Set(agentskillversion.FieldVersion, v) + return u +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *AgentSkillVersionUpsert) UpdateVersion() *AgentSkillVersionUpsert { + u.SetExcluded(agentskillversion.FieldVersion) + return u +} + +// SetS3Key sets the "s3_key" field. +func (u *AgentSkillVersionUpsert) SetS3Key(v string) *AgentSkillVersionUpsert { + u.Set(agentskillversion.FieldS3Key, v) + return u +} + +// UpdateS3Key sets the "s3_key" field to the value that was provided on create. +func (u *AgentSkillVersionUpsert) UpdateS3Key() *AgentSkillVersionUpsert { + u.SetExcluded(agentskillversion.FieldS3Key) + return u +} + +// SetParsedMeta sets the "parsed_meta" field. +func (u *AgentSkillVersionUpsert) SetParsedMeta(v types.SkillParsedMeta) *AgentSkillVersionUpsert { + u.Set(agentskillversion.FieldParsedMeta, v) + return u +} + +// UpdateParsedMeta sets the "parsed_meta" field to the value that was provided on create. +func (u *AgentSkillVersionUpsert) UpdateParsedMeta() *AgentSkillVersionUpsert { + u.SetExcluded(agentskillversion.FieldParsedMeta) + return u +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (u *AgentSkillVersionUpsert) ClearParsedMeta() *AgentSkillVersionUpsert { + u.SetNull(agentskillversion.FieldParsedMeta) + return u +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSkillVersionUpsert) SetCreatedAt(v time.Time) *AgentSkillVersionUpsert { + u.Set(agentskillversion.FieldCreatedAt, v) + return u +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSkillVersionUpsert) UpdateCreatedAt() *AgentSkillVersionUpsert { + u.SetExcluded(agentskillversion.FieldCreatedAt) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.AgentSkillVersion.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentskillversion.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentSkillVersionUpsertOne) UpdateNewValues() *AgentSkillVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(agentskillversion.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentSkillVersion.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentSkillVersionUpsertOne) Ignore() *AgentSkillVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentSkillVersionUpsertOne) DoNothing() *AgentSkillVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentSkillVersionCreate.OnConflict +// documentation for more info. +func (u *AgentSkillVersionUpsertOne) Update(set func(*AgentSkillVersionUpsert)) *AgentSkillVersionUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentSkillVersionUpsert{UpdateSet: update}) + })) + return u +} + +// SetResourceID sets the "resource_id" field. +func (u *AgentSkillVersionUpsertOne) SetResourceID(v uuid.UUID) *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.SetResourceID(v) + }) +} + +// UpdateResourceID sets the "resource_id" field to the value that was provided on create. +func (u *AgentSkillVersionUpsertOne) UpdateResourceID() *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.UpdateResourceID() + }) +} + +// SetVersion sets the "version" field. +func (u *AgentSkillVersionUpsertOne) SetVersion(v string) *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *AgentSkillVersionUpsertOne) UpdateVersion() *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.UpdateVersion() + }) +} + +// SetS3Key sets the "s3_key" field. +func (u *AgentSkillVersionUpsertOne) SetS3Key(v string) *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.SetS3Key(v) + }) +} + +// UpdateS3Key sets the "s3_key" field to the value that was provided on create. +func (u *AgentSkillVersionUpsertOne) UpdateS3Key() *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.UpdateS3Key() + }) +} + +// SetParsedMeta sets the "parsed_meta" field. +func (u *AgentSkillVersionUpsertOne) SetParsedMeta(v types.SkillParsedMeta) *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.SetParsedMeta(v) + }) +} + +// UpdateParsedMeta sets the "parsed_meta" field to the value that was provided on create. +func (u *AgentSkillVersionUpsertOne) UpdateParsedMeta() *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.UpdateParsedMeta() + }) +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (u *AgentSkillVersionUpsertOne) ClearParsedMeta() *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.ClearParsedMeta() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSkillVersionUpsertOne) SetCreatedAt(v time.Time) *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSkillVersionUpsertOne) UpdateCreatedAt() *AgentSkillVersionUpsertOne { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.UpdateCreatedAt() + }) +} + +// Exec executes the query. +func (u *AgentSkillVersionUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentSkillVersionCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentSkillVersionUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *AgentSkillVersionUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: AgentSkillVersionUpsertOne.ID is not supported by MySQL driver. Use AgentSkillVersionUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *AgentSkillVersionUpsertOne) IDX(ctx context.Context) uuid.UUID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// AgentSkillVersionCreateBulk is the builder for creating many AgentSkillVersion entities in bulk. +type AgentSkillVersionCreateBulk struct { + config + err error + builders []*AgentSkillVersionCreate + conflict []sql.ConflictOption +} + +// Save creates the AgentSkillVersion entities in the database. +func (_c *AgentSkillVersionCreateBulk) Save(ctx context.Context) ([]*AgentSkillVersion, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*AgentSkillVersion, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AgentSkillVersionMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = _c.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AgentSkillVersionCreateBulk) SaveX(ctx context.Context) []*AgentSkillVersion { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentSkillVersionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentSkillVersionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentSkillVersion.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentSkillVersionUpsert) { +// SetResourceID(v+v). +// }). +// Exec(ctx) +func (_c *AgentSkillVersionCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentSkillVersionUpsertBulk { + _c.conflict = opts + return &AgentSkillVersionUpsertBulk{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentSkillVersion.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentSkillVersionCreateBulk) OnConflictColumns(columns ...string) *AgentSkillVersionUpsertBulk { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentSkillVersionUpsertBulk{ + create: _c, + } +} + +// AgentSkillVersionUpsertBulk is the builder for "upsert"-ing +// a bulk of AgentSkillVersion nodes. +type AgentSkillVersionUpsertBulk struct { + create *AgentSkillVersionCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.AgentSkillVersion.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentskillversion.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentSkillVersionUpsertBulk) UpdateNewValues() *AgentSkillVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(agentskillversion.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentSkillVersion.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentSkillVersionUpsertBulk) Ignore() *AgentSkillVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentSkillVersionUpsertBulk) DoNothing() *AgentSkillVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentSkillVersionCreateBulk.OnConflict +// documentation for more info. +func (u *AgentSkillVersionUpsertBulk) Update(set func(*AgentSkillVersionUpsert)) *AgentSkillVersionUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentSkillVersionUpsert{UpdateSet: update}) + })) + return u +} + +// SetResourceID sets the "resource_id" field. +func (u *AgentSkillVersionUpsertBulk) SetResourceID(v uuid.UUID) *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.SetResourceID(v) + }) +} + +// UpdateResourceID sets the "resource_id" field to the value that was provided on create. +func (u *AgentSkillVersionUpsertBulk) UpdateResourceID() *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.UpdateResourceID() + }) +} + +// SetVersion sets the "version" field. +func (u *AgentSkillVersionUpsertBulk) SetVersion(v string) *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.SetVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *AgentSkillVersionUpsertBulk) UpdateVersion() *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.UpdateVersion() + }) +} + +// SetS3Key sets the "s3_key" field. +func (u *AgentSkillVersionUpsertBulk) SetS3Key(v string) *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.SetS3Key(v) + }) +} + +// UpdateS3Key sets the "s3_key" field to the value that was provided on create. +func (u *AgentSkillVersionUpsertBulk) UpdateS3Key() *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.UpdateS3Key() + }) +} + +// SetParsedMeta sets the "parsed_meta" field. +func (u *AgentSkillVersionUpsertBulk) SetParsedMeta(v types.SkillParsedMeta) *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.SetParsedMeta(v) + }) +} + +// UpdateParsedMeta sets the "parsed_meta" field to the value that was provided on create. +func (u *AgentSkillVersionUpsertBulk) UpdateParsedMeta() *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.UpdateParsedMeta() + }) +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (u *AgentSkillVersionUpsertBulk) ClearParsedMeta() *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.ClearParsedMeta() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSkillVersionUpsertBulk) SetCreatedAt(v time.Time) *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSkillVersionUpsertBulk) UpdateCreatedAt() *AgentSkillVersionUpsertBulk { + return u.Update(func(s *AgentSkillVersionUpsert) { + s.UpdateCreatedAt() + }) +} + +// Exec executes the query. +func (u *AgentSkillVersionUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentSkillVersionCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentSkillVersionCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentSkillVersionUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentskillversion_delete.go b/backend/db/agentskillversion_delete.go new file mode 100644 index 00000000..d553e4f8 --- /dev/null +++ b/backend/db/agentskillversion_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" +) + +// AgentSkillVersionDelete is the builder for deleting a AgentSkillVersion entity. +type AgentSkillVersionDelete struct { + config + hooks []Hook + mutation *AgentSkillVersionMutation +} + +// Where appends a list predicates to the AgentSkillVersionDelete builder. +func (_d *AgentSkillVersionDelete) Where(ps ...predicate.AgentSkillVersion) *AgentSkillVersionDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *AgentSkillVersionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentSkillVersionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *AgentSkillVersionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(agentskillversion.Table, sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// AgentSkillVersionDeleteOne is the builder for deleting a single AgentSkillVersion entity. +type AgentSkillVersionDeleteOne struct { + _d *AgentSkillVersionDelete +} + +// Where appends a list predicates to the AgentSkillVersionDelete builder. +func (_d *AgentSkillVersionDeleteOne) Where(ps ...predicate.AgentSkillVersion) *AgentSkillVersionDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *AgentSkillVersionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{agentskillversion.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentSkillVersionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/teamskill_query.go b/backend/db/agentskillversion_query.go similarity index 56% rename from backend/db/teamskill_query.go rename to backend/db/agentskillversion_query.go index 875d0672..c07bbf2c 100644 --- a/backend/db/teamskill_query.go +++ b/backend/db/agentskillversion_query.go @@ -12,84 +12,60 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" - "github.com/chaitin/MonkeyCode/backend/db/team" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" "github.com/google/uuid" ) -// TeamSkillQuery is the builder for querying TeamSkill entities. -type TeamSkillQuery struct { +// AgentSkillVersionQuery is the builder for querying AgentSkillVersion entities. +type AgentSkillVersionQuery struct { config ctx *QueryContext - order []teamskill.OrderOption + order []agentskillversion.OrderOption inters []Interceptor - predicates []predicate.TeamSkill - withTeam *TeamQuery - withSkill *SkillQuery + predicates []predicate.AgentSkillVersion + withSkill *AgentSkillQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) } -// Where adds a new predicate for the TeamSkillQuery builder. -func (_q *TeamSkillQuery) Where(ps ...predicate.TeamSkill) *TeamSkillQuery { +// Where adds a new predicate for the AgentSkillVersionQuery builder. +func (_q *AgentSkillVersionQuery) Where(ps ...predicate.AgentSkillVersion) *AgentSkillVersionQuery { _q.predicates = append(_q.predicates, ps...) return _q } // Limit the number of records to be returned by this query. -func (_q *TeamSkillQuery) Limit(limit int) *TeamSkillQuery { +func (_q *AgentSkillVersionQuery) Limit(limit int) *AgentSkillVersionQuery { _q.ctx.Limit = &limit return _q } // Offset to start from. -func (_q *TeamSkillQuery) Offset(offset int) *TeamSkillQuery { +func (_q *AgentSkillVersionQuery) Offset(offset int) *AgentSkillVersionQuery { _q.ctx.Offset = &offset return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (_q *TeamSkillQuery) Unique(unique bool) *TeamSkillQuery { +func (_q *AgentSkillVersionQuery) Unique(unique bool) *AgentSkillVersionQuery { _q.ctx.Unique = &unique return _q } // Order specifies how the records should be ordered. -func (_q *TeamSkillQuery) Order(o ...teamskill.OrderOption) *TeamSkillQuery { +func (_q *AgentSkillVersionQuery) Order(o ...agentskillversion.OrderOption) *AgentSkillVersionQuery { _q.order = append(_q.order, o...) return _q } -// QueryTeam chains the current query on the "team" edge. -func (_q *TeamSkillQuery) QueryTeam() *TeamQuery { - query := (&TeamClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(teamskill.Table, teamskill.FieldID, selector), - sqlgraph.To(team.Table, team.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, teamskill.TeamTable, teamskill.TeamColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - // QuerySkill chains the current query on the "skill" edge. -func (_q *TeamSkillQuery) QuerySkill() *SkillQuery { - query := (&SkillClient{config: _q.config}).Query() +func (_q *AgentSkillVersionQuery) QuerySkill() *AgentSkillQuery { + query := (&AgentSkillClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err @@ -99,9 +75,9 @@ func (_q *TeamSkillQuery) QuerySkill() *SkillQuery { return nil, err } step := sqlgraph.NewStep( - sqlgraph.From(teamskill.Table, teamskill.FieldID, selector), - sqlgraph.To(skill.Table, skill.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, teamskill.SkillTable, teamskill.SkillColumn), + sqlgraph.From(agentskillversion.Table, agentskillversion.FieldID, selector), + sqlgraph.To(agentskill.Table, agentskill.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, agentskillversion.SkillTable, agentskillversion.SkillColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -109,21 +85,21 @@ func (_q *TeamSkillQuery) QuerySkill() *SkillQuery { return query } -// First returns the first TeamSkill entity from the query. -// Returns a *NotFoundError when no TeamSkill was found. -func (_q *TeamSkillQuery) First(ctx context.Context) (*TeamSkill, error) { +// First returns the first AgentSkillVersion entity from the query. +// Returns a *NotFoundError when no AgentSkillVersion was found. +func (_q *AgentSkillVersionQuery) First(ctx context.Context) (*AgentSkillVersion, error) { nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } if len(nodes) == 0 { - return nil, &NotFoundError{teamskill.Label} + return nil, &NotFoundError{agentskillversion.Label} } return nodes[0], nil } // FirstX is like First, but panics if an error occurs. -func (_q *TeamSkillQuery) FirstX(ctx context.Context) *TeamSkill { +func (_q *AgentSkillVersionQuery) FirstX(ctx context.Context) *AgentSkillVersion { node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -131,22 +107,22 @@ func (_q *TeamSkillQuery) FirstX(ctx context.Context) *TeamSkill { return node } -// FirstID returns the first TeamSkill ID from the query. -// Returns a *NotFoundError when no TeamSkill ID was found. -func (_q *TeamSkillQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { +// FirstID returns the first AgentSkillVersion ID from the query. +// Returns a *NotFoundError when no AgentSkillVersion ID was found. +func (_q *AgentSkillVersionQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { - err = &NotFoundError{teamskill.Label} + err = &NotFoundError{agentskillversion.Label} return } return ids[0], nil } // FirstIDX is like FirstID, but panics if an error occurs. -func (_q *TeamSkillQuery) FirstIDX(ctx context.Context) uuid.UUID { +func (_q *AgentSkillVersionQuery) FirstIDX(ctx context.Context) uuid.UUID { id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -154,10 +130,10 @@ func (_q *TeamSkillQuery) FirstIDX(ctx context.Context) uuid.UUID { return id } -// Only returns a single TeamSkill entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one TeamSkill entity is found. -// Returns a *NotFoundError when no TeamSkill entities are found. -func (_q *TeamSkillQuery) Only(ctx context.Context) (*TeamSkill, error) { +// Only returns a single AgentSkillVersion entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one AgentSkillVersion entity is found. +// Returns a *NotFoundError when no AgentSkillVersion entities are found. +func (_q *AgentSkillVersionQuery) Only(ctx context.Context) (*AgentSkillVersion, error) { nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err @@ -166,14 +142,14 @@ func (_q *TeamSkillQuery) Only(ctx context.Context) (*TeamSkill, error) { case 1: return nodes[0], nil case 0: - return nil, &NotFoundError{teamskill.Label} + return nil, &NotFoundError{agentskillversion.Label} default: - return nil, &NotSingularError{teamskill.Label} + return nil, &NotSingularError{agentskillversion.Label} } } // OnlyX is like Only, but panics if an error occurs. -func (_q *TeamSkillQuery) OnlyX(ctx context.Context) *TeamSkill { +func (_q *AgentSkillVersionQuery) OnlyX(ctx context.Context) *AgentSkillVersion { node, err := _q.Only(ctx) if err != nil { panic(err) @@ -181,10 +157,10 @@ func (_q *TeamSkillQuery) OnlyX(ctx context.Context) *TeamSkill { return node } -// OnlyID is like Only, but returns the only TeamSkill ID in the query. -// Returns a *NotSingularError when more than one TeamSkill ID is found. +// OnlyID is like Only, but returns the only AgentSkillVersion ID in the query. +// Returns a *NotSingularError when more than one AgentSkillVersion ID is found. // Returns a *NotFoundError when no entities are found. -func (_q *TeamSkillQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { +func (_q *AgentSkillVersionQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return @@ -193,15 +169,15 @@ func (_q *TeamSkillQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) case 1: id = ids[0] case 0: - err = &NotFoundError{teamskill.Label} + err = &NotFoundError{agentskillversion.Label} default: - err = &NotSingularError{teamskill.Label} + err = &NotSingularError{agentskillversion.Label} } return } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *TeamSkillQuery) OnlyIDX(ctx context.Context) uuid.UUID { +func (_q *AgentSkillVersionQuery) OnlyIDX(ctx context.Context) uuid.UUID { id, err := _q.OnlyID(ctx) if err != nil { panic(err) @@ -209,18 +185,18 @@ func (_q *TeamSkillQuery) OnlyIDX(ctx context.Context) uuid.UUID { return id } -// All executes the query and returns a list of TeamSkills. -func (_q *TeamSkillQuery) All(ctx context.Context) ([]*TeamSkill, error) { +// All executes the query and returns a list of AgentSkillVersions. +func (_q *AgentSkillVersionQuery) All(ctx context.Context) ([]*AgentSkillVersion, error) { ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) if err := _q.prepareQuery(ctx); err != nil { return nil, err } - qr := querierAll[[]*TeamSkill, *TeamSkillQuery]() - return withInterceptors[[]*TeamSkill](ctx, _q, qr, _q.inters) + qr := querierAll[[]*AgentSkillVersion, *AgentSkillVersionQuery]() + return withInterceptors[[]*AgentSkillVersion](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (_q *TeamSkillQuery) AllX(ctx context.Context) []*TeamSkill { +func (_q *AgentSkillVersionQuery) AllX(ctx context.Context) []*AgentSkillVersion { nodes, err := _q.All(ctx) if err != nil { panic(err) @@ -228,20 +204,20 @@ func (_q *TeamSkillQuery) AllX(ctx context.Context) []*TeamSkill { return nodes } -// IDs executes the query and returns a list of TeamSkill IDs. -func (_q *TeamSkillQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { +// IDs executes the query and returns a list of AgentSkillVersion IDs. +func (_q *AgentSkillVersionQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if _q.ctx.Unique == nil && _q.path != nil { _q.Unique(true) } ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(teamskill.FieldID).Scan(ctx, &ids); err != nil { + if err = _q.Select(agentskillversion.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (_q *TeamSkillQuery) IDsX(ctx context.Context) []uuid.UUID { +func (_q *AgentSkillVersionQuery) IDsX(ctx context.Context) []uuid.UUID { ids, err := _q.IDs(ctx) if err != nil { panic(err) @@ -250,16 +226,16 @@ func (_q *TeamSkillQuery) IDsX(ctx context.Context) []uuid.UUID { } // Count returns the count of the given query. -func (_q *TeamSkillQuery) Count(ctx context.Context) (int, error) { +func (_q *AgentSkillVersionQuery) Count(ctx context.Context) (int, error) { ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, _q, querierCount[*TeamSkillQuery](), _q.inters) + return withInterceptors[int](ctx, _q, querierCount[*AgentSkillVersionQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (_q *TeamSkillQuery) CountX(ctx context.Context) int { +func (_q *AgentSkillVersionQuery) CountX(ctx context.Context) int { count, err := _q.Count(ctx) if err != nil { panic(err) @@ -268,7 +244,7 @@ func (_q *TeamSkillQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (_q *TeamSkillQuery) Exist(ctx context.Context) (bool, error) { +func (_q *AgentSkillVersionQuery) Exist(ctx context.Context) (bool, error) { ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) switch _, err := _q.FirstID(ctx); { case IsNotFound(err): @@ -281,7 +257,7 @@ func (_q *TeamSkillQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (_q *TeamSkillQuery) ExistX(ctx context.Context) bool { +func (_q *AgentSkillVersionQuery) ExistX(ctx context.Context) bool { exist, err := _q.Exist(ctx) if err != nil { panic(err) @@ -289,19 +265,18 @@ func (_q *TeamSkillQuery) ExistX(ctx context.Context) bool { return exist } -// Clone returns a duplicate of the TeamSkillQuery builder, including all associated steps. It can be +// Clone returns a duplicate of the AgentSkillVersionQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (_q *TeamSkillQuery) Clone() *TeamSkillQuery { +func (_q *AgentSkillVersionQuery) Clone() *AgentSkillVersionQuery { if _q == nil { return nil } - return &TeamSkillQuery{ + return &AgentSkillVersionQuery{ config: _q.config, ctx: _q.ctx.Clone(), - order: append([]teamskill.OrderOption{}, _q.order...), + order: append([]agentskillversion.OrderOption{}, _q.order...), inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.TeamSkill{}, _q.predicates...), - withTeam: _q.withTeam.Clone(), + predicates: append([]predicate.AgentSkillVersion{}, _q.predicates...), withSkill: _q.withSkill.Clone(), // clone intermediate query. sql: _q.sql.Clone(), @@ -310,21 +285,10 @@ func (_q *TeamSkillQuery) Clone() *TeamSkillQuery { } } -// WithTeam tells the query-builder to eager-load the nodes that are connected to -// the "team" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *TeamSkillQuery) WithTeam(opts ...func(*TeamQuery)) *TeamSkillQuery { - query := (&TeamClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withTeam = query - return _q -} - // WithSkill tells the query-builder to eager-load the nodes that are connected to // the "skill" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *TeamSkillQuery) WithSkill(opts ...func(*SkillQuery)) *TeamSkillQuery { - query := (&SkillClient{config: _q.config}).Query() +func (_q *AgentSkillVersionQuery) WithSkill(opts ...func(*AgentSkillQuery)) *AgentSkillVersionQuery { + query := (&AgentSkillClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } @@ -338,19 +302,19 @@ func (_q *TeamSkillQuery) WithSkill(opts ...func(*SkillQuery)) *TeamSkillQuery { // Example: // // var v []struct { -// TeamID uuid.UUID `json:"team_id,omitempty"` +// ResourceID uuid.UUID `json:"resource_id,omitempty"` // Count int `json:"count,omitempty"` // } // -// client.TeamSkill.Query(). -// GroupBy(teamskill.FieldTeamID). +// client.AgentSkillVersion.Query(). +// GroupBy(agentskillversion.FieldResourceID). // Aggregate(db.Count()). // Scan(ctx, &v) -func (_q *TeamSkillQuery) GroupBy(field string, fields ...string) *TeamSkillGroupBy { +func (_q *AgentSkillVersionQuery) GroupBy(field string, fields ...string) *AgentSkillVersionGroupBy { _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &TeamSkillGroupBy{build: _q} + grbuild := &AgentSkillVersionGroupBy{build: _q} grbuild.flds = &_q.ctx.Fields - grbuild.label = teamskill.Label + grbuild.label = agentskillversion.Label grbuild.scan = grbuild.Scan return grbuild } @@ -361,26 +325,26 @@ func (_q *TeamSkillQuery) GroupBy(field string, fields ...string) *TeamSkillGrou // Example: // // var v []struct { -// TeamID uuid.UUID `json:"team_id,omitempty"` +// ResourceID uuid.UUID `json:"resource_id,omitempty"` // } // -// client.TeamSkill.Query(). -// Select(teamskill.FieldTeamID). +// client.AgentSkillVersion.Query(). +// Select(agentskillversion.FieldResourceID). // Scan(ctx, &v) -func (_q *TeamSkillQuery) Select(fields ...string) *TeamSkillSelect { +func (_q *AgentSkillVersionQuery) Select(fields ...string) *AgentSkillVersionSelect { _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &TeamSkillSelect{TeamSkillQuery: _q} - sbuild.label = teamskill.Label + sbuild := &AgentSkillVersionSelect{AgentSkillVersionQuery: _q} + sbuild.label = agentskillversion.Label sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } -// Aggregate returns a TeamSkillSelect configured with the given aggregations. -func (_q *TeamSkillQuery) Aggregate(fns ...AggregateFunc) *TeamSkillSelect { +// Aggregate returns a AgentSkillVersionSelect configured with the given aggregations. +func (_q *AgentSkillVersionQuery) Aggregate(fns ...AggregateFunc) *AgentSkillVersionSelect { return _q.Select().Aggregate(fns...) } -func (_q *TeamSkillQuery) prepareQuery(ctx context.Context) error { +func (_q *AgentSkillVersionQuery) prepareQuery(ctx context.Context) error { for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") @@ -392,7 +356,7 @@ func (_q *TeamSkillQuery) prepareQuery(ctx context.Context) error { } } for _, f := range _q.ctx.Fields { - if !teamskill.ValidColumn(f) { + if !agentskillversion.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} } } @@ -406,20 +370,19 @@ func (_q *TeamSkillQuery) prepareQuery(ctx context.Context) error { return nil } -func (_q *TeamSkillQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*TeamSkill, error) { +func (_q *AgentSkillVersionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AgentSkillVersion, error) { var ( - nodes = []*TeamSkill{} + nodes = []*AgentSkillVersion{} _spec = _q.querySpec() - loadedTypes = [2]bool{ - _q.withTeam != nil, + loadedTypes = [1]bool{ _q.withSkill != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { - return (*TeamSkill).scanValues(nil, columns) + return (*AgentSkillVersion).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &TeamSkill{config: _q.config} + node := &AgentSkillVersion{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) @@ -436,26 +399,20 @@ func (_q *TeamSkillQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Te if len(nodes) == 0 { return nodes, nil } - if query := _q.withTeam; query != nil { - if err := _q.loadTeam(ctx, query, nodes, nil, - func(n *TeamSkill, e *Team) { n.Edges.Team = e }); err != nil { - return nil, err - } - } if query := _q.withSkill; query != nil { if err := _q.loadSkill(ctx, query, nodes, nil, - func(n *TeamSkill, e *Skill) { n.Edges.Skill = e }); err != nil { + func(n *AgentSkillVersion, e *AgentSkill) { n.Edges.Skill = e }); err != nil { return nil, err } } return nodes, nil } -func (_q *TeamSkillQuery) loadTeam(ctx context.Context, query *TeamQuery, nodes []*TeamSkill, init func(*TeamSkill), assign func(*TeamSkill, *Team)) error { +func (_q *AgentSkillVersionQuery) loadSkill(ctx context.Context, query *AgentSkillQuery, nodes []*AgentSkillVersion, init func(*AgentSkillVersion), assign func(*AgentSkillVersion, *AgentSkill)) error { ids := make([]uuid.UUID, 0, len(nodes)) - nodeids := make(map[uuid.UUID][]*TeamSkill) + nodeids := make(map[uuid.UUID][]*AgentSkillVersion) for i := range nodes { - fk := nodes[i].TeamID + fk := nodes[i].ResourceID if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -464,7 +421,7 @@ func (_q *TeamSkillQuery) loadTeam(ctx context.Context, query *TeamQuery, nodes if len(ids) == 0 { return nil } - query.Where(team.IDIn(ids...)) + query.Where(agentskill.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { return err @@ -472,36 +429,7 @@ func (_q *TeamSkillQuery) loadTeam(ctx context.Context, query *TeamQuery, nodes for _, n := range neighbors { nodes, ok := nodeids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "team_id" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} -func (_q *TeamSkillQuery) loadSkill(ctx context.Context, query *SkillQuery, nodes []*TeamSkill, init func(*TeamSkill), assign func(*TeamSkill, *Skill)) error { - ids := make([]uuid.UUID, 0, len(nodes)) - nodeids := make(map[uuid.UUID][]*TeamSkill) - for i := range nodes { - fk := nodes[i].SkillID - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(skill.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "skill_id" returned %v`, n.ID) + return fmt.Errorf(`unexpected foreign-key "resource_id" returned %v`, n.ID) } for i := range nodes { assign(nodes[i], n) @@ -510,7 +438,7 @@ func (_q *TeamSkillQuery) loadSkill(ctx context.Context, query *SkillQuery, node return nil } -func (_q *TeamSkillQuery) sqlCount(ctx context.Context) (int, error) { +func (_q *AgentSkillVersionQuery) sqlCount(ctx context.Context) (int, error) { _spec := _q.querySpec() if len(_q.modifiers) > 0 { _spec.Modifiers = _q.modifiers @@ -522,8 +450,8 @@ func (_q *TeamSkillQuery) sqlCount(ctx context.Context) (int, error) { return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (_q *TeamSkillQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(teamskill.Table, teamskill.Columns, sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID)) +func (_q *AgentSkillVersionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(agentskillversion.Table, agentskillversion.Columns, sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID)) _spec.From = _q.sql if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique @@ -532,17 +460,14 @@ func (_q *TeamSkillQuery) querySpec() *sqlgraph.QuerySpec { } if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, teamskill.FieldID) + _spec.Node.Columns = append(_spec.Node.Columns, agentskillversion.FieldID) for i := range fields { - if fields[i] != teamskill.FieldID { + if fields[i] != agentskillversion.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if _q.withTeam != nil { - _spec.Node.AddColumnOnce(teamskill.FieldTeamID) - } if _q.withSkill != nil { - _spec.Node.AddColumnOnce(teamskill.FieldSkillID) + _spec.Node.AddColumnOnce(agentskillversion.FieldResourceID) } } if ps := _q.predicates; len(ps) > 0 { @@ -568,12 +493,12 @@ func (_q *TeamSkillQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (_q *TeamSkillQuery) sqlQuery(ctx context.Context) *sql.Selector { +func (_q *AgentSkillVersionQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(teamskill.Table) + t1 := builder.Table(agentskillversion.Table) columns := _q.ctx.Fields if len(columns) == 0 { - columns = teamskill.Columns + columns = agentskillversion.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) if _q.sql != nil { @@ -606,7 +531,7 @@ func (_q *TeamSkillQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (_q *TeamSkillQuery) ForUpdate(opts ...sql.LockOption) *TeamSkillQuery { +func (_q *AgentSkillVersionQuery) ForUpdate(opts ...sql.LockOption) *AgentSkillVersionQuery { if _q.driver.Dialect() == dialect.Postgres { _q.Unique(false) } @@ -619,7 +544,7 @@ func (_q *TeamSkillQuery) ForUpdate(opts ...sql.LockOption) *TeamSkillQuery { // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (_q *TeamSkillQuery) ForShare(opts ...sql.LockOption) *TeamSkillQuery { +func (_q *AgentSkillVersionQuery) ForShare(opts ...sql.LockOption) *AgentSkillVersionQuery { if _q.driver.Dialect() == dialect.Postgres { _q.Unique(false) } @@ -630,33 +555,33 @@ func (_q *TeamSkillQuery) ForShare(opts ...sql.LockOption) *TeamSkillQuery { } // Modify adds a query modifier for attaching custom logic to queries. -func (_q *TeamSkillQuery) Modify(modifiers ...func(s *sql.Selector)) *TeamSkillSelect { +func (_q *AgentSkillVersionQuery) Modify(modifiers ...func(s *sql.Selector)) *AgentSkillVersionSelect { _q.modifiers = append(_q.modifiers, modifiers...) return _q.Select() } -// TeamSkillGroupBy is the group-by builder for TeamSkill entities. -type TeamSkillGroupBy struct { +// AgentSkillVersionGroupBy is the group-by builder for AgentSkillVersion entities. +type AgentSkillVersionGroupBy struct { selector - build *TeamSkillQuery + build *AgentSkillVersionQuery } // Aggregate adds the given aggregation functions to the group-by query. -func (_g *TeamSkillGroupBy) Aggregate(fns ...AggregateFunc) *TeamSkillGroupBy { +func (_g *AgentSkillVersionGroupBy) Aggregate(fns ...AggregateFunc) *AgentSkillVersionGroupBy { _g.fns = append(_g.fns, fns...) return _g } // Scan applies the selector query and scans the result into the given value. -func (_g *TeamSkillGroupBy) Scan(ctx context.Context, v any) error { +func (_g *AgentSkillVersionGroupBy) Scan(ctx context.Context, v any) error { ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*TeamSkillQuery, *TeamSkillGroupBy](ctx, _g.build, _g, _g.build.inters, v) + return scanWithInterceptors[*AgentSkillVersionQuery, *AgentSkillVersionGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (_g *TeamSkillGroupBy) sqlScan(ctx context.Context, root *TeamSkillQuery, v any) error { +func (_g *AgentSkillVersionGroupBy) sqlScan(ctx context.Context, root *AgentSkillVersionQuery, v any) error { selector := root.sqlQuery(ctx).Select() aggregation := make([]string, 0, len(_g.fns)) for _, fn := range _g.fns { @@ -683,28 +608,28 @@ func (_g *TeamSkillGroupBy) sqlScan(ctx context.Context, root *TeamSkillQuery, v return sql.ScanSlice(rows, v) } -// TeamSkillSelect is the builder for selecting fields of TeamSkill entities. -type TeamSkillSelect struct { - *TeamSkillQuery +// AgentSkillVersionSelect is the builder for selecting fields of AgentSkillVersion entities. +type AgentSkillVersionSelect struct { + *AgentSkillVersionQuery selector } // Aggregate adds the given aggregation functions to the selector query. -func (_s *TeamSkillSelect) Aggregate(fns ...AggregateFunc) *TeamSkillSelect { +func (_s *AgentSkillVersionSelect) Aggregate(fns ...AggregateFunc) *AgentSkillVersionSelect { _s.fns = append(_s.fns, fns...) return _s } // Scan applies the selector query and scans the result into the given value. -func (_s *TeamSkillSelect) Scan(ctx context.Context, v any) error { +func (_s *AgentSkillVersionSelect) Scan(ctx context.Context, v any) error { ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*TeamSkillQuery, *TeamSkillSelect](ctx, _s.TeamSkillQuery, _s, _s.inters, v) + return scanWithInterceptors[*AgentSkillVersionQuery, *AgentSkillVersionSelect](ctx, _s.AgentSkillVersionQuery, _s, _s.inters, v) } -func (_s *TeamSkillSelect) sqlScan(ctx context.Context, root *TeamSkillQuery, v any) error { +func (_s *AgentSkillVersionSelect) sqlScan(ctx context.Context, root *AgentSkillVersionQuery, v any) error { selector := root.sqlQuery(ctx) aggregation := make([]string, 0, len(_s.fns)) for _, fn := range _s.fns { @@ -726,7 +651,7 @@ func (_s *TeamSkillSelect) sqlScan(ctx context.Context, root *TeamSkillQuery, v } // Modify adds a query modifier for attaching custom logic to queries. -func (_s *TeamSkillSelect) Modify(modifiers ...func(s *sql.Selector)) *TeamSkillSelect { +func (_s *AgentSkillVersionSelect) Modify(modifiers ...func(s *sql.Selector)) *AgentSkillVersionSelect { _s.modifiers = append(_s.modifiers, modifiers...) return _s } diff --git a/backend/db/agentskillversion_update.go b/backend/db/agentskillversion_update.go new file mode 100644 index 00000000..f92db7b3 --- /dev/null +++ b/backend/db/agentskillversion_update.go @@ -0,0 +1,511 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentSkillVersionUpdate is the builder for updating AgentSkillVersion entities. +type AgentSkillVersionUpdate struct { + config + hooks []Hook + mutation *AgentSkillVersionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the AgentSkillVersionUpdate builder. +func (_u *AgentSkillVersionUpdate) Where(ps ...predicate.AgentSkillVersion) *AgentSkillVersionUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetResourceID sets the "resource_id" field. +func (_u *AgentSkillVersionUpdate) SetResourceID(v uuid.UUID) *AgentSkillVersionUpdate { + _u.mutation.SetResourceID(v) + return _u +} + +// SetNillableResourceID sets the "resource_id" field if the given value is not nil. +func (_u *AgentSkillVersionUpdate) SetNillableResourceID(v *uuid.UUID) *AgentSkillVersionUpdate { + if v != nil { + _u.SetResourceID(*v) + } + return _u +} + +// SetVersion sets the "version" field. +func (_u *AgentSkillVersionUpdate) SetVersion(v string) *AgentSkillVersionUpdate { + _u.mutation.SetVersion(v) + return _u +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (_u *AgentSkillVersionUpdate) SetNillableVersion(v *string) *AgentSkillVersionUpdate { + if v != nil { + _u.SetVersion(*v) + } + return _u +} + +// SetS3Key sets the "s3_key" field. +func (_u *AgentSkillVersionUpdate) SetS3Key(v string) *AgentSkillVersionUpdate { + _u.mutation.SetS3Key(v) + return _u +} + +// SetNillableS3Key sets the "s3_key" field if the given value is not nil. +func (_u *AgentSkillVersionUpdate) SetNillableS3Key(v *string) *AgentSkillVersionUpdate { + if v != nil { + _u.SetS3Key(*v) + } + return _u +} + +// SetParsedMeta sets the "parsed_meta" field. +func (_u *AgentSkillVersionUpdate) SetParsedMeta(v types.SkillParsedMeta) *AgentSkillVersionUpdate { + _u.mutation.SetParsedMeta(v) + return _u +} + +// SetNillableParsedMeta sets the "parsed_meta" field if the given value is not nil. +func (_u *AgentSkillVersionUpdate) SetNillableParsedMeta(v *types.SkillParsedMeta) *AgentSkillVersionUpdate { + if v != nil { + _u.SetParsedMeta(*v) + } + return _u +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (_u *AgentSkillVersionUpdate) ClearParsedMeta() *AgentSkillVersionUpdate { + _u.mutation.ClearParsedMeta() + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentSkillVersionUpdate) SetCreatedAt(v time.Time) *AgentSkillVersionUpdate { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentSkillVersionUpdate) SetNillableCreatedAt(v *time.Time) *AgentSkillVersionUpdate { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetSkillID sets the "skill" edge to the AgentSkill entity by ID. +func (_u *AgentSkillVersionUpdate) SetSkillID(id uuid.UUID) *AgentSkillVersionUpdate { + _u.mutation.SetSkillID(id) + return _u +} + +// SetSkill sets the "skill" edge to the AgentSkill entity. +func (_u *AgentSkillVersionUpdate) SetSkill(v *AgentSkill) *AgentSkillVersionUpdate { + return _u.SetSkillID(v.ID) +} + +// Mutation returns the AgentSkillVersionMutation object of the builder. +func (_u *AgentSkillVersionUpdate) Mutation() *AgentSkillVersionMutation { + return _u.mutation +} + +// ClearSkill clears the "skill" edge to the AgentSkill entity. +func (_u *AgentSkillVersionUpdate) ClearSkill() *AgentSkillVersionUpdate { + _u.mutation.ClearSkill() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AgentSkillVersionUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentSkillVersionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AgentSkillVersionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentSkillVersionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentSkillVersionUpdate) check() error { + if v, ok := _u.mutation.Version(); ok { + if err := agentskillversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "AgentSkillVersion.version": %w`, err)} + } + } + if v, ok := _u.mutation.S3Key(); ok { + if err := agentskillversion.S3KeyValidator(v); err != nil { + return &ValidationError{Name: "s3_key", err: fmt.Errorf(`db: validator failed for field "AgentSkillVersion.s3_key": %w`, err)} + } + } + if _u.mutation.SkillCleared() && len(_u.mutation.SkillIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentSkillVersion.skill"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentSkillVersionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillVersionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentSkillVersionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentskillversion.Table, agentskillversion.Columns, sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Version(); ok { + _spec.SetField(agentskillversion.FieldVersion, field.TypeString, value) + } + if value, ok := _u.mutation.S3Key(); ok { + _spec.SetField(agentskillversion.FieldS3Key, field.TypeString, value) + } + if value, ok := _u.mutation.ParsedMeta(); ok { + _spec.SetField(agentskillversion.FieldParsedMeta, field.TypeJSON, value) + } + if _u.mutation.ParsedMetaCleared() { + _spec.ClearField(agentskillversion.FieldParsedMeta, field.TypeJSON) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentskillversion.FieldCreatedAt, field.TypeTime, value) + } + if _u.mutation.SkillCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentskillversion.SkillTable, + Columns: []string{agentskillversion.SkillColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.SkillIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentskillversion.SkillTable, + Columns: []string{agentskillversion.SkillColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentskillversion.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AgentSkillVersionUpdateOne is the builder for updating a single AgentSkillVersion entity. +type AgentSkillVersionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AgentSkillVersionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetResourceID sets the "resource_id" field. +func (_u *AgentSkillVersionUpdateOne) SetResourceID(v uuid.UUID) *AgentSkillVersionUpdateOne { + _u.mutation.SetResourceID(v) + return _u +} + +// SetNillableResourceID sets the "resource_id" field if the given value is not nil. +func (_u *AgentSkillVersionUpdateOne) SetNillableResourceID(v *uuid.UUID) *AgentSkillVersionUpdateOne { + if v != nil { + _u.SetResourceID(*v) + } + return _u +} + +// SetVersion sets the "version" field. +func (_u *AgentSkillVersionUpdateOne) SetVersion(v string) *AgentSkillVersionUpdateOne { + _u.mutation.SetVersion(v) + return _u +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (_u *AgentSkillVersionUpdateOne) SetNillableVersion(v *string) *AgentSkillVersionUpdateOne { + if v != nil { + _u.SetVersion(*v) + } + return _u +} + +// SetS3Key sets the "s3_key" field. +func (_u *AgentSkillVersionUpdateOne) SetS3Key(v string) *AgentSkillVersionUpdateOne { + _u.mutation.SetS3Key(v) + return _u +} + +// SetNillableS3Key sets the "s3_key" field if the given value is not nil. +func (_u *AgentSkillVersionUpdateOne) SetNillableS3Key(v *string) *AgentSkillVersionUpdateOne { + if v != nil { + _u.SetS3Key(*v) + } + return _u +} + +// SetParsedMeta sets the "parsed_meta" field. +func (_u *AgentSkillVersionUpdateOne) SetParsedMeta(v types.SkillParsedMeta) *AgentSkillVersionUpdateOne { + _u.mutation.SetParsedMeta(v) + return _u +} + +// SetNillableParsedMeta sets the "parsed_meta" field if the given value is not nil. +func (_u *AgentSkillVersionUpdateOne) SetNillableParsedMeta(v *types.SkillParsedMeta) *AgentSkillVersionUpdateOne { + if v != nil { + _u.SetParsedMeta(*v) + } + return _u +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (_u *AgentSkillVersionUpdateOne) ClearParsedMeta() *AgentSkillVersionUpdateOne { + _u.mutation.ClearParsedMeta() + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentSkillVersionUpdateOne) SetCreatedAt(v time.Time) *AgentSkillVersionUpdateOne { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentSkillVersionUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentSkillVersionUpdateOne { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetSkillID sets the "skill" edge to the AgentSkill entity by ID. +func (_u *AgentSkillVersionUpdateOne) SetSkillID(id uuid.UUID) *AgentSkillVersionUpdateOne { + _u.mutation.SetSkillID(id) + return _u +} + +// SetSkill sets the "skill" edge to the AgentSkill entity. +func (_u *AgentSkillVersionUpdateOne) SetSkill(v *AgentSkill) *AgentSkillVersionUpdateOne { + return _u.SetSkillID(v.ID) +} + +// Mutation returns the AgentSkillVersionMutation object of the builder. +func (_u *AgentSkillVersionUpdateOne) Mutation() *AgentSkillVersionMutation { + return _u.mutation +} + +// ClearSkill clears the "skill" edge to the AgentSkill entity. +func (_u *AgentSkillVersionUpdateOne) ClearSkill() *AgentSkillVersionUpdateOne { + _u.mutation.ClearSkill() + return _u +} + +// Where appends a list predicates to the AgentSkillVersionUpdate builder. +func (_u *AgentSkillVersionUpdateOne) Where(ps ...predicate.AgentSkillVersion) *AgentSkillVersionUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *AgentSkillVersionUpdateOne) Select(field string, fields ...string) *AgentSkillVersionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated AgentSkillVersion entity. +func (_u *AgentSkillVersionUpdateOne) Save(ctx context.Context) (*AgentSkillVersion, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentSkillVersionUpdateOne) SaveX(ctx context.Context) *AgentSkillVersion { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AgentSkillVersionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentSkillVersionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentSkillVersionUpdateOne) check() error { + if v, ok := _u.mutation.Version(); ok { + if err := agentskillversion.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "AgentSkillVersion.version": %w`, err)} + } + } + if v, ok := _u.mutation.S3Key(); ok { + if err := agentskillversion.S3KeyValidator(v); err != nil { + return &ValidationError{Name: "s3_key", err: fmt.Errorf(`db: validator failed for field "AgentSkillVersion.s3_key": %w`, err)} + } + } + if _u.mutation.SkillCleared() && len(_u.mutation.SkillIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "AgentSkillVersion.skill"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentSkillVersionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSkillVersionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentSkillVersionUpdateOne) sqlSave(ctx context.Context) (_node *AgentSkillVersion, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentskillversion.Table, agentskillversion.Columns, sqlgraph.NewFieldSpec(agentskillversion.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentSkillVersion.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentskillversion.FieldID) + for _, f := range fields { + if !agentskillversion.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != agentskillversion.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.Version(); ok { + _spec.SetField(agentskillversion.FieldVersion, field.TypeString, value) + } + if value, ok := _u.mutation.S3Key(); ok { + _spec.SetField(agentskillversion.FieldS3Key, field.TypeString, value) + } + if value, ok := _u.mutation.ParsedMeta(); ok { + _spec.SetField(agentskillversion.FieldParsedMeta, field.TypeJSON, value) + } + if _u.mutation.ParsedMetaCleared() { + _spec.ClearField(agentskillversion.FieldParsedMeta, field.TypeJSON) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentskillversion.FieldCreatedAt, field.TypeTime, value) + } + if _u.mutation.SkillCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentskillversion.SkillTable, + Columns: []string{agentskillversion.SkillColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.SkillIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: agentskillversion.SkillTable, + Columns: []string{agentskillversion.SkillColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(agentskill.FieldID, field.TypeUUID), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &AgentSkillVersion{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentskillversion.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/db/agentsyncjob.go b/backend/db/agentsyncjob.go new file mode 100644 index 00000000..3858bd91 --- /dev/null +++ b/backend/db/agentsyncjob.go @@ -0,0 +1,264 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/chaitin/MonkeyCode/backend/db/agentsyncjob" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentSyncJob is the model entity for the AgentSyncJob schema. +type AgentSyncJob struct { + config `json:"-"` + // ID of the ent. + ID uuid.UUID `json:"id,omitempty"` + // ResourceKind holds the value of the "resource_kind" field. + ResourceKind agentsyncjob.ResourceKind `json:"resource_kind,omitempty"` + // RuleID holds the value of the "rule_id" field. + RuleID *uuid.UUID `json:"rule_id,omitempty"` + // RepoID holds the value of the "repo_id" field. + RepoID *uuid.UUID `json:"repo_id,omitempty"` + // SourceType holds the value of the "source_type" field. + SourceType agentsyncjob.SourceType `json:"source_type,omitempty"` + // Status holds the value of the "status" field. + Status agentsyncjob.Status `json:"status,omitempty"` + // TriggerType holds the value of the "trigger_type" field. + TriggerType agentsyncjob.TriggerType `json:"trigger_type,omitempty"` + // TriggeredBy holds the value of the "triggered_by" field. + TriggeredBy *uuid.UUID `json:"triggered_by,omitempty"` + // StartedAt holds the value of the "started_at" field. + StartedAt *time.Time `json:"started_at,omitempty"` + // FinishedAt holds the value of the "finished_at" field. + FinishedAt *time.Time `json:"finished_at,omitempty"` + // Errors holds the value of the "errors" field. + Errors types.SyncJobErrors `json:"errors,omitempty"` + // ResultSummary holds the value of the "result_summary" field. + ResultSummary types.SyncJobResultSummary `json:"result_summary,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*AgentSyncJob) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case agentsyncjob.FieldRuleID, agentsyncjob.FieldRepoID, agentsyncjob.FieldTriggeredBy: + values[i] = &sql.NullScanner{S: new(uuid.UUID)} + case agentsyncjob.FieldErrors, agentsyncjob.FieldResultSummary: + values[i] = new([]byte) + case agentsyncjob.FieldResourceKind, agentsyncjob.FieldSourceType, agentsyncjob.FieldStatus, agentsyncjob.FieldTriggerType: + values[i] = new(sql.NullString) + case agentsyncjob.FieldStartedAt, agentsyncjob.FieldFinishedAt, agentsyncjob.FieldCreatedAt, agentsyncjob.FieldUpdatedAt: + values[i] = new(sql.NullTime) + case agentsyncjob.FieldID: + values[i] = new(uuid.UUID) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the AgentSyncJob fields. +func (_m *AgentSyncJob) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case agentsyncjob.FieldID: + if value, ok := values[i].(*uuid.UUID); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value != nil { + _m.ID = *value + } + case agentsyncjob.FieldResourceKind: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field resource_kind", values[i]) + } else if value.Valid { + _m.ResourceKind = agentsyncjob.ResourceKind(value.String) + } + case agentsyncjob.FieldRuleID: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field rule_id", values[i]) + } else if value.Valid { + _m.RuleID = new(uuid.UUID) + *_m.RuleID = *value.S.(*uuid.UUID) + } + case agentsyncjob.FieldRepoID: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field repo_id", values[i]) + } else if value.Valid { + _m.RepoID = new(uuid.UUID) + *_m.RepoID = *value.S.(*uuid.UUID) + } + case agentsyncjob.FieldSourceType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field source_type", values[i]) + } else if value.Valid { + _m.SourceType = agentsyncjob.SourceType(value.String) + } + case agentsyncjob.FieldStatus: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = agentsyncjob.Status(value.String) + } + case agentsyncjob.FieldTriggerType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field trigger_type", values[i]) + } else if value.Valid { + _m.TriggerType = agentsyncjob.TriggerType(value.String) + } + case agentsyncjob.FieldTriggeredBy: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field triggered_by", values[i]) + } else if value.Valid { + _m.TriggeredBy = new(uuid.UUID) + *_m.TriggeredBy = *value.S.(*uuid.UUID) + } + case agentsyncjob.FieldStartedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field started_at", values[i]) + } else if value.Valid { + _m.StartedAt = new(time.Time) + *_m.StartedAt = value.Time + } + case agentsyncjob.FieldFinishedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field finished_at", values[i]) + } else if value.Valid { + _m.FinishedAt = new(time.Time) + *_m.FinishedAt = value.Time + } + case agentsyncjob.FieldErrors: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field errors", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.Errors); err != nil { + return fmt.Errorf("unmarshal field errors: %w", err) + } + } + case agentsyncjob.FieldResultSummary: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field result_summary", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.ResultSummary); err != nil { + return fmt.Errorf("unmarshal field result_summary: %w", err) + } + } + case agentsyncjob.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case agentsyncjob.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the AgentSyncJob. +// This includes values selected through modifiers, order, etc. +func (_m *AgentSyncJob) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this AgentSyncJob. +// Note that you need to call AgentSyncJob.Unwrap() before calling this method if this AgentSyncJob +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *AgentSyncJob) Update() *AgentSyncJobUpdateOne { + return NewAgentSyncJobClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the AgentSyncJob entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *AgentSyncJob) Unwrap() *AgentSyncJob { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("db: AgentSyncJob is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *AgentSyncJob) String() string { + var builder strings.Builder + builder.WriteString("AgentSyncJob(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("resource_kind=") + builder.WriteString(fmt.Sprintf("%v", _m.ResourceKind)) + builder.WriteString(", ") + if v := _m.RuleID; v != nil { + builder.WriteString("rule_id=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + if v := _m.RepoID; v != nil { + builder.WriteString("repo_id=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + builder.WriteString("source_type=") + builder.WriteString(fmt.Sprintf("%v", _m.SourceType)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("trigger_type=") + builder.WriteString(fmt.Sprintf("%v", _m.TriggerType)) + builder.WriteString(", ") + if v := _m.TriggeredBy; v != nil { + builder.WriteString("triggered_by=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + if v := _m.StartedAt; v != nil { + builder.WriteString("started_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + if v := _m.FinishedAt; v != nil { + builder.WriteString("finished_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("errors=") + builder.WriteString(fmt.Sprintf("%v", _m.Errors)) + builder.WriteString(", ") + builder.WriteString("result_summary=") + builder.WriteString(fmt.Sprintf("%v", _m.ResultSummary)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// AgentSyncJobs is a parsable slice of AgentSyncJob. +type AgentSyncJobs []*AgentSyncJob diff --git a/backend/db/agentsyncjob/agentsyncjob.go b/backend/db/agentsyncjob/agentsyncjob.go new file mode 100644 index 00000000..731c8bad --- /dev/null +++ b/backend/db/agentsyncjob/agentsyncjob.go @@ -0,0 +1,251 @@ +// Code generated by ent, DO NOT EDIT. + +package agentsyncjob + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "github.com/google/uuid" +) + +const ( + // Label holds the string label denoting the agentsyncjob type in the database. + Label = "agent_sync_job" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldResourceKind holds the string denoting the resource_kind field in the database. + FieldResourceKind = "resource_kind" + // FieldRuleID holds the string denoting the rule_id field in the database. + FieldRuleID = "rule_id" + // FieldRepoID holds the string denoting the repo_id field in the database. + FieldRepoID = "repo_id" + // FieldSourceType holds the string denoting the source_type field in the database. + FieldSourceType = "source_type" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTriggerType holds the string denoting the trigger_type field in the database. + FieldTriggerType = "trigger_type" + // FieldTriggeredBy holds the string denoting the triggered_by field in the database. + FieldTriggeredBy = "triggered_by" + // FieldStartedAt holds the string denoting the started_at field in the database. + FieldStartedAt = "started_at" + // FieldFinishedAt holds the string denoting the finished_at field in the database. + FieldFinishedAt = "finished_at" + // FieldErrors holds the string denoting the errors field in the database. + FieldErrors = "errors" + // FieldResultSummary holds the string denoting the result_summary field in the database. + FieldResultSummary = "result_summary" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // Table holds the table name of the agentsyncjob in the database. + Table = "agent_sync_jobs" +) + +// Columns holds all SQL columns for agentsyncjob fields. +var Columns = []string{ + FieldID, + FieldResourceKind, + FieldRuleID, + FieldRepoID, + FieldSourceType, + FieldStatus, + FieldTriggerType, + FieldTriggeredBy, + FieldStartedAt, + FieldFinishedAt, + FieldErrors, + FieldResultSummary, + FieldCreatedAt, + FieldUpdatedAt, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() uuid.UUID +) + +// ResourceKind defines the type for the "resource_kind" enum field. +type ResourceKind string + +// ResourceKind values. +const ( + ResourceKindRule ResourceKind = "rule" + ResourceKindSkill ResourceKind = "skill" + ResourceKindPlugin ResourceKind = "plugin" +) + +func (rk ResourceKind) String() string { + return string(rk) +} + +// ResourceKindValidator is a validator for the "resource_kind" field enum values. It is called by the builders before save. +func ResourceKindValidator(rk ResourceKind) error { + switch rk { + case ResourceKindRule, ResourceKindSkill, ResourceKindPlugin: + return nil + default: + return fmt.Errorf("agentsyncjob: invalid enum value for resource_kind field: %q", rk) + } +} + +// SourceType defines the type for the "source_type" enum field. +type SourceType string + +// SourceType values. +const ( + SourceTypeGithub SourceType = "github" + SourceTypeUpload SourceType = "upload" + SourceTypeNpm SourceType = "npm" + SourceTypeRuleInline SourceType = "rule_inline" +) + +func (st SourceType) String() string { + return string(st) +} + +// SourceTypeValidator is a validator for the "source_type" field enum values. It is called by the builders before save. +func SourceTypeValidator(st SourceType) error { + switch st { + case SourceTypeGithub, SourceTypeUpload, SourceTypeNpm, SourceTypeRuleInline: + return nil + default: + return fmt.Errorf("agentsyncjob: invalid enum value for source_type field: %q", st) + } +} + +// Status defines the type for the "status" enum field. +type Status string + +// StatusPending is the default value of the Status enum. +const DefaultStatus = StatusPending + +// Status values. +const ( + StatusPending Status = "pending" + StatusFetching Status = "fetching" + StatusParsing Status = "parsing" + StatusUploading Status = "uploading" + StatusDone Status = "done" + StatusFailed Status = "failed" +) + +func (s Status) String() string { + return string(s) +} + +// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. +func StatusValidator(s Status) error { + switch s { + case StatusPending, StatusFetching, StatusParsing, StatusUploading, StatusDone, StatusFailed: + return nil + default: + return fmt.Errorf("agentsyncjob: invalid enum value for status field: %q", s) + } +} + +// TriggerType defines the type for the "trigger_type" enum field. +type TriggerType string + +// TriggerType values. +const ( + TriggerTypeManual TriggerType = "manual" + TriggerTypeUpload TriggerType = "upload" + TriggerTypeRuleSave TriggerType = "rule_save" +) + +func (tt TriggerType) String() string { + return string(tt) +} + +// TriggerTypeValidator is a validator for the "trigger_type" field enum values. It is called by the builders before save. +func TriggerTypeValidator(tt TriggerType) error { + switch tt { + case TriggerTypeManual, TriggerTypeUpload, TriggerTypeRuleSave: + return nil + default: + return fmt.Errorf("agentsyncjob: invalid enum value for trigger_type field: %q", tt) + } +} + +// OrderOption defines the ordering options for the AgentSyncJob queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByResourceKind orders the results by the resource_kind field. +func ByResourceKind(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldResourceKind, opts...).ToFunc() +} + +// ByRuleID orders the results by the rule_id field. +func ByRuleID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRuleID, opts...).ToFunc() +} + +// ByRepoID orders the results by the repo_id field. +func ByRepoID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRepoID, opts...).ToFunc() +} + +// BySourceType orders the results by the source_type field. +func BySourceType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSourceType, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTriggerType orders the results by the trigger_type field. +func ByTriggerType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTriggerType, opts...).ToFunc() +} + +// ByTriggeredBy orders the results by the triggered_by field. +func ByTriggeredBy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTriggeredBy, opts...).ToFunc() +} + +// ByStartedAt orders the results by the started_at field. +func ByStartedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStartedAt, opts...).ToFunc() +} + +// ByFinishedAt orders the results by the finished_at field. +func ByFinishedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFinishedAt, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} diff --git a/backend/db/agentsyncjob/where.go b/backend/db/agentsyncjob/where.go new file mode 100644 index 00000000..069e4f11 --- /dev/null +++ b/backend/db/agentsyncjob/where.go @@ -0,0 +1,536 @@ +// Code generated by ent, DO NOT EDIT. + +package agentsyncjob + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// ID filters vertices based on their ID field. +func ID(id uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLTE(FieldID, id)) +} + +// RuleID applies equality check predicate on the "rule_id" field. It's identical to RuleIDEQ. +func RuleID(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldRuleID, v)) +} + +// RepoID applies equality check predicate on the "repo_id" field. It's identical to RepoIDEQ. +func RepoID(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldRepoID, v)) +} + +// TriggeredBy applies equality check predicate on the "triggered_by" field. It's identical to TriggeredByEQ. +func TriggeredBy(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldTriggeredBy, v)) +} + +// StartedAt applies equality check predicate on the "started_at" field. It's identical to StartedAtEQ. +func StartedAt(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldStartedAt, v)) +} + +// FinishedAt applies equality check predicate on the "finished_at" field. It's identical to FinishedAtEQ. +func FinishedAt(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldFinishedAt, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// ResourceKindEQ applies the EQ predicate on the "resource_kind" field. +func ResourceKindEQ(v ResourceKind) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldResourceKind, v)) +} + +// ResourceKindNEQ applies the NEQ predicate on the "resource_kind" field. +func ResourceKindNEQ(v ResourceKind) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldResourceKind, v)) +} + +// ResourceKindIn applies the In predicate on the "resource_kind" field. +func ResourceKindIn(vs ...ResourceKind) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldResourceKind, vs...)) +} + +// ResourceKindNotIn applies the NotIn predicate on the "resource_kind" field. +func ResourceKindNotIn(vs ...ResourceKind) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldResourceKind, vs...)) +} + +// RuleIDEQ applies the EQ predicate on the "rule_id" field. +func RuleIDEQ(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldRuleID, v)) +} + +// RuleIDNEQ applies the NEQ predicate on the "rule_id" field. +func RuleIDNEQ(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldRuleID, v)) +} + +// RuleIDIn applies the In predicate on the "rule_id" field. +func RuleIDIn(vs ...uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldRuleID, vs...)) +} + +// RuleIDNotIn applies the NotIn predicate on the "rule_id" field. +func RuleIDNotIn(vs ...uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldRuleID, vs...)) +} + +// RuleIDGT applies the GT predicate on the "rule_id" field. +func RuleIDGT(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGT(FieldRuleID, v)) +} + +// RuleIDGTE applies the GTE predicate on the "rule_id" field. +func RuleIDGTE(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGTE(FieldRuleID, v)) +} + +// RuleIDLT applies the LT predicate on the "rule_id" field. +func RuleIDLT(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLT(FieldRuleID, v)) +} + +// RuleIDLTE applies the LTE predicate on the "rule_id" field. +func RuleIDLTE(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLTE(FieldRuleID, v)) +} + +// RuleIDIsNil applies the IsNil predicate on the "rule_id" field. +func RuleIDIsNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIsNull(FieldRuleID)) +} + +// RuleIDNotNil applies the NotNil predicate on the "rule_id" field. +func RuleIDNotNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotNull(FieldRuleID)) +} + +// RepoIDEQ applies the EQ predicate on the "repo_id" field. +func RepoIDEQ(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldRepoID, v)) +} + +// RepoIDNEQ applies the NEQ predicate on the "repo_id" field. +func RepoIDNEQ(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldRepoID, v)) +} + +// RepoIDIn applies the In predicate on the "repo_id" field. +func RepoIDIn(vs ...uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldRepoID, vs...)) +} + +// RepoIDNotIn applies the NotIn predicate on the "repo_id" field. +func RepoIDNotIn(vs ...uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldRepoID, vs...)) +} + +// RepoIDGT applies the GT predicate on the "repo_id" field. +func RepoIDGT(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGT(FieldRepoID, v)) +} + +// RepoIDGTE applies the GTE predicate on the "repo_id" field. +func RepoIDGTE(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGTE(FieldRepoID, v)) +} + +// RepoIDLT applies the LT predicate on the "repo_id" field. +func RepoIDLT(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLT(FieldRepoID, v)) +} + +// RepoIDLTE applies the LTE predicate on the "repo_id" field. +func RepoIDLTE(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLTE(FieldRepoID, v)) +} + +// RepoIDIsNil applies the IsNil predicate on the "repo_id" field. +func RepoIDIsNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIsNull(FieldRepoID)) +} + +// RepoIDNotNil applies the NotNil predicate on the "repo_id" field. +func RepoIDNotNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotNull(FieldRepoID)) +} + +// SourceTypeEQ applies the EQ predicate on the "source_type" field. +func SourceTypeEQ(v SourceType) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldSourceType, v)) +} + +// SourceTypeNEQ applies the NEQ predicate on the "source_type" field. +func SourceTypeNEQ(v SourceType) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldSourceType, v)) +} + +// SourceTypeIn applies the In predicate on the "source_type" field. +func SourceTypeIn(vs ...SourceType) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldSourceType, vs...)) +} + +// SourceTypeNotIn applies the NotIn predicate on the "source_type" field. +func SourceTypeNotIn(vs ...SourceType) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldSourceType, vs...)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v Status) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v Status) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...Status) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...Status) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldStatus, vs...)) +} + +// TriggerTypeEQ applies the EQ predicate on the "trigger_type" field. +func TriggerTypeEQ(v TriggerType) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldTriggerType, v)) +} + +// TriggerTypeNEQ applies the NEQ predicate on the "trigger_type" field. +func TriggerTypeNEQ(v TriggerType) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldTriggerType, v)) +} + +// TriggerTypeIn applies the In predicate on the "trigger_type" field. +func TriggerTypeIn(vs ...TriggerType) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldTriggerType, vs...)) +} + +// TriggerTypeNotIn applies the NotIn predicate on the "trigger_type" field. +func TriggerTypeNotIn(vs ...TriggerType) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldTriggerType, vs...)) +} + +// TriggeredByEQ applies the EQ predicate on the "triggered_by" field. +func TriggeredByEQ(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldTriggeredBy, v)) +} + +// TriggeredByNEQ applies the NEQ predicate on the "triggered_by" field. +func TriggeredByNEQ(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldTriggeredBy, v)) +} + +// TriggeredByIn applies the In predicate on the "triggered_by" field. +func TriggeredByIn(vs ...uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldTriggeredBy, vs...)) +} + +// TriggeredByNotIn applies the NotIn predicate on the "triggered_by" field. +func TriggeredByNotIn(vs ...uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldTriggeredBy, vs...)) +} + +// TriggeredByGT applies the GT predicate on the "triggered_by" field. +func TriggeredByGT(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGT(FieldTriggeredBy, v)) +} + +// TriggeredByGTE applies the GTE predicate on the "triggered_by" field. +func TriggeredByGTE(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGTE(FieldTriggeredBy, v)) +} + +// TriggeredByLT applies the LT predicate on the "triggered_by" field. +func TriggeredByLT(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLT(FieldTriggeredBy, v)) +} + +// TriggeredByLTE applies the LTE predicate on the "triggered_by" field. +func TriggeredByLTE(v uuid.UUID) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLTE(FieldTriggeredBy, v)) +} + +// TriggeredByIsNil applies the IsNil predicate on the "triggered_by" field. +func TriggeredByIsNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIsNull(FieldTriggeredBy)) +} + +// TriggeredByNotNil applies the NotNil predicate on the "triggered_by" field. +func TriggeredByNotNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotNull(FieldTriggeredBy)) +} + +// StartedAtEQ applies the EQ predicate on the "started_at" field. +func StartedAtEQ(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldStartedAt, v)) +} + +// StartedAtNEQ applies the NEQ predicate on the "started_at" field. +func StartedAtNEQ(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldStartedAt, v)) +} + +// StartedAtIn applies the In predicate on the "started_at" field. +func StartedAtIn(vs ...time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldStartedAt, vs...)) +} + +// StartedAtNotIn applies the NotIn predicate on the "started_at" field. +func StartedAtNotIn(vs ...time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldStartedAt, vs...)) +} + +// StartedAtGT applies the GT predicate on the "started_at" field. +func StartedAtGT(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGT(FieldStartedAt, v)) +} + +// StartedAtGTE applies the GTE predicate on the "started_at" field. +func StartedAtGTE(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGTE(FieldStartedAt, v)) +} + +// StartedAtLT applies the LT predicate on the "started_at" field. +func StartedAtLT(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLT(FieldStartedAt, v)) +} + +// StartedAtLTE applies the LTE predicate on the "started_at" field. +func StartedAtLTE(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLTE(FieldStartedAt, v)) +} + +// StartedAtIsNil applies the IsNil predicate on the "started_at" field. +func StartedAtIsNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIsNull(FieldStartedAt)) +} + +// StartedAtNotNil applies the NotNil predicate on the "started_at" field. +func StartedAtNotNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotNull(FieldStartedAt)) +} + +// FinishedAtEQ applies the EQ predicate on the "finished_at" field. +func FinishedAtEQ(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldFinishedAt, v)) +} + +// FinishedAtNEQ applies the NEQ predicate on the "finished_at" field. +func FinishedAtNEQ(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldFinishedAt, v)) +} + +// FinishedAtIn applies the In predicate on the "finished_at" field. +func FinishedAtIn(vs ...time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldFinishedAt, vs...)) +} + +// FinishedAtNotIn applies the NotIn predicate on the "finished_at" field. +func FinishedAtNotIn(vs ...time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldFinishedAt, vs...)) +} + +// FinishedAtGT applies the GT predicate on the "finished_at" field. +func FinishedAtGT(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGT(FieldFinishedAt, v)) +} + +// FinishedAtGTE applies the GTE predicate on the "finished_at" field. +func FinishedAtGTE(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGTE(FieldFinishedAt, v)) +} + +// FinishedAtLT applies the LT predicate on the "finished_at" field. +func FinishedAtLT(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLT(FieldFinishedAt, v)) +} + +// FinishedAtLTE applies the LTE predicate on the "finished_at" field. +func FinishedAtLTE(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLTE(FieldFinishedAt, v)) +} + +// FinishedAtIsNil applies the IsNil predicate on the "finished_at" field. +func FinishedAtIsNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIsNull(FieldFinishedAt)) +} + +// FinishedAtNotNil applies the NotNil predicate on the "finished_at" field. +func FinishedAtNotNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotNull(FieldFinishedAt)) +} + +// ErrorsIsNil applies the IsNil predicate on the "errors" field. +func ErrorsIsNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIsNull(FieldErrors)) +} + +// ErrorsNotNil applies the NotNil predicate on the "errors" field. +func ErrorsNotNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotNull(FieldErrors)) +} + +// ResultSummaryIsNil applies the IsNil predicate on the "result_summary" field. +func ResultSummaryIsNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIsNull(FieldResultSummary)) +} + +// ResultSummaryNotNil applies the NotNil predicate on the "result_summary" field. +func ResultSummaryNotNil() predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotNull(FieldResultSummary)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.AgentSyncJob) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.AgentSyncJob) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.AgentSyncJob) predicate.AgentSyncJob { + return predicate.AgentSyncJob(sql.NotPredicates(p)) +} diff --git a/backend/db/agentsyncjob_create.go b/backend/db/agentsyncjob_create.go new file mode 100644 index 00000000..b549a72a --- /dev/null +++ b/backend/db/agentsyncjob_create.go @@ -0,0 +1,1369 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentsyncjob" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentSyncJobCreate is the builder for creating a AgentSyncJob entity. +type AgentSyncJobCreate struct { + config + mutation *AgentSyncJobMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetResourceKind sets the "resource_kind" field. +func (_c *AgentSyncJobCreate) SetResourceKind(v agentsyncjob.ResourceKind) *AgentSyncJobCreate { + _c.mutation.SetResourceKind(v) + return _c +} + +// SetRuleID sets the "rule_id" field. +func (_c *AgentSyncJobCreate) SetRuleID(v uuid.UUID) *AgentSyncJobCreate { + _c.mutation.SetRuleID(v) + return _c +} + +// SetNillableRuleID sets the "rule_id" field if the given value is not nil. +func (_c *AgentSyncJobCreate) SetNillableRuleID(v *uuid.UUID) *AgentSyncJobCreate { + if v != nil { + _c.SetRuleID(*v) + } + return _c +} + +// SetRepoID sets the "repo_id" field. +func (_c *AgentSyncJobCreate) SetRepoID(v uuid.UUID) *AgentSyncJobCreate { + _c.mutation.SetRepoID(v) + return _c +} + +// SetNillableRepoID sets the "repo_id" field if the given value is not nil. +func (_c *AgentSyncJobCreate) SetNillableRepoID(v *uuid.UUID) *AgentSyncJobCreate { + if v != nil { + _c.SetRepoID(*v) + } + return _c +} + +// SetSourceType sets the "source_type" field. +func (_c *AgentSyncJobCreate) SetSourceType(v agentsyncjob.SourceType) *AgentSyncJobCreate { + _c.mutation.SetSourceType(v) + return _c +} + +// SetStatus sets the "status" field. +func (_c *AgentSyncJobCreate) SetStatus(v agentsyncjob.Status) *AgentSyncJobCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *AgentSyncJobCreate) SetNillableStatus(v *agentsyncjob.Status) *AgentSyncJobCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTriggerType sets the "trigger_type" field. +func (_c *AgentSyncJobCreate) SetTriggerType(v agentsyncjob.TriggerType) *AgentSyncJobCreate { + _c.mutation.SetTriggerType(v) + return _c +} + +// SetTriggeredBy sets the "triggered_by" field. +func (_c *AgentSyncJobCreate) SetTriggeredBy(v uuid.UUID) *AgentSyncJobCreate { + _c.mutation.SetTriggeredBy(v) + return _c +} + +// SetNillableTriggeredBy sets the "triggered_by" field if the given value is not nil. +func (_c *AgentSyncJobCreate) SetNillableTriggeredBy(v *uuid.UUID) *AgentSyncJobCreate { + if v != nil { + _c.SetTriggeredBy(*v) + } + return _c +} + +// SetStartedAt sets the "started_at" field. +func (_c *AgentSyncJobCreate) SetStartedAt(v time.Time) *AgentSyncJobCreate { + _c.mutation.SetStartedAt(v) + return _c +} + +// SetNillableStartedAt sets the "started_at" field if the given value is not nil. +func (_c *AgentSyncJobCreate) SetNillableStartedAt(v *time.Time) *AgentSyncJobCreate { + if v != nil { + _c.SetStartedAt(*v) + } + return _c +} + +// SetFinishedAt sets the "finished_at" field. +func (_c *AgentSyncJobCreate) SetFinishedAt(v time.Time) *AgentSyncJobCreate { + _c.mutation.SetFinishedAt(v) + return _c +} + +// SetNillableFinishedAt sets the "finished_at" field if the given value is not nil. +func (_c *AgentSyncJobCreate) SetNillableFinishedAt(v *time.Time) *AgentSyncJobCreate { + if v != nil { + _c.SetFinishedAt(*v) + } + return _c +} + +// SetErrors sets the "errors" field. +func (_c *AgentSyncJobCreate) SetErrors(v types.SyncJobErrors) *AgentSyncJobCreate { + _c.mutation.SetErrors(v) + return _c +} + +// SetResultSummary sets the "result_summary" field. +func (_c *AgentSyncJobCreate) SetResultSummary(v types.SyncJobResultSummary) *AgentSyncJobCreate { + _c.mutation.SetResultSummary(v) + return _c +} + +// SetNillableResultSummary sets the "result_summary" field if the given value is not nil. +func (_c *AgentSyncJobCreate) SetNillableResultSummary(v *types.SyncJobResultSummary) *AgentSyncJobCreate { + if v != nil { + _c.SetResultSummary(*v) + } + return _c +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AgentSyncJobCreate) SetCreatedAt(v time.Time) *AgentSyncJobCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AgentSyncJobCreate) SetNillableCreatedAt(v *time.Time) *AgentSyncJobCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *AgentSyncJobCreate) SetUpdatedAt(v time.Time) *AgentSyncJobCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *AgentSyncJobCreate) SetNillableUpdatedAt(v *time.Time) *AgentSyncJobCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AgentSyncJobCreate) SetID(v uuid.UUID) *AgentSyncJobCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *AgentSyncJobCreate) SetNillableID(v *uuid.UUID) *AgentSyncJobCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// Mutation returns the AgentSyncJobMutation object of the builder. +func (_c *AgentSyncJobCreate) Mutation() *AgentSyncJobMutation { + return _c.mutation +} + +// Save creates the AgentSyncJob in the database. +func (_c *AgentSyncJobCreate) Save(ctx context.Context) (*AgentSyncJob, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AgentSyncJobCreate) SaveX(ctx context.Context) *AgentSyncJob { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentSyncJobCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentSyncJobCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AgentSyncJobCreate) defaults() { + if _, ok := _c.mutation.Status(); !ok { + v := agentsyncjob.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.CreatedAt(); !ok { + v := agentsyncjob.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := agentsyncjob.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := agentsyncjob.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AgentSyncJobCreate) check() error { + if _, ok := _c.mutation.ResourceKind(); !ok { + return &ValidationError{Name: "resource_kind", err: errors.New(`db: missing required field "AgentSyncJob.resource_kind"`)} + } + if v, ok := _c.mutation.ResourceKind(); ok { + if err := agentsyncjob.ResourceKindValidator(v); err != nil { + return &ValidationError{Name: "resource_kind", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.resource_kind": %w`, err)} + } + } + if _, ok := _c.mutation.SourceType(); !ok { + return &ValidationError{Name: "source_type", err: errors.New(`db: missing required field "AgentSyncJob.source_type"`)} + } + if v, ok := _c.mutation.SourceType(); ok { + if err := agentsyncjob.SourceTypeValidator(v); err != nil { + return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.source_type": %w`, err)} + } + } + if _, ok := _c.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`db: missing required field "AgentSyncJob.status"`)} + } + if v, ok := _c.mutation.Status(); ok { + if err := agentsyncjob.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.status": %w`, err)} + } + } + if _, ok := _c.mutation.TriggerType(); !ok { + return &ValidationError{Name: "trigger_type", err: errors.New(`db: missing required field "AgentSyncJob.trigger_type"`)} + } + if v, ok := _c.mutation.TriggerType(); ok { + if err := agentsyncjob.TriggerTypeValidator(v); err != nil { + return &ValidationError{Name: "trigger_type", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.trigger_type": %w`, err)} + } + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "AgentSyncJob.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "AgentSyncJob.updated_at"`)} + } + return nil +} + +func (_c *AgentSyncJobCreate) sqlSave(ctx context.Context) (*AgentSyncJob, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(*uuid.UUID); ok { + _node.ID = *id + } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { + return nil, err + } + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AgentSyncJobCreate) createSpec() (*AgentSyncJob, *sqlgraph.CreateSpec) { + var ( + _node = &AgentSyncJob{config: _c.config} + _spec = sqlgraph.NewCreateSpec(agentsyncjob.Table, sqlgraph.NewFieldSpec(agentsyncjob.FieldID, field.TypeUUID)) + ) + _spec.OnConflict = _c.conflict + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = &id + } + if value, ok := _c.mutation.ResourceKind(); ok { + _spec.SetField(agentsyncjob.FieldResourceKind, field.TypeEnum, value) + _node.ResourceKind = value + } + if value, ok := _c.mutation.RuleID(); ok { + _spec.SetField(agentsyncjob.FieldRuleID, field.TypeUUID, value) + _node.RuleID = &value + } + if value, ok := _c.mutation.RepoID(); ok { + _spec.SetField(agentsyncjob.FieldRepoID, field.TypeUUID, value) + _node.RepoID = &value + } + if value, ok := _c.mutation.SourceType(); ok { + _spec.SetField(agentsyncjob.FieldSourceType, field.TypeEnum, value) + _node.SourceType = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(agentsyncjob.FieldStatus, field.TypeEnum, value) + _node.Status = value + } + if value, ok := _c.mutation.TriggerType(); ok { + _spec.SetField(agentsyncjob.FieldTriggerType, field.TypeEnum, value) + _node.TriggerType = value + } + if value, ok := _c.mutation.TriggeredBy(); ok { + _spec.SetField(agentsyncjob.FieldTriggeredBy, field.TypeUUID, value) + _node.TriggeredBy = &value + } + if value, ok := _c.mutation.StartedAt(); ok { + _spec.SetField(agentsyncjob.FieldStartedAt, field.TypeTime, value) + _node.StartedAt = &value + } + if value, ok := _c.mutation.FinishedAt(); ok { + _spec.SetField(agentsyncjob.FieldFinishedAt, field.TypeTime, value) + _node.FinishedAt = &value + } + if value, ok := _c.mutation.Errors(); ok { + _spec.SetField(agentsyncjob.FieldErrors, field.TypeJSON, value) + _node.Errors = value + } + if value, ok := _c.mutation.ResultSummary(); ok { + _spec.SetField(agentsyncjob.FieldResultSummary, field.TypeJSON, value) + _node.ResultSummary = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(agentsyncjob.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(agentsyncjob.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentSyncJob.Create(). +// SetResourceKind(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentSyncJobUpsert) { +// SetResourceKind(v+v). +// }). +// Exec(ctx) +func (_c *AgentSyncJobCreate) OnConflict(opts ...sql.ConflictOption) *AgentSyncJobUpsertOne { + _c.conflict = opts + return &AgentSyncJobUpsertOne{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentSyncJob.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentSyncJobCreate) OnConflictColumns(columns ...string) *AgentSyncJobUpsertOne { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentSyncJobUpsertOne{ + create: _c, + } +} + +type ( + // AgentSyncJobUpsertOne is the builder for "upsert"-ing + // one AgentSyncJob node. + AgentSyncJobUpsertOne struct { + create *AgentSyncJobCreate + } + + // AgentSyncJobUpsert is the "OnConflict" setter. + AgentSyncJobUpsert struct { + *sql.UpdateSet + } +) + +// SetResourceKind sets the "resource_kind" field. +func (u *AgentSyncJobUpsert) SetResourceKind(v agentsyncjob.ResourceKind) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldResourceKind, v) + return u +} + +// UpdateResourceKind sets the "resource_kind" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateResourceKind() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldResourceKind) + return u +} + +// SetRuleID sets the "rule_id" field. +func (u *AgentSyncJobUpsert) SetRuleID(v uuid.UUID) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldRuleID, v) + return u +} + +// UpdateRuleID sets the "rule_id" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateRuleID() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldRuleID) + return u +} + +// ClearRuleID clears the value of the "rule_id" field. +func (u *AgentSyncJobUpsert) ClearRuleID() *AgentSyncJobUpsert { + u.SetNull(agentsyncjob.FieldRuleID) + return u +} + +// SetRepoID sets the "repo_id" field. +func (u *AgentSyncJobUpsert) SetRepoID(v uuid.UUID) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldRepoID, v) + return u +} + +// UpdateRepoID sets the "repo_id" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateRepoID() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldRepoID) + return u +} + +// ClearRepoID clears the value of the "repo_id" field. +func (u *AgentSyncJobUpsert) ClearRepoID() *AgentSyncJobUpsert { + u.SetNull(agentsyncjob.FieldRepoID) + return u +} + +// SetSourceType sets the "source_type" field. +func (u *AgentSyncJobUpsert) SetSourceType(v agentsyncjob.SourceType) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldSourceType, v) + return u +} + +// UpdateSourceType sets the "source_type" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateSourceType() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldSourceType) + return u +} + +// SetStatus sets the "status" field. +func (u *AgentSyncJobUpsert) SetStatus(v agentsyncjob.Status) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldStatus, v) + return u +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateStatus() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldStatus) + return u +} + +// SetTriggerType sets the "trigger_type" field. +func (u *AgentSyncJobUpsert) SetTriggerType(v agentsyncjob.TriggerType) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldTriggerType, v) + return u +} + +// UpdateTriggerType sets the "trigger_type" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateTriggerType() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldTriggerType) + return u +} + +// SetTriggeredBy sets the "triggered_by" field. +func (u *AgentSyncJobUpsert) SetTriggeredBy(v uuid.UUID) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldTriggeredBy, v) + return u +} + +// UpdateTriggeredBy sets the "triggered_by" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateTriggeredBy() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldTriggeredBy) + return u +} + +// ClearTriggeredBy clears the value of the "triggered_by" field. +func (u *AgentSyncJobUpsert) ClearTriggeredBy() *AgentSyncJobUpsert { + u.SetNull(agentsyncjob.FieldTriggeredBy) + return u +} + +// SetStartedAt sets the "started_at" field. +func (u *AgentSyncJobUpsert) SetStartedAt(v time.Time) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldStartedAt, v) + return u +} + +// UpdateStartedAt sets the "started_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateStartedAt() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldStartedAt) + return u +} + +// ClearStartedAt clears the value of the "started_at" field. +func (u *AgentSyncJobUpsert) ClearStartedAt() *AgentSyncJobUpsert { + u.SetNull(agentsyncjob.FieldStartedAt) + return u +} + +// SetFinishedAt sets the "finished_at" field. +func (u *AgentSyncJobUpsert) SetFinishedAt(v time.Time) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldFinishedAt, v) + return u +} + +// UpdateFinishedAt sets the "finished_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateFinishedAt() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldFinishedAt) + return u +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (u *AgentSyncJobUpsert) ClearFinishedAt() *AgentSyncJobUpsert { + u.SetNull(agentsyncjob.FieldFinishedAt) + return u +} + +// SetErrors sets the "errors" field. +func (u *AgentSyncJobUpsert) SetErrors(v types.SyncJobErrors) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldErrors, v) + return u +} + +// UpdateErrors sets the "errors" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateErrors() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldErrors) + return u +} + +// ClearErrors clears the value of the "errors" field. +func (u *AgentSyncJobUpsert) ClearErrors() *AgentSyncJobUpsert { + u.SetNull(agentsyncjob.FieldErrors) + return u +} + +// SetResultSummary sets the "result_summary" field. +func (u *AgentSyncJobUpsert) SetResultSummary(v types.SyncJobResultSummary) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldResultSummary, v) + return u +} + +// UpdateResultSummary sets the "result_summary" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateResultSummary() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldResultSummary) + return u +} + +// ClearResultSummary clears the value of the "result_summary" field. +func (u *AgentSyncJobUpsert) ClearResultSummary() *AgentSyncJobUpsert { + u.SetNull(agentsyncjob.FieldResultSummary) + return u +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSyncJobUpsert) SetCreatedAt(v time.Time) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldCreatedAt, v) + return u +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateCreatedAt() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldCreatedAt) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentSyncJobUpsert) SetUpdatedAt(v time.Time) *AgentSyncJobUpsert { + u.Set(agentsyncjob.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsert) UpdateUpdatedAt() *AgentSyncJobUpsert { + u.SetExcluded(agentsyncjob.FieldUpdatedAt) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.AgentSyncJob.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentsyncjob.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentSyncJobUpsertOne) UpdateNewValues() *AgentSyncJobUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(agentsyncjob.FieldID) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentSyncJob.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentSyncJobUpsertOne) Ignore() *AgentSyncJobUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentSyncJobUpsertOne) DoNothing() *AgentSyncJobUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentSyncJobCreate.OnConflict +// documentation for more info. +func (u *AgentSyncJobUpsertOne) Update(set func(*AgentSyncJobUpsert)) *AgentSyncJobUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentSyncJobUpsert{UpdateSet: update}) + })) + return u +} + +// SetResourceKind sets the "resource_kind" field. +func (u *AgentSyncJobUpsertOne) SetResourceKind(v agentsyncjob.ResourceKind) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetResourceKind(v) + }) +} + +// UpdateResourceKind sets the "resource_kind" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateResourceKind() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateResourceKind() + }) +} + +// SetRuleID sets the "rule_id" field. +func (u *AgentSyncJobUpsertOne) SetRuleID(v uuid.UUID) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetRuleID(v) + }) +} + +// UpdateRuleID sets the "rule_id" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateRuleID() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateRuleID() + }) +} + +// ClearRuleID clears the value of the "rule_id" field. +func (u *AgentSyncJobUpsertOne) ClearRuleID() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearRuleID() + }) +} + +// SetRepoID sets the "repo_id" field. +func (u *AgentSyncJobUpsertOne) SetRepoID(v uuid.UUID) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetRepoID(v) + }) +} + +// UpdateRepoID sets the "repo_id" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateRepoID() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateRepoID() + }) +} + +// ClearRepoID clears the value of the "repo_id" field. +func (u *AgentSyncJobUpsertOne) ClearRepoID() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearRepoID() + }) +} + +// SetSourceType sets the "source_type" field. +func (u *AgentSyncJobUpsertOne) SetSourceType(v agentsyncjob.SourceType) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetSourceType(v) + }) +} + +// UpdateSourceType sets the "source_type" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateSourceType() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateSourceType() + }) +} + +// SetStatus sets the "status" field. +func (u *AgentSyncJobUpsertOne) SetStatus(v agentsyncjob.Status) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetStatus(v) + }) +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateStatus() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateStatus() + }) +} + +// SetTriggerType sets the "trigger_type" field. +func (u *AgentSyncJobUpsertOne) SetTriggerType(v agentsyncjob.TriggerType) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetTriggerType(v) + }) +} + +// UpdateTriggerType sets the "trigger_type" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateTriggerType() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateTriggerType() + }) +} + +// SetTriggeredBy sets the "triggered_by" field. +func (u *AgentSyncJobUpsertOne) SetTriggeredBy(v uuid.UUID) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetTriggeredBy(v) + }) +} + +// UpdateTriggeredBy sets the "triggered_by" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateTriggeredBy() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateTriggeredBy() + }) +} + +// ClearTriggeredBy clears the value of the "triggered_by" field. +func (u *AgentSyncJobUpsertOne) ClearTriggeredBy() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearTriggeredBy() + }) +} + +// SetStartedAt sets the "started_at" field. +func (u *AgentSyncJobUpsertOne) SetStartedAt(v time.Time) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetStartedAt(v) + }) +} + +// UpdateStartedAt sets the "started_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateStartedAt() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateStartedAt() + }) +} + +// ClearStartedAt clears the value of the "started_at" field. +func (u *AgentSyncJobUpsertOne) ClearStartedAt() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearStartedAt() + }) +} + +// SetFinishedAt sets the "finished_at" field. +func (u *AgentSyncJobUpsertOne) SetFinishedAt(v time.Time) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetFinishedAt(v) + }) +} + +// UpdateFinishedAt sets the "finished_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateFinishedAt() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateFinishedAt() + }) +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (u *AgentSyncJobUpsertOne) ClearFinishedAt() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearFinishedAt() + }) +} + +// SetErrors sets the "errors" field. +func (u *AgentSyncJobUpsertOne) SetErrors(v types.SyncJobErrors) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetErrors(v) + }) +} + +// UpdateErrors sets the "errors" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateErrors() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateErrors() + }) +} + +// ClearErrors clears the value of the "errors" field. +func (u *AgentSyncJobUpsertOne) ClearErrors() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearErrors() + }) +} + +// SetResultSummary sets the "result_summary" field. +func (u *AgentSyncJobUpsertOne) SetResultSummary(v types.SyncJobResultSummary) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetResultSummary(v) + }) +} + +// UpdateResultSummary sets the "result_summary" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateResultSummary() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateResultSummary() + }) +} + +// ClearResultSummary clears the value of the "result_summary" field. +func (u *AgentSyncJobUpsertOne) ClearResultSummary() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearResultSummary() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSyncJobUpsertOne) SetCreatedAt(v time.Time) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateCreatedAt() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentSyncJobUpsertOne) SetUpdatedAt(v time.Time) *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsertOne) UpdateUpdatedAt() *AgentSyncJobUpsertOne { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentSyncJobUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentSyncJobCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentSyncJobUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *AgentSyncJobUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: AgentSyncJobUpsertOne.ID is not supported by MySQL driver. Use AgentSyncJobUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *AgentSyncJobUpsertOne) IDX(ctx context.Context) uuid.UUID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// AgentSyncJobCreateBulk is the builder for creating many AgentSyncJob entities in bulk. +type AgentSyncJobCreateBulk struct { + config + err error + builders []*AgentSyncJobCreate + conflict []sql.ConflictOption +} + +// Save creates the AgentSyncJob entities in the database. +func (_c *AgentSyncJobCreateBulk) Save(ctx context.Context) ([]*AgentSyncJob, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*AgentSyncJob, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AgentSyncJobMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = _c.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AgentSyncJobCreateBulk) SaveX(ctx context.Context) []*AgentSyncJob { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AgentSyncJobCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AgentSyncJobCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.AgentSyncJob.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.AgentSyncJobUpsert) { +// SetResourceKind(v+v). +// }). +// Exec(ctx) +func (_c *AgentSyncJobCreateBulk) OnConflict(opts ...sql.ConflictOption) *AgentSyncJobUpsertBulk { + _c.conflict = opts + return &AgentSyncJobUpsertBulk{ + create: _c, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.AgentSyncJob.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (_c *AgentSyncJobCreateBulk) OnConflictColumns(columns ...string) *AgentSyncJobUpsertBulk { + _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) + return &AgentSyncJobUpsertBulk{ + create: _c, + } +} + +// AgentSyncJobUpsertBulk is the builder for "upsert"-ing +// a bulk of AgentSyncJob nodes. +type AgentSyncJobUpsertBulk struct { + create *AgentSyncJobCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.AgentSyncJob.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(agentsyncjob.FieldID) +// }), +// ). +// Exec(ctx) +func (u *AgentSyncJobUpsertBulk) UpdateNewValues() *AgentSyncJobUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(agentsyncjob.FieldID) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.AgentSyncJob.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *AgentSyncJobUpsertBulk) Ignore() *AgentSyncJobUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *AgentSyncJobUpsertBulk) DoNothing() *AgentSyncJobUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the AgentSyncJobCreateBulk.OnConflict +// documentation for more info. +func (u *AgentSyncJobUpsertBulk) Update(set func(*AgentSyncJobUpsert)) *AgentSyncJobUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&AgentSyncJobUpsert{UpdateSet: update}) + })) + return u +} + +// SetResourceKind sets the "resource_kind" field. +func (u *AgentSyncJobUpsertBulk) SetResourceKind(v agentsyncjob.ResourceKind) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetResourceKind(v) + }) +} + +// UpdateResourceKind sets the "resource_kind" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateResourceKind() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateResourceKind() + }) +} + +// SetRuleID sets the "rule_id" field. +func (u *AgentSyncJobUpsertBulk) SetRuleID(v uuid.UUID) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetRuleID(v) + }) +} + +// UpdateRuleID sets the "rule_id" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateRuleID() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateRuleID() + }) +} + +// ClearRuleID clears the value of the "rule_id" field. +func (u *AgentSyncJobUpsertBulk) ClearRuleID() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearRuleID() + }) +} + +// SetRepoID sets the "repo_id" field. +func (u *AgentSyncJobUpsertBulk) SetRepoID(v uuid.UUID) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetRepoID(v) + }) +} + +// UpdateRepoID sets the "repo_id" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateRepoID() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateRepoID() + }) +} + +// ClearRepoID clears the value of the "repo_id" field. +func (u *AgentSyncJobUpsertBulk) ClearRepoID() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearRepoID() + }) +} + +// SetSourceType sets the "source_type" field. +func (u *AgentSyncJobUpsertBulk) SetSourceType(v agentsyncjob.SourceType) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetSourceType(v) + }) +} + +// UpdateSourceType sets the "source_type" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateSourceType() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateSourceType() + }) +} + +// SetStatus sets the "status" field. +func (u *AgentSyncJobUpsertBulk) SetStatus(v agentsyncjob.Status) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetStatus(v) + }) +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateStatus() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateStatus() + }) +} + +// SetTriggerType sets the "trigger_type" field. +func (u *AgentSyncJobUpsertBulk) SetTriggerType(v agentsyncjob.TriggerType) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetTriggerType(v) + }) +} + +// UpdateTriggerType sets the "trigger_type" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateTriggerType() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateTriggerType() + }) +} + +// SetTriggeredBy sets the "triggered_by" field. +func (u *AgentSyncJobUpsertBulk) SetTriggeredBy(v uuid.UUID) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetTriggeredBy(v) + }) +} + +// UpdateTriggeredBy sets the "triggered_by" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateTriggeredBy() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateTriggeredBy() + }) +} + +// ClearTriggeredBy clears the value of the "triggered_by" field. +func (u *AgentSyncJobUpsertBulk) ClearTriggeredBy() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearTriggeredBy() + }) +} + +// SetStartedAt sets the "started_at" field. +func (u *AgentSyncJobUpsertBulk) SetStartedAt(v time.Time) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetStartedAt(v) + }) +} + +// UpdateStartedAt sets the "started_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateStartedAt() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateStartedAt() + }) +} + +// ClearStartedAt clears the value of the "started_at" field. +func (u *AgentSyncJobUpsertBulk) ClearStartedAt() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearStartedAt() + }) +} + +// SetFinishedAt sets the "finished_at" field. +func (u *AgentSyncJobUpsertBulk) SetFinishedAt(v time.Time) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetFinishedAt(v) + }) +} + +// UpdateFinishedAt sets the "finished_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateFinishedAt() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateFinishedAt() + }) +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (u *AgentSyncJobUpsertBulk) ClearFinishedAt() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearFinishedAt() + }) +} + +// SetErrors sets the "errors" field. +func (u *AgentSyncJobUpsertBulk) SetErrors(v types.SyncJobErrors) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetErrors(v) + }) +} + +// UpdateErrors sets the "errors" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateErrors() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateErrors() + }) +} + +// ClearErrors clears the value of the "errors" field. +func (u *AgentSyncJobUpsertBulk) ClearErrors() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearErrors() + }) +} + +// SetResultSummary sets the "result_summary" field. +func (u *AgentSyncJobUpsertBulk) SetResultSummary(v types.SyncJobResultSummary) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetResultSummary(v) + }) +} + +// UpdateResultSummary sets the "result_summary" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateResultSummary() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateResultSummary() + }) +} + +// ClearResultSummary clears the value of the "result_summary" field. +func (u *AgentSyncJobUpsertBulk) ClearResultSummary() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.ClearResultSummary() + }) +} + +// SetCreatedAt sets the "created_at" field. +func (u *AgentSyncJobUpsertBulk) SetCreatedAt(v time.Time) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetCreatedAt(v) + }) +} + +// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateCreatedAt() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateCreatedAt() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *AgentSyncJobUpsertBulk) SetUpdatedAt(v time.Time) *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *AgentSyncJobUpsertBulk) UpdateUpdatedAt() *AgentSyncJobUpsertBulk { + return u.Update(func(s *AgentSyncJobUpsert) { + s.UpdateUpdatedAt() + }) +} + +// Exec executes the query. +func (u *AgentSyncJobUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the AgentSyncJobCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for AgentSyncJobCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *AgentSyncJobUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentsyncjob_delete.go b/backend/db/agentsyncjob_delete.go new file mode 100644 index 00000000..ea87a907 --- /dev/null +++ b/backend/db/agentsyncjob_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentsyncjob" + "github.com/chaitin/MonkeyCode/backend/db/predicate" +) + +// AgentSyncJobDelete is the builder for deleting a AgentSyncJob entity. +type AgentSyncJobDelete struct { + config + hooks []Hook + mutation *AgentSyncJobMutation +} + +// Where appends a list predicates to the AgentSyncJobDelete builder. +func (_d *AgentSyncJobDelete) Where(ps ...predicate.AgentSyncJob) *AgentSyncJobDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *AgentSyncJobDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentSyncJobDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *AgentSyncJobDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(agentsyncjob.Table, sqlgraph.NewFieldSpec(agentsyncjob.FieldID, field.TypeUUID)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// AgentSyncJobDeleteOne is the builder for deleting a single AgentSyncJob entity. +type AgentSyncJobDeleteOne struct { + _d *AgentSyncJobDelete +} + +// Where appends a list predicates to the AgentSyncJobDelete builder. +func (_d *AgentSyncJobDeleteOne) Where(ps ...predicate.AgentSyncJob) *AgentSyncJobDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *AgentSyncJobDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{agentsyncjob.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AgentSyncJobDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/backend/db/agentsyncjob_query.go b/backend/db/agentsyncjob_query.go new file mode 100644 index 00000000..7b2d5d01 --- /dev/null +++ b/backend/db/agentsyncjob_query.go @@ -0,0 +1,578 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentsyncjob" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/google/uuid" +) + +// AgentSyncJobQuery is the builder for querying AgentSyncJob entities. +type AgentSyncJobQuery struct { + config + ctx *QueryContext + order []agentsyncjob.OrderOption + inters []Interceptor + predicates []predicate.AgentSyncJob + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the AgentSyncJobQuery builder. +func (_q *AgentSyncJobQuery) Where(ps ...predicate.AgentSyncJob) *AgentSyncJobQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *AgentSyncJobQuery) Limit(limit int) *AgentSyncJobQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *AgentSyncJobQuery) Offset(offset int) *AgentSyncJobQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *AgentSyncJobQuery) Unique(unique bool) *AgentSyncJobQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *AgentSyncJobQuery) Order(o ...agentsyncjob.OrderOption) *AgentSyncJobQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first AgentSyncJob entity from the query. +// Returns a *NotFoundError when no AgentSyncJob was found. +func (_q *AgentSyncJobQuery) First(ctx context.Context) (*AgentSyncJob, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{agentsyncjob.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *AgentSyncJobQuery) FirstX(ctx context.Context) *AgentSyncJob { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first AgentSyncJob ID from the query. +// Returns a *NotFoundError when no AgentSyncJob ID was found. +func (_q *AgentSyncJobQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{agentsyncjob.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *AgentSyncJobQuery) FirstIDX(ctx context.Context) uuid.UUID { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single AgentSyncJob entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one AgentSyncJob entity is found. +// Returns a *NotFoundError when no AgentSyncJob entities are found. +func (_q *AgentSyncJobQuery) Only(ctx context.Context) (*AgentSyncJob, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{agentsyncjob.Label} + default: + return nil, &NotSingularError{agentsyncjob.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *AgentSyncJobQuery) OnlyX(ctx context.Context) *AgentSyncJob { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only AgentSyncJob ID in the query. +// Returns a *NotSingularError when more than one AgentSyncJob ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *AgentSyncJobQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { + var ids []uuid.UUID + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{agentsyncjob.Label} + default: + err = &NotSingularError{agentsyncjob.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *AgentSyncJobQuery) OnlyIDX(ctx context.Context) uuid.UUID { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of AgentSyncJobs. +func (_q *AgentSyncJobQuery) All(ctx context.Context) ([]*AgentSyncJob, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*AgentSyncJob, *AgentSyncJobQuery]() + return withInterceptors[[]*AgentSyncJob](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *AgentSyncJobQuery) AllX(ctx context.Context) []*AgentSyncJob { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of AgentSyncJob IDs. +func (_q *AgentSyncJobQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(agentsyncjob.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *AgentSyncJobQuery) IDsX(ctx context.Context) []uuid.UUID { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *AgentSyncJobQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*AgentSyncJobQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *AgentSyncJobQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *AgentSyncJobQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *AgentSyncJobQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AgentSyncJobQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *AgentSyncJobQuery) Clone() *AgentSyncJobQuery { + if _q == nil { + return nil + } + return &AgentSyncJobQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]agentsyncjob.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.AgentSyncJob{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// ResourceKind agentsyncjob.ResourceKind `json:"resource_kind,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.AgentSyncJob.Query(). +// GroupBy(agentsyncjob.FieldResourceKind). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (_q *AgentSyncJobQuery) GroupBy(field string, fields ...string) *AgentSyncJobGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &AgentSyncJobGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = agentsyncjob.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// ResourceKind agentsyncjob.ResourceKind `json:"resource_kind,omitempty"` +// } +// +// client.AgentSyncJob.Query(). +// Select(agentsyncjob.FieldResourceKind). +// Scan(ctx, &v) +func (_q *AgentSyncJobQuery) Select(fields ...string) *AgentSyncJobSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &AgentSyncJobSelect{AgentSyncJobQuery: _q} + sbuild.label = agentsyncjob.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AgentSyncJobSelect configured with the given aggregations. +func (_q *AgentSyncJobQuery) Aggregate(fns ...AggregateFunc) *AgentSyncJobSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *AgentSyncJobQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !agentsyncjob.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *AgentSyncJobQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AgentSyncJob, error) { + var ( + nodes = []*AgentSyncJob{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*AgentSyncJob).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &AgentSyncJob{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *AgentSyncJobQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *AgentSyncJobQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(agentsyncjob.Table, agentsyncjob.Columns, sqlgraph.NewFieldSpec(agentsyncjob.FieldID, field.TypeUUID)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentsyncjob.FieldID) + for i := range fields { + if fields[i] != agentsyncjob.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *AgentSyncJobQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(agentsyncjob.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = agentsyncjob.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *AgentSyncJobQuery) ForUpdate(opts ...sql.LockOption) *AgentSyncJobQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *AgentSyncJobQuery) ForShare(opts ...sql.LockOption) *AgentSyncJobQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *AgentSyncJobQuery) Modify(modifiers ...func(s *sql.Selector)) *AgentSyncJobSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// AgentSyncJobGroupBy is the group-by builder for AgentSyncJob entities. +type AgentSyncJobGroupBy struct { + selector + build *AgentSyncJobQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *AgentSyncJobGroupBy) Aggregate(fns ...AggregateFunc) *AgentSyncJobGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *AgentSyncJobGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentSyncJobQuery, *AgentSyncJobGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *AgentSyncJobGroupBy) sqlScan(ctx context.Context, root *AgentSyncJobQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// AgentSyncJobSelect is the builder for selecting fields of AgentSyncJob entities. +type AgentSyncJobSelect struct { + *AgentSyncJobQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *AgentSyncJobSelect) Aggregate(fns ...AggregateFunc) *AgentSyncJobSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *AgentSyncJobSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*AgentSyncJobQuery, *AgentSyncJobSelect](ctx, _s.AgentSyncJobQuery, _s, _s.inters, v) +} + +func (_s *AgentSyncJobSelect) sqlScan(ctx context.Context, root *AgentSyncJobQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *AgentSyncJobSelect) Modify(modifiers ...func(s *sql.Selector)) *AgentSyncJobSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/backend/db/agentsyncjob_update.go b/backend/db/agentsyncjob_update.go new file mode 100644 index 00000000..70591f35 --- /dev/null +++ b/backend/db/agentsyncjob_update.go @@ -0,0 +1,827 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/dialect/sql/sqljson" + "entgo.io/ent/schema/field" + "github.com/chaitin/MonkeyCode/backend/db/agentsyncjob" + "github.com/chaitin/MonkeyCode/backend/db/predicate" + "github.com/chaitin/MonkeyCode/backend/ent/types" + "github.com/google/uuid" +) + +// AgentSyncJobUpdate is the builder for updating AgentSyncJob entities. +type AgentSyncJobUpdate struct { + config + hooks []Hook + mutation *AgentSyncJobMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the AgentSyncJobUpdate builder. +func (_u *AgentSyncJobUpdate) Where(ps ...predicate.AgentSyncJob) *AgentSyncJobUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetResourceKind sets the "resource_kind" field. +func (_u *AgentSyncJobUpdate) SetResourceKind(v agentsyncjob.ResourceKind) *AgentSyncJobUpdate { + _u.mutation.SetResourceKind(v) + return _u +} + +// SetNillableResourceKind sets the "resource_kind" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableResourceKind(v *agentsyncjob.ResourceKind) *AgentSyncJobUpdate { + if v != nil { + _u.SetResourceKind(*v) + } + return _u +} + +// SetRuleID sets the "rule_id" field. +func (_u *AgentSyncJobUpdate) SetRuleID(v uuid.UUID) *AgentSyncJobUpdate { + _u.mutation.SetRuleID(v) + return _u +} + +// SetNillableRuleID sets the "rule_id" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableRuleID(v *uuid.UUID) *AgentSyncJobUpdate { + if v != nil { + _u.SetRuleID(*v) + } + return _u +} + +// ClearRuleID clears the value of the "rule_id" field. +func (_u *AgentSyncJobUpdate) ClearRuleID() *AgentSyncJobUpdate { + _u.mutation.ClearRuleID() + return _u +} + +// SetRepoID sets the "repo_id" field. +func (_u *AgentSyncJobUpdate) SetRepoID(v uuid.UUID) *AgentSyncJobUpdate { + _u.mutation.SetRepoID(v) + return _u +} + +// SetNillableRepoID sets the "repo_id" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableRepoID(v *uuid.UUID) *AgentSyncJobUpdate { + if v != nil { + _u.SetRepoID(*v) + } + return _u +} + +// ClearRepoID clears the value of the "repo_id" field. +func (_u *AgentSyncJobUpdate) ClearRepoID() *AgentSyncJobUpdate { + _u.mutation.ClearRepoID() + return _u +} + +// SetSourceType sets the "source_type" field. +func (_u *AgentSyncJobUpdate) SetSourceType(v agentsyncjob.SourceType) *AgentSyncJobUpdate { + _u.mutation.SetSourceType(v) + return _u +} + +// SetNillableSourceType sets the "source_type" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableSourceType(v *agentsyncjob.SourceType) *AgentSyncJobUpdate { + if v != nil { + _u.SetSourceType(*v) + } + return _u +} + +// SetStatus sets the "status" field. +func (_u *AgentSyncJobUpdate) SetStatus(v agentsyncjob.Status) *AgentSyncJobUpdate { + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableStatus(v *agentsyncjob.Status) *AgentSyncJobUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// SetTriggerType sets the "trigger_type" field. +func (_u *AgentSyncJobUpdate) SetTriggerType(v agentsyncjob.TriggerType) *AgentSyncJobUpdate { + _u.mutation.SetTriggerType(v) + return _u +} + +// SetNillableTriggerType sets the "trigger_type" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableTriggerType(v *agentsyncjob.TriggerType) *AgentSyncJobUpdate { + if v != nil { + _u.SetTriggerType(*v) + } + return _u +} + +// SetTriggeredBy sets the "triggered_by" field. +func (_u *AgentSyncJobUpdate) SetTriggeredBy(v uuid.UUID) *AgentSyncJobUpdate { + _u.mutation.SetTriggeredBy(v) + return _u +} + +// SetNillableTriggeredBy sets the "triggered_by" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableTriggeredBy(v *uuid.UUID) *AgentSyncJobUpdate { + if v != nil { + _u.SetTriggeredBy(*v) + } + return _u +} + +// ClearTriggeredBy clears the value of the "triggered_by" field. +func (_u *AgentSyncJobUpdate) ClearTriggeredBy() *AgentSyncJobUpdate { + _u.mutation.ClearTriggeredBy() + return _u +} + +// SetStartedAt sets the "started_at" field. +func (_u *AgentSyncJobUpdate) SetStartedAt(v time.Time) *AgentSyncJobUpdate { + _u.mutation.SetStartedAt(v) + return _u +} + +// SetNillableStartedAt sets the "started_at" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableStartedAt(v *time.Time) *AgentSyncJobUpdate { + if v != nil { + _u.SetStartedAt(*v) + } + return _u +} + +// ClearStartedAt clears the value of the "started_at" field. +func (_u *AgentSyncJobUpdate) ClearStartedAt() *AgentSyncJobUpdate { + _u.mutation.ClearStartedAt() + return _u +} + +// SetFinishedAt sets the "finished_at" field. +func (_u *AgentSyncJobUpdate) SetFinishedAt(v time.Time) *AgentSyncJobUpdate { + _u.mutation.SetFinishedAt(v) + return _u +} + +// SetNillableFinishedAt sets the "finished_at" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableFinishedAt(v *time.Time) *AgentSyncJobUpdate { + if v != nil { + _u.SetFinishedAt(*v) + } + return _u +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (_u *AgentSyncJobUpdate) ClearFinishedAt() *AgentSyncJobUpdate { + _u.mutation.ClearFinishedAt() + return _u +} + +// SetErrors sets the "errors" field. +func (_u *AgentSyncJobUpdate) SetErrors(v types.SyncJobErrors) *AgentSyncJobUpdate { + _u.mutation.SetErrors(v) + return _u +} + +// AppendErrors appends value to the "errors" field. +func (_u *AgentSyncJobUpdate) AppendErrors(v types.SyncJobErrors) *AgentSyncJobUpdate { + _u.mutation.AppendErrors(v) + return _u +} + +// ClearErrors clears the value of the "errors" field. +func (_u *AgentSyncJobUpdate) ClearErrors() *AgentSyncJobUpdate { + _u.mutation.ClearErrors() + return _u +} + +// SetResultSummary sets the "result_summary" field. +func (_u *AgentSyncJobUpdate) SetResultSummary(v types.SyncJobResultSummary) *AgentSyncJobUpdate { + _u.mutation.SetResultSummary(v) + return _u +} + +// SetNillableResultSummary sets the "result_summary" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableResultSummary(v *types.SyncJobResultSummary) *AgentSyncJobUpdate { + if v != nil { + _u.SetResultSummary(*v) + } + return _u +} + +// ClearResultSummary clears the value of the "result_summary" field. +func (_u *AgentSyncJobUpdate) ClearResultSummary() *AgentSyncJobUpdate { + _u.mutation.ClearResultSummary() + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentSyncJobUpdate) SetCreatedAt(v time.Time) *AgentSyncJobUpdate { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentSyncJobUpdate) SetNillableCreatedAt(v *time.Time) *AgentSyncJobUpdate { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentSyncJobUpdate) SetUpdatedAt(v time.Time) *AgentSyncJobUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// Mutation returns the AgentSyncJobMutation object of the builder. +func (_u *AgentSyncJobUpdate) Mutation() *AgentSyncJobMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AgentSyncJobUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentSyncJobUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AgentSyncJobUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentSyncJobUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentSyncJobUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentsyncjob.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentSyncJobUpdate) check() error { + if v, ok := _u.mutation.ResourceKind(); ok { + if err := agentsyncjob.ResourceKindValidator(v); err != nil { + return &ValidationError{Name: "resource_kind", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.resource_kind": %w`, err)} + } + } + if v, ok := _u.mutation.SourceType(); ok { + if err := agentsyncjob.SourceTypeValidator(v); err != nil { + return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.source_type": %w`, err)} + } + } + if v, ok := _u.mutation.Status(); ok { + if err := agentsyncjob.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.status": %w`, err)} + } + } + if v, ok := _u.mutation.TriggerType(); ok { + if err := agentsyncjob.TriggerTypeValidator(v); err != nil { + return &ValidationError{Name: "trigger_type", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.trigger_type": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentSyncJobUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSyncJobUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentSyncJobUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentsyncjob.Table, agentsyncjob.Columns, sqlgraph.NewFieldSpec(agentsyncjob.FieldID, field.TypeUUID)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.ResourceKind(); ok { + _spec.SetField(agentsyncjob.FieldResourceKind, field.TypeEnum, value) + } + if value, ok := _u.mutation.RuleID(); ok { + _spec.SetField(agentsyncjob.FieldRuleID, field.TypeUUID, value) + } + if _u.mutation.RuleIDCleared() { + _spec.ClearField(agentsyncjob.FieldRuleID, field.TypeUUID) + } + if value, ok := _u.mutation.RepoID(); ok { + _spec.SetField(agentsyncjob.FieldRepoID, field.TypeUUID, value) + } + if _u.mutation.RepoIDCleared() { + _spec.ClearField(agentsyncjob.FieldRepoID, field.TypeUUID) + } + if value, ok := _u.mutation.SourceType(); ok { + _spec.SetField(agentsyncjob.FieldSourceType, field.TypeEnum, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(agentsyncjob.FieldStatus, field.TypeEnum, value) + } + if value, ok := _u.mutation.TriggerType(); ok { + _spec.SetField(agentsyncjob.FieldTriggerType, field.TypeEnum, value) + } + if value, ok := _u.mutation.TriggeredBy(); ok { + _spec.SetField(agentsyncjob.FieldTriggeredBy, field.TypeUUID, value) + } + if _u.mutation.TriggeredByCleared() { + _spec.ClearField(agentsyncjob.FieldTriggeredBy, field.TypeUUID) + } + if value, ok := _u.mutation.StartedAt(); ok { + _spec.SetField(agentsyncjob.FieldStartedAt, field.TypeTime, value) + } + if _u.mutation.StartedAtCleared() { + _spec.ClearField(agentsyncjob.FieldStartedAt, field.TypeTime) + } + if value, ok := _u.mutation.FinishedAt(); ok { + _spec.SetField(agentsyncjob.FieldFinishedAt, field.TypeTime, value) + } + if _u.mutation.FinishedAtCleared() { + _spec.ClearField(agentsyncjob.FieldFinishedAt, field.TypeTime) + } + if value, ok := _u.mutation.Errors(); ok { + _spec.SetField(agentsyncjob.FieldErrors, field.TypeJSON, value) + } + if value, ok := _u.mutation.AppendedErrors(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, agentsyncjob.FieldErrors, value) + }) + } + if _u.mutation.ErrorsCleared() { + _spec.ClearField(agentsyncjob.FieldErrors, field.TypeJSON) + } + if value, ok := _u.mutation.ResultSummary(); ok { + _spec.SetField(agentsyncjob.FieldResultSummary, field.TypeJSON, value) + } + if _u.mutation.ResultSummaryCleared() { + _spec.ClearField(agentsyncjob.FieldResultSummary, field.TypeJSON) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentsyncjob.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentsyncjob.FieldUpdatedAt, field.TypeTime, value) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentsyncjob.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AgentSyncJobUpdateOne is the builder for updating a single AgentSyncJob entity. +type AgentSyncJobUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AgentSyncJobMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetResourceKind sets the "resource_kind" field. +func (_u *AgentSyncJobUpdateOne) SetResourceKind(v agentsyncjob.ResourceKind) *AgentSyncJobUpdateOne { + _u.mutation.SetResourceKind(v) + return _u +} + +// SetNillableResourceKind sets the "resource_kind" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableResourceKind(v *agentsyncjob.ResourceKind) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetResourceKind(*v) + } + return _u +} + +// SetRuleID sets the "rule_id" field. +func (_u *AgentSyncJobUpdateOne) SetRuleID(v uuid.UUID) *AgentSyncJobUpdateOne { + _u.mutation.SetRuleID(v) + return _u +} + +// SetNillableRuleID sets the "rule_id" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableRuleID(v *uuid.UUID) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetRuleID(*v) + } + return _u +} + +// ClearRuleID clears the value of the "rule_id" field. +func (_u *AgentSyncJobUpdateOne) ClearRuleID() *AgentSyncJobUpdateOne { + _u.mutation.ClearRuleID() + return _u +} + +// SetRepoID sets the "repo_id" field. +func (_u *AgentSyncJobUpdateOne) SetRepoID(v uuid.UUID) *AgentSyncJobUpdateOne { + _u.mutation.SetRepoID(v) + return _u +} + +// SetNillableRepoID sets the "repo_id" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableRepoID(v *uuid.UUID) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetRepoID(*v) + } + return _u +} + +// ClearRepoID clears the value of the "repo_id" field. +func (_u *AgentSyncJobUpdateOne) ClearRepoID() *AgentSyncJobUpdateOne { + _u.mutation.ClearRepoID() + return _u +} + +// SetSourceType sets the "source_type" field. +func (_u *AgentSyncJobUpdateOne) SetSourceType(v agentsyncjob.SourceType) *AgentSyncJobUpdateOne { + _u.mutation.SetSourceType(v) + return _u +} + +// SetNillableSourceType sets the "source_type" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableSourceType(v *agentsyncjob.SourceType) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetSourceType(*v) + } + return _u +} + +// SetStatus sets the "status" field. +func (_u *AgentSyncJobUpdateOne) SetStatus(v agentsyncjob.Status) *AgentSyncJobUpdateOne { + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableStatus(v *agentsyncjob.Status) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// SetTriggerType sets the "trigger_type" field. +func (_u *AgentSyncJobUpdateOne) SetTriggerType(v agentsyncjob.TriggerType) *AgentSyncJobUpdateOne { + _u.mutation.SetTriggerType(v) + return _u +} + +// SetNillableTriggerType sets the "trigger_type" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableTriggerType(v *agentsyncjob.TriggerType) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetTriggerType(*v) + } + return _u +} + +// SetTriggeredBy sets the "triggered_by" field. +func (_u *AgentSyncJobUpdateOne) SetTriggeredBy(v uuid.UUID) *AgentSyncJobUpdateOne { + _u.mutation.SetTriggeredBy(v) + return _u +} + +// SetNillableTriggeredBy sets the "triggered_by" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableTriggeredBy(v *uuid.UUID) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetTriggeredBy(*v) + } + return _u +} + +// ClearTriggeredBy clears the value of the "triggered_by" field. +func (_u *AgentSyncJobUpdateOne) ClearTriggeredBy() *AgentSyncJobUpdateOne { + _u.mutation.ClearTriggeredBy() + return _u +} + +// SetStartedAt sets the "started_at" field. +func (_u *AgentSyncJobUpdateOne) SetStartedAt(v time.Time) *AgentSyncJobUpdateOne { + _u.mutation.SetStartedAt(v) + return _u +} + +// SetNillableStartedAt sets the "started_at" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableStartedAt(v *time.Time) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetStartedAt(*v) + } + return _u +} + +// ClearStartedAt clears the value of the "started_at" field. +func (_u *AgentSyncJobUpdateOne) ClearStartedAt() *AgentSyncJobUpdateOne { + _u.mutation.ClearStartedAt() + return _u +} + +// SetFinishedAt sets the "finished_at" field. +func (_u *AgentSyncJobUpdateOne) SetFinishedAt(v time.Time) *AgentSyncJobUpdateOne { + _u.mutation.SetFinishedAt(v) + return _u +} + +// SetNillableFinishedAt sets the "finished_at" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableFinishedAt(v *time.Time) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetFinishedAt(*v) + } + return _u +} + +// ClearFinishedAt clears the value of the "finished_at" field. +func (_u *AgentSyncJobUpdateOne) ClearFinishedAt() *AgentSyncJobUpdateOne { + _u.mutation.ClearFinishedAt() + return _u +} + +// SetErrors sets the "errors" field. +func (_u *AgentSyncJobUpdateOne) SetErrors(v types.SyncJobErrors) *AgentSyncJobUpdateOne { + _u.mutation.SetErrors(v) + return _u +} + +// AppendErrors appends value to the "errors" field. +func (_u *AgentSyncJobUpdateOne) AppendErrors(v types.SyncJobErrors) *AgentSyncJobUpdateOne { + _u.mutation.AppendErrors(v) + return _u +} + +// ClearErrors clears the value of the "errors" field. +func (_u *AgentSyncJobUpdateOne) ClearErrors() *AgentSyncJobUpdateOne { + _u.mutation.ClearErrors() + return _u +} + +// SetResultSummary sets the "result_summary" field. +func (_u *AgentSyncJobUpdateOne) SetResultSummary(v types.SyncJobResultSummary) *AgentSyncJobUpdateOne { + _u.mutation.SetResultSummary(v) + return _u +} + +// SetNillableResultSummary sets the "result_summary" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableResultSummary(v *types.SyncJobResultSummary) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetResultSummary(*v) + } + return _u +} + +// ClearResultSummary clears the value of the "result_summary" field. +func (_u *AgentSyncJobUpdateOne) ClearResultSummary() *AgentSyncJobUpdateOne { + _u.mutation.ClearResultSummary() + return _u +} + +// SetCreatedAt sets the "created_at" field. +func (_u *AgentSyncJobUpdateOne) SetCreatedAt(v time.Time) *AgentSyncJobUpdateOne { + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_u *AgentSyncJobUpdateOne) SetNillableCreatedAt(v *time.Time) *AgentSyncJobUpdateOne { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AgentSyncJobUpdateOne) SetUpdatedAt(v time.Time) *AgentSyncJobUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// Mutation returns the AgentSyncJobMutation object of the builder. +func (_u *AgentSyncJobUpdateOne) Mutation() *AgentSyncJobMutation { + return _u.mutation +} + +// Where appends a list predicates to the AgentSyncJobUpdate builder. +func (_u *AgentSyncJobUpdateOne) Where(ps ...predicate.AgentSyncJob) *AgentSyncJobUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *AgentSyncJobUpdateOne) Select(field string, fields ...string) *AgentSyncJobUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated AgentSyncJob entity. +func (_u *AgentSyncJobUpdateOne) Save(ctx context.Context) (*AgentSyncJob, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AgentSyncJobUpdateOne) SaveX(ctx context.Context) *AgentSyncJob { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AgentSyncJobUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AgentSyncJobUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *AgentSyncJobUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := agentsyncjob.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *AgentSyncJobUpdateOne) check() error { + if v, ok := _u.mutation.ResourceKind(); ok { + if err := agentsyncjob.ResourceKindValidator(v); err != nil { + return &ValidationError{Name: "resource_kind", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.resource_kind": %w`, err)} + } + } + if v, ok := _u.mutation.SourceType(); ok { + if err := agentsyncjob.SourceTypeValidator(v); err != nil { + return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.source_type": %w`, err)} + } + } + if v, ok := _u.mutation.Status(); ok { + if err := agentsyncjob.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.status": %w`, err)} + } + } + if v, ok := _u.mutation.TriggerType(); ok { + if err := agentsyncjob.TriggerTypeValidator(v); err != nil { + return &ValidationError{Name: "trigger_type", err: fmt.Errorf(`db: validator failed for field "AgentSyncJob.trigger_type": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *AgentSyncJobUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *AgentSyncJobUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *AgentSyncJobUpdateOne) sqlSave(ctx context.Context) (_node *AgentSyncJob, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(agentsyncjob.Table, agentsyncjob.Columns, sqlgraph.NewFieldSpec(agentsyncjob.FieldID, field.TypeUUID)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AgentSyncJob.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, agentsyncjob.FieldID) + for _, f := range fields { + if !agentsyncjob.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != agentsyncjob.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.ResourceKind(); ok { + _spec.SetField(agentsyncjob.FieldResourceKind, field.TypeEnum, value) + } + if value, ok := _u.mutation.RuleID(); ok { + _spec.SetField(agentsyncjob.FieldRuleID, field.TypeUUID, value) + } + if _u.mutation.RuleIDCleared() { + _spec.ClearField(agentsyncjob.FieldRuleID, field.TypeUUID) + } + if value, ok := _u.mutation.RepoID(); ok { + _spec.SetField(agentsyncjob.FieldRepoID, field.TypeUUID, value) + } + if _u.mutation.RepoIDCleared() { + _spec.ClearField(agentsyncjob.FieldRepoID, field.TypeUUID) + } + if value, ok := _u.mutation.SourceType(); ok { + _spec.SetField(agentsyncjob.FieldSourceType, field.TypeEnum, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(agentsyncjob.FieldStatus, field.TypeEnum, value) + } + if value, ok := _u.mutation.TriggerType(); ok { + _spec.SetField(agentsyncjob.FieldTriggerType, field.TypeEnum, value) + } + if value, ok := _u.mutation.TriggeredBy(); ok { + _spec.SetField(agentsyncjob.FieldTriggeredBy, field.TypeUUID, value) + } + if _u.mutation.TriggeredByCleared() { + _spec.ClearField(agentsyncjob.FieldTriggeredBy, field.TypeUUID) + } + if value, ok := _u.mutation.StartedAt(); ok { + _spec.SetField(agentsyncjob.FieldStartedAt, field.TypeTime, value) + } + if _u.mutation.StartedAtCleared() { + _spec.ClearField(agentsyncjob.FieldStartedAt, field.TypeTime) + } + if value, ok := _u.mutation.FinishedAt(); ok { + _spec.SetField(agentsyncjob.FieldFinishedAt, field.TypeTime, value) + } + if _u.mutation.FinishedAtCleared() { + _spec.ClearField(agentsyncjob.FieldFinishedAt, field.TypeTime) + } + if value, ok := _u.mutation.Errors(); ok { + _spec.SetField(agentsyncjob.FieldErrors, field.TypeJSON, value) + } + if value, ok := _u.mutation.AppendedErrors(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, agentsyncjob.FieldErrors, value) + }) + } + if _u.mutation.ErrorsCleared() { + _spec.ClearField(agentsyncjob.FieldErrors, field.TypeJSON) + } + if value, ok := _u.mutation.ResultSummary(); ok { + _spec.SetField(agentsyncjob.FieldResultSummary, field.TypeJSON, value) + } + if _u.mutation.ResultSummaryCleared() { + _spec.ClearField(agentsyncjob.FieldResultSummary, field.TypeJSON) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(agentsyncjob.FieldCreatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(agentsyncjob.FieldUpdatedAt, field.TypeTime, value) + } + _spec.AddModifiers(_u.modifiers...) + _node = &AgentSyncJob{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{agentsyncjob.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/backend/db/client.go b/backend/db/client.go index 490ba3e8..e37cb06e 100644 --- a/backend/db/client.go +++ b/backend/db/client.go @@ -16,6 +16,16 @@ import ( "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/db/agentsyncjob" "github.com/chaitin/MonkeyCode/backend/db/audit" "github.com/chaitin/MonkeyCode/backend/db/gitbot" "github.com/chaitin/MonkeyCode/backend/db/gitbottask" @@ -39,7 +49,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/projectissue" "github.com/chaitin/MonkeyCode/backend/db/projectissuecomment" "github.com/chaitin/MonkeyCode/backend/db/projecttask" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/task" "github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch" "github.com/chaitin/MonkeyCode/backend/db/taskusagestat" @@ -51,13 +60,11 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/teamgroupimage" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmember" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/chaitin/MonkeyCode/backend/db/teamhost" "github.com/chaitin/MonkeyCode/backend/db/teamimage" "github.com/chaitin/MonkeyCode/backend/db/teammember" "github.com/chaitin/MonkeyCode/backend/db/teammodel" "github.com/chaitin/MonkeyCode/backend/db/teamoidcconfig" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/chaitin/MonkeyCode/backend/db/useridentity" "github.com/chaitin/MonkeyCode/backend/db/virtualmachine" @@ -70,6 +77,26 @@ type Client struct { config // Schema is the client for creating, migrating and dropping schema. Schema *migrate.Schema + // AgentPlugin is the client for interacting with the AgentPlugin builders. + AgentPlugin *AgentPluginClient + // AgentPluginRepo is the client for interacting with the AgentPluginRepo builders. + AgentPluginRepo *AgentPluginRepoClient + // AgentPluginVersion is the client for interacting with the AgentPluginVersion builders. + AgentPluginVersion *AgentPluginVersionClient + // AgentRule is the client for interacting with the AgentRule builders. + AgentRule *AgentRuleClient + // AgentRuleVersion is the client for interacting with the AgentRuleVersion builders. + AgentRuleVersion *AgentRuleVersionClient + // AgentSkill is the client for interacting with the AgentSkill builders. + AgentSkill *AgentSkillClient + // AgentSkillGroupBinding is the client for interacting with the AgentSkillGroupBinding builders. + AgentSkillGroupBinding *AgentSkillGroupBindingClient + // AgentSkillRepo is the client for interacting with the AgentSkillRepo builders. + AgentSkillRepo *AgentSkillRepoClient + // AgentSkillVersion is the client for interacting with the AgentSkillVersion builders. + AgentSkillVersion *AgentSkillVersionClient + // AgentSyncJob is the client for interacting with the AgentSyncJob builders. + AgentSyncJob *AgentSyncJobClient // Audit is the client for interacting with the Audit builders. Audit *AuditClient // GitBot is the client for interacting with the GitBot builders. @@ -116,8 +143,6 @@ type Client struct { ProjectIssueComment *ProjectIssueCommentClient // ProjectTask is the client for interacting with the ProjectTask builders. ProjectTask *ProjectTaskClient - // Skill is the client for interacting with the Skill builders. - Skill *SkillClient // Task is the client for interacting with the Task builders. Task *TaskClient // TaskModelSwitch is the client for interacting with the TaskModelSwitch builders. @@ -140,8 +165,6 @@ type Client struct { TeamGroupMember *TeamGroupMemberClient // TeamGroupModel is the client for interacting with the TeamGroupModel builders. TeamGroupModel *TeamGroupModelClient - // TeamGroupSkill is the client for interacting with the TeamGroupSkill builders. - TeamGroupSkill *TeamGroupSkillClient // TeamHost is the client for interacting with the TeamHost builders. TeamHost *TeamHostClient // TeamImage is the client for interacting with the TeamImage builders. @@ -152,8 +175,6 @@ type Client struct { TeamModel *TeamModelClient // TeamOIDCConfig is the client for interacting with the TeamOIDCConfig builders. TeamOIDCConfig *TeamOIDCConfigClient - // TeamSkill is the client for interacting with the TeamSkill builders. - TeamSkill *TeamSkillClient // User is the client for interacting with the User builders. User *UserClient // UserIdentity is the client for interacting with the UserIdentity builders. @@ -171,6 +192,16 @@ func NewClient(opts ...Option) *Client { func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) + c.AgentPlugin = NewAgentPluginClient(c.config) + c.AgentPluginRepo = NewAgentPluginRepoClient(c.config) + c.AgentPluginVersion = NewAgentPluginVersionClient(c.config) + c.AgentRule = NewAgentRuleClient(c.config) + c.AgentRuleVersion = NewAgentRuleVersionClient(c.config) + c.AgentSkill = NewAgentSkillClient(c.config) + c.AgentSkillGroupBinding = NewAgentSkillGroupBindingClient(c.config) + c.AgentSkillRepo = NewAgentSkillRepoClient(c.config) + c.AgentSkillVersion = NewAgentSkillVersionClient(c.config) + c.AgentSyncJob = NewAgentSyncJobClient(c.config) c.Audit = NewAuditClient(c.config) c.GitBot = NewGitBotClient(c.config) c.GitBotTask = NewGitBotTaskClient(c.config) @@ -194,7 +225,6 @@ func (c *Client) init() { c.ProjectIssue = NewProjectIssueClient(c.config) c.ProjectIssueComment = NewProjectIssueCommentClient(c.config) c.ProjectTask = NewProjectTaskClient(c.config) - c.Skill = NewSkillClient(c.config) c.Task = NewTaskClient(c.config) c.TaskModelSwitch = NewTaskModelSwitchClient(c.config) c.TaskUsageStat = NewTaskUsageStatClient(c.config) @@ -206,13 +236,11 @@ func (c *Client) init() { c.TeamGroupImage = NewTeamGroupImageClient(c.config) c.TeamGroupMember = NewTeamGroupMemberClient(c.config) c.TeamGroupModel = NewTeamGroupModelClient(c.config) - c.TeamGroupSkill = NewTeamGroupSkillClient(c.config) c.TeamHost = NewTeamHostClient(c.config) c.TeamImage = NewTeamImageClient(c.config) c.TeamMember = NewTeamMemberClient(c.config) c.TeamModel = NewTeamModelClient(c.config) c.TeamOIDCConfig = NewTeamOIDCConfigClient(c.config) - c.TeamSkill = NewTeamSkillClient(c.config) c.User = NewUserClient(c.config) c.UserIdentity = NewUserIdentityClient(c.config) c.VirtualMachine = NewVirtualMachineClient(c.config) @@ -308,6 +336,16 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { return &Tx{ ctx: ctx, config: cfg, + AgentPlugin: NewAgentPluginClient(cfg), + AgentPluginRepo: NewAgentPluginRepoClient(cfg), + AgentPluginVersion: NewAgentPluginVersionClient(cfg), + AgentRule: NewAgentRuleClient(cfg), + AgentRuleVersion: NewAgentRuleVersionClient(cfg), + AgentSkill: NewAgentSkillClient(cfg), + AgentSkillGroupBinding: NewAgentSkillGroupBindingClient(cfg), + AgentSkillRepo: NewAgentSkillRepoClient(cfg), + AgentSkillVersion: NewAgentSkillVersionClient(cfg), + AgentSyncJob: NewAgentSyncJobClient(cfg), Audit: NewAuditClient(cfg), GitBot: NewGitBotClient(cfg), GitBotTask: NewGitBotTaskClient(cfg), @@ -331,7 +369,6 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { ProjectIssue: NewProjectIssueClient(cfg), ProjectIssueComment: NewProjectIssueCommentClient(cfg), ProjectTask: NewProjectTaskClient(cfg), - Skill: NewSkillClient(cfg), Task: NewTaskClient(cfg), TaskModelSwitch: NewTaskModelSwitchClient(cfg), TaskUsageStat: NewTaskUsageStatClient(cfg), @@ -343,13 +380,11 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { TeamGroupImage: NewTeamGroupImageClient(cfg), TeamGroupMember: NewTeamGroupMemberClient(cfg), TeamGroupModel: NewTeamGroupModelClient(cfg), - TeamGroupSkill: NewTeamGroupSkillClient(cfg), TeamHost: NewTeamHostClient(cfg), TeamImage: NewTeamImageClient(cfg), TeamMember: NewTeamMemberClient(cfg), TeamModel: NewTeamModelClient(cfg), TeamOIDCConfig: NewTeamOIDCConfigClient(cfg), - TeamSkill: NewTeamSkillClient(cfg), User: NewUserClient(cfg), UserIdentity: NewUserIdentityClient(cfg), VirtualMachine: NewVirtualMachineClient(cfg), @@ -372,6 +407,16 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) return &Tx{ ctx: ctx, config: cfg, + AgentPlugin: NewAgentPluginClient(cfg), + AgentPluginRepo: NewAgentPluginRepoClient(cfg), + AgentPluginVersion: NewAgentPluginVersionClient(cfg), + AgentRule: NewAgentRuleClient(cfg), + AgentRuleVersion: NewAgentRuleVersionClient(cfg), + AgentSkill: NewAgentSkillClient(cfg), + AgentSkillGroupBinding: NewAgentSkillGroupBindingClient(cfg), + AgentSkillRepo: NewAgentSkillRepoClient(cfg), + AgentSkillVersion: NewAgentSkillVersionClient(cfg), + AgentSyncJob: NewAgentSyncJobClient(cfg), Audit: NewAuditClient(cfg), GitBot: NewGitBotClient(cfg), GitBotTask: NewGitBotTaskClient(cfg), @@ -395,7 +440,6 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) ProjectIssue: NewProjectIssueClient(cfg), ProjectIssueComment: NewProjectIssueCommentClient(cfg), ProjectTask: NewProjectTaskClient(cfg), - Skill: NewSkillClient(cfg), Task: NewTaskClient(cfg), TaskModelSwitch: NewTaskModelSwitchClient(cfg), TaskUsageStat: NewTaskUsageStatClient(cfg), @@ -407,13 +451,11 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) TeamGroupImage: NewTeamGroupImageClient(cfg), TeamGroupMember: NewTeamGroupMemberClient(cfg), TeamGroupModel: NewTeamGroupModelClient(cfg), - TeamGroupSkill: NewTeamGroupSkillClient(cfg), TeamHost: NewTeamHostClient(cfg), TeamImage: NewTeamImageClient(cfg), TeamMember: NewTeamMemberClient(cfg), TeamModel: NewTeamModelClient(cfg), TeamOIDCConfig: NewTeamOIDCConfigClient(cfg), - TeamSkill: NewTeamSkillClient(cfg), User: NewUserClient(cfg), UserIdentity: NewUserIdentityClient(cfg), VirtualMachine: NewVirtualMachineClient(cfg), @@ -423,7 +465,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) // Debug returns a new debug-client. It's used to get verbose logging on specific operations. // // client.Debug(). -// Audit. +// AgentPlugin. // Query(). // Count(ctx) func (c *Client) Debug() *Client { @@ -446,15 +488,17 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Audit, c.GitBot, c.GitBotTask, c.GitBotUser, c.GitIdentity, c.GitTask, c.Host, - c.Image, c.MCPTool, c.MCPUpstream, c.MCPUserToolSetting, c.Model, - c.ModelApiKey, c.ModelPricing, c.NotifyChannel, c.NotifySendLog, - c.NotifySubscription, c.Project, c.ProjectCollaborator, c.ProjectGitBot, - c.ProjectIssue, c.ProjectIssueComment, c.ProjectTask, c.Skill, c.Task, - c.TaskModelSwitch, c.TaskUsageStat, c.TaskVirtualMachine, c.Team, - c.TeamExtensionImageArchive, c.TeamGroup, c.TeamGroupHost, c.TeamGroupImage, - c.TeamGroupMember, c.TeamGroupModel, c.TeamGroupSkill, c.TeamHost, c.TeamImage, - c.TeamMember, c.TeamModel, c.TeamOIDCConfig, c.TeamSkill, c.User, + c.AgentPlugin, c.AgentPluginRepo, c.AgentPluginVersion, c.AgentRule, + c.AgentRuleVersion, c.AgentSkill, c.AgentSkillGroupBinding, c.AgentSkillRepo, + c.AgentSkillVersion, c.AgentSyncJob, c.Audit, c.GitBot, c.GitBotTask, + c.GitBotUser, c.GitIdentity, c.GitTask, c.Host, c.Image, c.MCPTool, + c.MCPUpstream, c.MCPUserToolSetting, c.Model, c.ModelApiKey, c.ModelPricing, + c.NotifyChannel, c.NotifySendLog, c.NotifySubscription, c.Project, + c.ProjectCollaborator, c.ProjectGitBot, c.ProjectIssue, c.ProjectIssueComment, + c.ProjectTask, c.Task, c.TaskModelSwitch, c.TaskUsageStat, + c.TaskVirtualMachine, c.Team, c.TeamExtensionImageArchive, c.TeamGroup, + c.TeamGroupHost, c.TeamGroupImage, c.TeamGroupMember, c.TeamGroupModel, + c.TeamHost, c.TeamImage, c.TeamMember, c.TeamModel, c.TeamOIDCConfig, c.User, c.UserIdentity, c.VirtualMachine, } { n.Use(hooks...) @@ -465,15 +509,17 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Audit, c.GitBot, c.GitBotTask, c.GitBotUser, c.GitIdentity, c.GitTask, c.Host, - c.Image, c.MCPTool, c.MCPUpstream, c.MCPUserToolSetting, c.Model, - c.ModelApiKey, c.ModelPricing, c.NotifyChannel, c.NotifySendLog, - c.NotifySubscription, c.Project, c.ProjectCollaborator, c.ProjectGitBot, - c.ProjectIssue, c.ProjectIssueComment, c.ProjectTask, c.Skill, c.Task, - c.TaskModelSwitch, c.TaskUsageStat, c.TaskVirtualMachine, c.Team, - c.TeamExtensionImageArchive, c.TeamGroup, c.TeamGroupHost, c.TeamGroupImage, - c.TeamGroupMember, c.TeamGroupModel, c.TeamGroupSkill, c.TeamHost, c.TeamImage, - c.TeamMember, c.TeamModel, c.TeamOIDCConfig, c.TeamSkill, c.User, + c.AgentPlugin, c.AgentPluginRepo, c.AgentPluginVersion, c.AgentRule, + c.AgentRuleVersion, c.AgentSkill, c.AgentSkillGroupBinding, c.AgentSkillRepo, + c.AgentSkillVersion, c.AgentSyncJob, c.Audit, c.GitBot, c.GitBotTask, + c.GitBotUser, c.GitIdentity, c.GitTask, c.Host, c.Image, c.MCPTool, + c.MCPUpstream, c.MCPUserToolSetting, c.Model, c.ModelApiKey, c.ModelPricing, + c.NotifyChannel, c.NotifySendLog, c.NotifySubscription, c.Project, + c.ProjectCollaborator, c.ProjectGitBot, c.ProjectIssue, c.ProjectIssueComment, + c.ProjectTask, c.Task, c.TaskModelSwitch, c.TaskUsageStat, + c.TaskVirtualMachine, c.Team, c.TeamExtensionImageArchive, c.TeamGroup, + c.TeamGroupHost, c.TeamGroupImage, c.TeamGroupMember, c.TeamGroupModel, + c.TeamHost, c.TeamImage, c.TeamMember, c.TeamModel, c.TeamOIDCConfig, c.User, c.UserIdentity, c.VirtualMachine, } { n.Intercept(interceptors...) @@ -483,6 +529,26 @@ func (c *Client) Intercept(interceptors ...Interceptor) { // Mutate implements the ent.Mutator interface. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { switch m := m.(type) { + case *AgentPluginMutation: + return c.AgentPlugin.mutate(ctx, m) + case *AgentPluginRepoMutation: + return c.AgentPluginRepo.mutate(ctx, m) + case *AgentPluginVersionMutation: + return c.AgentPluginVersion.mutate(ctx, m) + case *AgentRuleMutation: + return c.AgentRule.mutate(ctx, m) + case *AgentRuleVersionMutation: + return c.AgentRuleVersion.mutate(ctx, m) + case *AgentSkillMutation: + return c.AgentSkill.mutate(ctx, m) + case *AgentSkillGroupBindingMutation: + return c.AgentSkillGroupBinding.mutate(ctx, m) + case *AgentSkillRepoMutation: + return c.AgentSkillRepo.mutate(ctx, m) + case *AgentSkillVersionMutation: + return c.AgentSkillVersion.mutate(ctx, m) + case *AgentSyncJobMutation: + return c.AgentSyncJob.mutate(ctx, m) case *AuditMutation: return c.Audit.mutate(ctx, m) case *GitBotMutation: @@ -529,8 +595,6 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.ProjectIssueComment.mutate(ctx, m) case *ProjectTaskMutation: return c.ProjectTask.mutate(ctx, m) - case *SkillMutation: - return c.Skill.mutate(ctx, m) case *TaskMutation: return c.Task.mutate(ctx, m) case *TaskModelSwitchMutation: @@ -553,8 +617,6 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.TeamGroupMember.mutate(ctx, m) case *TeamGroupModelMutation: return c.TeamGroupModel.mutate(ctx, m) - case *TeamGroupSkillMutation: - return c.TeamGroupSkill.mutate(ctx, m) case *TeamHostMutation: return c.TeamHost.mutate(ctx, m) case *TeamImageMutation: @@ -565,8 +627,6 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.TeamModel.mutate(ctx, m) case *TeamOIDCConfigMutation: return c.TeamOIDCConfig.mutate(ctx, m) - case *TeamSkillMutation: - return c.TeamSkill.mutate(ctx, m) case *UserMutation: return c.User.mutate(ctx, m) case *UserIdentityMutation: @@ -578,6 +638,1528 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { } } +// AgentPluginClient is a client for the AgentPlugin schema. +type AgentPluginClient struct { + config +} + +// NewAgentPluginClient returns a client for the AgentPlugin from the given config. +func NewAgentPluginClient(c config) *AgentPluginClient { + return &AgentPluginClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `agentplugin.Hooks(f(g(h())))`. +func (c *AgentPluginClient) Use(hooks ...Hook) { + c.hooks.AgentPlugin = append(c.hooks.AgentPlugin, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `agentplugin.Intercept(f(g(h())))`. +func (c *AgentPluginClient) Intercept(interceptors ...Interceptor) { + c.inters.AgentPlugin = append(c.inters.AgentPlugin, interceptors...) +} + +// Create returns a builder for creating a AgentPlugin entity. +func (c *AgentPluginClient) Create() *AgentPluginCreate { + mutation := newAgentPluginMutation(c.config, OpCreate) + return &AgentPluginCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of AgentPlugin entities. +func (c *AgentPluginClient) CreateBulk(builders ...*AgentPluginCreate) *AgentPluginCreateBulk { + return &AgentPluginCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AgentPluginClient) MapCreateBulk(slice any, setFunc func(*AgentPluginCreate, int)) *AgentPluginCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AgentPluginCreateBulk{err: fmt.Errorf("calling to AgentPluginClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AgentPluginCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AgentPluginCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for AgentPlugin. +func (c *AgentPluginClient) Update() *AgentPluginUpdate { + mutation := newAgentPluginMutation(c.config, OpUpdate) + return &AgentPluginUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AgentPluginClient) UpdateOne(_m *AgentPlugin) *AgentPluginUpdateOne { + mutation := newAgentPluginMutation(c.config, OpUpdateOne, withAgentPlugin(_m)) + return &AgentPluginUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AgentPluginClient) UpdateOneID(id uuid.UUID) *AgentPluginUpdateOne { + mutation := newAgentPluginMutation(c.config, OpUpdateOne, withAgentPluginID(id)) + return &AgentPluginUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for AgentPlugin. +func (c *AgentPluginClient) Delete() *AgentPluginDelete { + mutation := newAgentPluginMutation(c.config, OpDelete) + return &AgentPluginDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AgentPluginClient) DeleteOne(_m *AgentPlugin) *AgentPluginDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AgentPluginClient) DeleteOneID(id uuid.UUID) *AgentPluginDeleteOne { + builder := c.Delete().Where(agentplugin.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AgentPluginDeleteOne{builder} +} + +// Query returns a query builder for AgentPlugin. +func (c *AgentPluginClient) Query() *AgentPluginQuery { + return &AgentPluginQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAgentPlugin}, + inters: c.Interceptors(), + } +} + +// Get returns a AgentPlugin entity by its id. +func (c *AgentPluginClient) Get(ctx context.Context, id uuid.UUID) (*AgentPlugin, error) { + return c.Query().Where(agentplugin.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AgentPluginClient) GetX(ctx context.Context, id uuid.UUID) *AgentPlugin { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryRepo queries the repo edge of a AgentPlugin. +func (c *AgentPluginClient) QueryRepo(_m *AgentPlugin) *AgentPluginRepoQuery { + query := (&AgentPluginRepoClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentplugin.Table, agentplugin.FieldID, id), + sqlgraph.To(agentpluginrepo.Table, agentpluginrepo.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, agentplugin.RepoTable, agentplugin.RepoColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryVersions queries the versions edge of a AgentPlugin. +func (c *AgentPluginClient) QueryVersions(_m *AgentPlugin) *AgentPluginVersionQuery { + query := (&AgentPluginVersionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentplugin.Table, agentplugin.FieldID, id), + sqlgraph.To(agentpluginversion.Table, agentpluginversion.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, agentplugin.VersionsTable, agentplugin.VersionsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AgentPluginClient) Hooks() []Hook { + return c.hooks.AgentPlugin +} + +// Interceptors returns the client interceptors. +func (c *AgentPluginClient) Interceptors() []Interceptor { + return c.inters.AgentPlugin +} + +func (c *AgentPluginClient) mutate(ctx context.Context, m *AgentPluginMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AgentPluginCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AgentPluginUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AgentPluginUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AgentPluginDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown AgentPlugin mutation op: %q", m.Op()) + } +} + +// AgentPluginRepoClient is a client for the AgentPluginRepo schema. +type AgentPluginRepoClient struct { + config +} + +// NewAgentPluginRepoClient returns a client for the AgentPluginRepo from the given config. +func NewAgentPluginRepoClient(c config) *AgentPluginRepoClient { + return &AgentPluginRepoClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `agentpluginrepo.Hooks(f(g(h())))`. +func (c *AgentPluginRepoClient) Use(hooks ...Hook) { + c.hooks.AgentPluginRepo = append(c.hooks.AgentPluginRepo, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `agentpluginrepo.Intercept(f(g(h())))`. +func (c *AgentPluginRepoClient) Intercept(interceptors ...Interceptor) { + c.inters.AgentPluginRepo = append(c.inters.AgentPluginRepo, interceptors...) +} + +// Create returns a builder for creating a AgentPluginRepo entity. +func (c *AgentPluginRepoClient) Create() *AgentPluginRepoCreate { + mutation := newAgentPluginRepoMutation(c.config, OpCreate) + return &AgentPluginRepoCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of AgentPluginRepo entities. +func (c *AgentPluginRepoClient) CreateBulk(builders ...*AgentPluginRepoCreate) *AgentPluginRepoCreateBulk { + return &AgentPluginRepoCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AgentPluginRepoClient) MapCreateBulk(slice any, setFunc func(*AgentPluginRepoCreate, int)) *AgentPluginRepoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AgentPluginRepoCreateBulk{err: fmt.Errorf("calling to AgentPluginRepoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AgentPluginRepoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AgentPluginRepoCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for AgentPluginRepo. +func (c *AgentPluginRepoClient) Update() *AgentPluginRepoUpdate { + mutation := newAgentPluginRepoMutation(c.config, OpUpdate) + return &AgentPluginRepoUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AgentPluginRepoClient) UpdateOne(_m *AgentPluginRepo) *AgentPluginRepoUpdateOne { + mutation := newAgentPluginRepoMutation(c.config, OpUpdateOne, withAgentPluginRepo(_m)) + return &AgentPluginRepoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AgentPluginRepoClient) UpdateOneID(id uuid.UUID) *AgentPluginRepoUpdateOne { + mutation := newAgentPluginRepoMutation(c.config, OpUpdateOne, withAgentPluginRepoID(id)) + return &AgentPluginRepoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for AgentPluginRepo. +func (c *AgentPluginRepoClient) Delete() *AgentPluginRepoDelete { + mutation := newAgentPluginRepoMutation(c.config, OpDelete) + return &AgentPluginRepoDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AgentPluginRepoClient) DeleteOne(_m *AgentPluginRepo) *AgentPluginRepoDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AgentPluginRepoClient) DeleteOneID(id uuid.UUID) *AgentPluginRepoDeleteOne { + builder := c.Delete().Where(agentpluginrepo.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AgentPluginRepoDeleteOne{builder} +} + +// Query returns a query builder for AgentPluginRepo. +func (c *AgentPluginRepoClient) Query() *AgentPluginRepoQuery { + return &AgentPluginRepoQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAgentPluginRepo}, + inters: c.Interceptors(), + } +} + +// Get returns a AgentPluginRepo entity by its id. +func (c *AgentPluginRepoClient) Get(ctx context.Context, id uuid.UUID) (*AgentPluginRepo, error) { + return c.Query().Where(agentpluginrepo.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AgentPluginRepoClient) GetX(ctx context.Context, id uuid.UUID) *AgentPluginRepo { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryPlugins queries the plugins edge of a AgentPluginRepo. +func (c *AgentPluginRepoClient) QueryPlugins(_m *AgentPluginRepo) *AgentPluginQuery { + query := (&AgentPluginClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentpluginrepo.Table, agentpluginrepo.FieldID, id), + sqlgraph.To(agentplugin.Table, agentplugin.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, agentpluginrepo.PluginsTable, agentpluginrepo.PluginsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AgentPluginRepoClient) Hooks() []Hook { + return c.hooks.AgentPluginRepo +} + +// Interceptors returns the client interceptors. +func (c *AgentPluginRepoClient) Interceptors() []Interceptor { + return c.inters.AgentPluginRepo +} + +func (c *AgentPluginRepoClient) mutate(ctx context.Context, m *AgentPluginRepoMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AgentPluginRepoCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AgentPluginRepoUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AgentPluginRepoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AgentPluginRepoDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown AgentPluginRepo mutation op: %q", m.Op()) + } +} + +// AgentPluginVersionClient is a client for the AgentPluginVersion schema. +type AgentPluginVersionClient struct { + config +} + +// NewAgentPluginVersionClient returns a client for the AgentPluginVersion from the given config. +func NewAgentPluginVersionClient(c config) *AgentPluginVersionClient { + return &AgentPluginVersionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `agentpluginversion.Hooks(f(g(h())))`. +func (c *AgentPluginVersionClient) Use(hooks ...Hook) { + c.hooks.AgentPluginVersion = append(c.hooks.AgentPluginVersion, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `agentpluginversion.Intercept(f(g(h())))`. +func (c *AgentPluginVersionClient) Intercept(interceptors ...Interceptor) { + c.inters.AgentPluginVersion = append(c.inters.AgentPluginVersion, interceptors...) +} + +// Create returns a builder for creating a AgentPluginVersion entity. +func (c *AgentPluginVersionClient) Create() *AgentPluginVersionCreate { + mutation := newAgentPluginVersionMutation(c.config, OpCreate) + return &AgentPluginVersionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of AgentPluginVersion entities. +func (c *AgentPluginVersionClient) CreateBulk(builders ...*AgentPluginVersionCreate) *AgentPluginVersionCreateBulk { + return &AgentPluginVersionCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AgentPluginVersionClient) MapCreateBulk(slice any, setFunc func(*AgentPluginVersionCreate, int)) *AgentPluginVersionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AgentPluginVersionCreateBulk{err: fmt.Errorf("calling to AgentPluginVersionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AgentPluginVersionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AgentPluginVersionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for AgentPluginVersion. +func (c *AgentPluginVersionClient) Update() *AgentPluginVersionUpdate { + mutation := newAgentPluginVersionMutation(c.config, OpUpdate) + return &AgentPluginVersionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AgentPluginVersionClient) UpdateOne(_m *AgentPluginVersion) *AgentPluginVersionUpdateOne { + mutation := newAgentPluginVersionMutation(c.config, OpUpdateOne, withAgentPluginVersion(_m)) + return &AgentPluginVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AgentPluginVersionClient) UpdateOneID(id uuid.UUID) *AgentPluginVersionUpdateOne { + mutation := newAgentPluginVersionMutation(c.config, OpUpdateOne, withAgentPluginVersionID(id)) + return &AgentPluginVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for AgentPluginVersion. +func (c *AgentPluginVersionClient) Delete() *AgentPluginVersionDelete { + mutation := newAgentPluginVersionMutation(c.config, OpDelete) + return &AgentPluginVersionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AgentPluginVersionClient) DeleteOne(_m *AgentPluginVersion) *AgentPluginVersionDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AgentPluginVersionClient) DeleteOneID(id uuid.UUID) *AgentPluginVersionDeleteOne { + builder := c.Delete().Where(agentpluginversion.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AgentPluginVersionDeleteOne{builder} +} + +// Query returns a query builder for AgentPluginVersion. +func (c *AgentPluginVersionClient) Query() *AgentPluginVersionQuery { + return &AgentPluginVersionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAgentPluginVersion}, + inters: c.Interceptors(), + } +} + +// Get returns a AgentPluginVersion entity by its id. +func (c *AgentPluginVersionClient) Get(ctx context.Context, id uuid.UUID) (*AgentPluginVersion, error) { + return c.Query().Where(agentpluginversion.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AgentPluginVersionClient) GetX(ctx context.Context, id uuid.UUID) *AgentPluginVersion { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryPlugin queries the plugin edge of a AgentPluginVersion. +func (c *AgentPluginVersionClient) QueryPlugin(_m *AgentPluginVersion) *AgentPluginQuery { + query := (&AgentPluginClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentpluginversion.Table, agentpluginversion.FieldID, id), + sqlgraph.To(agentplugin.Table, agentplugin.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, agentpluginversion.PluginTable, agentpluginversion.PluginColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AgentPluginVersionClient) Hooks() []Hook { + return c.hooks.AgentPluginVersion +} + +// Interceptors returns the client interceptors. +func (c *AgentPluginVersionClient) Interceptors() []Interceptor { + return c.inters.AgentPluginVersion +} + +func (c *AgentPluginVersionClient) mutate(ctx context.Context, m *AgentPluginVersionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AgentPluginVersionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AgentPluginVersionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AgentPluginVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AgentPluginVersionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown AgentPluginVersion mutation op: %q", m.Op()) + } +} + +// AgentRuleClient is a client for the AgentRule schema. +type AgentRuleClient struct { + config +} + +// NewAgentRuleClient returns a client for the AgentRule from the given config. +func NewAgentRuleClient(c config) *AgentRuleClient { + return &AgentRuleClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `agentrule.Hooks(f(g(h())))`. +func (c *AgentRuleClient) Use(hooks ...Hook) { + c.hooks.AgentRule = append(c.hooks.AgentRule, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `agentrule.Intercept(f(g(h())))`. +func (c *AgentRuleClient) Intercept(interceptors ...Interceptor) { + c.inters.AgentRule = append(c.inters.AgentRule, interceptors...) +} + +// Create returns a builder for creating a AgentRule entity. +func (c *AgentRuleClient) Create() *AgentRuleCreate { + mutation := newAgentRuleMutation(c.config, OpCreate) + return &AgentRuleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of AgentRule entities. +func (c *AgentRuleClient) CreateBulk(builders ...*AgentRuleCreate) *AgentRuleCreateBulk { + return &AgentRuleCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AgentRuleClient) MapCreateBulk(slice any, setFunc func(*AgentRuleCreate, int)) *AgentRuleCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AgentRuleCreateBulk{err: fmt.Errorf("calling to AgentRuleClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AgentRuleCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AgentRuleCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for AgentRule. +func (c *AgentRuleClient) Update() *AgentRuleUpdate { + mutation := newAgentRuleMutation(c.config, OpUpdate) + return &AgentRuleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AgentRuleClient) UpdateOne(_m *AgentRule) *AgentRuleUpdateOne { + mutation := newAgentRuleMutation(c.config, OpUpdateOne, withAgentRule(_m)) + return &AgentRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AgentRuleClient) UpdateOneID(id uuid.UUID) *AgentRuleUpdateOne { + mutation := newAgentRuleMutation(c.config, OpUpdateOne, withAgentRuleID(id)) + return &AgentRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for AgentRule. +func (c *AgentRuleClient) Delete() *AgentRuleDelete { + mutation := newAgentRuleMutation(c.config, OpDelete) + return &AgentRuleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AgentRuleClient) DeleteOne(_m *AgentRule) *AgentRuleDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AgentRuleClient) DeleteOneID(id uuid.UUID) *AgentRuleDeleteOne { + builder := c.Delete().Where(agentrule.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AgentRuleDeleteOne{builder} +} + +// Query returns a query builder for AgentRule. +func (c *AgentRuleClient) Query() *AgentRuleQuery { + return &AgentRuleQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAgentRule}, + inters: c.Interceptors(), + } +} + +// Get returns a AgentRule entity by its id. +func (c *AgentRuleClient) Get(ctx context.Context, id uuid.UUID) (*AgentRule, error) { + return c.Query().Where(agentrule.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AgentRuleClient) GetX(ctx context.Context, id uuid.UUID) *AgentRule { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryVersions queries the versions edge of a AgentRule. +func (c *AgentRuleClient) QueryVersions(_m *AgentRule) *AgentRuleVersionQuery { + query := (&AgentRuleVersionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentrule.Table, agentrule.FieldID, id), + sqlgraph.To(agentruleversion.Table, agentruleversion.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, agentrule.VersionsTable, agentrule.VersionsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AgentRuleClient) Hooks() []Hook { + return c.hooks.AgentRule +} + +// Interceptors returns the client interceptors. +func (c *AgentRuleClient) Interceptors() []Interceptor { + return c.inters.AgentRule +} + +func (c *AgentRuleClient) mutate(ctx context.Context, m *AgentRuleMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AgentRuleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AgentRuleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AgentRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AgentRuleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown AgentRule mutation op: %q", m.Op()) + } +} + +// AgentRuleVersionClient is a client for the AgentRuleVersion schema. +type AgentRuleVersionClient struct { + config +} + +// NewAgentRuleVersionClient returns a client for the AgentRuleVersion from the given config. +func NewAgentRuleVersionClient(c config) *AgentRuleVersionClient { + return &AgentRuleVersionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `agentruleversion.Hooks(f(g(h())))`. +func (c *AgentRuleVersionClient) Use(hooks ...Hook) { + c.hooks.AgentRuleVersion = append(c.hooks.AgentRuleVersion, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `agentruleversion.Intercept(f(g(h())))`. +func (c *AgentRuleVersionClient) Intercept(interceptors ...Interceptor) { + c.inters.AgentRuleVersion = append(c.inters.AgentRuleVersion, interceptors...) +} + +// Create returns a builder for creating a AgentRuleVersion entity. +func (c *AgentRuleVersionClient) Create() *AgentRuleVersionCreate { + mutation := newAgentRuleVersionMutation(c.config, OpCreate) + return &AgentRuleVersionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of AgentRuleVersion entities. +func (c *AgentRuleVersionClient) CreateBulk(builders ...*AgentRuleVersionCreate) *AgentRuleVersionCreateBulk { + return &AgentRuleVersionCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AgentRuleVersionClient) MapCreateBulk(slice any, setFunc func(*AgentRuleVersionCreate, int)) *AgentRuleVersionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AgentRuleVersionCreateBulk{err: fmt.Errorf("calling to AgentRuleVersionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AgentRuleVersionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AgentRuleVersionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for AgentRuleVersion. +func (c *AgentRuleVersionClient) Update() *AgentRuleVersionUpdate { + mutation := newAgentRuleVersionMutation(c.config, OpUpdate) + return &AgentRuleVersionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AgentRuleVersionClient) UpdateOne(_m *AgentRuleVersion) *AgentRuleVersionUpdateOne { + mutation := newAgentRuleVersionMutation(c.config, OpUpdateOne, withAgentRuleVersion(_m)) + return &AgentRuleVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AgentRuleVersionClient) UpdateOneID(id uuid.UUID) *AgentRuleVersionUpdateOne { + mutation := newAgentRuleVersionMutation(c.config, OpUpdateOne, withAgentRuleVersionID(id)) + return &AgentRuleVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for AgentRuleVersion. +func (c *AgentRuleVersionClient) Delete() *AgentRuleVersionDelete { + mutation := newAgentRuleVersionMutation(c.config, OpDelete) + return &AgentRuleVersionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AgentRuleVersionClient) DeleteOne(_m *AgentRuleVersion) *AgentRuleVersionDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AgentRuleVersionClient) DeleteOneID(id uuid.UUID) *AgentRuleVersionDeleteOne { + builder := c.Delete().Where(agentruleversion.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AgentRuleVersionDeleteOne{builder} +} + +// Query returns a query builder for AgentRuleVersion. +func (c *AgentRuleVersionClient) Query() *AgentRuleVersionQuery { + return &AgentRuleVersionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAgentRuleVersion}, + inters: c.Interceptors(), + } +} + +// Get returns a AgentRuleVersion entity by its id. +func (c *AgentRuleVersionClient) Get(ctx context.Context, id uuid.UUID) (*AgentRuleVersion, error) { + return c.Query().Where(agentruleversion.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AgentRuleVersionClient) GetX(ctx context.Context, id uuid.UUID) *AgentRuleVersion { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryRule queries the rule edge of a AgentRuleVersion. +func (c *AgentRuleVersionClient) QueryRule(_m *AgentRuleVersion) *AgentRuleQuery { + query := (&AgentRuleClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentruleversion.Table, agentruleversion.FieldID, id), + sqlgraph.To(agentrule.Table, agentrule.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, agentruleversion.RuleTable, agentruleversion.RuleColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AgentRuleVersionClient) Hooks() []Hook { + return c.hooks.AgentRuleVersion +} + +// Interceptors returns the client interceptors. +func (c *AgentRuleVersionClient) Interceptors() []Interceptor { + return c.inters.AgentRuleVersion +} + +func (c *AgentRuleVersionClient) mutate(ctx context.Context, m *AgentRuleVersionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AgentRuleVersionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AgentRuleVersionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AgentRuleVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AgentRuleVersionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown AgentRuleVersion mutation op: %q", m.Op()) + } +} + +// AgentSkillClient is a client for the AgentSkill schema. +type AgentSkillClient struct { + config +} + +// NewAgentSkillClient returns a client for the AgentSkill from the given config. +func NewAgentSkillClient(c config) *AgentSkillClient { + return &AgentSkillClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `agentskill.Hooks(f(g(h())))`. +func (c *AgentSkillClient) Use(hooks ...Hook) { + c.hooks.AgentSkill = append(c.hooks.AgentSkill, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `agentskill.Intercept(f(g(h())))`. +func (c *AgentSkillClient) Intercept(interceptors ...Interceptor) { + c.inters.AgentSkill = append(c.inters.AgentSkill, interceptors...) +} + +// Create returns a builder for creating a AgentSkill entity. +func (c *AgentSkillClient) Create() *AgentSkillCreate { + mutation := newAgentSkillMutation(c.config, OpCreate) + return &AgentSkillCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of AgentSkill entities. +func (c *AgentSkillClient) CreateBulk(builders ...*AgentSkillCreate) *AgentSkillCreateBulk { + return &AgentSkillCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AgentSkillClient) MapCreateBulk(slice any, setFunc func(*AgentSkillCreate, int)) *AgentSkillCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AgentSkillCreateBulk{err: fmt.Errorf("calling to AgentSkillClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AgentSkillCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AgentSkillCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for AgentSkill. +func (c *AgentSkillClient) Update() *AgentSkillUpdate { + mutation := newAgentSkillMutation(c.config, OpUpdate) + return &AgentSkillUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AgentSkillClient) UpdateOne(_m *AgentSkill) *AgentSkillUpdateOne { + mutation := newAgentSkillMutation(c.config, OpUpdateOne, withAgentSkill(_m)) + return &AgentSkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AgentSkillClient) UpdateOneID(id uuid.UUID) *AgentSkillUpdateOne { + mutation := newAgentSkillMutation(c.config, OpUpdateOne, withAgentSkillID(id)) + return &AgentSkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for AgentSkill. +func (c *AgentSkillClient) Delete() *AgentSkillDelete { + mutation := newAgentSkillMutation(c.config, OpDelete) + return &AgentSkillDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AgentSkillClient) DeleteOne(_m *AgentSkill) *AgentSkillDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AgentSkillClient) DeleteOneID(id uuid.UUID) *AgentSkillDeleteOne { + builder := c.Delete().Where(agentskill.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AgentSkillDeleteOne{builder} +} + +// Query returns a query builder for AgentSkill. +func (c *AgentSkillClient) Query() *AgentSkillQuery { + return &AgentSkillQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAgentSkill}, + inters: c.Interceptors(), + } +} + +// Get returns a AgentSkill entity by its id. +func (c *AgentSkillClient) Get(ctx context.Context, id uuid.UUID) (*AgentSkill, error) { + return c.Query().Where(agentskill.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AgentSkillClient) GetX(ctx context.Context, id uuid.UUID) *AgentSkill { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryRepo queries the repo edge of a AgentSkill. +func (c *AgentSkillClient) QueryRepo(_m *AgentSkill) *AgentSkillRepoQuery { + query := (&AgentSkillRepoClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentskill.Table, agentskill.FieldID, id), + sqlgraph.To(agentskillrepo.Table, agentskillrepo.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, agentskill.RepoTable, agentskill.RepoColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryVersions queries the versions edge of a AgentSkill. +func (c *AgentSkillClient) QueryVersions(_m *AgentSkill) *AgentSkillVersionQuery { + query := (&AgentSkillVersionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentskill.Table, agentskill.FieldID, id), + sqlgraph.To(agentskillversion.Table, agentskillversion.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, agentskill.VersionsTable, agentskill.VersionsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AgentSkillClient) Hooks() []Hook { + return c.hooks.AgentSkill +} + +// Interceptors returns the client interceptors. +func (c *AgentSkillClient) Interceptors() []Interceptor { + return c.inters.AgentSkill +} + +func (c *AgentSkillClient) mutate(ctx context.Context, m *AgentSkillMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AgentSkillCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AgentSkillUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AgentSkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AgentSkillDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown AgentSkill mutation op: %q", m.Op()) + } +} + +// AgentSkillGroupBindingClient is a client for the AgentSkillGroupBinding schema. +type AgentSkillGroupBindingClient struct { + config +} + +// NewAgentSkillGroupBindingClient returns a client for the AgentSkillGroupBinding from the given config. +func NewAgentSkillGroupBindingClient(c config) *AgentSkillGroupBindingClient { + return &AgentSkillGroupBindingClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `agentskillgroupbinding.Hooks(f(g(h())))`. +func (c *AgentSkillGroupBindingClient) Use(hooks ...Hook) { + c.hooks.AgentSkillGroupBinding = append(c.hooks.AgentSkillGroupBinding, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `agentskillgroupbinding.Intercept(f(g(h())))`. +func (c *AgentSkillGroupBindingClient) Intercept(interceptors ...Interceptor) { + c.inters.AgentSkillGroupBinding = append(c.inters.AgentSkillGroupBinding, interceptors...) +} + +// Create returns a builder for creating a AgentSkillGroupBinding entity. +func (c *AgentSkillGroupBindingClient) Create() *AgentSkillGroupBindingCreate { + mutation := newAgentSkillGroupBindingMutation(c.config, OpCreate) + return &AgentSkillGroupBindingCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of AgentSkillGroupBinding entities. +func (c *AgentSkillGroupBindingClient) CreateBulk(builders ...*AgentSkillGroupBindingCreate) *AgentSkillGroupBindingCreateBulk { + return &AgentSkillGroupBindingCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AgentSkillGroupBindingClient) MapCreateBulk(slice any, setFunc func(*AgentSkillGroupBindingCreate, int)) *AgentSkillGroupBindingCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AgentSkillGroupBindingCreateBulk{err: fmt.Errorf("calling to AgentSkillGroupBindingClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AgentSkillGroupBindingCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AgentSkillGroupBindingCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for AgentSkillGroupBinding. +func (c *AgentSkillGroupBindingClient) Update() *AgentSkillGroupBindingUpdate { + mutation := newAgentSkillGroupBindingMutation(c.config, OpUpdate) + return &AgentSkillGroupBindingUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AgentSkillGroupBindingClient) UpdateOne(_m *AgentSkillGroupBinding) *AgentSkillGroupBindingUpdateOne { + mutation := newAgentSkillGroupBindingMutation(c.config, OpUpdateOne, withAgentSkillGroupBinding(_m)) + return &AgentSkillGroupBindingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AgentSkillGroupBindingClient) UpdateOneID(id uuid.UUID) *AgentSkillGroupBindingUpdateOne { + mutation := newAgentSkillGroupBindingMutation(c.config, OpUpdateOne, withAgentSkillGroupBindingID(id)) + return &AgentSkillGroupBindingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for AgentSkillGroupBinding. +func (c *AgentSkillGroupBindingClient) Delete() *AgentSkillGroupBindingDelete { + mutation := newAgentSkillGroupBindingMutation(c.config, OpDelete) + return &AgentSkillGroupBindingDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AgentSkillGroupBindingClient) DeleteOne(_m *AgentSkillGroupBinding) *AgentSkillGroupBindingDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AgentSkillGroupBindingClient) DeleteOneID(id uuid.UUID) *AgentSkillGroupBindingDeleteOne { + builder := c.Delete().Where(agentskillgroupbinding.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AgentSkillGroupBindingDeleteOne{builder} +} + +// Query returns a query builder for AgentSkillGroupBinding. +func (c *AgentSkillGroupBindingClient) Query() *AgentSkillGroupBindingQuery { + return &AgentSkillGroupBindingQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAgentSkillGroupBinding}, + inters: c.Interceptors(), + } +} + +// Get returns a AgentSkillGroupBinding entity by its id. +func (c *AgentSkillGroupBindingClient) Get(ctx context.Context, id uuid.UUID) (*AgentSkillGroupBinding, error) { + return c.Query().Where(agentskillgroupbinding.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AgentSkillGroupBindingClient) GetX(ctx context.Context, id uuid.UUID) *AgentSkillGroupBinding { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QuerySkill queries the skill edge of a AgentSkillGroupBinding. +func (c *AgentSkillGroupBindingClient) QuerySkill(_m *AgentSkillGroupBinding) *AgentSkillQuery { + query := (&AgentSkillClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentskillgroupbinding.Table, agentskillgroupbinding.FieldID, id), + sqlgraph.To(agentskill.Table, agentskill.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, agentskillgroupbinding.SkillTable, agentskillgroupbinding.SkillColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryGroup queries the group edge of a AgentSkillGroupBinding. +func (c *AgentSkillGroupBindingClient) QueryGroup(_m *AgentSkillGroupBinding) *TeamGroupQuery { + query := (&TeamGroupClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentskillgroupbinding.Table, agentskillgroupbinding.FieldID, id), + sqlgraph.To(teamgroup.Table, teamgroup.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, agentskillgroupbinding.GroupTable, agentskillgroupbinding.GroupColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AgentSkillGroupBindingClient) Hooks() []Hook { + return c.hooks.AgentSkillGroupBinding +} + +// Interceptors returns the client interceptors. +func (c *AgentSkillGroupBindingClient) Interceptors() []Interceptor { + return c.inters.AgentSkillGroupBinding +} + +func (c *AgentSkillGroupBindingClient) mutate(ctx context.Context, m *AgentSkillGroupBindingMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AgentSkillGroupBindingCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AgentSkillGroupBindingUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AgentSkillGroupBindingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AgentSkillGroupBindingDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown AgentSkillGroupBinding mutation op: %q", m.Op()) + } +} + +// AgentSkillRepoClient is a client for the AgentSkillRepo schema. +type AgentSkillRepoClient struct { + config +} + +// NewAgentSkillRepoClient returns a client for the AgentSkillRepo from the given config. +func NewAgentSkillRepoClient(c config) *AgentSkillRepoClient { + return &AgentSkillRepoClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `agentskillrepo.Hooks(f(g(h())))`. +func (c *AgentSkillRepoClient) Use(hooks ...Hook) { + c.hooks.AgentSkillRepo = append(c.hooks.AgentSkillRepo, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `agentskillrepo.Intercept(f(g(h())))`. +func (c *AgentSkillRepoClient) Intercept(interceptors ...Interceptor) { + c.inters.AgentSkillRepo = append(c.inters.AgentSkillRepo, interceptors...) +} + +// Create returns a builder for creating a AgentSkillRepo entity. +func (c *AgentSkillRepoClient) Create() *AgentSkillRepoCreate { + mutation := newAgentSkillRepoMutation(c.config, OpCreate) + return &AgentSkillRepoCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of AgentSkillRepo entities. +func (c *AgentSkillRepoClient) CreateBulk(builders ...*AgentSkillRepoCreate) *AgentSkillRepoCreateBulk { + return &AgentSkillRepoCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AgentSkillRepoClient) MapCreateBulk(slice any, setFunc func(*AgentSkillRepoCreate, int)) *AgentSkillRepoCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AgentSkillRepoCreateBulk{err: fmt.Errorf("calling to AgentSkillRepoClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AgentSkillRepoCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AgentSkillRepoCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for AgentSkillRepo. +func (c *AgentSkillRepoClient) Update() *AgentSkillRepoUpdate { + mutation := newAgentSkillRepoMutation(c.config, OpUpdate) + return &AgentSkillRepoUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AgentSkillRepoClient) UpdateOne(_m *AgentSkillRepo) *AgentSkillRepoUpdateOne { + mutation := newAgentSkillRepoMutation(c.config, OpUpdateOne, withAgentSkillRepo(_m)) + return &AgentSkillRepoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AgentSkillRepoClient) UpdateOneID(id uuid.UUID) *AgentSkillRepoUpdateOne { + mutation := newAgentSkillRepoMutation(c.config, OpUpdateOne, withAgentSkillRepoID(id)) + return &AgentSkillRepoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for AgentSkillRepo. +func (c *AgentSkillRepoClient) Delete() *AgentSkillRepoDelete { + mutation := newAgentSkillRepoMutation(c.config, OpDelete) + return &AgentSkillRepoDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AgentSkillRepoClient) DeleteOne(_m *AgentSkillRepo) *AgentSkillRepoDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AgentSkillRepoClient) DeleteOneID(id uuid.UUID) *AgentSkillRepoDeleteOne { + builder := c.Delete().Where(agentskillrepo.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AgentSkillRepoDeleteOne{builder} +} + +// Query returns a query builder for AgentSkillRepo. +func (c *AgentSkillRepoClient) Query() *AgentSkillRepoQuery { + return &AgentSkillRepoQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAgentSkillRepo}, + inters: c.Interceptors(), + } +} + +// Get returns a AgentSkillRepo entity by its id. +func (c *AgentSkillRepoClient) Get(ctx context.Context, id uuid.UUID) (*AgentSkillRepo, error) { + return c.Query().Where(agentskillrepo.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AgentSkillRepoClient) GetX(ctx context.Context, id uuid.UUID) *AgentSkillRepo { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QuerySkills queries the skills edge of a AgentSkillRepo. +func (c *AgentSkillRepoClient) QuerySkills(_m *AgentSkillRepo) *AgentSkillQuery { + query := (&AgentSkillClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentskillrepo.Table, agentskillrepo.FieldID, id), + sqlgraph.To(agentskill.Table, agentskill.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, agentskillrepo.SkillsTable, agentskillrepo.SkillsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AgentSkillRepoClient) Hooks() []Hook { + return c.hooks.AgentSkillRepo +} + +// Interceptors returns the client interceptors. +func (c *AgentSkillRepoClient) Interceptors() []Interceptor { + return c.inters.AgentSkillRepo +} + +func (c *AgentSkillRepoClient) mutate(ctx context.Context, m *AgentSkillRepoMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AgentSkillRepoCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AgentSkillRepoUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AgentSkillRepoUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AgentSkillRepoDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown AgentSkillRepo mutation op: %q", m.Op()) + } +} + +// AgentSkillVersionClient is a client for the AgentSkillVersion schema. +type AgentSkillVersionClient struct { + config +} + +// NewAgentSkillVersionClient returns a client for the AgentSkillVersion from the given config. +func NewAgentSkillVersionClient(c config) *AgentSkillVersionClient { + return &AgentSkillVersionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `agentskillversion.Hooks(f(g(h())))`. +func (c *AgentSkillVersionClient) Use(hooks ...Hook) { + c.hooks.AgentSkillVersion = append(c.hooks.AgentSkillVersion, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `agentskillversion.Intercept(f(g(h())))`. +func (c *AgentSkillVersionClient) Intercept(interceptors ...Interceptor) { + c.inters.AgentSkillVersion = append(c.inters.AgentSkillVersion, interceptors...) +} + +// Create returns a builder for creating a AgentSkillVersion entity. +func (c *AgentSkillVersionClient) Create() *AgentSkillVersionCreate { + mutation := newAgentSkillVersionMutation(c.config, OpCreate) + return &AgentSkillVersionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of AgentSkillVersion entities. +func (c *AgentSkillVersionClient) CreateBulk(builders ...*AgentSkillVersionCreate) *AgentSkillVersionCreateBulk { + return &AgentSkillVersionCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AgentSkillVersionClient) MapCreateBulk(slice any, setFunc func(*AgentSkillVersionCreate, int)) *AgentSkillVersionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AgentSkillVersionCreateBulk{err: fmt.Errorf("calling to AgentSkillVersionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AgentSkillVersionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AgentSkillVersionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for AgentSkillVersion. +func (c *AgentSkillVersionClient) Update() *AgentSkillVersionUpdate { + mutation := newAgentSkillVersionMutation(c.config, OpUpdate) + return &AgentSkillVersionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AgentSkillVersionClient) UpdateOne(_m *AgentSkillVersion) *AgentSkillVersionUpdateOne { + mutation := newAgentSkillVersionMutation(c.config, OpUpdateOne, withAgentSkillVersion(_m)) + return &AgentSkillVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AgentSkillVersionClient) UpdateOneID(id uuid.UUID) *AgentSkillVersionUpdateOne { + mutation := newAgentSkillVersionMutation(c.config, OpUpdateOne, withAgentSkillVersionID(id)) + return &AgentSkillVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for AgentSkillVersion. +func (c *AgentSkillVersionClient) Delete() *AgentSkillVersionDelete { + mutation := newAgentSkillVersionMutation(c.config, OpDelete) + return &AgentSkillVersionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AgentSkillVersionClient) DeleteOne(_m *AgentSkillVersion) *AgentSkillVersionDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AgentSkillVersionClient) DeleteOneID(id uuid.UUID) *AgentSkillVersionDeleteOne { + builder := c.Delete().Where(agentskillversion.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AgentSkillVersionDeleteOne{builder} +} + +// Query returns a query builder for AgentSkillVersion. +func (c *AgentSkillVersionClient) Query() *AgentSkillVersionQuery { + return &AgentSkillVersionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAgentSkillVersion}, + inters: c.Interceptors(), + } +} + +// Get returns a AgentSkillVersion entity by its id. +func (c *AgentSkillVersionClient) Get(ctx context.Context, id uuid.UUID) (*AgentSkillVersion, error) { + return c.Query().Where(agentskillversion.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AgentSkillVersionClient) GetX(ctx context.Context, id uuid.UUID) *AgentSkillVersion { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QuerySkill queries the skill edge of a AgentSkillVersion. +func (c *AgentSkillVersionClient) QuerySkill(_m *AgentSkillVersion) *AgentSkillQuery { + query := (&AgentSkillClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(agentskillversion.Table, agentskillversion.FieldID, id), + sqlgraph.To(agentskill.Table, agentskill.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, agentskillversion.SkillTable, agentskillversion.SkillColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AgentSkillVersionClient) Hooks() []Hook { + return c.hooks.AgentSkillVersion +} + +// Interceptors returns the client interceptors. +func (c *AgentSkillVersionClient) Interceptors() []Interceptor { + return c.inters.AgentSkillVersion +} + +func (c *AgentSkillVersionClient) mutate(ctx context.Context, m *AgentSkillVersionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AgentSkillVersionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AgentSkillVersionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AgentSkillVersionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AgentSkillVersionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown AgentSkillVersion mutation op: %q", m.Op()) + } +} + +// AgentSyncJobClient is a client for the AgentSyncJob schema. +type AgentSyncJobClient struct { + config +} + +// NewAgentSyncJobClient returns a client for the AgentSyncJob from the given config. +func NewAgentSyncJobClient(c config) *AgentSyncJobClient { + return &AgentSyncJobClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `agentsyncjob.Hooks(f(g(h())))`. +func (c *AgentSyncJobClient) Use(hooks ...Hook) { + c.hooks.AgentSyncJob = append(c.hooks.AgentSyncJob, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `agentsyncjob.Intercept(f(g(h())))`. +func (c *AgentSyncJobClient) Intercept(interceptors ...Interceptor) { + c.inters.AgentSyncJob = append(c.inters.AgentSyncJob, interceptors...) +} + +// Create returns a builder for creating a AgentSyncJob entity. +func (c *AgentSyncJobClient) Create() *AgentSyncJobCreate { + mutation := newAgentSyncJobMutation(c.config, OpCreate) + return &AgentSyncJobCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of AgentSyncJob entities. +func (c *AgentSyncJobClient) CreateBulk(builders ...*AgentSyncJobCreate) *AgentSyncJobCreateBulk { + return &AgentSyncJobCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AgentSyncJobClient) MapCreateBulk(slice any, setFunc func(*AgentSyncJobCreate, int)) *AgentSyncJobCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AgentSyncJobCreateBulk{err: fmt.Errorf("calling to AgentSyncJobClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AgentSyncJobCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AgentSyncJobCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for AgentSyncJob. +func (c *AgentSyncJobClient) Update() *AgentSyncJobUpdate { + mutation := newAgentSyncJobMutation(c.config, OpUpdate) + return &AgentSyncJobUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AgentSyncJobClient) UpdateOne(_m *AgentSyncJob) *AgentSyncJobUpdateOne { + mutation := newAgentSyncJobMutation(c.config, OpUpdateOne, withAgentSyncJob(_m)) + return &AgentSyncJobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AgentSyncJobClient) UpdateOneID(id uuid.UUID) *AgentSyncJobUpdateOne { + mutation := newAgentSyncJobMutation(c.config, OpUpdateOne, withAgentSyncJobID(id)) + return &AgentSyncJobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for AgentSyncJob. +func (c *AgentSyncJobClient) Delete() *AgentSyncJobDelete { + mutation := newAgentSyncJobMutation(c.config, OpDelete) + return &AgentSyncJobDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AgentSyncJobClient) DeleteOne(_m *AgentSyncJob) *AgentSyncJobDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AgentSyncJobClient) DeleteOneID(id uuid.UUID) *AgentSyncJobDeleteOne { + builder := c.Delete().Where(agentsyncjob.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AgentSyncJobDeleteOne{builder} +} + +// Query returns a query builder for AgentSyncJob. +func (c *AgentSyncJobClient) Query() *AgentSyncJobQuery { + return &AgentSyncJobQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeAgentSyncJob}, + inters: c.Interceptors(), + } +} + +// Get returns a AgentSyncJob entity by its id. +func (c *AgentSyncJobClient) Get(ctx context.Context, id uuid.UUID) (*AgentSyncJob, error) { + return c.Query().Where(agentsyncjob.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AgentSyncJobClient) GetX(ctx context.Context, id uuid.UUID) *AgentSyncJob { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *AgentSyncJobClient) Hooks() []Hook { + return c.hooks.AgentSyncJob +} + +// Interceptors returns the client interceptors. +func (c *AgentSyncJobClient) Interceptors() []Interceptor { + return c.inters.AgentSyncJob +} + +func (c *AgentSyncJobClient) mutate(ctx context.Context, m *AgentSyncJobMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AgentSyncJobCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AgentSyncJobUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AgentSyncJobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AgentSyncJobDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown AgentSyncJob mutation op: %q", m.Op()) + } +} + // AuditClient is a client for the Audit schema. type AuditClient struct { config @@ -4831,236 +6413,21 @@ func (c *ProjectTaskClient) Hooks() []Hook { // Interceptors returns the client interceptors. func (c *ProjectTaskClient) Interceptors() []Interceptor { - return c.inters.ProjectTask -} - -func (c *ProjectTaskClient) mutate(ctx context.Context, m *ProjectTaskMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&ProjectTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&ProjectTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&ProjectTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&ProjectTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("db: unknown ProjectTask mutation op: %q", m.Op()) - } -} - -// SkillClient is a client for the Skill schema. -type SkillClient struct { - config -} - -// NewSkillClient returns a client for the Skill from the given config. -func NewSkillClient(c config) *SkillClient { - return &SkillClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `skill.Hooks(f(g(h())))`. -func (c *SkillClient) Use(hooks ...Hook) { - c.hooks.Skill = append(c.hooks.Skill, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `skill.Intercept(f(g(h())))`. -func (c *SkillClient) Intercept(interceptors ...Interceptor) { - c.inters.Skill = append(c.inters.Skill, interceptors...) -} - -// Create returns a builder for creating a Skill entity. -func (c *SkillClient) Create() *SkillCreate { - mutation := newSkillMutation(c.config, OpCreate) - return &SkillCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Skill entities. -func (c *SkillClient) CreateBulk(builders ...*SkillCreate) *SkillCreateBulk { - return &SkillCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *SkillClient) MapCreateBulk(slice any, setFunc func(*SkillCreate, int)) *SkillCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &SkillCreateBulk{err: fmt.Errorf("calling to SkillClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*SkillCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &SkillCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Skill. -func (c *SkillClient) Update() *SkillUpdate { - mutation := newSkillMutation(c.config, OpUpdate) - return &SkillUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *SkillClient) UpdateOne(_m *Skill) *SkillUpdateOne { - mutation := newSkillMutation(c.config, OpUpdateOne, withSkill(_m)) - return &SkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *SkillClient) UpdateOneID(id uuid.UUID) *SkillUpdateOne { - mutation := newSkillMutation(c.config, OpUpdateOne, withSkillID(id)) - return &SkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Skill. -func (c *SkillClient) Delete() *SkillDelete { - mutation := newSkillMutation(c.config, OpDelete) - return &SkillDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *SkillClient) DeleteOne(_m *Skill) *SkillDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *SkillClient) DeleteOneID(id uuid.UUID) *SkillDeleteOne { - builder := c.Delete().Where(skill.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &SkillDeleteOne{builder} -} - -// Query returns a query builder for Skill. -func (c *SkillClient) Query() *SkillQuery { - return &SkillQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeSkill}, - inters: c.Interceptors(), - } -} - -// Get returns a Skill entity by its id. -func (c *SkillClient) Get(ctx context.Context, id uuid.UUID) (*Skill, error) { - return c.Query().Where(skill.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *SkillClient) GetX(ctx context.Context, id uuid.UUID) *Skill { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryUser queries the user edge of a Skill. -func (c *SkillClient) QueryUser(_m *Skill) *UserQuery { - query := (&UserClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(skill.Table, skill.FieldID, id), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, skill.UserTable, skill.UserColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryTeams queries the teams edge of a Skill. -func (c *SkillClient) QueryTeams(_m *Skill) *TeamQuery { - query := (&TeamClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(skill.Table, skill.FieldID, id), - sqlgraph.To(team.Table, team.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, skill.TeamsTable, skill.TeamsPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryGroups queries the groups edge of a Skill. -func (c *SkillClient) QueryGroups(_m *Skill) *TeamGroupQuery { - query := (&TeamGroupClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(skill.Table, skill.FieldID, id), - sqlgraph.To(teamgroup.Table, teamgroup.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, skill.GroupsTable, skill.GroupsPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryTeamSkills queries the team_skills edge of a Skill. -func (c *SkillClient) QueryTeamSkills(_m *Skill) *TeamSkillQuery { - query := (&TeamSkillClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(skill.Table, skill.FieldID, id), - sqlgraph.To(teamskill.Table, teamskill.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, skill.TeamSkillsTable, skill.TeamSkillsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryTeamGroupSkills queries the team_group_skills edge of a Skill. -func (c *SkillClient) QueryTeamGroupSkills(_m *Skill) *TeamGroupSkillQuery { - query := (&TeamGroupSkillClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(skill.Table, skill.FieldID, id), - sqlgraph.To(teamgroupskill.Table, teamgroupskill.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, skill.TeamGroupSkillsTable, skill.TeamGroupSkillsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *SkillClient) Hooks() []Hook { - hooks := c.hooks.Skill - return append(hooks[:len(hooks):len(hooks)], skill.Hooks[:]...) -} - -// Interceptors returns the client interceptors. -func (c *SkillClient) Interceptors() []Interceptor { - inters := c.inters.Skill - return append(inters[:len(inters):len(inters)], skill.Interceptors[:]...) + return c.inters.ProjectTask } -func (c *SkillClient) mutate(ctx context.Context, m *SkillMutation) (Value, error) { +func (c *ProjectTaskClient) mutate(ctx context.Context, m *ProjectTaskMutation) (Value, error) { switch m.Op() { case OpCreate: - return (&SkillCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + return (&ProjectTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: - return (&SkillUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + return (&ProjectTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: - return (&SkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + return (&ProjectTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: - return (&SkillDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + return (&ProjectTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: - return nil, fmt.Errorf("db: unknown Skill mutation op: %q", m.Op()) + return nil, fmt.Errorf("db: unknown ProjectTask mutation op: %q", m.Op()) } } @@ -5978,22 +7345,6 @@ func (c *TeamClient) QueryImages(_m *Team) *ImageQuery { return query } -// QuerySkills queries the skills edge of a Team. -func (c *TeamClient) QuerySkills(_m *Team) *SkillQuery { - query := (&SkillClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(team.Table, team.FieldID, id), - sqlgraph.To(skill.Table, skill.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, team.SkillsTable, team.SkillsPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - // QueryExtensionImageArchives queries the extension_image_archives edge of a Team. func (c *TeamClient) QueryExtensionImageArchives(_m *Team) *TeamExtensionImageArchiveQuery { query := (&TeamExtensionImageArchiveClient{config: c.config}).Query() @@ -6058,22 +7409,6 @@ func (c *TeamClient) QueryTeamImages(_m *Team) *TeamImageQuery { return query } -// QueryTeamSkills queries the team_skills edge of a Team. -func (c *TeamClient) QueryTeamSkills(_m *Team) *TeamSkillQuery { - query := (&TeamSkillClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(team.Table, team.FieldID, id), - sqlgraph.To(teamskill.Table, teamskill.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, team.TeamSkillsTable, team.TeamSkillsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - // Hooks returns the client hooks. func (c *TeamClient) Hooks() []Hook { hooks := c.hooks.Team @@ -6454,22 +7789,6 @@ func (c *TeamGroupClient) QueryHosts(_m *TeamGroup) *HostQuery { return query } -// QuerySkills queries the skills edge of a TeamGroup. -func (c *TeamGroupClient) QuerySkills(_m *TeamGroup) *SkillQuery { - query := (&SkillClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(teamgroup.Table, teamgroup.FieldID, id), - sqlgraph.To(skill.Table, skill.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, teamgroup.SkillsTable, teamgroup.SkillsPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - // QueryTeamGroupMembers queries the team_group_members edge of a TeamGroup. func (c *TeamGroupClient) QueryTeamGroupMembers(_m *TeamGroup) *TeamGroupMemberQuery { query := (&TeamGroupMemberClient{config: c.config}).Query() @@ -6534,22 +7853,6 @@ func (c *TeamGroupClient) QueryTeamGroupHosts(_m *TeamGroup) *TeamGroupHostQuery return query } -// QueryTeamGroupSkills queries the team_group_skills edge of a TeamGroup. -func (c *TeamGroupClient) QueryTeamGroupSkills(_m *TeamGroup) *TeamGroupSkillQuery { - query := (&TeamGroupSkillClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(teamgroup.Table, teamgroup.FieldID, id), - sqlgraph.To(teamgroupskill.Table, teamgroupskill.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, teamgroup.TeamGroupSkillsTable, teamgroup.TeamGroupSkillsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - // Hooks returns the client hooks. func (c *TeamGroupClient) Hooks() []Hook { hooks := c.hooks.TeamGroup @@ -7237,171 +8540,6 @@ func (c *TeamGroupModelClient) mutate(ctx context.Context, m *TeamGroupModelMuta } } -// TeamGroupSkillClient is a client for the TeamGroupSkill schema. -type TeamGroupSkillClient struct { - config -} - -// NewTeamGroupSkillClient returns a client for the TeamGroupSkill from the given config. -func NewTeamGroupSkillClient(c config) *TeamGroupSkillClient { - return &TeamGroupSkillClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `teamgroupskill.Hooks(f(g(h())))`. -func (c *TeamGroupSkillClient) Use(hooks ...Hook) { - c.hooks.TeamGroupSkill = append(c.hooks.TeamGroupSkill, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `teamgroupskill.Intercept(f(g(h())))`. -func (c *TeamGroupSkillClient) Intercept(interceptors ...Interceptor) { - c.inters.TeamGroupSkill = append(c.inters.TeamGroupSkill, interceptors...) -} - -// Create returns a builder for creating a TeamGroupSkill entity. -func (c *TeamGroupSkillClient) Create() *TeamGroupSkillCreate { - mutation := newTeamGroupSkillMutation(c.config, OpCreate) - return &TeamGroupSkillCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of TeamGroupSkill entities. -func (c *TeamGroupSkillClient) CreateBulk(builders ...*TeamGroupSkillCreate) *TeamGroupSkillCreateBulk { - return &TeamGroupSkillCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *TeamGroupSkillClient) MapCreateBulk(slice any, setFunc func(*TeamGroupSkillCreate, int)) *TeamGroupSkillCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &TeamGroupSkillCreateBulk{err: fmt.Errorf("calling to TeamGroupSkillClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*TeamGroupSkillCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &TeamGroupSkillCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for TeamGroupSkill. -func (c *TeamGroupSkillClient) Update() *TeamGroupSkillUpdate { - mutation := newTeamGroupSkillMutation(c.config, OpUpdate) - return &TeamGroupSkillUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *TeamGroupSkillClient) UpdateOne(_m *TeamGroupSkill) *TeamGroupSkillUpdateOne { - mutation := newTeamGroupSkillMutation(c.config, OpUpdateOne, withTeamGroupSkill(_m)) - return &TeamGroupSkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *TeamGroupSkillClient) UpdateOneID(id uuid.UUID) *TeamGroupSkillUpdateOne { - mutation := newTeamGroupSkillMutation(c.config, OpUpdateOne, withTeamGroupSkillID(id)) - return &TeamGroupSkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for TeamGroupSkill. -func (c *TeamGroupSkillClient) Delete() *TeamGroupSkillDelete { - mutation := newTeamGroupSkillMutation(c.config, OpDelete) - return &TeamGroupSkillDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *TeamGroupSkillClient) DeleteOne(_m *TeamGroupSkill) *TeamGroupSkillDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *TeamGroupSkillClient) DeleteOneID(id uuid.UUID) *TeamGroupSkillDeleteOne { - builder := c.Delete().Where(teamgroupskill.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &TeamGroupSkillDeleteOne{builder} -} - -// Query returns a query builder for TeamGroupSkill. -func (c *TeamGroupSkillClient) Query() *TeamGroupSkillQuery { - return &TeamGroupSkillQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeTeamGroupSkill}, - inters: c.Interceptors(), - } -} - -// Get returns a TeamGroupSkill entity by its id. -func (c *TeamGroupSkillClient) Get(ctx context.Context, id uuid.UUID) (*TeamGroupSkill, error) { - return c.Query().Where(teamgroupskill.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *TeamGroupSkillClient) GetX(ctx context.Context, id uuid.UUID) *TeamGroupSkill { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryGroup queries the group edge of a TeamGroupSkill. -func (c *TeamGroupSkillClient) QueryGroup(_m *TeamGroupSkill) *TeamGroupQuery { - query := (&TeamGroupClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(teamgroupskill.Table, teamgroupskill.FieldID, id), - sqlgraph.To(teamgroup.Table, teamgroup.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, teamgroupskill.GroupTable, teamgroupskill.GroupColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QuerySkill queries the skill edge of a TeamGroupSkill. -func (c *TeamGroupSkillClient) QuerySkill(_m *TeamGroupSkill) *SkillQuery { - query := (&SkillClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(teamgroupskill.Table, teamgroupskill.FieldID, id), - sqlgraph.To(skill.Table, skill.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, teamgroupskill.SkillTable, teamgroupskill.SkillColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *TeamGroupSkillClient) Hooks() []Hook { - return c.hooks.TeamGroupSkill -} - -// Interceptors returns the client interceptors. -func (c *TeamGroupSkillClient) Interceptors() []Interceptor { - return c.inters.TeamGroupSkill -} - -func (c *TeamGroupSkillClient) mutate(ctx context.Context, m *TeamGroupSkillMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&TeamGroupSkillCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&TeamGroupSkillUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&TeamGroupSkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&TeamGroupSkillDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("db: unknown TeamGroupSkill mutation op: %q", m.Op()) - } -} - // TeamHostClient is a client for the TeamHost schema. type TeamHostClient struct { config @@ -8211,171 +9349,6 @@ func (c *TeamOIDCConfigClient) mutate(ctx context.Context, m *TeamOIDCConfigMuta } } -// TeamSkillClient is a client for the TeamSkill schema. -type TeamSkillClient struct { - config -} - -// NewTeamSkillClient returns a client for the TeamSkill from the given config. -func NewTeamSkillClient(c config) *TeamSkillClient { - return &TeamSkillClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `teamskill.Hooks(f(g(h())))`. -func (c *TeamSkillClient) Use(hooks ...Hook) { - c.hooks.TeamSkill = append(c.hooks.TeamSkill, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `teamskill.Intercept(f(g(h())))`. -func (c *TeamSkillClient) Intercept(interceptors ...Interceptor) { - c.inters.TeamSkill = append(c.inters.TeamSkill, interceptors...) -} - -// Create returns a builder for creating a TeamSkill entity. -func (c *TeamSkillClient) Create() *TeamSkillCreate { - mutation := newTeamSkillMutation(c.config, OpCreate) - return &TeamSkillCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of TeamSkill entities. -func (c *TeamSkillClient) CreateBulk(builders ...*TeamSkillCreate) *TeamSkillCreateBulk { - return &TeamSkillCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *TeamSkillClient) MapCreateBulk(slice any, setFunc func(*TeamSkillCreate, int)) *TeamSkillCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &TeamSkillCreateBulk{err: fmt.Errorf("calling to TeamSkillClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*TeamSkillCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &TeamSkillCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for TeamSkill. -func (c *TeamSkillClient) Update() *TeamSkillUpdate { - mutation := newTeamSkillMutation(c.config, OpUpdate) - return &TeamSkillUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *TeamSkillClient) UpdateOne(_m *TeamSkill) *TeamSkillUpdateOne { - mutation := newTeamSkillMutation(c.config, OpUpdateOne, withTeamSkill(_m)) - return &TeamSkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *TeamSkillClient) UpdateOneID(id uuid.UUID) *TeamSkillUpdateOne { - mutation := newTeamSkillMutation(c.config, OpUpdateOne, withTeamSkillID(id)) - return &TeamSkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for TeamSkill. -func (c *TeamSkillClient) Delete() *TeamSkillDelete { - mutation := newTeamSkillMutation(c.config, OpDelete) - return &TeamSkillDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *TeamSkillClient) DeleteOne(_m *TeamSkill) *TeamSkillDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *TeamSkillClient) DeleteOneID(id uuid.UUID) *TeamSkillDeleteOne { - builder := c.Delete().Where(teamskill.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &TeamSkillDeleteOne{builder} -} - -// Query returns a query builder for TeamSkill. -func (c *TeamSkillClient) Query() *TeamSkillQuery { - return &TeamSkillQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeTeamSkill}, - inters: c.Interceptors(), - } -} - -// Get returns a TeamSkill entity by its id. -func (c *TeamSkillClient) Get(ctx context.Context, id uuid.UUID) (*TeamSkill, error) { - return c.Query().Where(teamskill.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *TeamSkillClient) GetX(ctx context.Context, id uuid.UUID) *TeamSkill { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryTeam queries the team edge of a TeamSkill. -func (c *TeamSkillClient) QueryTeam(_m *TeamSkill) *TeamQuery { - query := (&TeamClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(teamskill.Table, teamskill.FieldID, id), - sqlgraph.To(team.Table, team.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, teamskill.TeamTable, teamskill.TeamColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QuerySkill queries the skill edge of a TeamSkill. -func (c *TeamSkillClient) QuerySkill(_m *TeamSkill) *SkillQuery { - query := (&SkillClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(teamskill.Table, teamskill.FieldID, id), - sqlgraph.To(skill.Table, skill.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, teamskill.SkillTable, teamskill.SkillColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *TeamSkillClient) Hooks() []Hook { - return c.hooks.TeamSkill -} - -// Interceptors returns the client interceptors. -func (c *TeamSkillClient) Interceptors() []Interceptor { - return c.inters.TeamSkill -} - -func (c *TeamSkillClient) mutate(ctx context.Context, m *TeamSkillMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&TeamSkillCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&TeamSkillUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&TeamSkillUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&TeamSkillDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("db: unknown TeamSkill mutation op: %q", m.Op()) - } -} - // UserClient is a client for the User schema. type UserClient struct { config @@ -8580,22 +9553,6 @@ func (c *UserClient) QueryImages(_m *User) *ImageQuery { return query } -// QuerySkills queries the skills edge of a User. -func (c *UserClient) QuerySkills(_m *User) *SkillQuery { - query := (&SkillClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, id), - sqlgraph.To(skill.Table, skill.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, user.SkillsTable, user.SkillsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - // QueryHosts queries the hosts edge of a User. func (c *UserClient) QueryHosts(_m *User) *HostQuery { query := (&HostClient{config: c.config}).Query() @@ -9248,26 +10205,28 @@ func (c *VirtualMachineClient) mutate(ctx context.Context, m *VirtualMachineMuta // hooks and interceptors per client, for fast access. type ( hooks struct { - Audit, GitBot, GitBotTask, GitBotUser, GitIdentity, GitTask, Host, Image, - MCPTool, MCPUpstream, MCPUserToolSetting, Model, ModelApiKey, ModelPricing, - NotifyChannel, NotifySendLog, NotifySubscription, Project, ProjectCollaborator, - ProjectGitBot, ProjectIssue, ProjectIssueComment, ProjectTask, Skill, Task, - TaskModelSwitch, TaskUsageStat, TaskVirtualMachine, Team, + AgentPlugin, AgentPluginRepo, AgentPluginVersion, AgentRule, AgentRuleVersion, + AgentSkill, AgentSkillGroupBinding, AgentSkillRepo, AgentSkillVersion, + AgentSyncJob, Audit, GitBot, GitBotTask, GitBotUser, GitIdentity, GitTask, + Host, Image, MCPTool, MCPUpstream, MCPUserToolSetting, Model, ModelApiKey, + ModelPricing, NotifyChannel, NotifySendLog, NotifySubscription, Project, + ProjectCollaborator, ProjectGitBot, ProjectIssue, ProjectIssueComment, + ProjectTask, Task, TaskModelSwitch, TaskUsageStat, TaskVirtualMachine, Team, TeamExtensionImageArchive, TeamGroup, TeamGroupHost, TeamGroupImage, - TeamGroupMember, TeamGroupModel, TeamGroupSkill, TeamHost, TeamImage, - TeamMember, TeamModel, TeamOIDCConfig, TeamSkill, User, UserIdentity, - VirtualMachine []ent.Hook + TeamGroupMember, TeamGroupModel, TeamHost, TeamImage, TeamMember, TeamModel, + TeamOIDCConfig, User, UserIdentity, VirtualMachine []ent.Hook } inters struct { - Audit, GitBot, GitBotTask, GitBotUser, GitIdentity, GitTask, Host, Image, - MCPTool, MCPUpstream, MCPUserToolSetting, Model, ModelApiKey, ModelPricing, - NotifyChannel, NotifySendLog, NotifySubscription, Project, ProjectCollaborator, - ProjectGitBot, ProjectIssue, ProjectIssueComment, ProjectTask, Skill, Task, - TaskModelSwitch, TaskUsageStat, TaskVirtualMachine, Team, + AgentPlugin, AgentPluginRepo, AgentPluginVersion, AgentRule, AgentRuleVersion, + AgentSkill, AgentSkillGroupBinding, AgentSkillRepo, AgentSkillVersion, + AgentSyncJob, Audit, GitBot, GitBotTask, GitBotUser, GitIdentity, GitTask, + Host, Image, MCPTool, MCPUpstream, MCPUserToolSetting, Model, ModelApiKey, + ModelPricing, NotifyChannel, NotifySendLog, NotifySubscription, Project, + ProjectCollaborator, ProjectGitBot, ProjectIssue, ProjectIssueComment, + ProjectTask, Task, TaskModelSwitch, TaskUsageStat, TaskVirtualMachine, Team, TeamExtensionImageArchive, TeamGroup, TeamGroupHost, TeamGroupImage, - TeamGroupMember, TeamGroupModel, TeamGroupSkill, TeamHost, TeamImage, - TeamMember, TeamModel, TeamOIDCConfig, TeamSkill, User, UserIdentity, - VirtualMachine []ent.Interceptor + TeamGroupMember, TeamGroupModel, TeamHost, TeamImage, TeamMember, TeamModel, + TeamOIDCConfig, User, UserIdentity, VirtualMachine []ent.Interceptor } ) diff --git a/backend/db/cursor.go b/backend/db/cursor.go index 5c53d7cf..c2ca17eb 100644 --- a/backend/db/cursor.go +++ b/backend/db/cursor.go @@ -22,12 +22,10 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/project" "github.com/chaitin/MonkeyCode/backend/db/projectissue" "github.com/chaitin/MonkeyCode/backend/db/projectissuecomment" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/task" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" "github.com/chaitin/MonkeyCode/backend/db/teamgrouphost" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/google/uuid" ) @@ -620,51 +618,6 @@ func (q *ProjectIssueCommentQuery) After(ctx context.Context, cursor string, lim return nodes, res, nil } -func (q *SkillQuery) After(ctx context.Context, cursor string, limit int) ([]*Skill, *Cursor, error) { - i, err := unmarshalCreatedAt(cursor) - if err != nil { - return nil, nil, err - } - q.Order(skill.ByCreatedAt(sql.OrderDesc()), skill.ByID(sql.OrderDesc())) - q.Limit(limit + 1) - - if i != nil { - q.Where(func(s *sql.Selector) { - s.Where(sql.Or( - sql.LT(s.C("created_at"), i.CreatedAt), - sql.And( - sql.EQ(s.C("created_at"), i.CreatedAt), - sql.LT(s.C("id"), i.ID), - ), - )) - }) - } - nodes, err := q.All(ctx) - if err != nil { - return nil, nil, err - } - - res := &Cursor{} - if len(nodes) > limit { - res.HasNextPage = true - nodes = nodes[:limit] - } - - if len(nodes) > 0 { - last := nodes[len(nodes)-1] - i := &createdAtCursor{ - CreatedAt: last.CreatedAt, - ID: last.ID, - } - cursor, err := i.marshal() - if err != nil { - return nil, nil, err - } - res.Cursor = cursor - } - return nodes, res, nil -} - func (q *TaskQuery) After(ctx context.Context, cursor string, limit int) ([]*Task, *Cursor, error) { i, err := unmarshalCreatedAt(cursor) if err != nil { @@ -844,48 +797,3 @@ func (q *TeamGroupModelQuery) After(ctx context.Context, cursor string, limit in } return nodes, res, nil } - -func (q *TeamGroupSkillQuery) After(ctx context.Context, cursor string, limit int) ([]*TeamGroupSkill, *Cursor, error) { - i, err := unmarshalCreatedAt(cursor) - if err != nil { - return nil, nil, err - } - q.Order(teamgroupskill.ByCreatedAt(sql.OrderDesc()), teamgroupskill.ByID(sql.OrderDesc())) - q.Limit(limit + 1) - - if i != nil { - q.Where(func(s *sql.Selector) { - s.Where(sql.Or( - sql.LT(s.C("created_at"), i.CreatedAt), - sql.And( - sql.EQ(s.C("created_at"), i.CreatedAt), - sql.LT(s.C("id"), i.ID), - ), - )) - }) - } - nodes, err := q.All(ctx) - if err != nil { - return nil, nil, err - } - - res := &Cursor{} - if len(nodes) > limit { - res.HasNextPage = true - nodes = nodes[:limit] - } - - if len(nodes) > 0 { - last := nodes[len(nodes)-1] - i := &createdAtCursor{ - CreatedAt: last.CreatedAt, - ID: last.ID, - } - cursor, err := i.marshal() - if err != nil { - return nil, nil, err - } - res.Cursor = cursor - } - return nodes, res, nil -} diff --git a/backend/db/ent.go b/backend/db/ent.go index f52955de..6331eed9 100644 --- a/backend/db/ent.go +++ b/backend/db/ent.go @@ -12,6 +12,16 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/db/agentsyncjob" "github.com/chaitin/MonkeyCode/backend/db/audit" "github.com/chaitin/MonkeyCode/backend/db/gitbot" "github.com/chaitin/MonkeyCode/backend/db/gitbottask" @@ -35,7 +45,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/projectissue" "github.com/chaitin/MonkeyCode/backend/db/projectissuecomment" "github.com/chaitin/MonkeyCode/backend/db/projecttask" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/task" "github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch" "github.com/chaitin/MonkeyCode/backend/db/taskusagestat" @@ -47,13 +56,11 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/teamgroupimage" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmember" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/chaitin/MonkeyCode/backend/db/teamhost" "github.com/chaitin/MonkeyCode/backend/db/teamimage" "github.com/chaitin/MonkeyCode/backend/db/teammember" "github.com/chaitin/MonkeyCode/backend/db/teammodel" "github.com/chaitin/MonkeyCode/backend/db/teamoidcconfig" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/chaitin/MonkeyCode/backend/db/useridentity" "github.com/chaitin/MonkeyCode/backend/db/virtualmachine" @@ -117,6 +124,16 @@ var ( func checkColumn(t, c string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + agentplugin.Table: agentplugin.ValidColumn, + agentpluginrepo.Table: agentpluginrepo.ValidColumn, + agentpluginversion.Table: agentpluginversion.ValidColumn, + agentrule.Table: agentrule.ValidColumn, + agentruleversion.Table: agentruleversion.ValidColumn, + agentskill.Table: agentskill.ValidColumn, + agentskillgroupbinding.Table: agentskillgroupbinding.ValidColumn, + agentskillrepo.Table: agentskillrepo.ValidColumn, + agentskillversion.Table: agentskillversion.ValidColumn, + agentsyncjob.Table: agentsyncjob.ValidColumn, audit.Table: audit.ValidColumn, gitbot.Table: gitbot.ValidColumn, gitbottask.Table: gitbottask.ValidColumn, @@ -140,7 +157,6 @@ func checkColumn(t, c string) error { projectissue.Table: projectissue.ValidColumn, projectissuecomment.Table: projectissuecomment.ValidColumn, projecttask.Table: projecttask.ValidColumn, - skill.Table: skill.ValidColumn, task.Table: task.ValidColumn, taskmodelswitch.Table: taskmodelswitch.ValidColumn, taskusagestat.Table: taskusagestat.ValidColumn, @@ -152,13 +168,11 @@ func checkColumn(t, c string) error { teamgroupimage.Table: teamgroupimage.ValidColumn, teamgroupmember.Table: teamgroupmember.ValidColumn, teamgroupmodel.Table: teamgroupmodel.ValidColumn, - teamgroupskill.Table: teamgroupskill.ValidColumn, teamhost.Table: teamhost.ValidColumn, teamimage.Table: teamimage.ValidColumn, teammember.Table: teammember.ValidColumn, teammodel.Table: teammodel.ValidColumn, teamoidcconfig.Table: teamoidcconfig.ValidColumn, - teamskill.Table: teamskill.ValidColumn, user.Table: user.ValidColumn, useridentity.Table: useridentity.ValidColumn, virtualmachine.Table: virtualmachine.ValidColumn, diff --git a/backend/db/hook/hook.go b/backend/db/hook/hook.go index ffcc2e94..48da622c 100644 --- a/backend/db/hook/hook.go +++ b/backend/db/hook/hook.go @@ -9,6 +9,126 @@ import ( "github.com/chaitin/MonkeyCode/backend/db" ) +// The AgentPluginFunc type is an adapter to allow the use of ordinary +// function as AgentPlugin mutator. +type AgentPluginFunc func(context.Context, *db.AgentPluginMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f AgentPluginFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.AgentPluginMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.AgentPluginMutation", m) +} + +// The AgentPluginRepoFunc type is an adapter to allow the use of ordinary +// function as AgentPluginRepo mutator. +type AgentPluginRepoFunc func(context.Context, *db.AgentPluginRepoMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f AgentPluginRepoFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.AgentPluginRepoMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.AgentPluginRepoMutation", m) +} + +// The AgentPluginVersionFunc type is an adapter to allow the use of ordinary +// function as AgentPluginVersion mutator. +type AgentPluginVersionFunc func(context.Context, *db.AgentPluginVersionMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f AgentPluginVersionFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.AgentPluginVersionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.AgentPluginVersionMutation", m) +} + +// The AgentRuleFunc type is an adapter to allow the use of ordinary +// function as AgentRule mutator. +type AgentRuleFunc func(context.Context, *db.AgentRuleMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f AgentRuleFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.AgentRuleMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.AgentRuleMutation", m) +} + +// The AgentRuleVersionFunc type is an adapter to allow the use of ordinary +// function as AgentRuleVersion mutator. +type AgentRuleVersionFunc func(context.Context, *db.AgentRuleVersionMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f AgentRuleVersionFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.AgentRuleVersionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.AgentRuleVersionMutation", m) +} + +// The AgentSkillFunc type is an adapter to allow the use of ordinary +// function as AgentSkill mutator. +type AgentSkillFunc func(context.Context, *db.AgentSkillMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f AgentSkillFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.AgentSkillMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.AgentSkillMutation", m) +} + +// The AgentSkillGroupBindingFunc type is an adapter to allow the use of ordinary +// function as AgentSkillGroupBinding mutator. +type AgentSkillGroupBindingFunc func(context.Context, *db.AgentSkillGroupBindingMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f AgentSkillGroupBindingFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.AgentSkillGroupBindingMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.AgentSkillGroupBindingMutation", m) +} + +// The AgentSkillRepoFunc type is an adapter to allow the use of ordinary +// function as AgentSkillRepo mutator. +type AgentSkillRepoFunc func(context.Context, *db.AgentSkillRepoMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f AgentSkillRepoFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.AgentSkillRepoMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.AgentSkillRepoMutation", m) +} + +// The AgentSkillVersionFunc type is an adapter to allow the use of ordinary +// function as AgentSkillVersion mutator. +type AgentSkillVersionFunc func(context.Context, *db.AgentSkillVersionMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f AgentSkillVersionFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.AgentSkillVersionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.AgentSkillVersionMutation", m) +} + +// The AgentSyncJobFunc type is an adapter to allow the use of ordinary +// function as AgentSyncJob mutator. +type AgentSyncJobFunc func(context.Context, *db.AgentSyncJobMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f AgentSyncJobFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.AgentSyncJobMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.AgentSyncJobMutation", m) +} + // The AuditFunc type is an adapter to allow the use of ordinary // function as Audit mutator. type AuditFunc func(context.Context, *db.AuditMutation) (db.Value, error) @@ -285,18 +405,6 @@ func (f ProjectTaskFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, e return nil, fmt.Errorf("unexpected mutation type %T. expect *db.ProjectTaskMutation", m) } -// The SkillFunc type is an adapter to allow the use of ordinary -// function as Skill mutator. -type SkillFunc func(context.Context, *db.SkillMutation) (db.Value, error) - -// Mutate calls f(ctx, m). -func (f SkillFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { - if mv, ok := m.(*db.SkillMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *db.SkillMutation", m) -} - // The TaskFunc type is an adapter to allow the use of ordinary // function as Task mutator. type TaskFunc func(context.Context, *db.TaskMutation) (db.Value, error) @@ -429,18 +537,6 @@ func (f TeamGroupModelFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value return nil, fmt.Errorf("unexpected mutation type %T. expect *db.TeamGroupModelMutation", m) } -// The TeamGroupSkillFunc type is an adapter to allow the use of ordinary -// function as TeamGroupSkill mutator. -type TeamGroupSkillFunc func(context.Context, *db.TeamGroupSkillMutation) (db.Value, error) - -// Mutate calls f(ctx, m). -func (f TeamGroupSkillFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { - if mv, ok := m.(*db.TeamGroupSkillMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *db.TeamGroupSkillMutation", m) -} - // The TeamHostFunc type is an adapter to allow the use of ordinary // function as TeamHost mutator. type TeamHostFunc func(context.Context, *db.TeamHostMutation) (db.Value, error) @@ -501,18 +597,6 @@ func (f TeamOIDCConfigFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value return nil, fmt.Errorf("unexpected mutation type %T. expect *db.TeamOIDCConfigMutation", m) } -// The TeamSkillFunc type is an adapter to allow the use of ordinary -// function as TeamSkill mutator. -type TeamSkillFunc func(context.Context, *db.TeamSkillMutation) (db.Value, error) - -// Mutate calls f(ctx, m). -func (f TeamSkillFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { - if mv, ok := m.(*db.TeamSkillMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *db.TeamSkillMutation", m) -} - // The UserFunc type is an adapter to allow the use of ordinary // function as User mutator. type UserFunc func(context.Context, *db.UserMutation) (db.Value, error) diff --git a/backend/db/intercept/intercept.go b/backend/db/intercept/intercept.go index d6e65e15..71b8ba4d 100644 --- a/backend/db/intercept/intercept.go +++ b/backend/db/intercept/intercept.go @@ -8,6 +8,16 @@ import ( "entgo.io/ent/dialect/sql" "github.com/chaitin/MonkeyCode/backend/db" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/db/agentsyncjob" "github.com/chaitin/MonkeyCode/backend/db/audit" "github.com/chaitin/MonkeyCode/backend/db/gitbot" "github.com/chaitin/MonkeyCode/backend/db/gitbottask" @@ -32,7 +42,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/projectissue" "github.com/chaitin/MonkeyCode/backend/db/projectissuecomment" "github.com/chaitin/MonkeyCode/backend/db/projecttask" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/task" "github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch" "github.com/chaitin/MonkeyCode/backend/db/taskusagestat" @@ -44,13 +53,11 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/teamgroupimage" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmember" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/chaitin/MonkeyCode/backend/db/teamhost" "github.com/chaitin/MonkeyCode/backend/db/teamimage" "github.com/chaitin/MonkeyCode/backend/db/teammember" "github.com/chaitin/MonkeyCode/backend/db/teammodel" "github.com/chaitin/MonkeyCode/backend/db/teamoidcconfig" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/chaitin/MonkeyCode/backend/db/useridentity" "github.com/chaitin/MonkeyCode/backend/db/virtualmachine" @@ -112,6 +119,276 @@ func (f TraverseFunc) Traverse(ctx context.Context, q db.Query) error { return f(ctx, query) } +// The AgentPluginFunc type is an adapter to allow the use of ordinary function as a Querier. +type AgentPluginFunc func(context.Context, *db.AgentPluginQuery) (db.Value, error) + +// Query calls f(ctx, q). +func (f AgentPluginFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { + if q, ok := q.(*db.AgentPluginQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *db.AgentPluginQuery", q) +} + +// The TraverseAgentPlugin type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAgentPlugin func(context.Context, *db.AgentPluginQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAgentPlugin) Intercept(next db.Querier) db.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAgentPlugin) Traverse(ctx context.Context, q db.Query) error { + if q, ok := q.(*db.AgentPluginQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *db.AgentPluginQuery", q) +} + +// The AgentPluginRepoFunc type is an adapter to allow the use of ordinary function as a Querier. +type AgentPluginRepoFunc func(context.Context, *db.AgentPluginRepoQuery) (db.Value, error) + +// Query calls f(ctx, q). +func (f AgentPluginRepoFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { + if q, ok := q.(*db.AgentPluginRepoQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *db.AgentPluginRepoQuery", q) +} + +// The TraverseAgentPluginRepo type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAgentPluginRepo func(context.Context, *db.AgentPluginRepoQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAgentPluginRepo) Intercept(next db.Querier) db.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAgentPluginRepo) Traverse(ctx context.Context, q db.Query) error { + if q, ok := q.(*db.AgentPluginRepoQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *db.AgentPluginRepoQuery", q) +} + +// The AgentPluginVersionFunc type is an adapter to allow the use of ordinary function as a Querier. +type AgentPluginVersionFunc func(context.Context, *db.AgentPluginVersionQuery) (db.Value, error) + +// Query calls f(ctx, q). +func (f AgentPluginVersionFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { + if q, ok := q.(*db.AgentPluginVersionQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *db.AgentPluginVersionQuery", q) +} + +// The TraverseAgentPluginVersion type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAgentPluginVersion func(context.Context, *db.AgentPluginVersionQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAgentPluginVersion) Intercept(next db.Querier) db.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAgentPluginVersion) Traverse(ctx context.Context, q db.Query) error { + if q, ok := q.(*db.AgentPluginVersionQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *db.AgentPluginVersionQuery", q) +} + +// The AgentRuleFunc type is an adapter to allow the use of ordinary function as a Querier. +type AgentRuleFunc func(context.Context, *db.AgentRuleQuery) (db.Value, error) + +// Query calls f(ctx, q). +func (f AgentRuleFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { + if q, ok := q.(*db.AgentRuleQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *db.AgentRuleQuery", q) +} + +// The TraverseAgentRule type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAgentRule func(context.Context, *db.AgentRuleQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAgentRule) Intercept(next db.Querier) db.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAgentRule) Traverse(ctx context.Context, q db.Query) error { + if q, ok := q.(*db.AgentRuleQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *db.AgentRuleQuery", q) +} + +// The AgentRuleVersionFunc type is an adapter to allow the use of ordinary function as a Querier. +type AgentRuleVersionFunc func(context.Context, *db.AgentRuleVersionQuery) (db.Value, error) + +// Query calls f(ctx, q). +func (f AgentRuleVersionFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { + if q, ok := q.(*db.AgentRuleVersionQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *db.AgentRuleVersionQuery", q) +} + +// The TraverseAgentRuleVersion type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAgentRuleVersion func(context.Context, *db.AgentRuleVersionQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAgentRuleVersion) Intercept(next db.Querier) db.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAgentRuleVersion) Traverse(ctx context.Context, q db.Query) error { + if q, ok := q.(*db.AgentRuleVersionQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *db.AgentRuleVersionQuery", q) +} + +// The AgentSkillFunc type is an adapter to allow the use of ordinary function as a Querier. +type AgentSkillFunc func(context.Context, *db.AgentSkillQuery) (db.Value, error) + +// Query calls f(ctx, q). +func (f AgentSkillFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { + if q, ok := q.(*db.AgentSkillQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *db.AgentSkillQuery", q) +} + +// The TraverseAgentSkill type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAgentSkill func(context.Context, *db.AgentSkillQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAgentSkill) Intercept(next db.Querier) db.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAgentSkill) Traverse(ctx context.Context, q db.Query) error { + if q, ok := q.(*db.AgentSkillQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *db.AgentSkillQuery", q) +} + +// The AgentSkillGroupBindingFunc type is an adapter to allow the use of ordinary function as a Querier. +type AgentSkillGroupBindingFunc func(context.Context, *db.AgentSkillGroupBindingQuery) (db.Value, error) + +// Query calls f(ctx, q). +func (f AgentSkillGroupBindingFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { + if q, ok := q.(*db.AgentSkillGroupBindingQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *db.AgentSkillGroupBindingQuery", q) +} + +// The TraverseAgentSkillGroupBinding type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAgentSkillGroupBinding func(context.Context, *db.AgentSkillGroupBindingQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAgentSkillGroupBinding) Intercept(next db.Querier) db.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAgentSkillGroupBinding) Traverse(ctx context.Context, q db.Query) error { + if q, ok := q.(*db.AgentSkillGroupBindingQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *db.AgentSkillGroupBindingQuery", q) +} + +// The AgentSkillRepoFunc type is an adapter to allow the use of ordinary function as a Querier. +type AgentSkillRepoFunc func(context.Context, *db.AgentSkillRepoQuery) (db.Value, error) + +// Query calls f(ctx, q). +func (f AgentSkillRepoFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { + if q, ok := q.(*db.AgentSkillRepoQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *db.AgentSkillRepoQuery", q) +} + +// The TraverseAgentSkillRepo type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAgentSkillRepo func(context.Context, *db.AgentSkillRepoQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAgentSkillRepo) Intercept(next db.Querier) db.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAgentSkillRepo) Traverse(ctx context.Context, q db.Query) error { + if q, ok := q.(*db.AgentSkillRepoQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *db.AgentSkillRepoQuery", q) +} + +// The AgentSkillVersionFunc type is an adapter to allow the use of ordinary function as a Querier. +type AgentSkillVersionFunc func(context.Context, *db.AgentSkillVersionQuery) (db.Value, error) + +// Query calls f(ctx, q). +func (f AgentSkillVersionFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { + if q, ok := q.(*db.AgentSkillVersionQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *db.AgentSkillVersionQuery", q) +} + +// The TraverseAgentSkillVersion type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAgentSkillVersion func(context.Context, *db.AgentSkillVersionQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAgentSkillVersion) Intercept(next db.Querier) db.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAgentSkillVersion) Traverse(ctx context.Context, q db.Query) error { + if q, ok := q.(*db.AgentSkillVersionQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *db.AgentSkillVersionQuery", q) +} + +// The AgentSyncJobFunc type is an adapter to allow the use of ordinary function as a Querier. +type AgentSyncJobFunc func(context.Context, *db.AgentSyncJobQuery) (db.Value, error) + +// Query calls f(ctx, q). +func (f AgentSyncJobFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { + if q, ok := q.(*db.AgentSyncJobQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *db.AgentSyncJobQuery", q) +} + +// The TraverseAgentSyncJob type is an adapter to allow the use of ordinary function as Traverser. +type TraverseAgentSyncJob func(context.Context, *db.AgentSyncJobQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseAgentSyncJob) Intercept(next db.Querier) db.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseAgentSyncJob) Traverse(ctx context.Context, q db.Query) error { + if q, ok := q.(*db.AgentSyncJobQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *db.AgentSyncJobQuery", q) +} + // The AuditFunc type is an adapter to allow the use of ordinary function as a Querier. type AuditFunc func(context.Context, *db.AuditQuery) (db.Value, error) @@ -733,33 +1010,6 @@ func (f TraverseProjectTask) Traverse(ctx context.Context, q db.Query) error { return fmt.Errorf("unexpected query type %T. expect *db.ProjectTaskQuery", q) } -// The SkillFunc type is an adapter to allow the use of ordinary function as a Querier. -type SkillFunc func(context.Context, *db.SkillQuery) (db.Value, error) - -// Query calls f(ctx, q). -func (f SkillFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { - if q, ok := q.(*db.SkillQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *db.SkillQuery", q) -} - -// The TraverseSkill type is an adapter to allow the use of ordinary function as Traverser. -type TraverseSkill func(context.Context, *db.SkillQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseSkill) Intercept(next db.Querier) db.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseSkill) Traverse(ctx context.Context, q db.Query) error { - if q, ok := q.(*db.SkillQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *db.SkillQuery", q) -} - // The TaskFunc type is an adapter to allow the use of ordinary function as a Querier. type TaskFunc func(context.Context, *db.TaskQuery) (db.Value, error) @@ -1057,33 +1307,6 @@ func (f TraverseTeamGroupModel) Traverse(ctx context.Context, q db.Query) error return fmt.Errorf("unexpected query type %T. expect *db.TeamGroupModelQuery", q) } -// The TeamGroupSkillFunc type is an adapter to allow the use of ordinary function as a Querier. -type TeamGroupSkillFunc func(context.Context, *db.TeamGroupSkillQuery) (db.Value, error) - -// Query calls f(ctx, q). -func (f TeamGroupSkillFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { - if q, ok := q.(*db.TeamGroupSkillQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamGroupSkillQuery", q) -} - -// The TraverseTeamGroupSkill type is an adapter to allow the use of ordinary function as Traverser. -type TraverseTeamGroupSkill func(context.Context, *db.TeamGroupSkillQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseTeamGroupSkill) Intercept(next db.Querier) db.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseTeamGroupSkill) Traverse(ctx context.Context, q db.Query) error { - if q, ok := q.(*db.TeamGroupSkillQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *db.TeamGroupSkillQuery", q) -} - // The TeamHostFunc type is an adapter to allow the use of ordinary function as a Querier. type TeamHostFunc func(context.Context, *db.TeamHostQuery) (db.Value, error) @@ -1219,33 +1442,6 @@ func (f TraverseTeamOIDCConfig) Traverse(ctx context.Context, q db.Query) error return fmt.Errorf("unexpected query type %T. expect *db.TeamOIDCConfigQuery", q) } -// The TeamSkillFunc type is an adapter to allow the use of ordinary function as a Querier. -type TeamSkillFunc func(context.Context, *db.TeamSkillQuery) (db.Value, error) - -// Query calls f(ctx, q). -func (f TeamSkillFunc) Query(ctx context.Context, q db.Query) (db.Value, error) { - if q, ok := q.(*db.TeamSkillQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamSkillQuery", q) -} - -// The TraverseTeamSkill type is an adapter to allow the use of ordinary function as Traverser. -type TraverseTeamSkill func(context.Context, *db.TeamSkillQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseTeamSkill) Intercept(next db.Querier) db.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseTeamSkill) Traverse(ctx context.Context, q db.Query) error { - if q, ok := q.(*db.TeamSkillQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *db.TeamSkillQuery", q) -} - // The UserFunc type is an adapter to allow the use of ordinary function as a Querier. type UserFunc func(context.Context, *db.UserQuery) (db.Value, error) @@ -1330,6 +1526,26 @@ func (f TraverseVirtualMachine) Traverse(ctx context.Context, q db.Query) error // NewQuery returns the generic Query interface for the given typed query. func NewQuery(q db.Query) (Query, error) { switch q := q.(type) { + case *db.AgentPluginQuery: + return &query[*db.AgentPluginQuery, predicate.AgentPlugin, agentplugin.OrderOption]{typ: db.TypeAgentPlugin, tq: q}, nil + case *db.AgentPluginRepoQuery: + return &query[*db.AgentPluginRepoQuery, predicate.AgentPluginRepo, agentpluginrepo.OrderOption]{typ: db.TypeAgentPluginRepo, tq: q}, nil + case *db.AgentPluginVersionQuery: + return &query[*db.AgentPluginVersionQuery, predicate.AgentPluginVersion, agentpluginversion.OrderOption]{typ: db.TypeAgentPluginVersion, tq: q}, nil + case *db.AgentRuleQuery: + return &query[*db.AgentRuleQuery, predicate.AgentRule, agentrule.OrderOption]{typ: db.TypeAgentRule, tq: q}, nil + case *db.AgentRuleVersionQuery: + return &query[*db.AgentRuleVersionQuery, predicate.AgentRuleVersion, agentruleversion.OrderOption]{typ: db.TypeAgentRuleVersion, tq: q}, nil + case *db.AgentSkillQuery: + return &query[*db.AgentSkillQuery, predicate.AgentSkill, agentskill.OrderOption]{typ: db.TypeAgentSkill, tq: q}, nil + case *db.AgentSkillGroupBindingQuery: + return &query[*db.AgentSkillGroupBindingQuery, predicate.AgentSkillGroupBinding, agentskillgroupbinding.OrderOption]{typ: db.TypeAgentSkillGroupBinding, tq: q}, nil + case *db.AgentSkillRepoQuery: + return &query[*db.AgentSkillRepoQuery, predicate.AgentSkillRepo, agentskillrepo.OrderOption]{typ: db.TypeAgentSkillRepo, tq: q}, nil + case *db.AgentSkillVersionQuery: + return &query[*db.AgentSkillVersionQuery, predicate.AgentSkillVersion, agentskillversion.OrderOption]{typ: db.TypeAgentSkillVersion, tq: q}, nil + case *db.AgentSyncJobQuery: + return &query[*db.AgentSyncJobQuery, predicate.AgentSyncJob, agentsyncjob.OrderOption]{typ: db.TypeAgentSyncJob, tq: q}, nil case *db.AuditQuery: return &query[*db.AuditQuery, predicate.Audit, audit.OrderOption]{typ: db.TypeAudit, tq: q}, nil case *db.GitBotQuery: @@ -1376,8 +1592,6 @@ func NewQuery(q db.Query) (Query, error) { return &query[*db.ProjectIssueCommentQuery, predicate.ProjectIssueComment, projectissuecomment.OrderOption]{typ: db.TypeProjectIssueComment, tq: q}, nil case *db.ProjectTaskQuery: return &query[*db.ProjectTaskQuery, predicate.ProjectTask, projecttask.OrderOption]{typ: db.TypeProjectTask, tq: q}, nil - case *db.SkillQuery: - return &query[*db.SkillQuery, predicate.Skill, skill.OrderOption]{typ: db.TypeSkill, tq: q}, nil case *db.TaskQuery: return &query[*db.TaskQuery, predicate.Task, task.OrderOption]{typ: db.TypeTask, tq: q}, nil case *db.TaskModelSwitchQuery: @@ -1400,8 +1614,6 @@ func NewQuery(q db.Query) (Query, error) { return &query[*db.TeamGroupMemberQuery, predicate.TeamGroupMember, teamgroupmember.OrderOption]{typ: db.TypeTeamGroupMember, tq: q}, nil case *db.TeamGroupModelQuery: return &query[*db.TeamGroupModelQuery, predicate.TeamGroupModel, teamgroupmodel.OrderOption]{typ: db.TypeTeamGroupModel, tq: q}, nil - case *db.TeamGroupSkillQuery: - return &query[*db.TeamGroupSkillQuery, predicate.TeamGroupSkill, teamgroupskill.OrderOption]{typ: db.TypeTeamGroupSkill, tq: q}, nil case *db.TeamHostQuery: return &query[*db.TeamHostQuery, predicate.TeamHost, teamhost.OrderOption]{typ: db.TypeTeamHost, tq: q}, nil case *db.TeamImageQuery: @@ -1412,8 +1624,6 @@ func NewQuery(q db.Query) (Query, error) { return &query[*db.TeamModelQuery, predicate.TeamModel, teammodel.OrderOption]{typ: db.TypeTeamModel, tq: q}, nil case *db.TeamOIDCConfigQuery: return &query[*db.TeamOIDCConfigQuery, predicate.TeamOIDCConfig, teamoidcconfig.OrderOption]{typ: db.TypeTeamOIDCConfig, tq: q}, nil - case *db.TeamSkillQuery: - return &query[*db.TeamSkillQuery, predicate.TeamSkill, teamskill.OrderOption]{typ: db.TypeTeamSkill, tq: q}, nil case *db.UserQuery: return &query[*db.UserQuery, predicate.User, user.OrderOption]{typ: db.TypeUser, tq: q}, nil case *db.UserIdentityQuery: diff --git a/backend/db/migrate/schema.go b/backend/db/migrate/schema.go index 761f0760..b5921fa5 100644 --- a/backend/db/migrate/schema.go +++ b/backend/db/migrate/schema.go @@ -9,6 +9,369 @@ import ( ) var ( + // AgentPluginsColumns holds the columns for the "agent_plugins" table. + AgentPluginsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "name", Type: field.TypeString}, + {Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647}, + {Name: "scope_type", Type: field.TypeEnum, Enums: []string{"global", "team", "user"}, Default: "global"}, + {Name: "scope_id", Type: field.TypeString, Default: "global"}, + {Name: "created_by", Type: field.TypeUUID}, + {Name: "active_version_id", Type: field.TypeUUID, Nullable: true}, + {Name: "is_force_delivery", Type: field.TypeBool, Default: false}, + {Name: "is_orphan", Type: field.TypeBool, Default: false}, + {Name: "is_deleted", Type: field.TypeBool, Default: false}, + {Name: "enabled", Type: field.TypeBool, Default: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "repo_id", Type: field.TypeUUID}, + } + // AgentPluginsTable holds the schema information for the "agent_plugins" table. + AgentPluginsTable = &schema.Table{ + Name: "agent_plugins", + Columns: AgentPluginsColumns, + PrimaryKey: []*schema.Column{AgentPluginsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "agent_plugins_agent_plugin_repos_plugins", + Columns: []*schema.Column{AgentPluginsColumns[13]}, + RefColumns: []*schema.Column{AgentPluginReposColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "agentplugin_repo_id_name", + Unique: true, + Columns: []*schema.Column{AgentPluginsColumns[13], AgentPluginsColumns[1]}, + }, + { + Name: "agentplugin_scope_type_scope_id", + Unique: false, + Columns: []*schema.Column{AgentPluginsColumns[3], AgentPluginsColumns[4]}, + }, + { + Name: "agentplugin_active_version_id", + Unique: false, + Columns: []*schema.Column{AgentPluginsColumns[6]}, + }, + }, + } + // AgentPluginReposColumns holds the columns for the "agent_plugin_repos" table. + AgentPluginReposColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "name", Type: field.TypeString}, + {Name: "scope_type", Type: field.TypeEnum, Enums: []string{"global", "team", "user"}, Default: "global"}, + {Name: "scope_id", Type: field.TypeString, Default: "global"}, + {Name: "created_by", Type: field.TypeUUID}, + {Name: "source_type", Type: field.TypeEnum, Enums: []string{"github", "upload", "npm", "bare"}}, + {Name: "github_url", Type: field.TypeString, Nullable: true}, + {Name: "ref_type", Type: field.TypeEnum, Nullable: true, Enums: []string{"branch", "tag", "commit"}}, + {Name: "ref_value", Type: field.TypeString, Nullable: true}, + {Name: "last_upload_filename", Type: field.TypeString, Nullable: true}, + {Name: "last_upload_at", Type: field.TypeTime, Nullable: true}, + {Name: "plugin_discovery_auto_package_json", Type: field.TypeBool, Default: true}, + {Name: "plugin_manual_entries", Type: field.TypeJSON, Nullable: true}, + {Name: "npm_package_name", Type: field.TypeString, Nullable: true}, + {Name: "npm_version_spec", Type: field.TypeString, Nullable: true}, + {Name: "npm_registry_url", Type: field.TypeString, Nullable: true}, + {Name: "is_deleted", Type: field.TypeBool, Default: false}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + } + // AgentPluginReposTable holds the schema information for the "agent_plugin_repos" table. + AgentPluginReposTable = &schema.Table{ + Name: "agent_plugin_repos", + Columns: AgentPluginReposColumns, + PrimaryKey: []*schema.Column{AgentPluginReposColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "agentpluginrepo_scope_type_scope_id", + Unique: false, + Columns: []*schema.Column{AgentPluginReposColumns[2], AgentPluginReposColumns[3]}, + }, + }, + } + // AgentPluginVersionsColumns holds the columns for the "agent_plugin_versions" table. + AgentPluginVersionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "version", Type: field.TypeString}, + {Name: "s3_key", Type: field.TypeString}, + {Name: "parsed_meta", Type: field.TypeJSON, Nullable: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "resource_id", Type: field.TypeUUID}, + } + // AgentPluginVersionsTable holds the schema information for the "agent_plugin_versions" table. + AgentPluginVersionsTable = &schema.Table{ + Name: "agent_plugin_versions", + Columns: AgentPluginVersionsColumns, + PrimaryKey: []*schema.Column{AgentPluginVersionsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "agent_plugin_versions_agent_plugins_versions", + Columns: []*schema.Column{AgentPluginVersionsColumns[5]}, + RefColumns: []*schema.Column{AgentPluginsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "agentpluginversion_resource_id", + Unique: false, + Columns: []*schema.Column{AgentPluginVersionsColumns[5]}, + }, + }, + } + // AgentRulesColumns holds the columns for the "agent_rules" table. + AgentRulesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "name", Type: field.TypeString}, + {Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647}, + {Name: "scope_type", Type: field.TypeEnum, Enums: []string{"global"}, Default: "global"}, + {Name: "scope_id", Type: field.TypeString, Default: "global"}, + {Name: "created_by", Type: field.TypeUUID}, + {Name: "active_version_id", Type: field.TypeUUID, Nullable: true}, + {Name: "is_deleted", Type: field.TypeBool, Default: false}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + } + // AgentRulesTable holds the schema information for the "agent_rules" table. + AgentRulesTable = &schema.Table{ + Name: "agent_rules", + Columns: AgentRulesColumns, + PrimaryKey: []*schema.Column{AgentRulesColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "agentrule_scope_type_scope_id", + Unique: false, + Columns: []*schema.Column{AgentRulesColumns[3], AgentRulesColumns[4]}, + }, + { + Name: "agentrule_active_version_id", + Unique: false, + Columns: []*schema.Column{AgentRulesColumns[6]}, + }, + }, + } + // AgentRuleVersionsColumns holds the columns for the "agent_rule_versions" table. + AgentRuleVersionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "version", Type: field.TypeString, Size: 14}, + {Name: "content", Type: field.TypeString, Size: 2147483647}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "rule_id", Type: field.TypeUUID}, + } + // AgentRuleVersionsTable holds the schema information for the "agent_rule_versions" table. + AgentRuleVersionsTable = &schema.Table{ + Name: "agent_rule_versions", + Columns: AgentRuleVersionsColumns, + PrimaryKey: []*schema.Column{AgentRuleVersionsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "agent_rule_versions_agent_rules_versions", + Columns: []*schema.Column{AgentRuleVersionsColumns[4]}, + RefColumns: []*schema.Column{AgentRulesColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "agentruleversion_rule_id", + Unique: false, + Columns: []*schema.Column{AgentRuleVersionsColumns[4]}, + }, + }, + } + // AgentSkillsColumns holds the columns for the "agent_skills" table. + AgentSkillsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "name", Type: field.TypeString}, + {Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647}, + {Name: "scope_type", Type: field.TypeEnum, Enums: []string{"global", "team", "user"}, Default: "global"}, + {Name: "scope_id", Type: field.TypeString, Default: "global"}, + {Name: "created_by", Type: field.TypeUUID}, + {Name: "active_version_id", Type: field.TypeUUID, Nullable: true}, + {Name: "is_force_delivery", Type: field.TypeBool, Default: false}, + {Name: "is_orphan", Type: field.TypeBool, Default: false}, + {Name: "is_deleted", Type: field.TypeBool, Default: false}, + {Name: "enabled", Type: field.TypeBool, Default: true}, + {Name: "extension_package_id", Type: field.TypeString, Nullable: true}, + {Name: "admin_description", Type: field.TypeString, Nullable: true, Size: 2147483647}, + {Name: "admin_tags", Type: field.TypeJSON, Nullable: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "repo_id", Type: field.TypeUUID}, + } + // AgentSkillsTable holds the schema information for the "agent_skills" table. + AgentSkillsTable = &schema.Table{ + Name: "agent_skills", + Columns: AgentSkillsColumns, + PrimaryKey: []*schema.Column{AgentSkillsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "agent_skills_agent_skill_repos_skills", + Columns: []*schema.Column{AgentSkillsColumns[16]}, + RefColumns: []*schema.Column{AgentSkillReposColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "agentskill_repo_id_name", + Unique: true, + Columns: []*schema.Column{AgentSkillsColumns[16], AgentSkillsColumns[1]}, + }, + { + Name: "agentskill_scope_type_scope_id", + Unique: false, + Columns: []*schema.Column{AgentSkillsColumns[3], AgentSkillsColumns[4]}, + }, + { + Name: "agentskill_active_version_id", + Unique: false, + Columns: []*schema.Column{AgentSkillsColumns[6]}, + }, + }, + } + // AgentSkillGroupBindingsColumns holds the columns for the "agent_skill_group_bindings" table. + AgentSkillGroupBindingsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "skill_id", Type: field.TypeUUID}, + {Name: "group_id", Type: field.TypeUUID}, + } + // AgentSkillGroupBindingsTable holds the schema information for the "agent_skill_group_bindings" table. + AgentSkillGroupBindingsTable = &schema.Table{ + Name: "agent_skill_group_bindings", + Columns: AgentSkillGroupBindingsColumns, + PrimaryKey: []*schema.Column{AgentSkillGroupBindingsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "agent_skill_group_bindings_agent_skills_skill", + Columns: []*schema.Column{AgentSkillGroupBindingsColumns[2]}, + RefColumns: []*schema.Column{AgentSkillsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "agent_skill_group_bindings_team_groups_group", + Columns: []*schema.Column{AgentSkillGroupBindingsColumns[3]}, + RefColumns: []*schema.Column{TeamGroupsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "agentskillgroupbinding_skill_id_group_id", + Unique: true, + Columns: []*schema.Column{AgentSkillGroupBindingsColumns[2], AgentSkillGroupBindingsColumns[3]}, + }, + { + Name: "agentskillgroupbinding_group_id", + Unique: false, + Columns: []*schema.Column{AgentSkillGroupBindingsColumns[3]}, + }, + }, + } + // AgentSkillReposColumns holds the columns for the "agent_skill_repos" table. + AgentSkillReposColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "name", Type: field.TypeString}, + {Name: "scope_type", Type: field.TypeEnum, Enums: []string{"global", "team", "user"}, Default: "global"}, + {Name: "scope_id", Type: field.TypeString, Default: "global"}, + {Name: "created_by", Type: field.TypeUUID}, + {Name: "source_type", Type: field.TypeEnum, Enums: []string{"github", "upload", "bare"}}, + {Name: "github_url", Type: field.TypeString, Nullable: true}, + {Name: "ref_type", Type: field.TypeEnum, Nullable: true, Enums: []string{"branch", "tag", "commit"}}, + {Name: "ref_value", Type: field.TypeString, Nullable: true}, + {Name: "last_upload_filename", Type: field.TypeString, Nullable: true}, + {Name: "last_upload_at", Type: field.TypeTime, Nullable: true}, + {Name: "is_deleted", Type: field.TypeBool, Default: false}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + } + // AgentSkillReposTable holds the schema information for the "agent_skill_repos" table. + AgentSkillReposTable = &schema.Table{ + Name: "agent_skill_repos", + Columns: AgentSkillReposColumns, + PrimaryKey: []*schema.Column{AgentSkillReposColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "agentskillrepo_scope_type_scope_id", + Unique: false, + Columns: []*schema.Column{AgentSkillReposColumns[2], AgentSkillReposColumns[3]}, + }, + }, + } + // AgentSkillVersionsColumns holds the columns for the "agent_skill_versions" table. + AgentSkillVersionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "version", Type: field.TypeString}, + {Name: "s3_key", Type: field.TypeString}, + {Name: "parsed_meta", Type: field.TypeJSON, Nullable: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "resource_id", Type: field.TypeUUID}, + } + // AgentSkillVersionsTable holds the schema information for the "agent_skill_versions" table. + AgentSkillVersionsTable = &schema.Table{ + Name: "agent_skill_versions", + Columns: AgentSkillVersionsColumns, + PrimaryKey: []*schema.Column{AgentSkillVersionsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "agent_skill_versions_agent_skills_versions", + Columns: []*schema.Column{AgentSkillVersionsColumns[5]}, + RefColumns: []*schema.Column{AgentSkillsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "agentskillversion_resource_id", + Unique: false, + Columns: []*schema.Column{AgentSkillVersionsColumns[5]}, + }, + }, + } + // AgentSyncJobsColumns holds the columns for the "agent_sync_jobs" table. + AgentSyncJobsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUUID}, + {Name: "resource_kind", Type: field.TypeEnum, Enums: []string{"rule", "skill", "plugin"}}, + {Name: "rule_id", Type: field.TypeUUID, Nullable: true}, + {Name: "repo_id", Type: field.TypeUUID, Nullable: true}, + {Name: "source_type", Type: field.TypeEnum, Enums: []string{"github", "upload", "npm", "rule_inline"}}, + {Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "fetching", "parsing", "uploading", "done", "failed"}, Default: "pending"}, + {Name: "trigger_type", Type: field.TypeEnum, Enums: []string{"manual", "upload", "rule_save"}}, + {Name: "triggered_by", Type: field.TypeUUID, Nullable: true}, + {Name: "started_at", Type: field.TypeTime, Nullable: true}, + {Name: "finished_at", Type: field.TypeTime, Nullable: true}, + {Name: "errors", Type: field.TypeJSON, Nullable: true}, + {Name: "result_summary", Type: field.TypeJSON, Nullable: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + } + // AgentSyncJobsTable holds the schema information for the "agent_sync_jobs" table. + AgentSyncJobsTable = &schema.Table{ + Name: "agent_sync_jobs", + Columns: AgentSyncJobsColumns, + PrimaryKey: []*schema.Column{AgentSyncJobsColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "agentsyncjob_status_created_at", + Unique: false, + Columns: []*schema.Column{AgentSyncJobsColumns[5], AgentSyncJobsColumns[12]}, + }, + { + Name: "agentsyncjob_rule_id", + Unique: false, + Columns: []*schema.Column{AgentSyncJobsColumns[2]}, + }, + { + Name: "agentsyncjob_repo_id", + Unique: false, + Columns: []*schema.Column{AgentSyncJobsColumns[3]}, + }, + }, + } // AuditsColumns holds the columns for the "audits" table. AuditsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -786,40 +1149,6 @@ var ( }, }, } - // SkillsColumns holds the columns for the "skills" table. - SkillsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeUUID, Unique: true}, - {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, - {Name: "name", Type: field.TypeString}, - {Name: "description", Type: field.TypeString, Size: 2147483647}, - {Name: "tags", Type: field.TypeJSON, Nullable: true}, - {Name: "content", Type: field.TypeString, Size: 2147483647}, - {Name: "package_object_key", Type: field.TypeString, Nullable: true}, - {Name: "package_url", Type: field.TypeString, Nullable: true}, - {Name: "source_type", Type: field.TypeString}, - {Name: "source_label", Type: field.TypeString}, - {Name: "skill_md_path", Type: field.TypeString, Nullable: true}, - {Name: "extension_package_id", Type: field.TypeString, Nullable: true}, - {Name: "extension_skill_id", Type: field.TypeString, Nullable: true}, - {Name: "extension_version", Type: field.TypeString, Nullable: true}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "updated_at", Type: field.TypeTime}, - {Name: "user_id", Type: field.TypeUUID}, - } - // SkillsTable holds the schema information for the "skills" table. - SkillsTable = &schema.Table{ - Name: "skills", - Columns: SkillsColumns, - PrimaryKey: []*schema.Column{SkillsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "skills_users_skills", - Columns: []*schema.Column{SkillsColumns[16]}, - RefColumns: []*schema.Column{UsersColumns[0]}, - OnDelete: schema.NoAction, - }, - }, - } // TasksColumns holds the columns for the "tasks" table. TasksColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, @@ -1188,40 +1517,6 @@ var ( }, }, } - // TeamGroupSkillsColumns holds the columns for the "team_group_skills" table. - TeamGroupSkillsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeUUID, Unique: true}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "group_id", Type: field.TypeUUID}, - {Name: "skill_id", Type: field.TypeUUID}, - } - // TeamGroupSkillsTable holds the schema information for the "team_group_skills" table. - TeamGroupSkillsTable = &schema.Table{ - Name: "team_group_skills", - Columns: TeamGroupSkillsColumns, - PrimaryKey: []*schema.Column{TeamGroupSkillsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "team_group_skills_team_groups_group", - Columns: []*schema.Column{TeamGroupSkillsColumns[2]}, - RefColumns: []*schema.Column{TeamGroupsColumns[0]}, - OnDelete: schema.NoAction, - }, - { - Symbol: "team_group_skills_skills_skill", - Columns: []*schema.Column{TeamGroupSkillsColumns[3]}, - RefColumns: []*schema.Column{SkillsColumns[0]}, - OnDelete: schema.NoAction, - }, - }, - Indexes: []*schema.Index{ - { - Name: "teamgroupskill_group_id_skill_id", - Unique: true, - Columns: []*schema.Column{TeamGroupSkillsColumns[2], TeamGroupSkillsColumns[3]}, - }, - }, - } // TeamHostsColumns holds the columns for the "team_hosts" table. TeamHostsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, @@ -1389,40 +1684,6 @@ var ( }, }, } - // TeamSkillsColumns holds the columns for the "team_skills" table. - TeamSkillsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeUUID}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "team_id", Type: field.TypeUUID}, - {Name: "skill_id", Type: field.TypeUUID}, - } - // TeamSkillsTable holds the schema information for the "team_skills" table. - TeamSkillsTable = &schema.Table{ - Name: "team_skills", - Columns: TeamSkillsColumns, - PrimaryKey: []*schema.Column{TeamSkillsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "team_skills_teams_team", - Columns: []*schema.Column{TeamSkillsColumns[2]}, - RefColumns: []*schema.Column{TeamsColumns[0]}, - OnDelete: schema.NoAction, - }, - { - Symbol: "team_skills_skills_skill", - Columns: []*schema.Column{TeamSkillsColumns[3]}, - RefColumns: []*schema.Column{SkillsColumns[0]}, - OnDelete: schema.NoAction, - }, - }, - Indexes: []*schema.Index{ - { - Name: "teamskill_team_id_skill_id", - Unique: true, - Columns: []*schema.Column{TeamSkillsColumns[2], TeamSkillsColumns[3]}, - }, - }, - } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, @@ -1534,6 +1795,16 @@ var ( } // Tables holds all the tables in the schema. Tables = []*schema.Table{ + AgentPluginsTable, + AgentPluginReposTable, + AgentPluginVersionsTable, + AgentRulesTable, + AgentRuleVersionsTable, + AgentSkillsTable, + AgentSkillGroupBindingsTable, + AgentSkillReposTable, + AgentSkillVersionsTable, + AgentSyncJobsTable, AuditsTable, GitBotsTable, GitBotTasksTable, @@ -1557,7 +1828,6 @@ var ( ProjectIssuesTable, ProjectIssueCommentsTable, ProjectTasksTable, - SkillsTable, TasksTable, TaskModelSwitchesTable, TaskUsageStatsTable, @@ -1569,13 +1839,11 @@ var ( TeamGroupImagesTable, TeamGroupMembersTable, TeamGroupModelsTable, - TeamGroupSkillsTable, TeamHostsTable, TeamImagesTable, TeamMembersTable, TeamModelsTable, TeamOidcConfigsTable, - TeamSkillsTable, UsersTable, UserIdentitiesTable, VirtualmachinesTable, @@ -1583,6 +1851,43 @@ var ( ) func init() { + AgentPluginsTable.ForeignKeys[0].RefTable = AgentPluginReposTable + AgentPluginsTable.Annotation = &entsql.Annotation{ + Table: "agent_plugins", + } + AgentPluginReposTable.Annotation = &entsql.Annotation{ + Table: "agent_plugin_repos", + } + AgentPluginVersionsTable.ForeignKeys[0].RefTable = AgentPluginsTable + AgentPluginVersionsTable.Annotation = &entsql.Annotation{ + Table: "agent_plugin_versions", + } + AgentRulesTable.Annotation = &entsql.Annotation{ + Table: "agent_rules", + } + AgentRuleVersionsTable.ForeignKeys[0].RefTable = AgentRulesTable + AgentRuleVersionsTable.Annotation = &entsql.Annotation{ + Table: "agent_rule_versions", + } + AgentSkillsTable.ForeignKeys[0].RefTable = AgentSkillReposTable + AgentSkillsTable.Annotation = &entsql.Annotation{ + Table: "agent_skills", + } + AgentSkillGroupBindingsTable.ForeignKeys[0].RefTable = AgentSkillsTable + AgentSkillGroupBindingsTable.ForeignKeys[1].RefTable = TeamGroupsTable + AgentSkillGroupBindingsTable.Annotation = &entsql.Annotation{ + Table: "agent_skill_group_bindings", + } + AgentSkillReposTable.Annotation = &entsql.Annotation{ + Table: "agent_skill_repos", + } + AgentSkillVersionsTable.ForeignKeys[0].RefTable = AgentSkillsTable + AgentSkillVersionsTable.Annotation = &entsql.Annotation{ + Table: "agent_skill_versions", + } + AgentSyncJobsTable.Annotation = &entsql.Annotation{ + Table: "agent_sync_jobs", + } AuditsTable.ForeignKeys[0].RefTable = UsersTable AuditsTable.Annotation = &entsql.Annotation{ Table: "audits", @@ -1687,10 +1992,6 @@ func init() { ProjectTasksTable.Annotation = &entsql.Annotation{ Table: "project_tasks", } - SkillsTable.ForeignKeys[0].RefTable = UsersTable - SkillsTable.Annotation = &entsql.Annotation{ - Table: "skills", - } TasksTable.ForeignKeys[0].RefTable = UsersTable TasksTable.Annotation = &entsql.Annotation{ Table: "tasks", @@ -1742,11 +2043,6 @@ func init() { TeamGroupModelsTable.Annotation = &entsql.Annotation{ Table: "team_group_models", } - TeamGroupSkillsTable.ForeignKeys[0].RefTable = TeamGroupsTable - TeamGroupSkillsTable.ForeignKeys[1].RefTable = SkillsTable - TeamGroupSkillsTable.Annotation = &entsql.Annotation{ - Table: "team_group_skills", - } TeamHostsTable.ForeignKeys[0].RefTable = TeamsTable TeamHostsTable.ForeignKeys[1].RefTable = HostsTable TeamHostsTable.Annotation = &entsql.Annotation{ @@ -1771,11 +2067,6 @@ func init() { TeamOidcConfigsTable.Annotation = &entsql.Annotation{ Table: "team_oidc_configs", } - TeamSkillsTable.ForeignKeys[0].RefTable = TeamsTable - TeamSkillsTable.ForeignKeys[1].RefTable = SkillsTable - TeamSkillsTable.Annotation = &entsql.Annotation{ - Table: "team_skills", - } UsersTable.Annotation = &entsql.Annotation{ Table: "users", } diff --git a/backend/db/mutation.go b/backend/db/mutation.go index 16364dec..6f8f32ee 100644 --- a/backend/db/mutation.go +++ b/backend/db/mutation.go @@ -12,6 +12,16 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/chaitin/MonkeyCode/backend/consts" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/db/agentsyncjob" "github.com/chaitin/MonkeyCode/backend/db/audit" "github.com/chaitin/MonkeyCode/backend/db/gitbot" "github.com/chaitin/MonkeyCode/backend/db/gitbottask" @@ -36,7 +46,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/projectissue" "github.com/chaitin/MonkeyCode/backend/db/projectissuecomment" "github.com/chaitin/MonkeyCode/backend/db/projecttask" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/task" "github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch" "github.com/chaitin/MonkeyCode/backend/db/taskusagestat" @@ -48,13 +57,11 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/teamgroupimage" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmember" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/chaitin/MonkeyCode/backend/db/teamhost" "github.com/chaitin/MonkeyCode/backend/db/teamimage" "github.com/chaitin/MonkeyCode/backend/db/teammember" "github.com/chaitin/MonkeyCode/backend/db/teammodel" "github.com/chaitin/MonkeyCode/backend/db/teamoidcconfig" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/chaitin/MonkeyCode/backend/db/useridentity" "github.com/chaitin/MonkeyCode/backend/db/virtualmachine" @@ -71,6 +78,16 @@ const ( OpUpdateOne = ent.OpUpdateOne // Node types. + TypeAgentPlugin = "AgentPlugin" + TypeAgentPluginRepo = "AgentPluginRepo" + TypeAgentPluginVersion = "AgentPluginVersion" + TypeAgentRule = "AgentRule" + TypeAgentRuleVersion = "AgentRuleVersion" + TypeAgentSkill = "AgentSkill" + TypeAgentSkillGroupBinding = "AgentSkillGroupBinding" + TypeAgentSkillRepo = "AgentSkillRepo" + TypeAgentSkillVersion = "AgentSkillVersion" + TypeAgentSyncJob = "AgentSyncJob" TypeAudit = "Audit" TypeGitBot = "GitBot" TypeGitBotTask = "GitBotTask" @@ -94,7 +111,6 @@ const ( TypeProjectIssue = "ProjectIssue" TypeProjectIssueComment = "ProjectIssueComment" TypeProjectTask = "ProjectTask" - TypeSkill = "Skill" TypeTask = "Task" TypeTaskModelSwitch = "TaskModelSwitch" TypeTaskUsageStat = "TaskUsageStat" @@ -106,49 +122,56 @@ const ( TypeTeamGroupImage = "TeamGroupImage" TypeTeamGroupMember = "TeamGroupMember" TypeTeamGroupModel = "TeamGroupModel" - TypeTeamGroupSkill = "TeamGroupSkill" TypeTeamHost = "TeamHost" TypeTeamImage = "TeamImage" TypeTeamMember = "TeamMember" TypeTeamModel = "TeamModel" TypeTeamOIDCConfig = "TeamOIDCConfig" - TypeTeamSkill = "TeamSkill" TypeUser = "User" TypeUserIdentity = "UserIdentity" TypeVirtualMachine = "VirtualMachine" ) -// AuditMutation represents an operation that mutates the Audit nodes in the graph. -type AuditMutation struct { +// AgentPluginMutation represents an operation that mutates the AgentPlugin nodes in the graph. +type AgentPluginMutation struct { config - op Op - typ string - id *uuid.UUID - operation *string - source_ip *string - user_agent *string - request *string - response *string - created_at *time.Time - clearedFields map[string]struct{} - user *uuid.UUID - cleareduser bool - done bool - oldValue func(context.Context) (*Audit, error) - predicates []predicate.Audit + op Op + typ string + id *uuid.UUID + name *string + description *string + scope_type *agentplugin.ScopeType + scope_id *string + created_by *uuid.UUID + active_version_id *uuid.UUID + is_force_delivery *bool + is_orphan *bool + is_deleted *bool + enabled *bool + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + repo *uuid.UUID + clearedrepo bool + versions map[uuid.UUID]struct{} + removedversions map[uuid.UUID]struct{} + clearedversions bool + done bool + oldValue func(context.Context) (*AgentPlugin, error) + predicates []predicate.AgentPlugin } -var _ ent.Mutation = (*AuditMutation)(nil) +var _ ent.Mutation = (*AgentPluginMutation)(nil) -// auditOption allows management of the mutation configuration using functional options. -type auditOption func(*AuditMutation) +// agentpluginOption allows management of the mutation configuration using functional options. +type agentpluginOption func(*AgentPluginMutation) -// newAuditMutation creates new mutation for the Audit entity. -func newAuditMutation(c config, op Op, opts ...auditOption) *AuditMutation { - m := &AuditMutation{ +// newAgentPluginMutation creates new mutation for the AgentPlugin entity. +func newAgentPluginMutation(c config, op Op, opts ...agentpluginOption) *AgentPluginMutation { + m := &AgentPluginMutation{ config: c, op: op, - typ: TypeAudit, + typ: TypeAgentPlugin, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -157,20 +180,20 @@ func newAuditMutation(c config, op Op, opts ...auditOption) *AuditMutation { return m } -// withAuditID sets the ID field of the mutation. -func withAuditID(id uuid.UUID) auditOption { - return func(m *AuditMutation) { +// withAgentPluginID sets the ID field of the mutation. +func withAgentPluginID(id uuid.UUID) agentpluginOption { + return func(m *AgentPluginMutation) { var ( err error once sync.Once - value *Audit + value *AgentPlugin ) - m.oldValue = func(ctx context.Context) (*Audit, error) { + m.oldValue = func(ctx context.Context) (*AgentPlugin, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Audit.Get(ctx, id) + value, err = m.Client().AgentPlugin.Get(ctx, id) } }) return value, err @@ -179,10 +202,10 @@ func withAuditID(id uuid.UUID) auditOption { } } -// withAudit sets the old Audit of the mutation. -func withAudit(node *Audit) auditOption { - return func(m *AuditMutation) { - m.oldValue = func(context.Context) (*Audit, error) { +// withAgentPlugin sets the old AgentPlugin of the mutation. +func withAgentPlugin(node *AgentPlugin) agentpluginOption { + return func(m *AgentPluginMutation) { + m.oldValue = func(context.Context) (*AgentPlugin, error) { return node, nil } m.id = &node.ID @@ -191,7 +214,7 @@ func withAudit(node *Audit) auditOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m AuditMutation) Client() *Client { +func (m AgentPluginMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -199,7 +222,7 @@ func (m AuditMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m AuditMutation) Tx() (*Tx, error) { +func (m AgentPluginMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -209,14 +232,14 @@ func (m AuditMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Audit entities. -func (m *AuditMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of AgentPlugin entities. +func (m *AgentPluginMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *AuditMutation) ID() (id uuid.UUID, exists bool) { +func (m *AgentPluginMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -227,7 +250,7 @@ func (m *AuditMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *AuditMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *AgentPluginMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -236,248 +259,441 @@ func (m *AuditMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Audit.Query().Where(m.predicates...).IDs(ctx) + return m.Client().AgentPlugin.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetUserID sets the "user_id" field. -func (m *AuditMutation) SetUserID(u uuid.UUID) { - m.user = &u +// SetRepoID sets the "repo_id" field. +func (m *AgentPluginMutation) SetRepoID(u uuid.UUID) { + m.repo = &u } -// UserID returns the value of the "user_id" field in the mutation. -func (m *AuditMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user +// RepoID returns the value of the "repo_id" field in the mutation. +func (m *AgentPluginMutation) RepoID() (r uuid.UUID, exists bool) { + v := m.repo if v == nil { return } return *v, true } -// OldUserID returns the old "user_id" field's value of the Audit entity. -// If the Audit object wasn't provided to the builder, the object is fetched from the database. +// OldRepoID returns the old "repo_id" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *AuditMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AgentPluginMutation) OldRepoID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") + return v, errors.New("OldRepoID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") + return v, errors.New("OldRepoID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + return v, fmt.Errorf("querying old value for OldRepoID: %w", err) } - return oldValue.UserID, nil + return oldValue.RepoID, nil } -// ResetUserID resets all changes to the "user_id" field. -func (m *AuditMutation) ResetUserID() { - m.user = nil +// ResetRepoID resets all changes to the "repo_id" field. +func (m *AgentPluginMutation) ResetRepoID() { + m.repo = nil } -// SetOperation sets the "operation" field. -func (m *AuditMutation) SetOperation(s string) { - m.operation = &s +// SetName sets the "name" field. +func (m *AgentPluginMutation) SetName(s string) { + m.name = &s } -// Operation returns the value of the "operation" field in the mutation. -func (m *AuditMutation) Operation() (r string, exists bool) { - v := m.operation +// Name returns the value of the "name" field in the mutation. +func (m *AgentPluginMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldOperation returns the old "operation" field's value of the Audit entity. -// If the Audit object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *AuditMutation) OldOperation(ctx context.Context) (v string, err error) { +func (m *AgentPluginMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOperation is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOperation requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOperation: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.Operation, nil + return oldValue.Name, nil } -// ResetOperation resets all changes to the "operation" field. -func (m *AuditMutation) ResetOperation() { - m.operation = nil +// ResetName resets all changes to the "name" field. +func (m *AgentPluginMutation) ResetName() { + m.name = nil } -// SetSourceIP sets the "source_ip" field. -func (m *AuditMutation) SetSourceIP(s string) { - m.source_ip = &s +// SetDescription sets the "description" field. +func (m *AgentPluginMutation) SetDescription(s string) { + m.description = &s } -// SourceIP returns the value of the "source_ip" field in the mutation. -func (m *AuditMutation) SourceIP() (r string, exists bool) { - v := m.source_ip +// Description returns the value of the "description" field in the mutation. +func (m *AgentPluginMutation) Description() (r string, exists bool) { + v := m.description if v == nil { return } return *v, true } -// OldSourceIP returns the old "source_ip" field's value of the Audit entity. -// If the Audit object wasn't provided to the builder, the object is fetched from the database. +// OldDescription returns the old "description" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *AuditMutation) OldSourceIP(ctx context.Context) (v string, err error) { +func (m *AgentPluginMutation) OldDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSourceIP is only allowed on UpdateOne operations") + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSourceIP requires an ID field in the mutation") + return v, errors.New("OldDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSourceIP: %w", err) + return v, fmt.Errorf("querying old value for OldDescription: %w", err) } - return oldValue.SourceIP, nil + return oldValue.Description, nil } -// ResetSourceIP resets all changes to the "source_ip" field. -func (m *AuditMutation) ResetSourceIP() { - m.source_ip = nil +// ClearDescription clears the value of the "description" field. +func (m *AgentPluginMutation) ClearDescription() { + m.description = nil + m.clearedFields[agentplugin.FieldDescription] = struct{}{} } -// SetUserAgent sets the "user_agent" field. -func (m *AuditMutation) SetUserAgent(s string) { - m.user_agent = &s +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *AgentPluginMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[agentplugin.FieldDescription] + return ok } -// UserAgent returns the value of the "user_agent" field in the mutation. -func (m *AuditMutation) UserAgent() (r string, exists bool) { - v := m.user_agent +// ResetDescription resets all changes to the "description" field. +func (m *AgentPluginMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, agentplugin.FieldDescription) +} + +// SetScopeType sets the "scope_type" field. +func (m *AgentPluginMutation) SetScopeType(at agentplugin.ScopeType) { + m.scope_type = &at +} + +// ScopeType returns the value of the "scope_type" field in the mutation. +func (m *AgentPluginMutation) ScopeType() (r agentplugin.ScopeType, exists bool) { + v := m.scope_type if v == nil { return } return *v, true } -// OldUserAgent returns the old "user_agent" field's value of the Audit entity. -// If the Audit object wasn't provided to the builder, the object is fetched from the database. +// OldScopeType returns the old "scope_type" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *AuditMutation) OldUserAgent(ctx context.Context) (v string, err error) { +func (m *AgentPluginMutation) OldScopeType(ctx context.Context) (v agentplugin.ScopeType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserAgent is only allowed on UpdateOne operations") + return v, errors.New("OldScopeType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserAgent requires an ID field in the mutation") + return v, errors.New("OldScopeType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserAgent: %w", err) + return v, fmt.Errorf("querying old value for OldScopeType: %w", err) } - return oldValue.UserAgent, nil + return oldValue.ScopeType, nil } -// ResetUserAgent resets all changes to the "user_agent" field. -func (m *AuditMutation) ResetUserAgent() { - m.user_agent = nil +// ResetScopeType resets all changes to the "scope_type" field. +func (m *AgentPluginMutation) ResetScopeType() { + m.scope_type = nil } -// SetRequest sets the "request" field. -func (m *AuditMutation) SetRequest(s string) { - m.request = &s +// SetScopeID sets the "scope_id" field. +func (m *AgentPluginMutation) SetScopeID(s string) { + m.scope_id = &s } -// Request returns the value of the "request" field in the mutation. -func (m *AuditMutation) Request() (r string, exists bool) { - v := m.request +// ScopeID returns the value of the "scope_id" field in the mutation. +func (m *AgentPluginMutation) ScopeID() (r string, exists bool) { + v := m.scope_id if v == nil { return } return *v, true } -// OldRequest returns the old "request" field's value of the Audit entity. -// If the Audit object wasn't provided to the builder, the object is fetched from the database. +// OldScopeID returns the old "scope_id" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *AuditMutation) OldRequest(ctx context.Context) (v string, err error) { +func (m *AgentPluginMutation) OldScopeID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRequest is only allowed on UpdateOne operations") + return v, errors.New("OldScopeID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRequest requires an ID field in the mutation") + return v, errors.New("OldScopeID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRequest: %w", err) + return v, fmt.Errorf("querying old value for OldScopeID: %w", err) } - return oldValue.Request, nil + return oldValue.ScopeID, nil } -// ResetRequest resets all changes to the "request" field. -func (m *AuditMutation) ResetRequest() { - m.request = nil +// ResetScopeID resets all changes to the "scope_id" field. +func (m *AgentPluginMutation) ResetScopeID() { + m.scope_id = nil } -// SetResponse sets the "response" field. -func (m *AuditMutation) SetResponse(s string) { - m.response = &s +// SetCreatedBy sets the "created_by" field. +func (m *AgentPluginMutation) SetCreatedBy(u uuid.UUID) { + m.created_by = &u } -// Response returns the value of the "response" field in the mutation. -func (m *AuditMutation) Response() (r string, exists bool) { - v := m.response +// CreatedBy returns the value of the "created_by" field in the mutation. +func (m *AgentPluginMutation) CreatedBy() (r uuid.UUID, exists bool) { + v := m.created_by if v == nil { return } return *v, true } -// OldResponse returns the old "response" field's value of the Audit entity. -// If the Audit object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedBy returns the old "created_by" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *AuditMutation) OldResponse(ctx context.Context) (v string, err error) { +func (m *AgentPluginMutation) OldCreatedBy(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldResponse is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldResponse requires an ID field in the mutation") + return v, errors.New("OldCreatedBy requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldResponse: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err) } - return oldValue.Response, nil + return oldValue.CreatedBy, nil } -// ClearResponse clears the value of the "response" field. -func (m *AuditMutation) ClearResponse() { - m.response = nil - m.clearedFields[audit.FieldResponse] = struct{}{} +// ResetCreatedBy resets all changes to the "created_by" field. +func (m *AgentPluginMutation) ResetCreatedBy() { + m.created_by = nil } -// ResponseCleared returns if the "response" field was cleared in this mutation. -func (m *AuditMutation) ResponseCleared() bool { - _, ok := m.clearedFields[audit.FieldResponse] +// SetActiveVersionID sets the "active_version_id" field. +func (m *AgentPluginMutation) SetActiveVersionID(u uuid.UUID) { + m.active_version_id = &u +} + +// ActiveVersionID returns the value of the "active_version_id" field in the mutation. +func (m *AgentPluginMutation) ActiveVersionID() (r uuid.UUID, exists bool) { + v := m.active_version_id + if v == nil { + return + } + return *v, true +} + +// OldActiveVersionID returns the old "active_version_id" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginMutation) OldActiveVersionID(ctx context.Context) (v *uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldActiveVersionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldActiveVersionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldActiveVersionID: %w", err) + } + return oldValue.ActiveVersionID, nil +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (m *AgentPluginMutation) ClearActiveVersionID() { + m.active_version_id = nil + m.clearedFields[agentplugin.FieldActiveVersionID] = struct{}{} +} + +// ActiveVersionIDCleared returns if the "active_version_id" field was cleared in this mutation. +func (m *AgentPluginMutation) ActiveVersionIDCleared() bool { + _, ok := m.clearedFields[agentplugin.FieldActiveVersionID] return ok } -// ResetResponse resets all changes to the "response" field. -func (m *AuditMutation) ResetResponse() { - m.response = nil - delete(m.clearedFields, audit.FieldResponse) +// ResetActiveVersionID resets all changes to the "active_version_id" field. +func (m *AgentPluginMutation) ResetActiveVersionID() { + m.active_version_id = nil + delete(m.clearedFields, agentplugin.FieldActiveVersionID) +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (m *AgentPluginMutation) SetIsForceDelivery(b bool) { + m.is_force_delivery = &b +} + +// IsForceDelivery returns the value of the "is_force_delivery" field in the mutation. +func (m *AgentPluginMutation) IsForceDelivery() (r bool, exists bool) { + v := m.is_force_delivery + if v == nil { + return + } + return *v, true +} + +// OldIsForceDelivery returns the old "is_force_delivery" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginMutation) OldIsForceDelivery(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsForceDelivery is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsForceDelivery requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsForceDelivery: %w", err) + } + return oldValue.IsForceDelivery, nil +} + +// ResetIsForceDelivery resets all changes to the "is_force_delivery" field. +func (m *AgentPluginMutation) ResetIsForceDelivery() { + m.is_force_delivery = nil +} + +// SetIsOrphan sets the "is_orphan" field. +func (m *AgentPluginMutation) SetIsOrphan(b bool) { + m.is_orphan = &b +} + +// IsOrphan returns the value of the "is_orphan" field in the mutation. +func (m *AgentPluginMutation) IsOrphan() (r bool, exists bool) { + v := m.is_orphan + if v == nil { + return + } + return *v, true +} + +// OldIsOrphan returns the old "is_orphan" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginMutation) OldIsOrphan(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsOrphan is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsOrphan requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsOrphan: %w", err) + } + return oldValue.IsOrphan, nil +} + +// ResetIsOrphan resets all changes to the "is_orphan" field. +func (m *AgentPluginMutation) ResetIsOrphan() { + m.is_orphan = nil +} + +// SetIsDeleted sets the "is_deleted" field. +func (m *AgentPluginMutation) SetIsDeleted(b bool) { + m.is_deleted = &b +} + +// IsDeleted returns the value of the "is_deleted" field in the mutation. +func (m *AgentPluginMutation) IsDeleted() (r bool, exists bool) { + v := m.is_deleted + if v == nil { + return + } + return *v, true +} + +// OldIsDeleted returns the old "is_deleted" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginMutation) OldIsDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsDeleted: %w", err) + } + return oldValue.IsDeleted, nil +} + +// ResetIsDeleted resets all changes to the "is_deleted" field. +func (m *AgentPluginMutation) ResetIsDeleted() { + m.is_deleted = nil +} + +// SetEnabled sets the "enabled" field. +func (m *AgentPluginMutation) SetEnabled(b bool) { + m.enabled = &b +} + +// Enabled returns the value of the "enabled" field in the mutation. +func (m *AgentPluginMutation) Enabled() (r bool, exists bool) { + v := m.enabled + if v == nil { + return + } + return *v, true +} + +// OldEnabled returns the old "enabled" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginMutation) OldEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEnabled: %w", err) + } + return oldValue.Enabled, nil +} + +// ResetEnabled resets all changes to the "enabled" field. +func (m *AgentPluginMutation) ResetEnabled() { + m.enabled = nil } // SetCreatedAt sets the "created_at" field. -func (m *AuditMutation) SetCreatedAt(t time.Time) { +func (m *AgentPluginMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *AuditMutation) CreatedAt() (r time.Time, exists bool) { +func (m *AgentPluginMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -485,10 +701,10 @@ func (m *AuditMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Audit entity. -// If the Audit object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *AuditMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentPluginMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -503,46 +719,136 @@ func (m *AuditMutation) OldCreatedAt(ctx context.Context) (v time.Time, err erro } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *AuditMutation) ResetCreatedAt() { +func (m *AgentPluginMutation) ResetCreatedAt() { m.created_at = nil } -// ClearUser clears the "user" edge to the User entity. -func (m *AuditMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[audit.FieldUserID] = struct{}{} +// SetUpdatedAt sets the "updated_at" field. +func (m *AgentPluginMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *AuditMutation) UserCleared() bool { - return m.cleareduser +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *AgentPluginMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true } -// UserIDs returns the "user" edge IDs in the mutation. +// OldUpdatedAt returns the old "updated_at" field's value of the AgentPlugin entity. +// If the AgentPlugin object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *AgentPluginMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// ClearRepo clears the "repo" edge to the AgentPluginRepo entity. +func (m *AgentPluginMutation) ClearRepo() { + m.clearedrepo = true + m.clearedFields[agentplugin.FieldRepoID] = struct{}{} +} + +// RepoCleared reports if the "repo" edge to the AgentPluginRepo entity was cleared. +func (m *AgentPluginMutation) RepoCleared() bool { + return m.clearedrepo +} + +// RepoIDs returns the "repo" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *AuditMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { +// RepoID instead. It exists only for internal usage by the builders. +func (m *AgentPluginMutation) RepoIDs() (ids []uuid.UUID) { + if id := m.repo; id != nil { ids = append(ids, *id) } return } -// ResetUser resets all changes to the "user" edge. -func (m *AuditMutation) ResetUser() { - m.user = nil - m.cleareduser = false +// ResetRepo resets all changes to the "repo" edge. +func (m *AgentPluginMutation) ResetRepo() { + m.repo = nil + m.clearedrepo = false } -// Where appends a list predicates to the AuditMutation builder. -func (m *AuditMutation) Where(ps ...predicate.Audit) { +// AddVersionIDs adds the "versions" edge to the AgentPluginVersion entity by ids. +func (m *AgentPluginMutation) AddVersionIDs(ids ...uuid.UUID) { + if m.versions == nil { + m.versions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.versions[ids[i]] = struct{}{} + } +} + +// ClearVersions clears the "versions" edge to the AgentPluginVersion entity. +func (m *AgentPluginMutation) ClearVersions() { + m.clearedversions = true +} + +// VersionsCleared reports if the "versions" edge to the AgentPluginVersion entity was cleared. +func (m *AgentPluginMutation) VersionsCleared() bool { + return m.clearedversions +} + +// RemoveVersionIDs removes the "versions" edge to the AgentPluginVersion entity by IDs. +func (m *AgentPluginMutation) RemoveVersionIDs(ids ...uuid.UUID) { + if m.removedversions == nil { + m.removedversions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.versions, ids[i]) + m.removedversions[ids[i]] = struct{}{} + } +} + +// RemovedVersions returns the removed IDs of the "versions" edge to the AgentPluginVersion entity. +func (m *AgentPluginMutation) RemovedVersionsIDs() (ids []uuid.UUID) { + for id := range m.removedversions { + ids = append(ids, id) + } + return +} + +// VersionsIDs returns the "versions" edge IDs in the mutation. +func (m *AgentPluginMutation) VersionsIDs() (ids []uuid.UUID) { + for id := range m.versions { + ids = append(ids, id) + } + return +} + +// ResetVersions resets all changes to the "versions" edge. +func (m *AgentPluginMutation) ResetVersions() { + m.versions = nil + m.clearedversions = false + m.removedversions = nil +} + +// Where appends a list predicates to the AgentPluginMutation builder. +func (m *AgentPluginMutation) Where(ps ...predicate.AgentPlugin) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the AuditMutation builder. Using this method, +// WhereP appends storage-level predicates to the AgentPluginMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *AuditMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Audit, len(ps)) +func (m *AgentPluginMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.AgentPlugin, len(ps)) for i := range ps { p[i] = ps[i] } @@ -550,45 +856,63 @@ func (m *AuditMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *AuditMutation) Op() Op { +func (m *AgentPluginMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *AuditMutation) SetOp(op Op) { +func (m *AgentPluginMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Audit). -func (m *AuditMutation) Type() string { +// Type returns the node type of this mutation (AgentPlugin). +func (m *AgentPluginMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *AuditMutation) Fields() []string { - fields := make([]string, 0, 7) - if m.user != nil { - fields = append(fields, audit.FieldUserID) +func (m *AgentPluginMutation) Fields() []string { + fields := make([]string, 0, 13) + if m.repo != nil { + fields = append(fields, agentplugin.FieldRepoID) } - if m.operation != nil { - fields = append(fields, audit.FieldOperation) + if m.name != nil { + fields = append(fields, agentplugin.FieldName) } - if m.source_ip != nil { - fields = append(fields, audit.FieldSourceIP) + if m.description != nil { + fields = append(fields, agentplugin.FieldDescription) } - if m.user_agent != nil { - fields = append(fields, audit.FieldUserAgent) + if m.scope_type != nil { + fields = append(fields, agentplugin.FieldScopeType) } - if m.request != nil { - fields = append(fields, audit.FieldRequest) + if m.scope_id != nil { + fields = append(fields, agentplugin.FieldScopeID) } - if m.response != nil { - fields = append(fields, audit.FieldResponse) + if m.created_by != nil { + fields = append(fields, agentplugin.FieldCreatedBy) + } + if m.active_version_id != nil { + fields = append(fields, agentplugin.FieldActiveVersionID) + } + if m.is_force_delivery != nil { + fields = append(fields, agentplugin.FieldIsForceDelivery) + } + if m.is_orphan != nil { + fields = append(fields, agentplugin.FieldIsOrphan) + } + if m.is_deleted != nil { + fields = append(fields, agentplugin.FieldIsDeleted) + } + if m.enabled != nil { + fields = append(fields, agentplugin.FieldEnabled) } if m.created_at != nil { - fields = append(fields, audit.FieldCreatedAt) + fields = append(fields, agentplugin.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, agentplugin.FieldUpdatedAt) } return fields } @@ -596,22 +920,34 @@ func (m *AuditMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *AuditMutation) Field(name string) (ent.Value, bool) { +func (m *AgentPluginMutation) Field(name string) (ent.Value, bool) { switch name { - case audit.FieldUserID: - return m.UserID() - case audit.FieldOperation: - return m.Operation() - case audit.FieldSourceIP: - return m.SourceIP() - case audit.FieldUserAgent: - return m.UserAgent() - case audit.FieldRequest: - return m.Request() - case audit.FieldResponse: - return m.Response() - case audit.FieldCreatedAt: + case agentplugin.FieldRepoID: + return m.RepoID() + case agentplugin.FieldName: + return m.Name() + case agentplugin.FieldDescription: + return m.Description() + case agentplugin.FieldScopeType: + return m.ScopeType() + case agentplugin.FieldScopeID: + return m.ScopeID() + case agentplugin.FieldCreatedBy: + return m.CreatedBy() + case agentplugin.FieldActiveVersionID: + return m.ActiveVersionID() + case agentplugin.FieldIsForceDelivery: + return m.IsForceDelivery() + case agentplugin.FieldIsOrphan: + return m.IsOrphan() + case agentplugin.FieldIsDeleted: + return m.IsDeleted() + case agentplugin.FieldEnabled: + return m.Enabled() + case agentplugin.FieldCreatedAt: return m.CreatedAt() + case agentplugin.FieldUpdatedAt: + return m.UpdatedAt() } return nil, false } @@ -619,284 +955,388 @@ func (m *AuditMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *AuditMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *AgentPluginMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case audit.FieldUserID: - return m.OldUserID(ctx) - case audit.FieldOperation: - return m.OldOperation(ctx) - case audit.FieldSourceIP: - return m.OldSourceIP(ctx) - case audit.FieldUserAgent: - return m.OldUserAgent(ctx) - case audit.FieldRequest: - return m.OldRequest(ctx) - case audit.FieldResponse: - return m.OldResponse(ctx) - case audit.FieldCreatedAt: + case agentplugin.FieldRepoID: + return m.OldRepoID(ctx) + case agentplugin.FieldName: + return m.OldName(ctx) + case agentplugin.FieldDescription: + return m.OldDescription(ctx) + case agentplugin.FieldScopeType: + return m.OldScopeType(ctx) + case agentplugin.FieldScopeID: + return m.OldScopeID(ctx) + case agentplugin.FieldCreatedBy: + return m.OldCreatedBy(ctx) + case agentplugin.FieldActiveVersionID: + return m.OldActiveVersionID(ctx) + case agentplugin.FieldIsForceDelivery: + return m.OldIsForceDelivery(ctx) + case agentplugin.FieldIsOrphan: + return m.OldIsOrphan(ctx) + case agentplugin.FieldIsDeleted: + return m.OldIsDeleted(ctx) + case agentplugin.FieldEnabled: + return m.OldEnabled(ctx) + case agentplugin.FieldCreatedAt: return m.OldCreatedAt(ctx) + case agentplugin.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown Audit field %s", name) + return nil, fmt.Errorf("unknown AgentPlugin field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *AuditMutation) SetField(name string, value ent.Value) error { +func (m *AgentPluginMutation) SetField(name string, value ent.Value) error { switch name { - case audit.FieldUserID: + case agentplugin.FieldRepoID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) + m.SetRepoID(v) return nil - case audit.FieldOperation: + case agentplugin.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOperation(v) + m.SetName(v) return nil - case audit.FieldSourceIP: + case agentplugin.FieldDescription: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSourceIP(v) + m.SetDescription(v) return nil - case audit.FieldUserAgent: - v, ok := value.(string) + case agentplugin.FieldScopeType: + v, ok := value.(agentplugin.ScopeType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserAgent(v) + m.SetScopeType(v) return nil - case audit.FieldRequest: + case agentplugin.FieldScopeID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRequest(v) + m.SetScopeID(v) return nil - case audit.FieldResponse: - v, ok := value.(string) + case agentplugin.FieldCreatedBy: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetResponse(v) + m.SetCreatedBy(v) return nil - case audit.FieldCreatedAt: + case agentplugin.FieldActiveVersionID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetActiveVersionID(v) + return nil + case agentplugin.FieldIsForceDelivery: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsForceDelivery(v) + return nil + case agentplugin.FieldIsOrphan: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsOrphan(v) + return nil + case agentplugin.FieldIsDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsDeleted(v) + return nil + case agentplugin.FieldEnabled: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEnabled(v) + return nil + case agentplugin.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil + case agentplugin.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil } - return fmt.Errorf("unknown Audit field %s", name) + return fmt.Errorf("unknown AgentPlugin field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *AuditMutation) AddedFields() []string { +func (m *AgentPluginMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *AuditMutation) AddedField(name string) (ent.Value, bool) { +func (m *AgentPluginMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *AuditMutation) AddField(name string, value ent.Value) error { +func (m *AgentPluginMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Audit numeric field %s", name) + return fmt.Errorf("unknown AgentPlugin numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *AuditMutation) ClearedFields() []string { +func (m *AgentPluginMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(audit.FieldResponse) { - fields = append(fields, audit.FieldResponse) + if m.FieldCleared(agentplugin.FieldDescription) { + fields = append(fields, agentplugin.FieldDescription) + } + if m.FieldCleared(agentplugin.FieldActiveVersionID) { + fields = append(fields, agentplugin.FieldActiveVersionID) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *AuditMutation) FieldCleared(name string) bool { +func (m *AgentPluginMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *AuditMutation) ClearField(name string) error { +func (m *AgentPluginMutation) ClearField(name string) error { switch name { - case audit.FieldResponse: - m.ClearResponse() + case agentplugin.FieldDescription: + m.ClearDescription() + return nil + case agentplugin.FieldActiveVersionID: + m.ClearActiveVersionID() return nil } - return fmt.Errorf("unknown Audit nullable field %s", name) + return fmt.Errorf("unknown AgentPlugin nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *AuditMutation) ResetField(name string) error { +func (m *AgentPluginMutation) ResetField(name string) error { switch name { - case audit.FieldUserID: - m.ResetUserID() + case agentplugin.FieldRepoID: + m.ResetRepoID() return nil - case audit.FieldOperation: - m.ResetOperation() + case agentplugin.FieldName: + m.ResetName() return nil - case audit.FieldSourceIP: - m.ResetSourceIP() + case agentplugin.FieldDescription: + m.ResetDescription() return nil - case audit.FieldUserAgent: - m.ResetUserAgent() + case agentplugin.FieldScopeType: + m.ResetScopeType() return nil - case audit.FieldRequest: - m.ResetRequest() + case agentplugin.FieldScopeID: + m.ResetScopeID() return nil - case audit.FieldResponse: - m.ResetResponse() + case agentplugin.FieldCreatedBy: + m.ResetCreatedBy() return nil - case audit.FieldCreatedAt: + case agentplugin.FieldActiveVersionID: + m.ResetActiveVersionID() + return nil + case agentplugin.FieldIsForceDelivery: + m.ResetIsForceDelivery() + return nil + case agentplugin.FieldIsOrphan: + m.ResetIsOrphan() + return nil + case agentplugin.FieldIsDeleted: + m.ResetIsDeleted() + return nil + case agentplugin.FieldEnabled: + m.ResetEnabled() + return nil + case agentplugin.FieldCreatedAt: m.ResetCreatedAt() return nil + case agentplugin.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil } - return fmt.Errorf("unknown Audit field %s", name) + return fmt.Errorf("unknown AgentPlugin field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *AuditMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.user != nil { - edges = append(edges, audit.EdgeUser) +func (m *AgentPluginMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.repo != nil { + edges = append(edges, agentplugin.EdgeRepo) + } + if m.versions != nil { + edges = append(edges, agentplugin.EdgeVersions) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *AuditMutation) AddedIDs(name string) []ent.Value { +func (m *AgentPluginMutation) AddedIDs(name string) []ent.Value { switch name { - case audit.EdgeUser: - if id := m.user; id != nil { + case agentplugin.EdgeRepo: + if id := m.repo; id != nil { return []ent.Value{*id} } + case agentplugin.EdgeVersions: + ids := make([]ent.Value, 0, len(m.versions)) + for id := range m.versions { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *AuditMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) +func (m *AgentPluginMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedversions != nil { + edges = append(edges, agentplugin.EdgeVersions) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *AuditMutation) RemovedIDs(name string) []ent.Value { +func (m *AgentPluginMutation) RemovedIDs(name string) []ent.Value { + switch name { + case agentplugin.EdgeVersions: + ids := make([]ent.Value, 0, len(m.removedversions)) + for id := range m.removedversions { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *AuditMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.cleareduser { - edges = append(edges, audit.EdgeUser) +func (m *AgentPluginMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedrepo { + edges = append(edges, agentplugin.EdgeRepo) + } + if m.clearedversions { + edges = append(edges, agentplugin.EdgeVersions) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *AuditMutation) EdgeCleared(name string) bool { +func (m *AgentPluginMutation) EdgeCleared(name string) bool { switch name { - case audit.EdgeUser: - return m.cleareduser + case agentplugin.EdgeRepo: + return m.clearedrepo + case agentplugin.EdgeVersions: + return m.clearedversions } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *AuditMutation) ClearEdge(name string) error { +func (m *AgentPluginMutation) ClearEdge(name string) error { switch name { - case audit.EdgeUser: - m.ClearUser() + case agentplugin.EdgeRepo: + m.ClearRepo() return nil } - return fmt.Errorf("unknown Audit unique edge %s", name) + return fmt.Errorf("unknown AgentPlugin unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *AuditMutation) ResetEdge(name string) error { +func (m *AgentPluginMutation) ResetEdge(name string) error { switch name { - case audit.EdgeUser: - m.ResetUser() + case agentplugin.EdgeRepo: + m.ResetRepo() + return nil + case agentplugin.EdgeVersions: + m.ResetVersions() return nil } - return fmt.Errorf("unknown Audit edge %s", name) + return fmt.Errorf("unknown AgentPlugin edge %s", name) } -// GitBotMutation represents an operation that mutates the GitBot nodes in the graph. -type GitBotMutation struct { +// AgentPluginRepoMutation represents an operation that mutates the AgentPluginRepo nodes in the graph. +type AgentPluginRepoMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - user_id *uuid.UUID - name *string - token *string - secret_token *string - platform *consts.GitPlatform - created_at *time.Time - clearedFields map[string]struct{} - git_bot_tasks map[uuid.UUID]struct{} - removedgit_bot_tasks map[uuid.UUID]struct{} - clearedgit_bot_tasks bool - host *string - clearedhost bool - users map[uuid.UUID]struct{} - removedusers map[uuid.UUID]struct{} - clearedusers bool - projects map[uuid.UUID]struct{} - removedprojects map[uuid.UUID]struct{} - clearedprojects bool - git_bot_users map[uuid.UUID]struct{} - removedgit_bot_users map[uuid.UUID]struct{} - clearedgit_bot_users bool - project_git_bots map[uuid.UUID]struct{} - removedproject_git_bots map[uuid.UUID]struct{} - clearedproject_git_bots bool - done bool - oldValue func(context.Context) (*GitBot, error) - predicates []predicate.GitBot -} - -var _ ent.Mutation = (*GitBotMutation)(nil) - -// gitbotOption allows management of the mutation configuration using functional options. -type gitbotOption func(*GitBotMutation) - -// newGitBotMutation creates new mutation for the GitBot entity. -func newGitBotMutation(c config, op Op, opts ...gitbotOption) *GitBotMutation { - m := &GitBotMutation{ + op Op + typ string + id *uuid.UUID + name *string + scope_type *agentpluginrepo.ScopeType + scope_id *string + created_by *uuid.UUID + source_type *agentpluginrepo.SourceType + github_url *string + ref_type *agentpluginrepo.RefType + ref_value *string + last_upload_filename *string + last_upload_at *time.Time + plugin_discovery_auto_package_json *bool + plugin_manual_entries *types.PluginManualEntries + appendplugin_manual_entries types.PluginManualEntries + npm_package_name *string + npm_version_spec *string + npm_registry_url *string + is_deleted *bool + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + plugins map[uuid.UUID]struct{} + removedplugins map[uuid.UUID]struct{} + clearedplugins bool + done bool + oldValue func(context.Context) (*AgentPluginRepo, error) + predicates []predicate.AgentPluginRepo +} + +var _ ent.Mutation = (*AgentPluginRepoMutation)(nil) + +// agentpluginrepoOption allows management of the mutation configuration using functional options. +type agentpluginrepoOption func(*AgentPluginRepoMutation) + +// newAgentPluginRepoMutation creates new mutation for the AgentPluginRepo entity. +func newAgentPluginRepoMutation(c config, op Op, opts ...agentpluginrepoOption) *AgentPluginRepoMutation { + m := &AgentPluginRepoMutation{ config: c, op: op, - typ: TypeGitBot, + typ: TypeAgentPluginRepo, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -905,20 +1345,20 @@ func newGitBotMutation(c config, op Op, opts ...gitbotOption) *GitBotMutation { return m } -// withGitBotID sets the ID field of the mutation. -func withGitBotID(id uuid.UUID) gitbotOption { - return func(m *GitBotMutation) { +// withAgentPluginRepoID sets the ID field of the mutation. +func withAgentPluginRepoID(id uuid.UUID) agentpluginrepoOption { + return func(m *AgentPluginRepoMutation) { var ( err error once sync.Once - value *GitBot + value *AgentPluginRepo ) - m.oldValue = func(ctx context.Context) (*GitBot, error) { + m.oldValue = func(ctx context.Context) (*AgentPluginRepo, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().GitBot.Get(ctx, id) + value, err = m.Client().AgentPluginRepo.Get(ctx, id) } }) return value, err @@ -927,10 +1367,10 @@ func withGitBotID(id uuid.UUID) gitbotOption { } } -// withGitBot sets the old GitBot of the mutation. -func withGitBot(node *GitBot) gitbotOption { - return func(m *GitBotMutation) { - m.oldValue = func(context.Context) (*GitBot, error) { +// withAgentPluginRepo sets the old AgentPluginRepo of the mutation. +func withAgentPluginRepo(node *AgentPluginRepo) agentpluginrepoOption { + return func(m *AgentPluginRepoMutation) { + m.oldValue = func(context.Context) (*AgentPluginRepo, error) { return node, nil } m.id = &node.ID @@ -939,7 +1379,7 @@ func withGitBot(node *GitBot) gitbotOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m GitBotMutation) Client() *Client { +func (m AgentPluginRepoMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -947,7 +1387,7 @@ func (m GitBotMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m GitBotMutation) Tx() (*Tx, error) { +func (m AgentPluginRepoMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -957,14 +1397,14 @@ func (m GitBotMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of GitBot entities. -func (m *GitBotMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of AgentPluginRepo entities. +func (m *AgentPluginRepoMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *GitBotMutation) ID() (id uuid.UUID, exists bool) { +func (m *AgentPluginRepoMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -975,7 +1415,7 @@ func (m *GitBotMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *GitBotMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *AgentPluginRepoMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -984,658 +1424,856 @@ func (m *GitBotMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().GitBot.Query().Where(m.predicates...).IDs(ctx) + return m.Client().AgentPluginRepo.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetDeletedAt sets the "deleted_at" field. -func (m *GitBotMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t +// SetName sets the "name" field. +func (m *AgentPluginRepoMutation) SetName(s string) { + m.name = &s } -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *GitBotMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at +// Name returns the value of the "name" field in the mutation. +func (m *AgentPluginRepoMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldDeletedAt returns the old "deleted_at" field's value of the GitBot entity. -// If the GitBot object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentPluginRepoMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.DeletedAt, nil -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *GitBotMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[gitbot.FieldDeletedAt] = struct{}{} -} - -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *GitBotMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[gitbot.FieldDeletedAt] - return ok + return oldValue.Name, nil } -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *GitBotMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, gitbot.FieldDeletedAt) +// ResetName resets all changes to the "name" field. +func (m *AgentPluginRepoMutation) ResetName() { + m.name = nil } -// SetUserID sets the "user_id" field. -func (m *GitBotMutation) SetUserID(u uuid.UUID) { - m.user_id = &u +// SetScopeType sets the "scope_type" field. +func (m *AgentPluginRepoMutation) SetScopeType(at agentpluginrepo.ScopeType) { + m.scope_type = &at } -// UserID returns the value of the "user_id" field in the mutation. -func (m *GitBotMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user_id +// ScopeType returns the value of the "scope_type" field in the mutation. +func (m *AgentPluginRepoMutation) ScopeType() (r agentpluginrepo.ScopeType, exists bool) { + v := m.scope_type if v == nil { return } return *v, true } -// OldUserID returns the old "user_id" field's value of the GitBot entity. -// If the GitBot object wasn't provided to the builder, the object is fetched from the database. +// OldScopeType returns the old "scope_type" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AgentPluginRepoMutation) OldScopeType(ctx context.Context) (v agentpluginrepo.ScopeType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") + return v, errors.New("OldScopeType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") + return v, errors.New("OldScopeType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + return v, fmt.Errorf("querying old value for OldScopeType: %w", err) } - return oldValue.UserID, nil + return oldValue.ScopeType, nil } -// ResetUserID resets all changes to the "user_id" field. -func (m *GitBotMutation) ResetUserID() { - m.user_id = nil +// ResetScopeType resets all changes to the "scope_type" field. +func (m *AgentPluginRepoMutation) ResetScopeType() { + m.scope_type = nil } -// SetName sets the "name" field. -func (m *GitBotMutation) SetName(s string) { - m.name = &s +// SetScopeID sets the "scope_id" field. +func (m *AgentPluginRepoMutation) SetScopeID(s string) { + m.scope_id = &s } -// Name returns the value of the "name" field in the mutation. -func (m *GitBotMutation) Name() (r string, exists bool) { - v := m.name +// ScopeID returns the value of the "scope_id" field in the mutation. +func (m *AgentPluginRepoMutation) ScopeID() (r string, exists bool) { + v := m.scope_id if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the GitBot entity. -// If the GitBot object wasn't provided to the builder, the object is fetched from the database. +// OldScopeID returns the old "scope_id" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotMutation) OldName(ctx context.Context) (v string, err error) { +func (m *AgentPluginRepoMutation) OldScopeID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldScopeID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldScopeID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldScopeID: %w", err) } - return oldValue.Name, nil + return oldValue.ScopeID, nil } -// ClearName clears the value of the "name" field. -func (m *GitBotMutation) ClearName() { - m.name = nil - m.clearedFields[gitbot.FieldName] = struct{}{} +// ResetScopeID resets all changes to the "scope_id" field. +func (m *AgentPluginRepoMutation) ResetScopeID() { + m.scope_id = nil } -// NameCleared returns if the "name" field was cleared in this mutation. -func (m *GitBotMutation) NameCleared() bool { - _, ok := m.clearedFields[gitbot.FieldName] - return ok +// SetCreatedBy sets the "created_by" field. +func (m *AgentPluginRepoMutation) SetCreatedBy(u uuid.UUID) { + m.created_by = &u } -// ResetName resets all changes to the "name" field. -func (m *GitBotMutation) ResetName() { - m.name = nil - delete(m.clearedFields, gitbot.FieldName) +// CreatedBy returns the value of the "created_by" field in the mutation. +func (m *AgentPluginRepoMutation) CreatedBy() (r uuid.UUID, exists bool) { + v := m.created_by + if v == nil { + return + } + return *v, true } -// SetHostID sets the "host_id" field. -func (m *GitBotMutation) SetHostID(s string) { - m.host = &s +// OldCreatedBy returns the old "created_by" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginRepoMutation) OldCreatedBy(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedBy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err) + } + return oldValue.CreatedBy, nil } -// HostID returns the value of the "host_id" field in the mutation. -func (m *GitBotMutation) HostID() (r string, exists bool) { - v := m.host +// ResetCreatedBy resets all changes to the "created_by" field. +func (m *AgentPluginRepoMutation) ResetCreatedBy() { + m.created_by = nil +} + +// SetSourceType sets the "source_type" field. +func (m *AgentPluginRepoMutation) SetSourceType(at agentpluginrepo.SourceType) { + m.source_type = &at +} + +// SourceType returns the value of the "source_type" field in the mutation. +func (m *AgentPluginRepoMutation) SourceType() (r agentpluginrepo.SourceType, exists bool) { + v := m.source_type if v == nil { return } return *v, true } -// OldHostID returns the old "host_id" field's value of the GitBot entity. -// If the GitBot object wasn't provided to the builder, the object is fetched from the database. +// OldSourceType returns the old "source_type" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotMutation) OldHostID(ctx context.Context) (v string, err error) { +func (m *AgentPluginRepoMutation) OldSourceType(ctx context.Context) (v agentpluginrepo.SourceType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHostID is only allowed on UpdateOne operations") + return v, errors.New("OldSourceType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHostID requires an ID field in the mutation") + return v, errors.New("OldSourceType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldHostID: %w", err) + return v, fmt.Errorf("querying old value for OldSourceType: %w", err) } - return oldValue.HostID, nil + return oldValue.SourceType, nil } -// ResetHostID resets all changes to the "host_id" field. -func (m *GitBotMutation) ResetHostID() { - m.host = nil +// ResetSourceType resets all changes to the "source_type" field. +func (m *AgentPluginRepoMutation) ResetSourceType() { + m.source_type = nil } -// SetToken sets the "token" field. -func (m *GitBotMutation) SetToken(s string) { - m.token = &s +// SetGithubURL sets the "github_url" field. +func (m *AgentPluginRepoMutation) SetGithubURL(s string) { + m.github_url = &s } -// Token returns the value of the "token" field in the mutation. -func (m *GitBotMutation) Token() (r string, exists bool) { - v := m.token +// GithubURL returns the value of the "github_url" field in the mutation. +func (m *AgentPluginRepoMutation) GithubURL() (r string, exists bool) { + v := m.github_url if v == nil { return } return *v, true } -// OldToken returns the old "token" field's value of the GitBot entity. -// If the GitBot object wasn't provided to the builder, the object is fetched from the database. +// OldGithubURL returns the old "github_url" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotMutation) OldToken(ctx context.Context) (v string, err error) { +func (m *AgentPluginRepoMutation) OldGithubURL(ctx context.Context) (v *string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldToken is only allowed on UpdateOne operations") + return v, errors.New("OldGithubURL is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldToken requires an ID field in the mutation") + return v, errors.New("OldGithubURL requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldToken: %w", err) + return v, fmt.Errorf("querying old value for OldGithubURL: %w", err) } - return oldValue.Token, nil + return oldValue.GithubURL, nil } -// ClearToken clears the value of the "token" field. -func (m *GitBotMutation) ClearToken() { - m.token = nil - m.clearedFields[gitbot.FieldToken] = struct{}{} +// ClearGithubURL clears the value of the "github_url" field. +func (m *AgentPluginRepoMutation) ClearGithubURL() { + m.github_url = nil + m.clearedFields[agentpluginrepo.FieldGithubURL] = struct{}{} } -// TokenCleared returns if the "token" field was cleared in this mutation. -func (m *GitBotMutation) TokenCleared() bool { - _, ok := m.clearedFields[gitbot.FieldToken] +// GithubURLCleared returns if the "github_url" field was cleared in this mutation. +func (m *AgentPluginRepoMutation) GithubURLCleared() bool { + _, ok := m.clearedFields[agentpluginrepo.FieldGithubURL] return ok } -// ResetToken resets all changes to the "token" field. -func (m *GitBotMutation) ResetToken() { - m.token = nil - delete(m.clearedFields, gitbot.FieldToken) +// ResetGithubURL resets all changes to the "github_url" field. +func (m *AgentPluginRepoMutation) ResetGithubURL() { + m.github_url = nil + delete(m.clearedFields, agentpluginrepo.FieldGithubURL) } -// SetSecretToken sets the "secret_token" field. -func (m *GitBotMutation) SetSecretToken(s string) { - m.secret_token = &s +// SetRefType sets the "ref_type" field. +func (m *AgentPluginRepoMutation) SetRefType(at agentpluginrepo.RefType) { + m.ref_type = &at } -// SecretToken returns the value of the "secret_token" field in the mutation. -func (m *GitBotMutation) SecretToken() (r string, exists bool) { - v := m.secret_token +// RefType returns the value of the "ref_type" field in the mutation. +func (m *AgentPluginRepoMutation) RefType() (r agentpluginrepo.RefType, exists bool) { + v := m.ref_type if v == nil { return } return *v, true } -// OldSecretToken returns the old "secret_token" field's value of the GitBot entity. -// If the GitBot object wasn't provided to the builder, the object is fetched from the database. +// OldRefType returns the old "ref_type" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotMutation) OldSecretToken(ctx context.Context) (v string, err error) { +func (m *AgentPluginRepoMutation) OldRefType(ctx context.Context) (v *agentpluginrepo.RefType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSecretToken is only allowed on UpdateOne operations") + return v, errors.New("OldRefType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSecretToken requires an ID field in the mutation") + return v, errors.New("OldRefType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSecretToken: %w", err) + return v, fmt.Errorf("querying old value for OldRefType: %w", err) } - return oldValue.SecretToken, nil + return oldValue.RefType, nil } -// ClearSecretToken clears the value of the "secret_token" field. -func (m *GitBotMutation) ClearSecretToken() { - m.secret_token = nil - m.clearedFields[gitbot.FieldSecretToken] = struct{}{} +// ClearRefType clears the value of the "ref_type" field. +func (m *AgentPluginRepoMutation) ClearRefType() { + m.ref_type = nil + m.clearedFields[agentpluginrepo.FieldRefType] = struct{}{} } -// SecretTokenCleared returns if the "secret_token" field was cleared in this mutation. -func (m *GitBotMutation) SecretTokenCleared() bool { - _, ok := m.clearedFields[gitbot.FieldSecretToken] +// RefTypeCleared returns if the "ref_type" field was cleared in this mutation. +func (m *AgentPluginRepoMutation) RefTypeCleared() bool { + _, ok := m.clearedFields[agentpluginrepo.FieldRefType] return ok } -// ResetSecretToken resets all changes to the "secret_token" field. -func (m *GitBotMutation) ResetSecretToken() { - m.secret_token = nil - delete(m.clearedFields, gitbot.FieldSecretToken) +// ResetRefType resets all changes to the "ref_type" field. +func (m *AgentPluginRepoMutation) ResetRefType() { + m.ref_type = nil + delete(m.clearedFields, agentpluginrepo.FieldRefType) } -// SetPlatform sets the "platform" field. -func (m *GitBotMutation) SetPlatform(cp consts.GitPlatform) { - m.platform = &cp +// SetRefValue sets the "ref_value" field. +func (m *AgentPluginRepoMutation) SetRefValue(s string) { + m.ref_value = &s } -// Platform returns the value of the "platform" field in the mutation. -func (m *GitBotMutation) Platform() (r consts.GitPlatform, exists bool) { - v := m.platform +// RefValue returns the value of the "ref_value" field in the mutation. +func (m *AgentPluginRepoMutation) RefValue() (r string, exists bool) { + v := m.ref_value if v == nil { return } return *v, true } -// OldPlatform returns the old "platform" field's value of the GitBot entity. -// If the GitBot object wasn't provided to the builder, the object is fetched from the database. +// OldRefValue returns the old "ref_value" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotMutation) OldPlatform(ctx context.Context) (v consts.GitPlatform, err error) { +func (m *AgentPluginRepoMutation) OldRefValue(ctx context.Context) (v *string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPlatform is only allowed on UpdateOne operations") + return v, errors.New("OldRefValue is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPlatform requires an ID field in the mutation") + return v, errors.New("OldRefValue requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPlatform: %w", err) + return v, fmt.Errorf("querying old value for OldRefValue: %w", err) } - return oldValue.Platform, nil + return oldValue.RefValue, nil } -// ResetPlatform resets all changes to the "platform" field. -func (m *GitBotMutation) ResetPlatform() { - m.platform = nil +// ClearRefValue clears the value of the "ref_value" field. +func (m *AgentPluginRepoMutation) ClearRefValue() { + m.ref_value = nil + m.clearedFields[agentpluginrepo.FieldRefValue] = struct{}{} } -// SetCreatedAt sets the "created_at" field. -func (m *GitBotMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// RefValueCleared returns if the "ref_value" field was cleared in this mutation. +func (m *AgentPluginRepoMutation) RefValueCleared() bool { + _, ok := m.clearedFields[agentpluginrepo.FieldRefValue] + return ok } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *GitBotMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// ResetRefValue resets all changes to the "ref_value" field. +func (m *AgentPluginRepoMutation) ResetRefValue() { + m.ref_value = nil + delete(m.clearedFields, agentpluginrepo.FieldRefValue) +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (m *AgentPluginRepoMutation) SetLastUploadFilename(s string) { + m.last_upload_filename = &s +} + +// LastUploadFilename returns the value of the "last_upload_filename" field in the mutation. +func (m *AgentPluginRepoMutation) LastUploadFilename() (r string, exists bool) { + v := m.last_upload_filename if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the GitBot entity. -// If the GitBot object wasn't provided to the builder, the object is fetched from the database. +// OldLastUploadFilename returns the old "last_upload_filename" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentPluginRepoMutation) OldLastUploadFilename(ctx context.Context) (v *string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldLastUploadFilename is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + return v, errors.New("OldLastUploadFilename requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldLastUploadFilename: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.LastUploadFilename, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *GitBotMutation) ResetCreatedAt() { - m.created_at = nil +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (m *AgentPluginRepoMutation) ClearLastUploadFilename() { + m.last_upload_filename = nil + m.clearedFields[agentpluginrepo.FieldLastUploadFilename] = struct{}{} } -// AddGitBotTaskIDs adds the "git_bot_tasks" edge to the GitBotTask entity by ids. -func (m *GitBotMutation) AddGitBotTaskIDs(ids ...uuid.UUID) { - if m.git_bot_tasks == nil { - m.git_bot_tasks = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.git_bot_tasks[ids[i]] = struct{}{} - } +// LastUploadFilenameCleared returns if the "last_upload_filename" field was cleared in this mutation. +func (m *AgentPluginRepoMutation) LastUploadFilenameCleared() bool { + _, ok := m.clearedFields[agentpluginrepo.FieldLastUploadFilename] + return ok } -// ClearGitBotTasks clears the "git_bot_tasks" edge to the GitBotTask entity. -func (m *GitBotMutation) ClearGitBotTasks() { - m.clearedgit_bot_tasks = true +// ResetLastUploadFilename resets all changes to the "last_upload_filename" field. +func (m *AgentPluginRepoMutation) ResetLastUploadFilename() { + m.last_upload_filename = nil + delete(m.clearedFields, agentpluginrepo.FieldLastUploadFilename) } -// GitBotTasksCleared reports if the "git_bot_tasks" edge to the GitBotTask entity was cleared. -func (m *GitBotMutation) GitBotTasksCleared() bool { - return m.clearedgit_bot_tasks +// SetLastUploadAt sets the "last_upload_at" field. +func (m *AgentPluginRepoMutation) SetLastUploadAt(t time.Time) { + m.last_upload_at = &t } -// RemoveGitBotTaskIDs removes the "git_bot_tasks" edge to the GitBotTask entity by IDs. -func (m *GitBotMutation) RemoveGitBotTaskIDs(ids ...uuid.UUID) { - if m.removedgit_bot_tasks == nil { - m.removedgit_bot_tasks = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.git_bot_tasks, ids[i]) - m.removedgit_bot_tasks[ids[i]] = struct{}{} +// LastUploadAt returns the value of the "last_upload_at" field in the mutation. +func (m *AgentPluginRepoMutation) LastUploadAt() (r time.Time, exists bool) { + v := m.last_upload_at + if v == nil { + return } + return *v, true } -// RemovedGitBotTasks returns the removed IDs of the "git_bot_tasks" edge to the GitBotTask entity. -func (m *GitBotMutation) RemovedGitBotTasksIDs() (ids []uuid.UUID) { - for id := range m.removedgit_bot_tasks { - ids = append(ids, id) +// OldLastUploadAt returns the old "last_upload_at" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginRepoMutation) OldLastUploadAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastUploadAt is only allowed on UpdateOne operations") } - return -} - -// GitBotTasksIDs returns the "git_bot_tasks" edge IDs in the mutation. -func (m *GitBotMutation) GitBotTasksIDs() (ids []uuid.UUID) { - for id := range m.git_bot_tasks { - ids = append(ids, id) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastUploadAt requires an ID field in the mutation") } - return + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastUploadAt: %w", err) + } + return oldValue.LastUploadAt, nil } -// ResetGitBotTasks resets all changes to the "git_bot_tasks" edge. -func (m *GitBotMutation) ResetGitBotTasks() { - m.git_bot_tasks = nil - m.clearedgit_bot_tasks = false - m.removedgit_bot_tasks = nil +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (m *AgentPluginRepoMutation) ClearLastUploadAt() { + m.last_upload_at = nil + m.clearedFields[agentpluginrepo.FieldLastUploadAt] = struct{}{} } -// ClearHost clears the "host" edge to the Host entity. -func (m *GitBotMutation) ClearHost() { - m.clearedhost = true - m.clearedFields[gitbot.FieldHostID] = struct{}{} +// LastUploadAtCleared returns if the "last_upload_at" field was cleared in this mutation. +func (m *AgentPluginRepoMutation) LastUploadAtCleared() bool { + _, ok := m.clearedFields[agentpluginrepo.FieldLastUploadAt] + return ok } -// HostCleared reports if the "host" edge to the Host entity was cleared. -func (m *GitBotMutation) HostCleared() bool { - return m.clearedhost +// ResetLastUploadAt resets all changes to the "last_upload_at" field. +func (m *AgentPluginRepoMutation) ResetLastUploadAt() { + m.last_upload_at = nil + delete(m.clearedFields, agentpluginrepo.FieldLastUploadAt) } -// HostIDs returns the "host" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// HostID instead. It exists only for internal usage by the builders. -func (m *GitBotMutation) HostIDs() (ids []string) { - if id := m.host; id != nil { - ids = append(ids, *id) - } - return +// SetPluginDiscoveryAutoPackageJSON sets the "plugin_discovery_auto_package_json" field. +func (m *AgentPluginRepoMutation) SetPluginDiscoveryAutoPackageJSON(b bool) { + m.plugin_discovery_auto_package_json = &b } -// ResetHost resets all changes to the "host" edge. -func (m *GitBotMutation) ResetHost() { - m.host = nil - m.clearedhost = false +// PluginDiscoveryAutoPackageJSON returns the value of the "plugin_discovery_auto_package_json" field in the mutation. +func (m *AgentPluginRepoMutation) PluginDiscoveryAutoPackageJSON() (r bool, exists bool) { + v := m.plugin_discovery_auto_package_json + if v == nil { + return + } + return *v, true } -// AddUserIDs adds the "users" edge to the User entity by ids. -func (m *GitBotMutation) AddUserIDs(ids ...uuid.UUID) { - if m.users == nil { - m.users = make(map[uuid.UUID]struct{}) +// OldPluginDiscoveryAutoPackageJSON returns the old "plugin_discovery_auto_package_json" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginRepoMutation) OldPluginDiscoveryAutoPackageJSON(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPluginDiscoveryAutoPackageJSON is only allowed on UpdateOne operations") } - for i := range ids { - m.users[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPluginDiscoveryAutoPackageJSON requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPluginDiscoveryAutoPackageJSON: %w", err) } + return oldValue.PluginDiscoveryAutoPackageJSON, nil } -// ClearUsers clears the "users" edge to the User entity. -func (m *GitBotMutation) ClearUsers() { - m.clearedusers = true +// ResetPluginDiscoveryAutoPackageJSON resets all changes to the "plugin_discovery_auto_package_json" field. +func (m *AgentPluginRepoMutation) ResetPluginDiscoveryAutoPackageJSON() { + m.plugin_discovery_auto_package_json = nil } -// UsersCleared reports if the "users" edge to the User entity was cleared. -func (m *GitBotMutation) UsersCleared() bool { - return m.clearedusers +// SetPluginManualEntries sets the "plugin_manual_entries" field. +func (m *AgentPluginRepoMutation) SetPluginManualEntries(tme types.PluginManualEntries) { + m.plugin_manual_entries = &tme + m.appendplugin_manual_entries = nil } -// RemoveUserIDs removes the "users" edge to the User entity by IDs. -func (m *GitBotMutation) RemoveUserIDs(ids ...uuid.UUID) { - if m.removedusers == nil { - m.removedusers = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.users, ids[i]) - m.removedusers[ids[i]] = struct{}{} +// PluginManualEntries returns the value of the "plugin_manual_entries" field in the mutation. +func (m *AgentPluginRepoMutation) PluginManualEntries() (r types.PluginManualEntries, exists bool) { + v := m.plugin_manual_entries + if v == nil { + return } + return *v, true } -// RemovedUsers returns the removed IDs of the "users" edge to the User entity. -func (m *GitBotMutation) RemovedUsersIDs() (ids []uuid.UUID) { - for id := range m.removedusers { - ids = append(ids, id) +// OldPluginManualEntries returns the old "plugin_manual_entries" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginRepoMutation) OldPluginManualEntries(ctx context.Context) (v types.PluginManualEntries, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPluginManualEntries is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPluginManualEntries requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPluginManualEntries: %w", err) + } + return oldValue.PluginManualEntries, nil } -// UsersIDs returns the "users" edge IDs in the mutation. -func (m *GitBotMutation) UsersIDs() (ids []uuid.UUID) { - for id := range m.users { - ids = append(ids, id) +// AppendPluginManualEntries adds tme to the "plugin_manual_entries" field. +func (m *AgentPluginRepoMutation) AppendPluginManualEntries(tme types.PluginManualEntries) { + m.appendplugin_manual_entries = append(m.appendplugin_manual_entries, tme...) +} + +// AppendedPluginManualEntries returns the list of values that were appended to the "plugin_manual_entries" field in this mutation. +func (m *AgentPluginRepoMutation) AppendedPluginManualEntries() (types.PluginManualEntries, bool) { + if len(m.appendplugin_manual_entries) == 0 { + return nil, false } - return + return m.appendplugin_manual_entries, true } -// ResetUsers resets all changes to the "users" edge. -func (m *GitBotMutation) ResetUsers() { - m.users = nil - m.clearedusers = false - m.removedusers = nil +// ClearPluginManualEntries clears the value of the "plugin_manual_entries" field. +func (m *AgentPluginRepoMutation) ClearPluginManualEntries() { + m.plugin_manual_entries = nil + m.appendplugin_manual_entries = nil + m.clearedFields[agentpluginrepo.FieldPluginManualEntries] = struct{}{} } -// AddProjectIDs adds the "projects" edge to the Project entity by ids. -func (m *GitBotMutation) AddProjectIDs(ids ...uuid.UUID) { - if m.projects == nil { - m.projects = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.projects[ids[i]] = struct{}{} - } +// PluginManualEntriesCleared returns if the "plugin_manual_entries" field was cleared in this mutation. +func (m *AgentPluginRepoMutation) PluginManualEntriesCleared() bool { + _, ok := m.clearedFields[agentpluginrepo.FieldPluginManualEntries] + return ok } -// ClearProjects clears the "projects" edge to the Project entity. -func (m *GitBotMutation) ClearProjects() { - m.clearedprojects = true +// ResetPluginManualEntries resets all changes to the "plugin_manual_entries" field. +func (m *AgentPluginRepoMutation) ResetPluginManualEntries() { + m.plugin_manual_entries = nil + m.appendplugin_manual_entries = nil + delete(m.clearedFields, agentpluginrepo.FieldPluginManualEntries) } -// ProjectsCleared reports if the "projects" edge to the Project entity was cleared. -func (m *GitBotMutation) ProjectsCleared() bool { - return m.clearedprojects +// SetNpmPackageName sets the "npm_package_name" field. +func (m *AgentPluginRepoMutation) SetNpmPackageName(s string) { + m.npm_package_name = &s } -// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs. -func (m *GitBotMutation) RemoveProjectIDs(ids ...uuid.UUID) { - if m.removedprojects == nil { - m.removedprojects = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.projects, ids[i]) - m.removedprojects[ids[i]] = struct{}{} +// NpmPackageName returns the value of the "npm_package_name" field in the mutation. +func (m *AgentPluginRepoMutation) NpmPackageName() (r string, exists bool) { + v := m.npm_package_name + if v == nil { + return } + return *v, true } -// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity. -func (m *GitBotMutation) RemovedProjectsIDs() (ids []uuid.UUID) { - for id := range m.removedprojects { - ids = append(ids, id) +// OldNpmPackageName returns the old "npm_package_name" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginRepoMutation) OldNpmPackageName(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNpmPackageName is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNpmPackageName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNpmPackageName: %w", err) + } + return oldValue.NpmPackageName, nil } -// ProjectsIDs returns the "projects" edge IDs in the mutation. -func (m *GitBotMutation) ProjectsIDs() (ids []uuid.UUID) { - for id := range m.projects { - ids = append(ids, id) - } - return +// ClearNpmPackageName clears the value of the "npm_package_name" field. +func (m *AgentPluginRepoMutation) ClearNpmPackageName() { + m.npm_package_name = nil + m.clearedFields[agentpluginrepo.FieldNpmPackageName] = struct{}{} } -// ResetProjects resets all changes to the "projects" edge. -func (m *GitBotMutation) ResetProjects() { - m.projects = nil - m.clearedprojects = false - m.removedprojects = nil +// NpmPackageNameCleared returns if the "npm_package_name" field was cleared in this mutation. +func (m *AgentPluginRepoMutation) NpmPackageNameCleared() bool { + _, ok := m.clearedFields[agentpluginrepo.FieldNpmPackageName] + return ok } -// AddGitBotUserIDs adds the "git_bot_users" edge to the GitBotUser entity by ids. -func (m *GitBotMutation) AddGitBotUserIDs(ids ...uuid.UUID) { - if m.git_bot_users == nil { - m.git_bot_users = make(map[uuid.UUID]struct{}) +// ResetNpmPackageName resets all changes to the "npm_package_name" field. +func (m *AgentPluginRepoMutation) ResetNpmPackageName() { + m.npm_package_name = nil + delete(m.clearedFields, agentpluginrepo.FieldNpmPackageName) +} + +// SetNpmVersionSpec sets the "npm_version_spec" field. +func (m *AgentPluginRepoMutation) SetNpmVersionSpec(s string) { + m.npm_version_spec = &s +} + +// NpmVersionSpec returns the value of the "npm_version_spec" field in the mutation. +func (m *AgentPluginRepoMutation) NpmVersionSpec() (r string, exists bool) { + v := m.npm_version_spec + if v == nil { + return } - for i := range ids { - m.git_bot_users[ids[i]] = struct{}{} + return *v, true +} + +// OldNpmVersionSpec returns the old "npm_version_spec" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginRepoMutation) OldNpmVersionSpec(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNpmVersionSpec is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNpmVersionSpec requires an ID field in the mutation") } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNpmVersionSpec: %w", err) + } + return oldValue.NpmVersionSpec, nil } -// ClearGitBotUsers clears the "git_bot_users" edge to the GitBotUser entity. -func (m *GitBotMutation) ClearGitBotUsers() { - m.clearedgit_bot_users = true +// ClearNpmVersionSpec clears the value of the "npm_version_spec" field. +func (m *AgentPluginRepoMutation) ClearNpmVersionSpec() { + m.npm_version_spec = nil + m.clearedFields[agentpluginrepo.FieldNpmVersionSpec] = struct{}{} } -// GitBotUsersCleared reports if the "git_bot_users" edge to the GitBotUser entity was cleared. -func (m *GitBotMutation) GitBotUsersCleared() bool { - return m.clearedgit_bot_users +// NpmVersionSpecCleared returns if the "npm_version_spec" field was cleared in this mutation. +func (m *AgentPluginRepoMutation) NpmVersionSpecCleared() bool { + _, ok := m.clearedFields[agentpluginrepo.FieldNpmVersionSpec] + return ok } -// RemoveGitBotUserIDs removes the "git_bot_users" edge to the GitBotUser entity by IDs. -func (m *GitBotMutation) RemoveGitBotUserIDs(ids ...uuid.UUID) { - if m.removedgit_bot_users == nil { - m.removedgit_bot_users = make(map[uuid.UUID]struct{}) +// ResetNpmVersionSpec resets all changes to the "npm_version_spec" field. +func (m *AgentPluginRepoMutation) ResetNpmVersionSpec() { + m.npm_version_spec = nil + delete(m.clearedFields, agentpluginrepo.FieldNpmVersionSpec) +} + +// SetNpmRegistryURL sets the "npm_registry_url" field. +func (m *AgentPluginRepoMutation) SetNpmRegistryURL(s string) { + m.npm_registry_url = &s +} + +// NpmRegistryURL returns the value of the "npm_registry_url" field in the mutation. +func (m *AgentPluginRepoMutation) NpmRegistryURL() (r string, exists bool) { + v := m.npm_registry_url + if v == nil { + return } - for i := range ids { - delete(m.git_bot_users, ids[i]) - m.removedgit_bot_users[ids[i]] = struct{}{} + return *v, true +} + +// OldNpmRegistryURL returns the old "npm_registry_url" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginRepoMutation) OldNpmRegistryURL(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNpmRegistryURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNpmRegistryURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNpmRegistryURL: %w", err) } + return oldValue.NpmRegistryURL, nil } -// RemovedGitBotUsers returns the removed IDs of the "git_bot_users" edge to the GitBotUser entity. -func (m *GitBotMutation) RemovedGitBotUsersIDs() (ids []uuid.UUID) { - for id := range m.removedgit_bot_users { - ids = append(ids, id) +// ClearNpmRegistryURL clears the value of the "npm_registry_url" field. +func (m *AgentPluginRepoMutation) ClearNpmRegistryURL() { + m.npm_registry_url = nil + m.clearedFields[agentpluginrepo.FieldNpmRegistryURL] = struct{}{} +} + +// NpmRegistryURLCleared returns if the "npm_registry_url" field was cleared in this mutation. +func (m *AgentPluginRepoMutation) NpmRegistryURLCleared() bool { + _, ok := m.clearedFields[agentpluginrepo.FieldNpmRegistryURL] + return ok +} + +// ResetNpmRegistryURL resets all changes to the "npm_registry_url" field. +func (m *AgentPluginRepoMutation) ResetNpmRegistryURL() { + m.npm_registry_url = nil + delete(m.clearedFields, agentpluginrepo.FieldNpmRegistryURL) +} + +// SetIsDeleted sets the "is_deleted" field. +func (m *AgentPluginRepoMutation) SetIsDeleted(b bool) { + m.is_deleted = &b +} + +// IsDeleted returns the value of the "is_deleted" field in the mutation. +func (m *AgentPluginRepoMutation) IsDeleted() (r bool, exists bool) { + v := m.is_deleted + if v == nil { + return } - return + return *v, true } -// GitBotUsersIDs returns the "git_bot_users" edge IDs in the mutation. -func (m *GitBotMutation) GitBotUsersIDs() (ids []uuid.UUID) { - for id := range m.git_bot_users { - ids = append(ids, id) +// OldIsDeleted returns the old "is_deleted" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginRepoMutation) OldIsDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsDeleted is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsDeleted: %w", err) + } + return oldValue.IsDeleted, nil } -// ResetGitBotUsers resets all changes to the "git_bot_users" edge. -func (m *GitBotMutation) ResetGitBotUsers() { - m.git_bot_users = nil - m.clearedgit_bot_users = false - m.removedgit_bot_users = nil +// ResetIsDeleted resets all changes to the "is_deleted" field. +func (m *AgentPluginRepoMutation) ResetIsDeleted() { + m.is_deleted = nil } -// AddProjectGitBotIDs adds the "project_git_bots" edge to the ProjectGitBot entity by ids. -func (m *GitBotMutation) AddProjectGitBotIDs(ids ...uuid.UUID) { - if m.project_git_bots == nil { - m.project_git_bots = make(map[uuid.UUID]struct{}) +// SetCreatedAt sets the "created_at" field. +func (m *AgentPluginRepoMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AgentPluginRepoMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginRepoMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *AgentPluginRepoMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *AgentPluginRepoMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *AgentPluginRepoMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the AgentPluginRepo entity. +// If the AgentPluginRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginRepoMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *AgentPluginRepoMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// AddPluginIDs adds the "plugins" edge to the AgentPlugin entity by ids. +func (m *AgentPluginRepoMutation) AddPluginIDs(ids ...uuid.UUID) { + if m.plugins == nil { + m.plugins = make(map[uuid.UUID]struct{}) } for i := range ids { - m.project_git_bots[ids[i]] = struct{}{} + m.plugins[ids[i]] = struct{}{} } } -// ClearProjectGitBots clears the "project_git_bots" edge to the ProjectGitBot entity. -func (m *GitBotMutation) ClearProjectGitBots() { - m.clearedproject_git_bots = true +// ClearPlugins clears the "plugins" edge to the AgentPlugin entity. +func (m *AgentPluginRepoMutation) ClearPlugins() { + m.clearedplugins = true } -// ProjectGitBotsCleared reports if the "project_git_bots" edge to the ProjectGitBot entity was cleared. -func (m *GitBotMutation) ProjectGitBotsCleared() bool { - return m.clearedproject_git_bots +// PluginsCleared reports if the "plugins" edge to the AgentPlugin entity was cleared. +func (m *AgentPluginRepoMutation) PluginsCleared() bool { + return m.clearedplugins } -// RemoveProjectGitBotIDs removes the "project_git_bots" edge to the ProjectGitBot entity by IDs. -func (m *GitBotMutation) RemoveProjectGitBotIDs(ids ...uuid.UUID) { - if m.removedproject_git_bots == nil { - m.removedproject_git_bots = make(map[uuid.UUID]struct{}) +// RemovePluginIDs removes the "plugins" edge to the AgentPlugin entity by IDs. +func (m *AgentPluginRepoMutation) RemovePluginIDs(ids ...uuid.UUID) { + if m.removedplugins == nil { + m.removedplugins = make(map[uuid.UUID]struct{}) } for i := range ids { - delete(m.project_git_bots, ids[i]) - m.removedproject_git_bots[ids[i]] = struct{}{} + delete(m.plugins, ids[i]) + m.removedplugins[ids[i]] = struct{}{} } } -// RemovedProjectGitBots returns the removed IDs of the "project_git_bots" edge to the ProjectGitBot entity. -func (m *GitBotMutation) RemovedProjectGitBotsIDs() (ids []uuid.UUID) { - for id := range m.removedproject_git_bots { +// RemovedPlugins returns the removed IDs of the "plugins" edge to the AgentPlugin entity. +func (m *AgentPluginRepoMutation) RemovedPluginsIDs() (ids []uuid.UUID) { + for id := range m.removedplugins { ids = append(ids, id) } return } -// ProjectGitBotsIDs returns the "project_git_bots" edge IDs in the mutation. -func (m *GitBotMutation) ProjectGitBotsIDs() (ids []uuid.UUID) { - for id := range m.project_git_bots { +// PluginsIDs returns the "plugins" edge IDs in the mutation. +func (m *AgentPluginRepoMutation) PluginsIDs() (ids []uuid.UUID) { + for id := range m.plugins { ids = append(ids, id) } return } -// ResetProjectGitBots resets all changes to the "project_git_bots" edge. -func (m *GitBotMutation) ResetProjectGitBots() { - m.project_git_bots = nil - m.clearedproject_git_bots = false - m.removedproject_git_bots = nil +// ResetPlugins resets all changes to the "plugins" edge. +func (m *AgentPluginRepoMutation) ResetPlugins() { + m.plugins = nil + m.clearedplugins = false + m.removedplugins = nil } -// Where appends a list predicates to the GitBotMutation builder. -func (m *GitBotMutation) Where(ps ...predicate.GitBot) { +// Where appends a list predicates to the AgentPluginRepoMutation builder. +func (m *AgentPluginRepoMutation) Where(ps ...predicate.AgentPluginRepo) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the GitBotMutation builder. Using this method, +// WhereP appends storage-level predicates to the AgentPluginRepoMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *GitBotMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.GitBot, len(ps)) +func (m *AgentPluginRepoMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.AgentPluginRepo, len(ps)) for i := range ps { p[i] = ps[i] } @@ -1643,48 +2281,78 @@ func (m *GitBotMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *GitBotMutation) Op() Op { +func (m *AgentPluginRepoMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *GitBotMutation) SetOp(op Op) { +func (m *AgentPluginRepoMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (GitBot). -func (m *GitBotMutation) Type() string { +// Type returns the node type of this mutation (AgentPluginRepo). +func (m *AgentPluginRepoMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *GitBotMutation) Fields() []string { - fields := make([]string, 0, 8) - if m.deleted_at != nil { - fields = append(fields, gitbot.FieldDeletedAt) +func (m *AgentPluginRepoMutation) Fields() []string { + fields := make([]string, 0, 18) + if m.name != nil { + fields = append(fields, agentpluginrepo.FieldName) } - if m.user_id != nil { - fields = append(fields, gitbot.FieldUserID) + if m.scope_type != nil { + fields = append(fields, agentpluginrepo.FieldScopeType) } - if m.name != nil { - fields = append(fields, gitbot.FieldName) + if m.scope_id != nil { + fields = append(fields, agentpluginrepo.FieldScopeID) } - if m.host != nil { - fields = append(fields, gitbot.FieldHostID) + if m.created_by != nil { + fields = append(fields, agentpluginrepo.FieldCreatedBy) } - if m.token != nil { - fields = append(fields, gitbot.FieldToken) + if m.source_type != nil { + fields = append(fields, agentpluginrepo.FieldSourceType) } - if m.secret_token != nil { - fields = append(fields, gitbot.FieldSecretToken) + if m.github_url != nil { + fields = append(fields, agentpluginrepo.FieldGithubURL) } - if m.platform != nil { - fields = append(fields, gitbot.FieldPlatform) + if m.ref_type != nil { + fields = append(fields, agentpluginrepo.FieldRefType) + } + if m.ref_value != nil { + fields = append(fields, agentpluginrepo.FieldRefValue) + } + if m.last_upload_filename != nil { + fields = append(fields, agentpluginrepo.FieldLastUploadFilename) + } + if m.last_upload_at != nil { + fields = append(fields, agentpluginrepo.FieldLastUploadAt) + } + if m.plugin_discovery_auto_package_json != nil { + fields = append(fields, agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON) + } + if m.plugin_manual_entries != nil { + fields = append(fields, agentpluginrepo.FieldPluginManualEntries) + } + if m.npm_package_name != nil { + fields = append(fields, agentpluginrepo.FieldNpmPackageName) + } + if m.npm_version_spec != nil { + fields = append(fields, agentpluginrepo.FieldNpmVersionSpec) + } + if m.npm_registry_url != nil { + fields = append(fields, agentpluginrepo.FieldNpmRegistryURL) + } + if m.is_deleted != nil { + fields = append(fields, agentpluginrepo.FieldIsDeleted) } if m.created_at != nil { - fields = append(fields, gitbot.FieldCreatedAt) + fields = append(fields, agentpluginrepo.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, agentpluginrepo.FieldUpdatedAt) } return fields } @@ -1692,24 +2360,44 @@ func (m *GitBotMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *GitBotMutation) Field(name string) (ent.Value, bool) { +func (m *AgentPluginRepoMutation) Field(name string) (ent.Value, bool) { switch name { - case gitbot.FieldDeletedAt: - return m.DeletedAt() - case gitbot.FieldUserID: - return m.UserID() - case gitbot.FieldName: + case agentpluginrepo.FieldName: return m.Name() - case gitbot.FieldHostID: - return m.HostID() - case gitbot.FieldToken: - return m.Token() - case gitbot.FieldSecretToken: - return m.SecretToken() - case gitbot.FieldPlatform: - return m.Platform() - case gitbot.FieldCreatedAt: + case agentpluginrepo.FieldScopeType: + return m.ScopeType() + case agentpluginrepo.FieldScopeID: + return m.ScopeID() + case agentpluginrepo.FieldCreatedBy: + return m.CreatedBy() + case agentpluginrepo.FieldSourceType: + return m.SourceType() + case agentpluginrepo.FieldGithubURL: + return m.GithubURL() + case agentpluginrepo.FieldRefType: + return m.RefType() + case agentpluginrepo.FieldRefValue: + return m.RefValue() + case agentpluginrepo.FieldLastUploadFilename: + return m.LastUploadFilename() + case agentpluginrepo.FieldLastUploadAt: + return m.LastUploadAt() + case agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON: + return m.PluginDiscoveryAutoPackageJSON() + case agentpluginrepo.FieldPluginManualEntries: + return m.PluginManualEntries() + case agentpluginrepo.FieldNpmPackageName: + return m.NpmPackageName() + case agentpluginrepo.FieldNpmVersionSpec: + return m.NpmVersionSpec() + case agentpluginrepo.FieldNpmRegistryURL: + return m.NpmRegistryURL() + case agentpluginrepo.FieldIsDeleted: + return m.IsDeleted() + case agentpluginrepo.FieldCreatedAt: return m.CreatedAt() + case agentpluginrepo.FieldUpdatedAt: + return m.UpdatedAt() } return nil, false } @@ -1717,252 +2405,359 @@ func (m *GitBotMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *GitBotMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *AgentPluginRepoMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case gitbot.FieldDeletedAt: - return m.OldDeletedAt(ctx) - case gitbot.FieldUserID: - return m.OldUserID(ctx) - case gitbot.FieldName: + case agentpluginrepo.FieldName: return m.OldName(ctx) - case gitbot.FieldHostID: - return m.OldHostID(ctx) - case gitbot.FieldToken: - return m.OldToken(ctx) - case gitbot.FieldSecretToken: - return m.OldSecretToken(ctx) - case gitbot.FieldPlatform: - return m.OldPlatform(ctx) - case gitbot.FieldCreatedAt: + case agentpluginrepo.FieldScopeType: + return m.OldScopeType(ctx) + case agentpluginrepo.FieldScopeID: + return m.OldScopeID(ctx) + case agentpluginrepo.FieldCreatedBy: + return m.OldCreatedBy(ctx) + case agentpluginrepo.FieldSourceType: + return m.OldSourceType(ctx) + case agentpluginrepo.FieldGithubURL: + return m.OldGithubURL(ctx) + case agentpluginrepo.FieldRefType: + return m.OldRefType(ctx) + case agentpluginrepo.FieldRefValue: + return m.OldRefValue(ctx) + case agentpluginrepo.FieldLastUploadFilename: + return m.OldLastUploadFilename(ctx) + case agentpluginrepo.FieldLastUploadAt: + return m.OldLastUploadAt(ctx) + case agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON: + return m.OldPluginDiscoveryAutoPackageJSON(ctx) + case agentpluginrepo.FieldPluginManualEntries: + return m.OldPluginManualEntries(ctx) + case agentpluginrepo.FieldNpmPackageName: + return m.OldNpmPackageName(ctx) + case agentpluginrepo.FieldNpmVersionSpec: + return m.OldNpmVersionSpec(ctx) + case agentpluginrepo.FieldNpmRegistryURL: + return m.OldNpmRegistryURL(ctx) + case agentpluginrepo.FieldIsDeleted: + return m.OldIsDeleted(ctx) + case agentpluginrepo.FieldCreatedAt: return m.OldCreatedAt(ctx) + case agentpluginrepo.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown GitBot field %s", name) + return nil, fmt.Errorf("unknown AgentPluginRepo field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *GitBotMutation) SetField(name string, value ent.Value) error { +func (m *AgentPluginRepoMutation) SetField(name string, value ent.Value) error { switch name { - case gitbot.FieldDeletedAt: - v, ok := value.(time.Time) + case agentpluginrepo.FieldName: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDeletedAt(v) + m.SetName(v) return nil - case gitbot.FieldUserID: + case agentpluginrepo.FieldScopeType: + v, ok := value.(agentpluginrepo.ScopeType) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScopeType(v) + return nil + case agentpluginrepo.FieldScopeID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScopeID(v) + return nil + case agentpluginrepo.FieldCreatedBy: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) + m.SetCreatedBy(v) return nil - case gitbot.FieldName: + case agentpluginrepo.FieldSourceType: + v, ok := value.(agentpluginrepo.SourceType) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSourceType(v) + return nil + case agentpluginrepo.FieldGithubURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetName(v) + m.SetGithubURL(v) return nil - case gitbot.FieldHostID: + case agentpluginrepo.FieldRefType: + v, ok := value.(agentpluginrepo.RefType) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefType(v) + return nil + case agentpluginrepo.FieldRefValue: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetHostID(v) + m.SetRefValue(v) return nil - case gitbot.FieldToken: + case agentpluginrepo.FieldLastUploadFilename: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetToken(v) + m.SetLastUploadFilename(v) return nil - case gitbot.FieldSecretToken: + case agentpluginrepo.FieldLastUploadAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastUploadAt(v) + return nil + case agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPluginDiscoveryAutoPackageJSON(v) + return nil + case agentpluginrepo.FieldPluginManualEntries: + v, ok := value.(types.PluginManualEntries) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPluginManualEntries(v) + return nil + case agentpluginrepo.FieldNpmPackageName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSecretToken(v) + m.SetNpmPackageName(v) return nil - case gitbot.FieldPlatform: - v, ok := value.(consts.GitPlatform) + case agentpluginrepo.FieldNpmVersionSpec: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPlatform(v) + m.SetNpmVersionSpec(v) return nil - case gitbot.FieldCreatedAt: + case agentpluginrepo.FieldNpmRegistryURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNpmRegistryURL(v) + return nil + case agentpluginrepo.FieldIsDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsDeleted(v) + return nil + case agentpluginrepo.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil + case agentpluginrepo.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil } - return fmt.Errorf("unknown GitBot field %s", name) + return fmt.Errorf("unknown AgentPluginRepo field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *GitBotMutation) AddedFields() []string { +func (m *AgentPluginRepoMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *GitBotMutation) AddedField(name string) (ent.Value, bool) { +func (m *AgentPluginRepoMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *GitBotMutation) AddField(name string, value ent.Value) error { +func (m *AgentPluginRepoMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown GitBot numeric field %s", name) + return fmt.Errorf("unknown AgentPluginRepo numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *GitBotMutation) ClearedFields() []string { +func (m *AgentPluginRepoMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(gitbot.FieldDeletedAt) { - fields = append(fields, gitbot.FieldDeletedAt) + if m.FieldCleared(agentpluginrepo.FieldGithubURL) { + fields = append(fields, agentpluginrepo.FieldGithubURL) } - if m.FieldCleared(gitbot.FieldName) { - fields = append(fields, gitbot.FieldName) + if m.FieldCleared(agentpluginrepo.FieldRefType) { + fields = append(fields, agentpluginrepo.FieldRefType) } - if m.FieldCleared(gitbot.FieldToken) { - fields = append(fields, gitbot.FieldToken) + if m.FieldCleared(agentpluginrepo.FieldRefValue) { + fields = append(fields, agentpluginrepo.FieldRefValue) } - if m.FieldCleared(gitbot.FieldSecretToken) { - fields = append(fields, gitbot.FieldSecretToken) + if m.FieldCleared(agentpluginrepo.FieldLastUploadFilename) { + fields = append(fields, agentpluginrepo.FieldLastUploadFilename) + } + if m.FieldCleared(agentpluginrepo.FieldLastUploadAt) { + fields = append(fields, agentpluginrepo.FieldLastUploadAt) + } + if m.FieldCleared(agentpluginrepo.FieldPluginManualEntries) { + fields = append(fields, agentpluginrepo.FieldPluginManualEntries) + } + if m.FieldCleared(agentpluginrepo.FieldNpmPackageName) { + fields = append(fields, agentpluginrepo.FieldNpmPackageName) + } + if m.FieldCleared(agentpluginrepo.FieldNpmVersionSpec) { + fields = append(fields, agentpluginrepo.FieldNpmVersionSpec) + } + if m.FieldCleared(agentpluginrepo.FieldNpmRegistryURL) { + fields = append(fields, agentpluginrepo.FieldNpmRegistryURL) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *GitBotMutation) FieldCleared(name string) bool { +func (m *AgentPluginRepoMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *GitBotMutation) ClearField(name string) error { +func (m *AgentPluginRepoMutation) ClearField(name string) error { switch name { - case gitbot.FieldDeletedAt: - m.ClearDeletedAt() + case agentpluginrepo.FieldGithubURL: + m.ClearGithubURL() return nil - case gitbot.FieldName: - m.ClearName() + case agentpluginrepo.FieldRefType: + m.ClearRefType() return nil - case gitbot.FieldToken: - m.ClearToken() + case agentpluginrepo.FieldRefValue: + m.ClearRefValue() return nil - case gitbot.FieldSecretToken: - m.ClearSecretToken() + case agentpluginrepo.FieldLastUploadFilename: + m.ClearLastUploadFilename() + return nil + case agentpluginrepo.FieldLastUploadAt: + m.ClearLastUploadAt() + return nil + case agentpluginrepo.FieldPluginManualEntries: + m.ClearPluginManualEntries() + return nil + case agentpluginrepo.FieldNpmPackageName: + m.ClearNpmPackageName() + return nil + case agentpluginrepo.FieldNpmVersionSpec: + m.ClearNpmVersionSpec() + return nil + case agentpluginrepo.FieldNpmRegistryURL: + m.ClearNpmRegistryURL() return nil } - return fmt.Errorf("unknown GitBot nullable field %s", name) + return fmt.Errorf("unknown AgentPluginRepo nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *GitBotMutation) ResetField(name string) error { +func (m *AgentPluginRepoMutation) ResetField(name string) error { switch name { - case gitbot.FieldDeletedAt: - m.ResetDeletedAt() + case agentpluginrepo.FieldName: + m.ResetName() return nil - case gitbot.FieldUserID: - m.ResetUserID() + case agentpluginrepo.FieldScopeType: + m.ResetScopeType() return nil - case gitbot.FieldName: - m.ResetName() + case agentpluginrepo.FieldScopeID: + m.ResetScopeID() return nil - case gitbot.FieldHostID: - m.ResetHostID() + case agentpluginrepo.FieldCreatedBy: + m.ResetCreatedBy() return nil - case gitbot.FieldToken: - m.ResetToken() + case agentpluginrepo.FieldSourceType: + m.ResetSourceType() return nil - case gitbot.FieldSecretToken: - m.ResetSecretToken() + case agentpluginrepo.FieldGithubURL: + m.ResetGithubURL() return nil - case gitbot.FieldPlatform: - m.ResetPlatform() + case agentpluginrepo.FieldRefType: + m.ResetRefType() return nil - case gitbot.FieldCreatedAt: + case agentpluginrepo.FieldRefValue: + m.ResetRefValue() + return nil + case agentpluginrepo.FieldLastUploadFilename: + m.ResetLastUploadFilename() + return nil + case agentpluginrepo.FieldLastUploadAt: + m.ResetLastUploadAt() + return nil + case agentpluginrepo.FieldPluginDiscoveryAutoPackageJSON: + m.ResetPluginDiscoveryAutoPackageJSON() + return nil + case agentpluginrepo.FieldPluginManualEntries: + m.ResetPluginManualEntries() + return nil + case agentpluginrepo.FieldNpmPackageName: + m.ResetNpmPackageName() + return nil + case agentpluginrepo.FieldNpmVersionSpec: + m.ResetNpmVersionSpec() + return nil + case agentpluginrepo.FieldNpmRegistryURL: + m.ResetNpmRegistryURL() + return nil + case agentpluginrepo.FieldIsDeleted: + m.ResetIsDeleted() + return nil + case agentpluginrepo.FieldCreatedAt: m.ResetCreatedAt() return nil + case agentpluginrepo.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil } - return fmt.Errorf("unknown GitBot field %s", name) + return fmt.Errorf("unknown AgentPluginRepo field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *GitBotMutation) AddedEdges() []string { - edges := make([]string, 0, 6) - if m.git_bot_tasks != nil { - edges = append(edges, gitbot.EdgeGitBotTasks) - } - if m.host != nil { - edges = append(edges, gitbot.EdgeHost) - } - if m.users != nil { - edges = append(edges, gitbot.EdgeUsers) - } - if m.projects != nil { - edges = append(edges, gitbot.EdgeProjects) - } - if m.git_bot_users != nil { - edges = append(edges, gitbot.EdgeGitBotUsers) - } - if m.project_git_bots != nil { - edges = append(edges, gitbot.EdgeProjectGitBots) +func (m *AgentPluginRepoMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.plugins != nil { + edges = append(edges, agentpluginrepo.EdgePlugins) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *GitBotMutation) AddedIDs(name string) []ent.Value { +func (m *AgentPluginRepoMutation) AddedIDs(name string) []ent.Value { switch name { - case gitbot.EdgeGitBotTasks: - ids := make([]ent.Value, 0, len(m.git_bot_tasks)) - for id := range m.git_bot_tasks { - ids = append(ids, id) - } - return ids - case gitbot.EdgeHost: - if id := m.host; id != nil { - return []ent.Value{*id} - } - case gitbot.EdgeUsers: - ids := make([]ent.Value, 0, len(m.users)) - for id := range m.users { - ids = append(ids, id) - } - return ids - case gitbot.EdgeProjects: - ids := make([]ent.Value, 0, len(m.projects)) - for id := range m.projects { - ids = append(ids, id) - } - return ids - case gitbot.EdgeGitBotUsers: - ids := make([]ent.Value, 0, len(m.git_bot_users)) - for id := range m.git_bot_users { - ids = append(ids, id) - } - return ids - case gitbot.EdgeProjectGitBots: - ids := make([]ent.Value, 0, len(m.project_git_bots)) - for id := range m.project_git_bots { + case agentpluginrepo.EdgePlugins: + ids := make([]ent.Value, 0, len(m.plugins)) + for id := range m.plugins { ids = append(ids, id) } return ids @@ -1971,57 +2766,21 @@ func (m *GitBotMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *GitBotMutation) RemovedEdges() []string { - edges := make([]string, 0, 6) - if m.removedgit_bot_tasks != nil { - edges = append(edges, gitbot.EdgeGitBotTasks) - } - if m.removedusers != nil { - edges = append(edges, gitbot.EdgeUsers) - } - if m.removedprojects != nil { - edges = append(edges, gitbot.EdgeProjects) - } - if m.removedgit_bot_users != nil { - edges = append(edges, gitbot.EdgeGitBotUsers) - } - if m.removedproject_git_bots != nil { - edges = append(edges, gitbot.EdgeProjectGitBots) +func (m *AgentPluginRepoMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + if m.removedplugins != nil { + edges = append(edges, agentpluginrepo.EdgePlugins) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *GitBotMutation) RemovedIDs(name string) []ent.Value { +func (m *AgentPluginRepoMutation) RemovedIDs(name string) []ent.Value { switch name { - case gitbot.EdgeGitBotTasks: - ids := make([]ent.Value, 0, len(m.removedgit_bot_tasks)) - for id := range m.removedgit_bot_tasks { - ids = append(ids, id) - } - return ids - case gitbot.EdgeUsers: - ids := make([]ent.Value, 0, len(m.removedusers)) - for id := range m.removedusers { - ids = append(ids, id) - } - return ids - case gitbot.EdgeProjects: - ids := make([]ent.Value, 0, len(m.removedprojects)) - for id := range m.removedprojects { - ids = append(ids, id) - } - return ids - case gitbot.EdgeGitBotUsers: - ids := make([]ent.Value, 0, len(m.removedgit_bot_users)) - for id := range m.removedgit_bot_users { - ids = append(ids, id) - } - return ids - case gitbot.EdgeProjectGitBots: - ids := make([]ent.Value, 0, len(m.removedproject_git_bots)) - for id := range m.removedproject_git_bots { + case agentpluginrepo.EdgePlugins: + ids := make([]ent.Value, 0, len(m.removedplugins)) + for id := range m.removedplugins { ids = append(ids, id) } return ids @@ -2030,114 +2789,72 @@ func (m *GitBotMutation) RemovedIDs(name string) []ent.Value { } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *GitBotMutation) ClearedEdges() []string { - edges := make([]string, 0, 6) - if m.clearedgit_bot_tasks { - edges = append(edges, gitbot.EdgeGitBotTasks) - } - if m.clearedhost { - edges = append(edges, gitbot.EdgeHost) - } - if m.clearedusers { - edges = append(edges, gitbot.EdgeUsers) - } - if m.clearedprojects { - edges = append(edges, gitbot.EdgeProjects) - } - if m.clearedgit_bot_users { - edges = append(edges, gitbot.EdgeGitBotUsers) - } - if m.clearedproject_git_bots { - edges = append(edges, gitbot.EdgeProjectGitBots) +func (m *AgentPluginRepoMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedplugins { + edges = append(edges, agentpluginrepo.EdgePlugins) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *GitBotMutation) EdgeCleared(name string) bool { +func (m *AgentPluginRepoMutation) EdgeCleared(name string) bool { switch name { - case gitbot.EdgeGitBotTasks: - return m.clearedgit_bot_tasks - case gitbot.EdgeHost: - return m.clearedhost - case gitbot.EdgeUsers: - return m.clearedusers - case gitbot.EdgeProjects: - return m.clearedprojects - case gitbot.EdgeGitBotUsers: - return m.clearedgit_bot_users - case gitbot.EdgeProjectGitBots: - return m.clearedproject_git_bots + case agentpluginrepo.EdgePlugins: + return m.clearedplugins } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *GitBotMutation) ClearEdge(name string) error { +func (m *AgentPluginRepoMutation) ClearEdge(name string) error { switch name { - case gitbot.EdgeHost: - m.ClearHost() - return nil } - return fmt.Errorf("unknown GitBot unique edge %s", name) + return fmt.Errorf("unknown AgentPluginRepo unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *GitBotMutation) ResetEdge(name string) error { +func (m *AgentPluginRepoMutation) ResetEdge(name string) error { switch name { - case gitbot.EdgeGitBotTasks: - m.ResetGitBotTasks() - return nil - case gitbot.EdgeHost: - m.ResetHost() - return nil - case gitbot.EdgeUsers: - m.ResetUsers() - return nil - case gitbot.EdgeProjects: - m.ResetProjects() - return nil - case gitbot.EdgeGitBotUsers: - m.ResetGitBotUsers() - return nil - case gitbot.EdgeProjectGitBots: - m.ResetProjectGitBots() + case agentpluginrepo.EdgePlugins: + m.ResetPlugins() return nil } - return fmt.Errorf("unknown GitBot edge %s", name) + return fmt.Errorf("unknown AgentPluginRepo edge %s", name) } -// GitBotTaskMutation represents an operation that mutates the GitBotTask nodes in the graph. -type GitBotTaskMutation struct { +// AgentPluginVersionMutation represents an operation that mutates the AgentPluginVersion nodes in the graph. +type AgentPluginVersionMutation struct { config - op Op - typ string - id *uuid.UUID - created_at *time.Time - clearedFields map[string]struct{} - task *uuid.UUID - clearedtask bool - git_bot *uuid.UUID - clearedgit_bot bool - done bool - oldValue func(context.Context) (*GitBotTask, error) - predicates []predicate.GitBotTask + op Op + typ string + id *uuid.UUID + version *string + s3_key *string + parsed_meta *types.PluginParsedMeta + created_at *time.Time + clearedFields map[string]struct{} + plugin *uuid.UUID + clearedplugin bool + done bool + oldValue func(context.Context) (*AgentPluginVersion, error) + predicates []predicate.AgentPluginVersion } -var _ ent.Mutation = (*GitBotTaskMutation)(nil) +var _ ent.Mutation = (*AgentPluginVersionMutation)(nil) -// gitbottaskOption allows management of the mutation configuration using functional options. -type gitbottaskOption func(*GitBotTaskMutation) +// agentpluginversionOption allows management of the mutation configuration using functional options. +type agentpluginversionOption func(*AgentPluginVersionMutation) -// newGitBotTaskMutation creates new mutation for the GitBotTask entity. -func newGitBotTaskMutation(c config, op Op, opts ...gitbottaskOption) *GitBotTaskMutation { - m := &GitBotTaskMutation{ +// newAgentPluginVersionMutation creates new mutation for the AgentPluginVersion entity. +func newAgentPluginVersionMutation(c config, op Op, opts ...agentpluginversionOption) *AgentPluginVersionMutation { + m := &AgentPluginVersionMutation{ config: c, op: op, - typ: TypeGitBotTask, + typ: TypeAgentPluginVersion, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -2146,20 +2863,20 @@ func newGitBotTaskMutation(c config, op Op, opts ...gitbottaskOption) *GitBotTas return m } -// withGitBotTaskID sets the ID field of the mutation. -func withGitBotTaskID(id uuid.UUID) gitbottaskOption { - return func(m *GitBotTaskMutation) { +// withAgentPluginVersionID sets the ID field of the mutation. +func withAgentPluginVersionID(id uuid.UUID) agentpluginversionOption { + return func(m *AgentPluginVersionMutation) { var ( err error once sync.Once - value *GitBotTask + value *AgentPluginVersion ) - m.oldValue = func(ctx context.Context) (*GitBotTask, error) { + m.oldValue = func(ctx context.Context) (*AgentPluginVersion, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().GitBotTask.Get(ctx, id) + value, err = m.Client().AgentPluginVersion.Get(ctx, id) } }) return value, err @@ -2168,10 +2885,10 @@ func withGitBotTaskID(id uuid.UUID) gitbottaskOption { } } -// withGitBotTask sets the old GitBotTask of the mutation. -func withGitBotTask(node *GitBotTask) gitbottaskOption { - return func(m *GitBotTaskMutation) { - m.oldValue = func(context.Context) (*GitBotTask, error) { +// withAgentPluginVersion sets the old AgentPluginVersion of the mutation. +func withAgentPluginVersion(node *AgentPluginVersion) agentpluginversionOption { + return func(m *AgentPluginVersionMutation) { + m.oldValue = func(context.Context) (*AgentPluginVersion, error) { return node, nil } m.id = &node.ID @@ -2180,7 +2897,7 @@ func withGitBotTask(node *GitBotTask) gitbottaskOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m GitBotTaskMutation) Client() *Client { +func (m AgentPluginVersionMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -2188,7 +2905,7 @@ func (m GitBotTaskMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m GitBotTaskMutation) Tx() (*Tx, error) { +func (m AgentPluginVersionMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -2198,14 +2915,14 @@ func (m GitBotTaskMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of GitBotTask entities. -func (m *GitBotTaskMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of AgentPluginVersion entities. +func (m *AgentPluginVersionMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *GitBotTaskMutation) ID() (id uuid.UUID, exists bool) { +func (m *AgentPluginVersionMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -2216,7 +2933,7 @@ func (m *GitBotTaskMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *GitBotTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *AgentPluginVersionMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -2225,91 +2942,176 @@ func (m *GitBotTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().GitBotTask.Query().Where(m.predicates...).IDs(ctx) + return m.Client().AgentPluginVersion.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetGitBotID sets the "git_bot_id" field. -func (m *GitBotTaskMutation) SetGitBotID(u uuid.UUID) { - m.git_bot = &u +// SetResourceID sets the "resource_id" field. +func (m *AgentPluginVersionMutation) SetResourceID(u uuid.UUID) { + m.plugin = &u } -// GitBotID returns the value of the "git_bot_id" field in the mutation. -func (m *GitBotTaskMutation) GitBotID() (r uuid.UUID, exists bool) { - v := m.git_bot +// ResourceID returns the value of the "resource_id" field in the mutation. +func (m *AgentPluginVersionMutation) ResourceID() (r uuid.UUID, exists bool) { + v := m.plugin if v == nil { return } return *v, true } -// OldGitBotID returns the old "git_bot_id" field's value of the GitBotTask entity. -// If the GitBotTask object wasn't provided to the builder, the object is fetched from the database. +// OldResourceID returns the old "resource_id" field's value of the AgentPluginVersion entity. +// If the AgentPluginVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotTaskMutation) OldGitBotID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AgentPluginVersionMutation) OldResourceID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldGitBotID is only allowed on UpdateOne operations") + return v, errors.New("OldResourceID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldGitBotID requires an ID field in the mutation") + return v, errors.New("OldResourceID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldGitBotID: %w", err) + return v, fmt.Errorf("querying old value for OldResourceID: %w", err) } - return oldValue.GitBotID, nil + return oldValue.ResourceID, nil } -// ResetGitBotID resets all changes to the "git_bot_id" field. -func (m *GitBotTaskMutation) ResetGitBotID() { - m.git_bot = nil +// ResetResourceID resets all changes to the "resource_id" field. +func (m *AgentPluginVersionMutation) ResetResourceID() { + m.plugin = nil } -// SetTaskID sets the "task_id" field. -func (m *GitBotTaskMutation) SetTaskID(u uuid.UUID) { - m.task = &u +// SetVersion sets the "version" field. +func (m *AgentPluginVersionMutation) SetVersion(s string) { + m.version = &s } -// TaskID returns the value of the "task_id" field in the mutation. -func (m *GitBotTaskMutation) TaskID() (r uuid.UUID, exists bool) { - v := m.task +// Version returns the value of the "version" field in the mutation. +func (m *AgentPluginVersionMutation) Version() (r string, exists bool) { + v := m.version if v == nil { return } return *v, true } -// OldTaskID returns the old "task_id" field's value of the GitBotTask entity. -// If the GitBotTask object wasn't provided to the builder, the object is fetched from the database. +// OldVersion returns the old "version" field's value of the AgentPluginVersion entity. +// If the AgentPluginVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotTaskMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AgentPluginVersionMutation) OldVersion(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTaskID is only allowed on UpdateOne operations") + return v, errors.New("OldVersion is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTaskID requires an ID field in the mutation") + return v, errors.New("OldVersion requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTaskID: %w", err) + return v, fmt.Errorf("querying old value for OldVersion: %w", err) } - return oldValue.TaskID, nil + return oldValue.Version, nil } -// ResetTaskID resets all changes to the "task_id" field. -func (m *GitBotTaskMutation) ResetTaskID() { - m.task = nil +// ResetVersion resets all changes to the "version" field. +func (m *AgentPluginVersionMutation) ResetVersion() { + m.version = nil +} + +// SetS3Key sets the "s3_key" field. +func (m *AgentPluginVersionMutation) SetS3Key(s string) { + m.s3_key = &s +} + +// S3Key returns the value of the "s3_key" field in the mutation. +func (m *AgentPluginVersionMutation) S3Key() (r string, exists bool) { + v := m.s3_key + if v == nil { + return + } + return *v, true +} + +// OldS3Key returns the old "s3_key" field's value of the AgentPluginVersion entity. +// If the AgentPluginVersion object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginVersionMutation) OldS3Key(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldS3Key is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldS3Key requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldS3Key: %w", err) + } + return oldValue.S3Key, nil +} + +// ResetS3Key resets all changes to the "s3_key" field. +func (m *AgentPluginVersionMutation) ResetS3Key() { + m.s3_key = nil +} + +// SetParsedMeta sets the "parsed_meta" field. +func (m *AgentPluginVersionMutation) SetParsedMeta(tpm types.PluginParsedMeta) { + m.parsed_meta = &tpm +} + +// ParsedMeta returns the value of the "parsed_meta" field in the mutation. +func (m *AgentPluginVersionMutation) ParsedMeta() (r types.PluginParsedMeta, exists bool) { + v := m.parsed_meta + if v == nil { + return + } + return *v, true +} + +// OldParsedMeta returns the old "parsed_meta" field's value of the AgentPluginVersion entity. +// If the AgentPluginVersion object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentPluginVersionMutation) OldParsedMeta(ctx context.Context) (v types.PluginParsedMeta, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldParsedMeta is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldParsedMeta requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldParsedMeta: %w", err) + } + return oldValue.ParsedMeta, nil +} + +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (m *AgentPluginVersionMutation) ClearParsedMeta() { + m.parsed_meta = nil + m.clearedFields[agentpluginversion.FieldParsedMeta] = struct{}{} +} + +// ParsedMetaCleared returns if the "parsed_meta" field was cleared in this mutation. +func (m *AgentPluginVersionMutation) ParsedMetaCleared() bool { + _, ok := m.clearedFields[agentpluginversion.FieldParsedMeta] + return ok +} + +// ResetParsedMeta resets all changes to the "parsed_meta" field. +func (m *AgentPluginVersionMutation) ResetParsedMeta() { + m.parsed_meta = nil + delete(m.clearedFields, agentpluginversion.FieldParsedMeta) } // SetCreatedAt sets the "created_at" field. -func (m *GitBotTaskMutation) SetCreatedAt(t time.Time) { +func (m *AgentPluginVersionMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *GitBotTaskMutation) CreatedAt() (r time.Time, exists bool) { +func (m *AgentPluginVersionMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -2317,10 +3119,10 @@ func (m *GitBotTaskMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the GitBotTask entity. -// If the GitBotTask object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the AgentPluginVersion entity. +// If the AgentPluginVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentPluginVersionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -2335,73 +3137,59 @@ func (m *GitBotTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *GitBotTaskMutation) ResetCreatedAt() { +func (m *AgentPluginVersionMutation) ResetCreatedAt() { m.created_at = nil } -// ClearTask clears the "task" edge to the Task entity. -func (m *GitBotTaskMutation) ClearTask() { - m.clearedtask = true - m.clearedFields[gitbottask.FieldTaskID] = struct{}{} -} - -// TaskCleared reports if the "task" edge to the Task entity was cleared. -func (m *GitBotTaskMutation) TaskCleared() bool { - return m.clearedtask -} - -// TaskIDs returns the "task" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TaskID instead. It exists only for internal usage by the builders. -func (m *GitBotTaskMutation) TaskIDs() (ids []uuid.UUID) { - if id := m.task; id != nil { - ids = append(ids, *id) - } - return +// SetPluginID sets the "plugin" edge to the AgentPlugin entity by id. +func (m *AgentPluginVersionMutation) SetPluginID(id uuid.UUID) { + m.plugin = &id } -// ResetTask resets all changes to the "task" edge. -func (m *GitBotTaskMutation) ResetTask() { - m.task = nil - m.clearedtask = false +// ClearPlugin clears the "plugin" edge to the AgentPlugin entity. +func (m *AgentPluginVersionMutation) ClearPlugin() { + m.clearedplugin = true + m.clearedFields[agentpluginversion.FieldResourceID] = struct{}{} } -// ClearGitBot clears the "git_bot" edge to the GitBot entity. -func (m *GitBotTaskMutation) ClearGitBot() { - m.clearedgit_bot = true - m.clearedFields[gitbottask.FieldGitBotID] = struct{}{} +// PluginCleared reports if the "plugin" edge to the AgentPlugin entity was cleared. +func (m *AgentPluginVersionMutation) PluginCleared() bool { + return m.clearedplugin } -// GitBotCleared reports if the "git_bot" edge to the GitBot entity was cleared. -func (m *GitBotTaskMutation) GitBotCleared() bool { - return m.clearedgit_bot +// PluginID returns the "plugin" edge ID in the mutation. +func (m *AgentPluginVersionMutation) PluginID() (id uuid.UUID, exists bool) { + if m.plugin != nil { + return *m.plugin, true + } + return } -// GitBotIDs returns the "git_bot" edge IDs in the mutation. +// PluginIDs returns the "plugin" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// GitBotID instead. It exists only for internal usage by the builders. -func (m *GitBotTaskMutation) GitBotIDs() (ids []uuid.UUID) { - if id := m.git_bot; id != nil { +// PluginID instead. It exists only for internal usage by the builders. +func (m *AgentPluginVersionMutation) PluginIDs() (ids []uuid.UUID) { + if id := m.plugin; id != nil { ids = append(ids, *id) } return } -// ResetGitBot resets all changes to the "git_bot" edge. -func (m *GitBotTaskMutation) ResetGitBot() { - m.git_bot = nil - m.clearedgit_bot = false +// ResetPlugin resets all changes to the "plugin" edge. +func (m *AgentPluginVersionMutation) ResetPlugin() { + m.plugin = nil + m.clearedplugin = false } -// Where appends a list predicates to the GitBotTaskMutation builder. -func (m *GitBotTaskMutation) Where(ps ...predicate.GitBotTask) { +// Where appends a list predicates to the AgentPluginVersionMutation builder. +func (m *AgentPluginVersionMutation) Where(ps ...predicate.AgentPluginVersion) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the GitBotTaskMutation builder. Using this method, +// WhereP appends storage-level predicates to the AgentPluginVersionMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *GitBotTaskMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.GitBotTask, len(ps)) +func (m *AgentPluginVersionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.AgentPluginVersion, len(ps)) for i := range ps { p[i] = ps[i] } @@ -2409,33 +3197,39 @@ func (m *GitBotTaskMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *GitBotTaskMutation) Op() Op { +func (m *AgentPluginVersionMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *GitBotTaskMutation) SetOp(op Op) { +func (m *AgentPluginVersionMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (GitBotTask). -func (m *GitBotTaskMutation) Type() string { +// Type returns the node type of this mutation (AgentPluginVersion). +func (m *AgentPluginVersionMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *GitBotTaskMutation) Fields() []string { - fields := make([]string, 0, 3) - if m.git_bot != nil { - fields = append(fields, gitbottask.FieldGitBotID) +func (m *AgentPluginVersionMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.plugin != nil { + fields = append(fields, agentpluginversion.FieldResourceID) } - if m.task != nil { - fields = append(fields, gitbottask.FieldTaskID) + if m.version != nil { + fields = append(fields, agentpluginversion.FieldVersion) + } + if m.s3_key != nil { + fields = append(fields, agentpluginversion.FieldS3Key) + } + if m.parsed_meta != nil { + fields = append(fields, agentpluginversion.FieldParsedMeta) } if m.created_at != nil { - fields = append(fields, gitbottask.FieldCreatedAt) + fields = append(fields, agentpluginversion.FieldCreatedAt) } return fields } @@ -2443,13 +3237,17 @@ func (m *GitBotTaskMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *GitBotTaskMutation) Field(name string) (ent.Value, bool) { +func (m *AgentPluginVersionMutation) Field(name string) (ent.Value, bool) { switch name { - case gitbottask.FieldGitBotID: - return m.GitBotID() - case gitbottask.FieldTaskID: - return m.TaskID() - case gitbottask.FieldCreatedAt: + case agentpluginversion.FieldResourceID: + return m.ResourceID() + case agentpluginversion.FieldVersion: + return m.Version() + case agentpluginversion.FieldS3Key: + return m.S3Key() + case agentpluginversion.FieldParsedMeta: + return m.ParsedMeta() + case agentpluginversion.FieldCreatedAt: return m.CreatedAt() } return nil, false @@ -2458,38 +3256,56 @@ func (m *GitBotTaskMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *GitBotTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *AgentPluginVersionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case gitbottask.FieldGitBotID: - return m.OldGitBotID(ctx) - case gitbottask.FieldTaskID: - return m.OldTaskID(ctx) - case gitbottask.FieldCreatedAt: + case agentpluginversion.FieldResourceID: + return m.OldResourceID(ctx) + case agentpluginversion.FieldVersion: + return m.OldVersion(ctx) + case agentpluginversion.FieldS3Key: + return m.OldS3Key(ctx) + case agentpluginversion.FieldParsedMeta: + return m.OldParsedMeta(ctx) + case agentpluginversion.FieldCreatedAt: return m.OldCreatedAt(ctx) } - return nil, fmt.Errorf("unknown GitBotTask field %s", name) + return nil, fmt.Errorf("unknown AgentPluginVersion field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *GitBotTaskMutation) SetField(name string, value ent.Value) error { +func (m *AgentPluginVersionMutation) SetField(name string, value ent.Value) error { switch name { - case gitbottask.FieldGitBotID: + case agentpluginversion.FieldResourceID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetGitBotID(v) + m.SetResourceID(v) return nil - case gitbottask.FieldTaskID: - v, ok := value.(uuid.UUID) + case agentpluginversion.FieldVersion: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetTaskID(v) + m.SetVersion(v) return nil - case gitbottask.FieldCreatedAt: + case agentpluginversion.FieldS3Key: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetS3Key(v) + return nil + case agentpluginversion.FieldParsedMeta: + v, ok := value.(types.PluginParsedMeta) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetParsedMeta(v) + return nil + case agentpluginversion.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) @@ -2497,89 +3313,97 @@ func (m *GitBotTaskMutation) SetField(name string, value ent.Value) error { m.SetCreatedAt(v) return nil } - return fmt.Errorf("unknown GitBotTask field %s", name) + return fmt.Errorf("unknown AgentPluginVersion field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *GitBotTaskMutation) AddedFields() []string { +func (m *AgentPluginVersionMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *GitBotTaskMutation) AddedField(name string) (ent.Value, bool) { +func (m *AgentPluginVersionMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *GitBotTaskMutation) AddField(name string, value ent.Value) error { +func (m *AgentPluginVersionMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown GitBotTask numeric field %s", name) + return fmt.Errorf("unknown AgentPluginVersion numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *GitBotTaskMutation) ClearedFields() []string { - return nil +func (m *AgentPluginVersionMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(agentpluginversion.FieldParsedMeta) { + fields = append(fields, agentpluginversion.FieldParsedMeta) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *GitBotTaskMutation) FieldCleared(name string) bool { +func (m *AgentPluginVersionMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *GitBotTaskMutation) ClearField(name string) error { - return fmt.Errorf("unknown GitBotTask nullable field %s", name) +func (m *AgentPluginVersionMutation) ClearField(name string) error { + switch name { + case agentpluginversion.FieldParsedMeta: + m.ClearParsedMeta() + return nil + } + return fmt.Errorf("unknown AgentPluginVersion nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *GitBotTaskMutation) ResetField(name string) error { +func (m *AgentPluginVersionMutation) ResetField(name string) error { switch name { - case gitbottask.FieldGitBotID: - m.ResetGitBotID() + case agentpluginversion.FieldResourceID: + m.ResetResourceID() return nil - case gitbottask.FieldTaskID: - m.ResetTaskID() + case agentpluginversion.FieldVersion: + m.ResetVersion() return nil - case gitbottask.FieldCreatedAt: + case agentpluginversion.FieldS3Key: + m.ResetS3Key() + return nil + case agentpluginversion.FieldParsedMeta: + m.ResetParsedMeta() + return nil + case agentpluginversion.FieldCreatedAt: m.ResetCreatedAt() return nil } - return fmt.Errorf("unknown GitBotTask field %s", name) + return fmt.Errorf("unknown AgentPluginVersion field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *GitBotTaskMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.task != nil { - edges = append(edges, gitbottask.EdgeTask) - } - if m.git_bot != nil { - edges = append(edges, gitbottask.EdgeGitBot) +func (m *AgentPluginVersionMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.plugin != nil { + edges = append(edges, agentpluginversion.EdgePlugin) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *GitBotTaskMutation) AddedIDs(name string) []ent.Value { +func (m *AgentPluginVersionMutation) AddedIDs(name string) []ent.Value { switch name { - case gitbottask.EdgeTask: - if id := m.task; id != nil { - return []ent.Value{*id} - } - case gitbottask.EdgeGitBot: - if id := m.git_bot; id != nil { + case agentpluginversion.EdgePlugin: + if id := m.plugin; id != nil { return []ent.Value{*id} } } @@ -2587,97 +3411,93 @@ func (m *GitBotTaskMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *GitBotTaskMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) +func (m *AgentPluginVersionMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *GitBotTaskMutation) RemovedIDs(name string) []ent.Value { +func (m *AgentPluginVersionMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *GitBotTaskMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedtask { - edges = append(edges, gitbottask.EdgeTask) - } - if m.clearedgit_bot { - edges = append(edges, gitbottask.EdgeGitBot) +func (m *AgentPluginVersionMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedplugin { + edges = append(edges, agentpluginversion.EdgePlugin) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *GitBotTaskMutation) EdgeCleared(name string) bool { +func (m *AgentPluginVersionMutation) EdgeCleared(name string) bool { switch name { - case gitbottask.EdgeTask: - return m.clearedtask - case gitbottask.EdgeGitBot: - return m.clearedgit_bot + case agentpluginversion.EdgePlugin: + return m.clearedplugin } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *GitBotTaskMutation) ClearEdge(name string) error { +func (m *AgentPluginVersionMutation) ClearEdge(name string) error { switch name { - case gitbottask.EdgeTask: - m.ClearTask() - return nil - case gitbottask.EdgeGitBot: - m.ClearGitBot() + case agentpluginversion.EdgePlugin: + m.ClearPlugin() return nil } - return fmt.Errorf("unknown GitBotTask unique edge %s", name) + return fmt.Errorf("unknown AgentPluginVersion unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *GitBotTaskMutation) ResetEdge(name string) error { +func (m *AgentPluginVersionMutation) ResetEdge(name string) error { switch name { - case gitbottask.EdgeTask: - m.ResetTask() - return nil - case gitbottask.EdgeGitBot: - m.ResetGitBot() + case agentpluginversion.EdgePlugin: + m.ResetPlugin() return nil } - return fmt.Errorf("unknown GitBotTask edge %s", name) + return fmt.Errorf("unknown AgentPluginVersion edge %s", name) } -// GitBotUserMutation represents an operation that mutates the GitBotUser nodes in the graph. -type GitBotUserMutation struct { +// AgentRuleMutation represents an operation that mutates the AgentRule nodes in the graph. +type AgentRuleMutation struct { config - op Op - typ string - id *uuid.UUID - created_at *time.Time - clearedFields map[string]struct{} - git_bot *uuid.UUID - clearedgit_bot bool - user *uuid.UUID - cleareduser bool - done bool - oldValue func(context.Context) (*GitBotUser, error) - predicates []predicate.GitBotUser + op Op + typ string + id *uuid.UUID + name *string + description *string + scope_type *agentrule.ScopeType + scope_id *string + created_by *uuid.UUID + active_version_id *uuid.UUID + is_deleted *bool + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + versions map[uuid.UUID]struct{} + removedversions map[uuid.UUID]struct{} + clearedversions bool + done bool + oldValue func(context.Context) (*AgentRule, error) + predicates []predicate.AgentRule } -var _ ent.Mutation = (*GitBotUserMutation)(nil) +var _ ent.Mutation = (*AgentRuleMutation)(nil) -// gitbotuserOption allows management of the mutation configuration using functional options. -type gitbotuserOption func(*GitBotUserMutation) +// agentruleOption allows management of the mutation configuration using functional options. +type agentruleOption func(*AgentRuleMutation) -// newGitBotUserMutation creates new mutation for the GitBotUser entity. -func newGitBotUserMutation(c config, op Op, opts ...gitbotuserOption) *GitBotUserMutation { - m := &GitBotUserMutation{ +// newAgentRuleMutation creates new mutation for the AgentRule entity. +func newAgentRuleMutation(c config, op Op, opts ...agentruleOption) *AgentRuleMutation { + m := &AgentRuleMutation{ config: c, op: op, - typ: TypeGitBotUser, + typ: TypeAgentRule, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -2686,20 +3506,20 @@ func newGitBotUserMutation(c config, op Op, opts ...gitbotuserOption) *GitBotUse return m } -// withGitBotUserID sets the ID field of the mutation. -func withGitBotUserID(id uuid.UUID) gitbotuserOption { - return func(m *GitBotUserMutation) { +// withAgentRuleID sets the ID field of the mutation. +func withAgentRuleID(id uuid.UUID) agentruleOption { + return func(m *AgentRuleMutation) { var ( err error once sync.Once - value *GitBotUser + value *AgentRule ) - m.oldValue = func(ctx context.Context) (*GitBotUser, error) { + m.oldValue = func(ctx context.Context) (*AgentRule, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().GitBotUser.Get(ctx, id) + value, err = m.Client().AgentRule.Get(ctx, id) } }) return value, err @@ -2708,10 +3528,10 @@ func withGitBotUserID(id uuid.UUID) gitbotuserOption { } } -// withGitBotUser sets the old GitBotUser of the mutation. -func withGitBotUser(node *GitBotUser) gitbotuserOption { - return func(m *GitBotUserMutation) { - m.oldValue = func(context.Context) (*GitBotUser, error) { +// withAgentRule sets the old AgentRule of the mutation. +func withAgentRule(node *AgentRule) agentruleOption { + return func(m *AgentRuleMutation) { + m.oldValue = func(context.Context) (*AgentRule, error) { return node, nil } m.id = &node.ID @@ -2720,7 +3540,7 @@ func withGitBotUser(node *GitBotUser) gitbotuserOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m GitBotUserMutation) Client() *Client { +func (m AgentRuleMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -2728,7 +3548,7 @@ func (m GitBotUserMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m GitBotUserMutation) Tx() (*Tx, error) { +func (m AgentRuleMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -2738,14 +3558,14 @@ func (m GitBotUserMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of GitBotUser entities. -func (m *GitBotUserMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of AgentRule entities. +func (m *AgentRuleMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *GitBotUserMutation) ID() (id uuid.UUID, exists bool) { +func (m *AgentRuleMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -2756,7 +3576,7 @@ func (m *GitBotUserMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *GitBotUserMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *AgentRuleMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -2765,183 +3585,425 @@ func (m *GitBotUserMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().GitBotUser.Query().Where(m.predicates...).IDs(ctx) + return m.Client().AgentRule.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetGitBotID sets the "git_bot_id" field. -func (m *GitBotUserMutation) SetGitBotID(u uuid.UUID) { - m.git_bot = &u +// SetName sets the "name" field. +func (m *AgentRuleMutation) SetName(s string) { + m.name = &s } -// GitBotID returns the value of the "git_bot_id" field in the mutation. -func (m *GitBotUserMutation) GitBotID() (r uuid.UUID, exists bool) { - v := m.git_bot +// Name returns the value of the "name" field in the mutation. +func (m *AgentRuleMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldGitBotID returns the old "git_bot_id" field's value of the GitBotUser entity. -// If the GitBotUser object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the AgentRule entity. +// If the AgentRule object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotUserMutation) OldGitBotID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AgentRuleMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldGitBotID is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldGitBotID requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldGitBotID: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.GitBotID, nil + return oldValue.Name, nil } -// ResetGitBotID resets all changes to the "git_bot_id" field. -func (m *GitBotUserMutation) ResetGitBotID() { - m.git_bot = nil +// ResetName resets all changes to the "name" field. +func (m *AgentRuleMutation) ResetName() { + m.name = nil } -// SetUserID sets the "user_id" field. -func (m *GitBotUserMutation) SetUserID(u uuid.UUID) { - m.user = &u +// SetDescription sets the "description" field. +func (m *AgentRuleMutation) SetDescription(s string) { + m.description = &s } -// UserID returns the value of the "user_id" field in the mutation. -func (m *GitBotUserMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user +// Description returns the value of the "description" field in the mutation. +func (m *AgentRuleMutation) Description() (r string, exists bool) { + v := m.description if v == nil { return } return *v, true } -// OldUserID returns the old "user_id" field's value of the GitBotUser entity. -// If the GitBotUser object wasn't provided to the builder, the object is fetched from the database. +// OldDescription returns the old "description" field's value of the AgentRule entity. +// If the AgentRule object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotUserMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AgentRuleMutation) OldDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") + return v, errors.New("OldDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + return v, fmt.Errorf("querying old value for OldDescription: %w", err) } - return oldValue.UserID, nil + return oldValue.Description, nil } -// ResetUserID resets all changes to the "user_id" field. -func (m *GitBotUserMutation) ResetUserID() { - m.user = nil +// ClearDescription clears the value of the "description" field. +func (m *AgentRuleMutation) ClearDescription() { + m.description = nil + m.clearedFields[agentrule.FieldDescription] = struct{}{} } -// SetCreatedAt sets the "created_at" field. -func (m *GitBotUserMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *AgentRuleMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[agentrule.FieldDescription] + return ok } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *GitBotUserMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// ResetDescription resets all changes to the "description" field. +func (m *AgentRuleMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, agentrule.FieldDescription) +} + +// SetScopeType sets the "scope_type" field. +func (m *AgentRuleMutation) SetScopeType(at agentrule.ScopeType) { + m.scope_type = &at +} + +// ScopeType returns the value of the "scope_type" field in the mutation. +func (m *AgentRuleMutation) ScopeType() (r agentrule.ScopeType, exists bool) { + v := m.scope_type if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the GitBotUser entity. -// If the GitBotUser object wasn't provided to the builder, the object is fetched from the database. +// OldScopeType returns the old "scope_type" field's value of the AgentRule entity. +// If the AgentRule object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitBotUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentRuleMutation) OldScopeType(ctx context.Context) (v agentrule.ScopeType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldScopeType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + return v, errors.New("OldScopeType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldScopeType: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.ScopeType, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *GitBotUserMutation) ResetCreatedAt() { - m.created_at = nil +// ResetScopeType resets all changes to the "scope_type" field. +func (m *AgentRuleMutation) ResetScopeType() { + m.scope_type = nil } -// ClearGitBot clears the "git_bot" edge to the GitBot entity. -func (m *GitBotUserMutation) ClearGitBot() { - m.clearedgit_bot = true - m.clearedFields[gitbotuser.FieldGitBotID] = struct{}{} +// SetScopeID sets the "scope_id" field. +func (m *AgentRuleMutation) SetScopeID(s string) { + m.scope_id = &s } -// GitBotCleared reports if the "git_bot" edge to the GitBot entity was cleared. -func (m *GitBotUserMutation) GitBotCleared() bool { - return m.clearedgit_bot +// ScopeID returns the value of the "scope_id" field in the mutation. +func (m *AgentRuleMutation) ScopeID() (r string, exists bool) { + v := m.scope_id + if v == nil { + return + } + return *v, true } -// GitBotIDs returns the "git_bot" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// GitBotID instead. It exists only for internal usage by the builders. -func (m *GitBotUserMutation) GitBotIDs() (ids []uuid.UUID) { - if id := m.git_bot; id != nil { - ids = append(ids, *id) +// OldScopeID returns the old "scope_id" field's value of the AgentRule entity. +// If the AgentRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentRuleMutation) OldScopeID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldScopeID is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldScopeID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldScopeID: %w", err) + } + return oldValue.ScopeID, nil } -// ResetGitBot resets all changes to the "git_bot" edge. -func (m *GitBotUserMutation) ResetGitBot() { - m.git_bot = nil - m.clearedgit_bot = false +// ResetScopeID resets all changes to the "scope_id" field. +func (m *AgentRuleMutation) ResetScopeID() { + m.scope_id = nil } -// ClearUser clears the "user" edge to the User entity. -func (m *GitBotUserMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[gitbotuser.FieldUserID] = struct{}{} +// SetCreatedBy sets the "created_by" field. +func (m *AgentRuleMutation) SetCreatedBy(u uuid.UUID) { + m.created_by = &u } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *GitBotUserMutation) UserCleared() bool { - return m.cleareduser +// CreatedBy returns the value of the "created_by" field in the mutation. +func (m *AgentRuleMutation) CreatedBy() (r uuid.UUID, exists bool) { + v := m.created_by + if v == nil { + return + } + return *v, true } -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *GitBotUserMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { - ids = append(ids, *id) +// OldCreatedBy returns the old "created_by" field's value of the AgentRule entity. +// If the AgentRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentRuleMutation) OldCreatedBy(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedBy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err) + } + return oldValue.CreatedBy, nil } -// ResetUser resets all changes to the "user" edge. -func (m *GitBotUserMutation) ResetUser() { - m.user = nil - m.cleareduser = false +// ResetCreatedBy resets all changes to the "created_by" field. +func (m *AgentRuleMutation) ResetCreatedBy() { + m.created_by = nil } -// Where appends a list predicates to the GitBotUserMutation builder. -func (m *GitBotUserMutation) Where(ps ...predicate.GitBotUser) { +// SetActiveVersionID sets the "active_version_id" field. +func (m *AgentRuleMutation) SetActiveVersionID(u uuid.UUID) { + m.active_version_id = &u +} + +// ActiveVersionID returns the value of the "active_version_id" field in the mutation. +func (m *AgentRuleMutation) ActiveVersionID() (r uuid.UUID, exists bool) { + v := m.active_version_id + if v == nil { + return + } + return *v, true +} + +// OldActiveVersionID returns the old "active_version_id" field's value of the AgentRule entity. +// If the AgentRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentRuleMutation) OldActiveVersionID(ctx context.Context) (v *uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldActiveVersionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldActiveVersionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldActiveVersionID: %w", err) + } + return oldValue.ActiveVersionID, nil +} + +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (m *AgentRuleMutation) ClearActiveVersionID() { + m.active_version_id = nil + m.clearedFields[agentrule.FieldActiveVersionID] = struct{}{} +} + +// ActiveVersionIDCleared returns if the "active_version_id" field was cleared in this mutation. +func (m *AgentRuleMutation) ActiveVersionIDCleared() bool { + _, ok := m.clearedFields[agentrule.FieldActiveVersionID] + return ok +} + +// ResetActiveVersionID resets all changes to the "active_version_id" field. +func (m *AgentRuleMutation) ResetActiveVersionID() { + m.active_version_id = nil + delete(m.clearedFields, agentrule.FieldActiveVersionID) +} + +// SetIsDeleted sets the "is_deleted" field. +func (m *AgentRuleMutation) SetIsDeleted(b bool) { + m.is_deleted = &b +} + +// IsDeleted returns the value of the "is_deleted" field in the mutation. +func (m *AgentRuleMutation) IsDeleted() (r bool, exists bool) { + v := m.is_deleted + if v == nil { + return + } + return *v, true +} + +// OldIsDeleted returns the old "is_deleted" field's value of the AgentRule entity. +// If the AgentRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentRuleMutation) OldIsDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsDeleted: %w", err) + } + return oldValue.IsDeleted, nil +} + +// ResetIsDeleted resets all changes to the "is_deleted" field. +func (m *AgentRuleMutation) ResetIsDeleted() { + m.is_deleted = nil +} + +// SetCreatedAt sets the "created_at" field. +func (m *AgentRuleMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AgentRuleMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the AgentRule entity. +// If the AgentRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentRuleMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *AgentRuleMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *AgentRuleMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *AgentRuleMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the AgentRule entity. +// If the AgentRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentRuleMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *AgentRuleMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// AddVersionIDs adds the "versions" edge to the AgentRuleVersion entity by ids. +func (m *AgentRuleMutation) AddVersionIDs(ids ...uuid.UUID) { + if m.versions == nil { + m.versions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.versions[ids[i]] = struct{}{} + } +} + +// ClearVersions clears the "versions" edge to the AgentRuleVersion entity. +func (m *AgentRuleMutation) ClearVersions() { + m.clearedversions = true +} + +// VersionsCleared reports if the "versions" edge to the AgentRuleVersion entity was cleared. +func (m *AgentRuleMutation) VersionsCleared() bool { + return m.clearedversions +} + +// RemoveVersionIDs removes the "versions" edge to the AgentRuleVersion entity by IDs. +func (m *AgentRuleMutation) RemoveVersionIDs(ids ...uuid.UUID) { + if m.removedversions == nil { + m.removedversions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.versions, ids[i]) + m.removedversions[ids[i]] = struct{}{} + } +} + +// RemovedVersions returns the removed IDs of the "versions" edge to the AgentRuleVersion entity. +func (m *AgentRuleMutation) RemovedVersionsIDs() (ids []uuid.UUID) { + for id := range m.removedversions { + ids = append(ids, id) + } + return +} + +// VersionsIDs returns the "versions" edge IDs in the mutation. +func (m *AgentRuleMutation) VersionsIDs() (ids []uuid.UUID) { + for id := range m.versions { + ids = append(ids, id) + } + return +} + +// ResetVersions resets all changes to the "versions" edge. +func (m *AgentRuleMutation) ResetVersions() { + m.versions = nil + m.clearedversions = false + m.removedversions = nil +} + +// Where appends a list predicates to the AgentRuleMutation builder. +func (m *AgentRuleMutation) Where(ps ...predicate.AgentRule) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the GitBotUserMutation builder. Using this method, +// WhereP appends storage-level predicates to the AgentRuleMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *GitBotUserMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.GitBotUser, len(ps)) +func (m *AgentRuleMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.AgentRule, len(ps)) for i := range ps { p[i] = ps[i] } @@ -2949,33 +4011,51 @@ func (m *GitBotUserMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *GitBotUserMutation) Op() Op { +func (m *AgentRuleMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *GitBotUserMutation) SetOp(op Op) { +func (m *AgentRuleMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (GitBotUser). -func (m *GitBotUserMutation) Type() string { +// Type returns the node type of this mutation (AgentRule). +func (m *AgentRuleMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *GitBotUserMutation) Fields() []string { - fields := make([]string, 0, 3) - if m.git_bot != nil { - fields = append(fields, gitbotuser.FieldGitBotID) +func (m *AgentRuleMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.name != nil { + fields = append(fields, agentrule.FieldName) } - if m.user != nil { - fields = append(fields, gitbotuser.FieldUserID) + if m.description != nil { + fields = append(fields, agentrule.FieldDescription) + } + if m.scope_type != nil { + fields = append(fields, agentrule.FieldScopeType) + } + if m.scope_id != nil { + fields = append(fields, agentrule.FieldScopeID) + } + if m.created_by != nil { + fields = append(fields, agentrule.FieldCreatedBy) + } + if m.active_version_id != nil { + fields = append(fields, agentrule.FieldActiveVersionID) + } + if m.is_deleted != nil { + fields = append(fields, agentrule.FieldIsDeleted) } if m.created_at != nil { - fields = append(fields, gitbotuser.FieldCreatedAt) + fields = append(fields, agentrule.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, agentrule.FieldUpdatedAt) } return fields } @@ -2983,14 +4063,26 @@ func (m *GitBotUserMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *GitBotUserMutation) Field(name string) (ent.Value, bool) { +func (m *AgentRuleMutation) Field(name string) (ent.Value, bool) { switch name { - case gitbotuser.FieldGitBotID: - return m.GitBotID() - case gitbotuser.FieldUserID: - return m.UserID() - case gitbotuser.FieldCreatedAt: + case agentrule.FieldName: + return m.Name() + case agentrule.FieldDescription: + return m.Description() + case agentrule.FieldScopeType: + return m.ScopeType() + case agentrule.FieldScopeID: + return m.ScopeID() + case agentrule.FieldCreatedBy: + return m.CreatedBy() + case agentrule.FieldActiveVersionID: + return m.ActiveVersionID() + case agentrule.FieldIsDeleted: + return m.IsDeleted() + case agentrule.FieldCreatedAt: return m.CreatedAt() + case agentrule.FieldUpdatedAt: + return m.UpdatedAt() } return nil, false } @@ -2998,246 +4090,305 @@ func (m *GitBotUserMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *GitBotUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *AgentRuleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case gitbotuser.FieldGitBotID: - return m.OldGitBotID(ctx) - case gitbotuser.FieldUserID: - return m.OldUserID(ctx) - case gitbotuser.FieldCreatedAt: + case agentrule.FieldName: + return m.OldName(ctx) + case agentrule.FieldDescription: + return m.OldDescription(ctx) + case agentrule.FieldScopeType: + return m.OldScopeType(ctx) + case agentrule.FieldScopeID: + return m.OldScopeID(ctx) + case agentrule.FieldCreatedBy: + return m.OldCreatedBy(ctx) + case agentrule.FieldActiveVersionID: + return m.OldActiveVersionID(ctx) + case agentrule.FieldIsDeleted: + return m.OldIsDeleted(ctx) + case agentrule.FieldCreatedAt: return m.OldCreatedAt(ctx) + case agentrule.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown GitBotUser field %s", name) + return nil, fmt.Errorf("unknown AgentRule field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *GitBotUserMutation) SetField(name string, value ent.Value) error { +func (m *AgentRuleMutation) SetField(name string, value ent.Value) error { switch name { - case gitbotuser.FieldGitBotID: + case agentrule.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case agentrule.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case agentrule.FieldScopeType: + v, ok := value.(agentrule.ScopeType) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScopeType(v) + return nil + case agentrule.FieldScopeID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScopeID(v) + return nil + case agentrule.FieldCreatedBy: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetGitBotID(v) + m.SetCreatedBy(v) return nil - case gitbotuser.FieldUserID: + case agentrule.FieldActiveVersionID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) + m.SetActiveVersionID(v) return nil - case gitbotuser.FieldCreatedAt: + case agentrule.FieldIsDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsDeleted(v) + return nil + case agentrule.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil + case agentrule.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil } - return fmt.Errorf("unknown GitBotUser field %s", name) + return fmt.Errorf("unknown AgentRule field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *GitBotUserMutation) AddedFields() []string { +func (m *AgentRuleMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *GitBotUserMutation) AddedField(name string) (ent.Value, bool) { +func (m *AgentRuleMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *GitBotUserMutation) AddField(name string, value ent.Value) error { +func (m *AgentRuleMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown GitBotUser numeric field %s", name) + return fmt.Errorf("unknown AgentRule numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *GitBotUserMutation) ClearedFields() []string { - return nil +func (m *AgentRuleMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(agentrule.FieldDescription) { + fields = append(fields, agentrule.FieldDescription) + } + if m.FieldCleared(agentrule.FieldActiveVersionID) { + fields = append(fields, agentrule.FieldActiveVersionID) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *GitBotUserMutation) FieldCleared(name string) bool { +func (m *AgentRuleMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *GitBotUserMutation) ClearField(name string) error { - return fmt.Errorf("unknown GitBotUser nullable field %s", name) +func (m *AgentRuleMutation) ClearField(name string) error { + switch name { + case agentrule.FieldDescription: + m.ClearDescription() + return nil + case agentrule.FieldActiveVersionID: + m.ClearActiveVersionID() + return nil + } + return fmt.Errorf("unknown AgentRule nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *GitBotUserMutation) ResetField(name string) error { +func (m *AgentRuleMutation) ResetField(name string) error { switch name { - case gitbotuser.FieldGitBotID: - m.ResetGitBotID() + case agentrule.FieldName: + m.ResetName() return nil - case gitbotuser.FieldUserID: - m.ResetUserID() + case agentrule.FieldDescription: + m.ResetDescription() return nil - case gitbotuser.FieldCreatedAt: + case agentrule.FieldScopeType: + m.ResetScopeType() + return nil + case agentrule.FieldScopeID: + m.ResetScopeID() + return nil + case agentrule.FieldCreatedBy: + m.ResetCreatedBy() + return nil + case agentrule.FieldActiveVersionID: + m.ResetActiveVersionID() + return nil + case agentrule.FieldIsDeleted: + m.ResetIsDeleted() + return nil + case agentrule.FieldCreatedAt: m.ResetCreatedAt() return nil + case agentrule.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil } - return fmt.Errorf("unknown GitBotUser field %s", name) + return fmt.Errorf("unknown AgentRule field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *GitBotUserMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.git_bot != nil { - edges = append(edges, gitbotuser.EdgeGitBot) - } - if m.user != nil { - edges = append(edges, gitbotuser.EdgeUser) +func (m *AgentRuleMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.versions != nil { + edges = append(edges, agentrule.EdgeVersions) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *GitBotUserMutation) AddedIDs(name string) []ent.Value { +func (m *AgentRuleMutation) AddedIDs(name string) []ent.Value { switch name { - case gitbotuser.EdgeGitBot: - if id := m.git_bot; id != nil { - return []ent.Value{*id} - } - case gitbotuser.EdgeUser: - if id := m.user; id != nil { - return []ent.Value{*id} + case agentrule.EdgeVersions: + ids := make([]ent.Value, 0, len(m.versions)) + for id := range m.versions { + ids = append(ids, id) } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *GitBotUserMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) +func (m *AgentRuleMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + if m.removedversions != nil { + edges = append(edges, agentrule.EdgeVersions) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *GitBotUserMutation) RemovedIDs(name string) []ent.Value { +func (m *AgentRuleMutation) RemovedIDs(name string) []ent.Value { + switch name { + case agentrule.EdgeVersions: + ids := make([]ent.Value, 0, len(m.removedversions)) + for id := range m.removedversions { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *GitBotUserMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedgit_bot { - edges = append(edges, gitbotuser.EdgeGitBot) - } - if m.cleareduser { - edges = append(edges, gitbotuser.EdgeUser) +func (m *AgentRuleMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedversions { + edges = append(edges, agentrule.EdgeVersions) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *GitBotUserMutation) EdgeCleared(name string) bool { +func (m *AgentRuleMutation) EdgeCleared(name string) bool { switch name { - case gitbotuser.EdgeGitBot: - return m.clearedgit_bot - case gitbotuser.EdgeUser: - return m.cleareduser + case agentrule.EdgeVersions: + return m.clearedversions } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *GitBotUserMutation) ClearEdge(name string) error { +func (m *AgentRuleMutation) ClearEdge(name string) error { switch name { - case gitbotuser.EdgeGitBot: - m.ClearGitBot() - return nil - case gitbotuser.EdgeUser: - m.ClearUser() - return nil } - return fmt.Errorf("unknown GitBotUser unique edge %s", name) + return fmt.Errorf("unknown AgentRule unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *GitBotUserMutation) ResetEdge(name string) error { +func (m *AgentRuleMutation) ResetEdge(name string) error { switch name { - case gitbotuser.EdgeGitBot: - m.ResetGitBot() - return nil - case gitbotuser.EdgeUser: - m.ResetUser() + case agentrule.EdgeVersions: + m.ResetVersions() return nil } - return fmt.Errorf("unknown GitBotUser edge %s", name) + return fmt.Errorf("unknown AgentRule edge %s", name) } -// GitIdentityMutation represents an operation that mutates the GitIdentity nodes in the graph. -type GitIdentityMutation struct { +// AgentRuleVersionMutation represents an operation that mutates the AgentRuleVersion nodes in the graph. +type AgentRuleVersionMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - platform *consts.GitPlatform - base_url *string - access_token *string - username *string - email *string - installation_id *int64 - addinstallation_id *int64 - organization_id *string - remark *string - oauth_refresh_token *string - oauth_expires_at *time.Time - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - user *uuid.UUID - cleareduser bool - projects map[uuid.UUID]struct{} - removedprojects map[uuid.UUID]struct{} - clearedprojects bool - project_tasks map[uuid.UUID]struct{} - removedproject_tasks map[uuid.UUID]struct{} - clearedproject_tasks bool - vms map[string]struct{} - removedvms map[string]struct{} - clearedvms bool - done bool - oldValue func(context.Context) (*GitIdentity, error) - predicates []predicate.GitIdentity + op Op + typ string + id *uuid.UUID + version *string + content *string + created_at *time.Time + clearedFields map[string]struct{} + rule *uuid.UUID + clearedrule bool + done bool + oldValue func(context.Context) (*AgentRuleVersion, error) + predicates []predicate.AgentRuleVersion } -var _ ent.Mutation = (*GitIdentityMutation)(nil) +var _ ent.Mutation = (*AgentRuleVersionMutation)(nil) -// gitidentityOption allows management of the mutation configuration using functional options. -type gitidentityOption func(*GitIdentityMutation) +// agentruleversionOption allows management of the mutation configuration using functional options. +type agentruleversionOption func(*AgentRuleVersionMutation) -// newGitIdentityMutation creates new mutation for the GitIdentity entity. -func newGitIdentityMutation(c config, op Op, opts ...gitidentityOption) *GitIdentityMutation { - m := &GitIdentityMutation{ +// newAgentRuleVersionMutation creates new mutation for the AgentRuleVersion entity. +func newAgentRuleVersionMutation(c config, op Op, opts ...agentruleversionOption) *AgentRuleVersionMutation { + m := &AgentRuleVersionMutation{ config: c, op: op, - typ: TypeGitIdentity, + typ: TypeAgentRuleVersion, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -3246,20 +4397,20 @@ func newGitIdentityMutation(c config, op Op, opts ...gitidentityOption) *GitIden return m } -// withGitIdentityID sets the ID field of the mutation. -func withGitIdentityID(id uuid.UUID) gitidentityOption { - return func(m *GitIdentityMutation) { +// withAgentRuleVersionID sets the ID field of the mutation. +func withAgentRuleVersionID(id uuid.UUID) agentruleversionOption { + return func(m *AgentRuleVersionMutation) { var ( err error once sync.Once - value *GitIdentity + value *AgentRuleVersion ) - m.oldValue = func(ctx context.Context) (*GitIdentity, error) { + m.oldValue = func(ctx context.Context) (*AgentRuleVersion, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().GitIdentity.Get(ctx, id) + value, err = m.Client().AgentRuleVersion.Get(ctx, id) } }) return value, err @@ -3268,10 +4419,10 @@ func withGitIdentityID(id uuid.UUID) gitidentityOption { } } -// withGitIdentity sets the old GitIdentity of the mutation. -func withGitIdentity(node *GitIdentity) gitidentityOption { - return func(m *GitIdentityMutation) { - m.oldValue = func(context.Context) (*GitIdentity, error) { +// withAgentRuleVersion sets the old AgentRuleVersion of the mutation. +func withAgentRuleVersion(node *AgentRuleVersion) agentruleversionOption { + return func(m *AgentRuleVersionMutation) { + m.oldValue = func(context.Context) (*AgentRuleVersion, error) { return node, nil } m.id = &node.ID @@ -3280,7 +4431,7 @@ func withGitIdentity(node *GitIdentity) gitidentityOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m GitIdentityMutation) Client() *Client { +func (m AgentRuleVersionMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -3288,7 +4439,7 @@ func (m GitIdentityMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m GitIdentityMutation) Tx() (*Tx, error) { +func (m AgentRuleVersionMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -3298,14 +4449,14 @@ func (m GitIdentityMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of GitIdentity entities. -func (m *GitIdentityMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of AgentRuleVersion entities. +func (m *AgentRuleVersionMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *GitIdentityMutation) ID() (id uuid.UUID, exists bool) { +func (m *AgentRuleVersionMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -3316,7 +4467,7 @@ func (m *GitIdentityMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *GitIdentityMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *AgentRuleVersionMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -3325,865 +4476,1323 @@ func (m *GitIdentityMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().GitIdentity.Query().Where(m.predicates...).IDs(ctx) + return m.Client().AgentRuleVersion.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetDeletedAt sets the "deleted_at" field. -func (m *GitIdentityMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t +// SetRuleID sets the "rule_id" field. +func (m *AgentRuleVersionMutation) SetRuleID(u uuid.UUID) { + m.rule = &u } -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *GitIdentityMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at +// RuleID returns the value of the "rule_id" field in the mutation. +func (m *AgentRuleVersionMutation) RuleID() (r uuid.UUID, exists bool) { + v := m.rule if v == nil { return } return *v, true } -// OldDeletedAt returns the old "deleted_at" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// OldRuleID returns the old "rule_id" field's value of the AgentRuleVersion entity. +// If the AgentRuleVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentRuleVersionMutation) OldRuleID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + return v, errors.New("OldRuleID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") + return v, errors.New("OldRuleID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + return v, fmt.Errorf("querying old value for OldRuleID: %w", err) } - return oldValue.DeletedAt, nil -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *GitIdentityMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[gitidentity.FieldDeletedAt] = struct{}{} -} - -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *GitIdentityMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[gitidentity.FieldDeletedAt] - return ok + return oldValue.RuleID, nil } -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *GitIdentityMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, gitidentity.FieldDeletedAt) +// ResetRuleID resets all changes to the "rule_id" field. +func (m *AgentRuleVersionMutation) ResetRuleID() { + m.rule = nil } -// SetUserID sets the "user_id" field. -func (m *GitIdentityMutation) SetUserID(u uuid.UUID) { - m.user = &u +// SetVersion sets the "version" field. +func (m *AgentRuleVersionMutation) SetVersion(s string) { + m.version = &s } -// UserID returns the value of the "user_id" field in the mutation. -func (m *GitIdentityMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user +// Version returns the value of the "version" field in the mutation. +func (m *AgentRuleVersionMutation) Version() (r string, exists bool) { + v := m.version if v == nil { return } return *v, true } -// OldUserID returns the old "user_id" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// OldVersion returns the old "version" field's value of the AgentRuleVersion entity. +// If the AgentRuleVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AgentRuleVersionMutation) OldVersion(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") + return v, errors.New("OldVersion is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") + return v, errors.New("OldVersion requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + return v, fmt.Errorf("querying old value for OldVersion: %w", err) } - return oldValue.UserID, nil + return oldValue.Version, nil } -// ResetUserID resets all changes to the "user_id" field. -func (m *GitIdentityMutation) ResetUserID() { - m.user = nil +// ResetVersion resets all changes to the "version" field. +func (m *AgentRuleVersionMutation) ResetVersion() { + m.version = nil } -// SetPlatform sets the "platform" field. -func (m *GitIdentityMutation) SetPlatform(cp consts.GitPlatform) { - m.platform = &cp +// SetContent sets the "content" field. +func (m *AgentRuleVersionMutation) SetContent(s string) { + m.content = &s } -// Platform returns the value of the "platform" field in the mutation. -func (m *GitIdentityMutation) Platform() (r consts.GitPlatform, exists bool) { - v := m.platform +// Content returns the value of the "content" field in the mutation. +func (m *AgentRuleVersionMutation) Content() (r string, exists bool) { + v := m.content if v == nil { return } return *v, true } -// OldPlatform returns the old "platform" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// OldContent returns the old "content" field's value of the AgentRuleVersion entity. +// If the AgentRuleVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldPlatform(ctx context.Context) (v consts.GitPlatform, err error) { +func (m *AgentRuleVersionMutation) OldContent(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPlatform is only allowed on UpdateOne operations") + return v, errors.New("OldContent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPlatform requires an ID field in the mutation") + return v, errors.New("OldContent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPlatform: %w", err) + return v, fmt.Errorf("querying old value for OldContent: %w", err) } - return oldValue.Platform, nil + return oldValue.Content, nil } -// ResetPlatform resets all changes to the "platform" field. -func (m *GitIdentityMutation) ResetPlatform() { - m.platform = nil +// ResetContent resets all changes to the "content" field. +func (m *AgentRuleVersionMutation) ResetContent() { + m.content = nil } -// SetBaseURL sets the "base_url" field. -func (m *GitIdentityMutation) SetBaseURL(s string) { - m.base_url = &s +// SetCreatedAt sets the "created_at" field. +func (m *AgentRuleVersionMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// BaseURL returns the value of the "base_url" field in the mutation. -func (m *GitIdentityMutation) BaseURL() (r string, exists bool) { - v := m.base_url +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AgentRuleVersionMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldBaseURL returns the old "base_url" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the AgentRuleVersion entity. +// If the AgentRuleVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldBaseURL(ctx context.Context) (v string, err error) { +func (m *AgentRuleVersionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBaseURL is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBaseURL requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBaseURL: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.BaseURL, nil + return oldValue.CreatedAt, nil } -// ClearBaseURL clears the value of the "base_url" field. -func (m *GitIdentityMutation) ClearBaseURL() { - m.base_url = nil - m.clearedFields[gitidentity.FieldBaseURL] = struct{}{} +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *AgentRuleVersionMutation) ResetCreatedAt() { + m.created_at = nil } -// BaseURLCleared returns if the "base_url" field was cleared in this mutation. -func (m *GitIdentityMutation) BaseURLCleared() bool { - _, ok := m.clearedFields[gitidentity.FieldBaseURL] - return ok +// ClearRule clears the "rule" edge to the AgentRule entity. +func (m *AgentRuleVersionMutation) ClearRule() { + m.clearedrule = true + m.clearedFields[agentruleversion.FieldRuleID] = struct{}{} } -// ResetBaseURL resets all changes to the "base_url" field. -func (m *GitIdentityMutation) ResetBaseURL() { - m.base_url = nil - delete(m.clearedFields, gitidentity.FieldBaseURL) +// RuleCleared reports if the "rule" edge to the AgentRule entity was cleared. +func (m *AgentRuleVersionMutation) RuleCleared() bool { + return m.clearedrule } -// SetAccessToken sets the "access_token" field. -func (m *GitIdentityMutation) SetAccessToken(s string) { - m.access_token = &s +// RuleIDs returns the "rule" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// RuleID instead. It exists only for internal usage by the builders. +func (m *AgentRuleVersionMutation) RuleIDs() (ids []uuid.UUID) { + if id := m.rule; id != nil { + ids = append(ids, *id) + } + return } -// AccessToken returns the value of the "access_token" field in the mutation. -func (m *GitIdentityMutation) AccessToken() (r string, exists bool) { - v := m.access_token - if v == nil { - return - } - return *v, true +// ResetRule resets all changes to the "rule" edge. +func (m *AgentRuleVersionMutation) ResetRule() { + m.rule = nil + m.clearedrule = false } -// OldAccessToken returns the old "access_token" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldAccessToken(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAccessToken is only allowed on UpdateOne operations") +// Where appends a list predicates to the AgentRuleVersionMutation builder. +func (m *AgentRuleVersionMutation) Where(ps ...predicate.AgentRuleVersion) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the AgentRuleVersionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *AgentRuleVersionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.AgentRuleVersion, len(ps)) + for i := range ps { + p[i] = ps[i] } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAccessToken requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAccessToken: %w", err) - } - return oldValue.AccessToken, nil + m.Where(p...) } -// ClearAccessToken clears the value of the "access_token" field. -func (m *GitIdentityMutation) ClearAccessToken() { - m.access_token = nil - m.clearedFields[gitidentity.FieldAccessToken] = struct{}{} +// Op returns the operation name. +func (m *AgentRuleVersionMutation) Op() Op { + return m.op } -// AccessTokenCleared returns if the "access_token" field was cleared in this mutation. -func (m *GitIdentityMutation) AccessTokenCleared() bool { - _, ok := m.clearedFields[gitidentity.FieldAccessToken] - return ok +// SetOp allows setting the mutation operation. +func (m *AgentRuleVersionMutation) SetOp(op Op) { + m.op = op } -// ResetAccessToken resets all changes to the "access_token" field. -func (m *GitIdentityMutation) ResetAccessToken() { - m.access_token = nil - delete(m.clearedFields, gitidentity.FieldAccessToken) +// Type returns the node type of this mutation (AgentRuleVersion). +func (m *AgentRuleVersionMutation) Type() string { + return m.typ } -// SetUsername sets the "username" field. -func (m *GitIdentityMutation) SetUsername(s string) { - m.username = &s +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *AgentRuleVersionMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.rule != nil { + fields = append(fields, agentruleversion.FieldRuleID) + } + if m.version != nil { + fields = append(fields, agentruleversion.FieldVersion) + } + if m.content != nil { + fields = append(fields, agentruleversion.FieldContent) + } + if m.created_at != nil { + fields = append(fields, agentruleversion.FieldCreatedAt) + } + return fields } -// Username returns the value of the "username" field in the mutation. -func (m *GitIdentityMutation) Username() (r string, exists bool) { - v := m.username - if v == nil { - return +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *AgentRuleVersionMutation) Field(name string) (ent.Value, bool) { + switch name { + case agentruleversion.FieldRuleID: + return m.RuleID() + case agentruleversion.FieldVersion: + return m.Version() + case agentruleversion.FieldContent: + return m.Content() + case agentruleversion.FieldCreatedAt: + return m.CreatedAt() } - return *v, true + return nil, false } -// OldUsername returns the old "username" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldUsername(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUsername is only allowed on UpdateOne operations") +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *AgentRuleVersionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case agentruleversion.FieldRuleID: + return m.OldRuleID(ctx) + case agentruleversion.FieldVersion: + return m.OldVersion(ctx) + case agentruleversion.FieldContent: + return m.OldContent(ctx) + case agentruleversion.FieldCreatedAt: + return m.OldCreatedAt(ctx) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUsername requires an ID field in the mutation") + return nil, fmt.Errorf("unknown AgentRuleVersion field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AgentRuleVersionMutation) SetField(name string, value ent.Value) error { + switch name { + case agentruleversion.FieldRuleID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRuleID(v) + return nil + case agentruleversion.FieldVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersion(v) + return nil + case agentruleversion.FieldContent: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetContent(v) + return nil + case agentruleversion.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUsername: %w", err) + return fmt.Errorf("unknown AgentRuleVersion field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *AgentRuleVersionMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *AgentRuleVersionMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AgentRuleVersionMutation) AddField(name string, value ent.Value) error { + switch name { } - return oldValue.Username, nil + return fmt.Errorf("unknown AgentRuleVersion numeric field %s", name) } -// ClearUsername clears the value of the "username" field. -func (m *GitIdentityMutation) ClearUsername() { - m.username = nil - m.clearedFields[gitidentity.FieldUsername] = struct{}{} +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *AgentRuleVersionMutation) ClearedFields() []string { + return nil } -// UsernameCleared returns if the "username" field was cleared in this mutation. -func (m *GitIdentityMutation) UsernameCleared() bool { - _, ok := m.clearedFields[gitidentity.FieldUsername] +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *AgentRuleVersionMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] return ok } -// ResetUsername resets all changes to the "username" field. -func (m *GitIdentityMutation) ResetUsername() { - m.username = nil - delete(m.clearedFields, gitidentity.FieldUsername) +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *AgentRuleVersionMutation) ClearField(name string) error { + return fmt.Errorf("unknown AgentRuleVersion nullable field %s", name) } -// SetEmail sets the "email" field. -func (m *GitIdentityMutation) SetEmail(s string) { - m.email = &s +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *AgentRuleVersionMutation) ResetField(name string) error { + switch name { + case agentruleversion.FieldRuleID: + m.ResetRuleID() + return nil + case agentruleversion.FieldVersion: + m.ResetVersion() + return nil + case agentruleversion.FieldContent: + m.ResetContent() + return nil + case agentruleversion.FieldCreatedAt: + m.ResetCreatedAt() + return nil + } + return fmt.Errorf("unknown AgentRuleVersion field %s", name) } -// Email returns the value of the "email" field in the mutation. -func (m *GitIdentityMutation) Email() (r string, exists bool) { - v := m.email - if v == nil { - return +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *AgentRuleVersionMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.rule != nil { + edges = append(edges, agentruleversion.EdgeRule) } - return *v, true + return edges } -// OldEmail returns the old "email" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldEmail(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEmail is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEmail requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEmail: %w", err) +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *AgentRuleVersionMutation) AddedIDs(name string) []ent.Value { + switch name { + case agentruleversion.EdgeRule: + if id := m.rule; id != nil { + return []ent.Value{*id} + } } - return oldValue.Email, nil + return nil } -// ClearEmail clears the value of the "email" field. -func (m *GitIdentityMutation) ClearEmail() { - m.email = nil - m.clearedFields[gitidentity.FieldEmail] = struct{}{} +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *AgentRuleVersionMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges } -// EmailCleared returns if the "email" field was cleared in this mutation. -func (m *GitIdentityMutation) EmailCleared() bool { - _, ok := m.clearedFields[gitidentity.FieldEmail] - return ok +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *AgentRuleVersionMutation) RemovedIDs(name string) []ent.Value { + return nil } -// ResetEmail resets all changes to the "email" field. -func (m *GitIdentityMutation) ResetEmail() { - m.email = nil - delete(m.clearedFields, gitidentity.FieldEmail) +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *AgentRuleVersionMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedrule { + edges = append(edges, agentruleversion.EdgeRule) + } + return edges } -// SetInstallationID sets the "installation_id" field. -func (m *GitIdentityMutation) SetInstallationID(i int64) { - m.installation_id = &i - m.addinstallation_id = nil +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *AgentRuleVersionMutation) EdgeCleared(name string) bool { + switch name { + case agentruleversion.EdgeRule: + return m.clearedrule + } + return false } -// InstallationID returns the value of the "installation_id" field in the mutation. -func (m *GitIdentityMutation) InstallationID() (r int64, exists bool) { - v := m.installation_id - if v == nil { - return +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *AgentRuleVersionMutation) ClearEdge(name string) error { + switch name { + case agentruleversion.EdgeRule: + m.ClearRule() + return nil } - return *v, true + return fmt.Errorf("unknown AgentRuleVersion unique edge %s", name) } -// OldInstallationID returns the old "installation_id" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldInstallationID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInstallationID is only allowed on UpdateOne operations") +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *AgentRuleVersionMutation) ResetEdge(name string) error { + switch name { + case agentruleversion.EdgeRule: + m.ResetRule() + return nil } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInstallationID requires an ID field in the mutation") + return fmt.Errorf("unknown AgentRuleVersion edge %s", name) +} + +// AgentSkillMutation represents an operation that mutates the AgentSkill nodes in the graph. +type AgentSkillMutation struct { + config + op Op + typ string + id *uuid.UUID + name *string + description *string + scope_type *agentskill.ScopeType + scope_id *string + created_by *uuid.UUID + active_version_id *uuid.UUID + is_force_delivery *bool + is_orphan *bool + is_deleted *bool + enabled *bool + extension_package_id *string + admin_description *string + admin_tags *[]string + appendadmin_tags []string + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + repo *uuid.UUID + clearedrepo bool + versions map[uuid.UUID]struct{} + removedversions map[uuid.UUID]struct{} + clearedversions bool + done bool + oldValue func(context.Context) (*AgentSkill, error) + predicates []predicate.AgentSkill +} + +var _ ent.Mutation = (*AgentSkillMutation)(nil) + +// agentskillOption allows management of the mutation configuration using functional options. +type agentskillOption func(*AgentSkillMutation) + +// newAgentSkillMutation creates new mutation for the AgentSkill entity. +func newAgentSkillMutation(c config, op Op, opts ...agentskillOption) *AgentSkillMutation { + m := &AgentSkillMutation{ + config: c, + op: op, + typ: TypeAgentSkill, + clearedFields: make(map[string]struct{}), } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInstallationID: %w", err) + for _, opt := range opts { + opt(m) } - return oldValue.InstallationID, nil + return m } -// AddInstallationID adds i to the "installation_id" field. -func (m *GitIdentityMutation) AddInstallationID(i int64) { - if m.addinstallation_id != nil { - *m.addinstallation_id += i - } else { - m.addinstallation_id = &i +// withAgentSkillID sets the ID field of the mutation. +func withAgentSkillID(id uuid.UUID) agentskillOption { + return func(m *AgentSkillMutation) { + var ( + err error + once sync.Once + value *AgentSkill + ) + m.oldValue = func(ctx context.Context) (*AgentSkill, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().AgentSkill.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } } -// AddedInstallationID returns the value that was added to the "installation_id" field in this mutation. -func (m *GitIdentityMutation) AddedInstallationID() (r int64, exists bool) { - v := m.addinstallation_id - if v == nil { - return +// withAgentSkill sets the old AgentSkill of the mutation. +func withAgentSkill(node *AgentSkill) agentskillOption { + return func(m *AgentSkillMutation) { + m.oldValue = func(context.Context) (*AgentSkill, error) { + return node, nil + } + m.id = &node.ID } - return *v, true } -// ClearInstallationID clears the value of the "installation_id" field. -func (m *GitIdentityMutation) ClearInstallationID() { - m.installation_id = nil - m.addinstallation_id = nil - m.clearedFields[gitidentity.FieldInstallationID] = struct{}{} +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m AgentSkillMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// InstallationIDCleared returns if the "installation_id" field was cleared in this mutation. -func (m *GitIdentityMutation) InstallationIDCleared() bool { - _, ok := m.clearedFields[gitidentity.FieldInstallationID] - return ok +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m AgentSkillMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// ResetInstallationID resets all changes to the "installation_id" field. -func (m *GitIdentityMutation) ResetInstallationID() { - m.installation_id = nil - m.addinstallation_id = nil - delete(m.clearedFields, gitidentity.FieldInstallationID) +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of AgentSkill entities. +func (m *AgentSkillMutation) SetID(id uuid.UUID) { + m.id = &id } -// SetOrganizationID sets the "organization_id" field. -func (m *GitIdentityMutation) SetOrganizationID(s string) { - m.organization_id = &s +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *AgentSkillMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true } -// OrganizationID returns the value of the "organization_id" field in the mutation. -func (m *GitIdentityMutation) OrganizationID() (r string, exists bool) { - v := m.organization_id +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *AgentSkillMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().AgentSkill.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetRepoID sets the "repo_id" field. +func (m *AgentSkillMutation) SetRepoID(u uuid.UUID) { + m.repo = &u +} + +// RepoID returns the value of the "repo_id" field in the mutation. +func (m *AgentSkillMutation) RepoID() (r uuid.UUID, exists bool) { + v := m.repo if v == nil { return } return *v, true } -// OldOrganizationID returns the old "organization_id" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// OldRepoID returns the old "repo_id" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldOrganizationID(ctx context.Context) (v string, err error) { +func (m *AgentSkillMutation) OldRepoID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations") + return v, errors.New("OldRepoID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOrganizationID requires an ID field in the mutation") + return v, errors.New("OldRepoID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err) + return v, fmt.Errorf("querying old value for OldRepoID: %w", err) } - return oldValue.OrganizationID, nil -} - -// ClearOrganizationID clears the value of the "organization_id" field. -func (m *GitIdentityMutation) ClearOrganizationID() { - m.organization_id = nil - m.clearedFields[gitidentity.FieldOrganizationID] = struct{}{} -} - -// OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation. -func (m *GitIdentityMutation) OrganizationIDCleared() bool { - _, ok := m.clearedFields[gitidentity.FieldOrganizationID] - return ok + return oldValue.RepoID, nil } -// ResetOrganizationID resets all changes to the "organization_id" field. -func (m *GitIdentityMutation) ResetOrganizationID() { - m.organization_id = nil - delete(m.clearedFields, gitidentity.FieldOrganizationID) +// ResetRepoID resets all changes to the "repo_id" field. +func (m *AgentSkillMutation) ResetRepoID() { + m.repo = nil } -// SetRemark sets the "remark" field. -func (m *GitIdentityMutation) SetRemark(s string) { - m.remark = &s +// SetName sets the "name" field. +func (m *AgentSkillMutation) SetName(s string) { + m.name = &s } -// Remark returns the value of the "remark" field in the mutation. -func (m *GitIdentityMutation) Remark() (r string, exists bool) { - v := m.remark +// Name returns the value of the "name" field in the mutation. +func (m *AgentSkillMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldRemark returns the old "remark" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldRemark(ctx context.Context) (v string, err error) { +func (m *AgentSkillMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRemark is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRemark requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRemark: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.Remark, nil -} - -// ClearRemark clears the value of the "remark" field. -func (m *GitIdentityMutation) ClearRemark() { - m.remark = nil - m.clearedFields[gitidentity.FieldRemark] = struct{}{} -} - -// RemarkCleared returns if the "remark" field was cleared in this mutation. -func (m *GitIdentityMutation) RemarkCleared() bool { - _, ok := m.clearedFields[gitidentity.FieldRemark] - return ok + return oldValue.Name, nil } -// ResetRemark resets all changes to the "remark" field. -func (m *GitIdentityMutation) ResetRemark() { - m.remark = nil - delete(m.clearedFields, gitidentity.FieldRemark) +// ResetName resets all changes to the "name" field. +func (m *AgentSkillMutation) ResetName() { + m.name = nil } -// SetOauthRefreshToken sets the "oauth_refresh_token" field. -func (m *GitIdentityMutation) SetOauthRefreshToken(s string) { - m.oauth_refresh_token = &s +// SetDescription sets the "description" field. +func (m *AgentSkillMutation) SetDescription(s string) { + m.description = &s } -// OauthRefreshToken returns the value of the "oauth_refresh_token" field in the mutation. -func (m *GitIdentityMutation) OauthRefreshToken() (r string, exists bool) { - v := m.oauth_refresh_token +// Description returns the value of the "description" field in the mutation. +func (m *AgentSkillMutation) Description() (r string, exists bool) { + v := m.description if v == nil { return } return *v, true } -// OldOauthRefreshToken returns the old "oauth_refresh_token" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// OldDescription returns the old "description" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldOauthRefreshToken(ctx context.Context) (v string, err error) { +func (m *AgentSkillMutation) OldDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOauthRefreshToken is only allowed on UpdateOne operations") + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOauthRefreshToken requires an ID field in the mutation") + return v, errors.New("OldDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOauthRefreshToken: %w", err) + return v, fmt.Errorf("querying old value for OldDescription: %w", err) } - return oldValue.OauthRefreshToken, nil + return oldValue.Description, nil } -// ClearOauthRefreshToken clears the value of the "oauth_refresh_token" field. -func (m *GitIdentityMutation) ClearOauthRefreshToken() { - m.oauth_refresh_token = nil - m.clearedFields[gitidentity.FieldOauthRefreshToken] = struct{}{} +// ClearDescription clears the value of the "description" field. +func (m *AgentSkillMutation) ClearDescription() { + m.description = nil + m.clearedFields[agentskill.FieldDescription] = struct{}{} } -// OauthRefreshTokenCleared returns if the "oauth_refresh_token" field was cleared in this mutation. -func (m *GitIdentityMutation) OauthRefreshTokenCleared() bool { - _, ok := m.clearedFields[gitidentity.FieldOauthRefreshToken] +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *AgentSkillMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[agentskill.FieldDescription] return ok } -// ResetOauthRefreshToken resets all changes to the "oauth_refresh_token" field. -func (m *GitIdentityMutation) ResetOauthRefreshToken() { - m.oauth_refresh_token = nil - delete(m.clearedFields, gitidentity.FieldOauthRefreshToken) +// ResetDescription resets all changes to the "description" field. +func (m *AgentSkillMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, agentskill.FieldDescription) } -// SetOauthExpiresAt sets the "oauth_expires_at" field. -func (m *GitIdentityMutation) SetOauthExpiresAt(t time.Time) { - m.oauth_expires_at = &t +// SetScopeType sets the "scope_type" field. +func (m *AgentSkillMutation) SetScopeType(at agentskill.ScopeType) { + m.scope_type = &at } -// OauthExpiresAt returns the value of the "oauth_expires_at" field in the mutation. -func (m *GitIdentityMutation) OauthExpiresAt() (r time.Time, exists bool) { - v := m.oauth_expires_at +// ScopeType returns the value of the "scope_type" field in the mutation. +func (m *AgentSkillMutation) ScopeType() (r agentskill.ScopeType, exists bool) { + v := m.scope_type if v == nil { return } return *v, true } -// OldOauthExpiresAt returns the old "oauth_expires_at" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// OldScopeType returns the old "scope_type" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldOauthExpiresAt(ctx context.Context) (v *time.Time, err error) { +func (m *AgentSkillMutation) OldScopeType(ctx context.Context) (v agentskill.ScopeType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOauthExpiresAt is only allowed on UpdateOne operations") + return v, errors.New("OldScopeType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOauthExpiresAt requires an ID field in the mutation") + return v, errors.New("OldScopeType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOauthExpiresAt: %w", err) + return v, fmt.Errorf("querying old value for OldScopeType: %w", err) } - return oldValue.OauthExpiresAt, nil -} - -// ClearOauthExpiresAt clears the value of the "oauth_expires_at" field. -func (m *GitIdentityMutation) ClearOauthExpiresAt() { - m.oauth_expires_at = nil - m.clearedFields[gitidentity.FieldOauthExpiresAt] = struct{}{} -} - -// OauthExpiresAtCleared returns if the "oauth_expires_at" field was cleared in this mutation. -func (m *GitIdentityMutation) OauthExpiresAtCleared() bool { - _, ok := m.clearedFields[gitidentity.FieldOauthExpiresAt] - return ok + return oldValue.ScopeType, nil } -// ResetOauthExpiresAt resets all changes to the "oauth_expires_at" field. -func (m *GitIdentityMutation) ResetOauthExpiresAt() { - m.oauth_expires_at = nil - delete(m.clearedFields, gitidentity.FieldOauthExpiresAt) +// ResetScopeType resets all changes to the "scope_type" field. +func (m *AgentSkillMutation) ResetScopeType() { + m.scope_type = nil } -// SetCreatedAt sets the "created_at" field. -func (m *GitIdentityMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// SetScopeID sets the "scope_id" field. +func (m *AgentSkillMutation) SetScopeID(s string) { + m.scope_id = &s } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *GitIdentityMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// ScopeID returns the value of the "scope_id" field in the mutation. +func (m *AgentSkillMutation) ScopeID() (r string, exists bool) { + v := m.scope_id if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// OldScopeID returns the old "scope_id" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentSkillMutation) OldScopeID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldScopeID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + return v, errors.New("OldScopeID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldScopeID: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.ScopeID, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *GitIdentityMutation) ResetCreatedAt() { - m.created_at = nil +// ResetScopeID resets all changes to the "scope_id" field. +func (m *AgentSkillMutation) ResetScopeID() { + m.scope_id = nil } -// SetUpdatedAt sets the "updated_at" field. -func (m *GitIdentityMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t +// SetCreatedBy sets the "created_by" field. +func (m *AgentSkillMutation) SetCreatedBy(u uuid.UUID) { + m.created_by = &u } -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *GitIdentityMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at +// CreatedBy returns the value of the "created_by" field in the mutation. +func (m *AgentSkillMutation) CreatedBy() (r uuid.UUID, exists bool) { + v := m.created_by if v == nil { return } return *v, true } -// OldUpdatedAt returns the old "updated_at" field's value of the GitIdentity entity. -// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedBy returns the old "created_by" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitIdentityMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentSkillMutation) OldCreatedBy(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + return v, errors.New("OldCreatedBy requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err) } - return oldValue.UpdatedAt, nil + return oldValue.CreatedBy, nil } -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *GitIdentityMutation) ResetUpdatedAt() { - m.updated_at = nil +// ResetCreatedBy resets all changes to the "created_by" field. +func (m *AgentSkillMutation) ResetCreatedBy() { + m.created_by = nil } -// ClearUser clears the "user" edge to the User entity. -func (m *GitIdentityMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[gitidentity.FieldUserID] = struct{}{} +// SetActiveVersionID sets the "active_version_id" field. +func (m *AgentSkillMutation) SetActiveVersionID(u uuid.UUID) { + m.active_version_id = &u } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *GitIdentityMutation) UserCleared() bool { - return m.cleareduser +// ActiveVersionID returns the value of the "active_version_id" field in the mutation. +func (m *AgentSkillMutation) ActiveVersionID() (r uuid.UUID, exists bool) { + v := m.active_version_id + if v == nil { + return + } + return *v, true } -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *GitIdentityMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { - ids = append(ids, *id) +// OldActiveVersionID returns the old "active_version_id" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillMutation) OldActiveVersionID(ctx context.Context) (v *uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldActiveVersionID is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldActiveVersionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldActiveVersionID: %w", err) + } + return oldValue.ActiveVersionID, nil } -// ResetUser resets all changes to the "user" edge. -func (m *GitIdentityMutation) ResetUser() { - m.user = nil - m.cleareduser = false +// ClearActiveVersionID clears the value of the "active_version_id" field. +func (m *AgentSkillMutation) ClearActiveVersionID() { + m.active_version_id = nil + m.clearedFields[agentskill.FieldActiveVersionID] = struct{}{} } -// AddProjectIDs adds the "projects" edge to the Project entity by ids. -func (m *GitIdentityMutation) AddProjectIDs(ids ...uuid.UUID) { - if m.projects == nil { - m.projects = make(map[uuid.UUID]struct{}) +// ActiveVersionIDCleared returns if the "active_version_id" field was cleared in this mutation. +func (m *AgentSkillMutation) ActiveVersionIDCleared() bool { + _, ok := m.clearedFields[agentskill.FieldActiveVersionID] + return ok +} + +// ResetActiveVersionID resets all changes to the "active_version_id" field. +func (m *AgentSkillMutation) ResetActiveVersionID() { + m.active_version_id = nil + delete(m.clearedFields, agentskill.FieldActiveVersionID) +} + +// SetIsForceDelivery sets the "is_force_delivery" field. +func (m *AgentSkillMutation) SetIsForceDelivery(b bool) { + m.is_force_delivery = &b +} + +// IsForceDelivery returns the value of the "is_force_delivery" field in the mutation. +func (m *AgentSkillMutation) IsForceDelivery() (r bool, exists bool) { + v := m.is_force_delivery + if v == nil { + return } - for i := range ids { - m.projects[ids[i]] = struct{}{} + return *v, true +} + +// OldIsForceDelivery returns the old "is_force_delivery" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillMutation) OldIsForceDelivery(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsForceDelivery is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsForceDelivery requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsForceDelivery: %w", err) } + return oldValue.IsForceDelivery, nil } -// ClearProjects clears the "projects" edge to the Project entity. -func (m *GitIdentityMutation) ClearProjects() { - m.clearedprojects = true +// ResetIsForceDelivery resets all changes to the "is_force_delivery" field. +func (m *AgentSkillMutation) ResetIsForceDelivery() { + m.is_force_delivery = nil } -// ProjectsCleared reports if the "projects" edge to the Project entity was cleared. -func (m *GitIdentityMutation) ProjectsCleared() bool { - return m.clearedprojects +// SetIsOrphan sets the "is_orphan" field. +func (m *AgentSkillMutation) SetIsOrphan(b bool) { + m.is_orphan = &b } -// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs. -func (m *GitIdentityMutation) RemoveProjectIDs(ids ...uuid.UUID) { - if m.removedprojects == nil { - m.removedprojects = make(map[uuid.UUID]struct{}) +// IsOrphan returns the value of the "is_orphan" field in the mutation. +func (m *AgentSkillMutation) IsOrphan() (r bool, exists bool) { + v := m.is_orphan + if v == nil { + return } - for i := range ids { - delete(m.projects, ids[i]) - m.removedprojects[ids[i]] = struct{}{} + return *v, true +} + +// OldIsOrphan returns the old "is_orphan" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillMutation) OldIsOrphan(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsOrphan is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsOrphan requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsOrphan: %w", err) } + return oldValue.IsOrphan, nil } -// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity. -func (m *GitIdentityMutation) RemovedProjectsIDs() (ids []uuid.UUID) { - for id := range m.removedprojects { - ids = append(ids, id) +// ResetIsOrphan resets all changes to the "is_orphan" field. +func (m *AgentSkillMutation) ResetIsOrphan() { + m.is_orphan = nil +} + +// SetIsDeleted sets the "is_deleted" field. +func (m *AgentSkillMutation) SetIsDeleted(b bool) { + m.is_deleted = &b +} + +// IsDeleted returns the value of the "is_deleted" field in the mutation. +func (m *AgentSkillMutation) IsDeleted() (r bool, exists bool) { + v := m.is_deleted + if v == nil { + return } - return + return *v, true } -// ProjectsIDs returns the "projects" edge IDs in the mutation. -func (m *GitIdentityMutation) ProjectsIDs() (ids []uuid.UUID) { - for id := range m.projects { - ids = append(ids, id) +// OldIsDeleted returns the old "is_deleted" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillMutation) OldIsDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsDeleted is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsDeleted: %w", err) + } + return oldValue.IsDeleted, nil } -// ResetProjects resets all changes to the "projects" edge. -func (m *GitIdentityMutation) ResetProjects() { - m.projects = nil - m.clearedprojects = false - m.removedprojects = nil +// ResetIsDeleted resets all changes to the "is_deleted" field. +func (m *AgentSkillMutation) ResetIsDeleted() { + m.is_deleted = nil } -// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids. -func (m *GitIdentityMutation) AddProjectTaskIDs(ids ...uuid.UUID) { - if m.project_tasks == nil { - m.project_tasks = make(map[uuid.UUID]struct{}) +// SetEnabled sets the "enabled" field. +func (m *AgentSkillMutation) SetEnabled(b bool) { + m.enabled = &b +} + +// Enabled returns the value of the "enabled" field in the mutation. +func (m *AgentSkillMutation) Enabled() (r bool, exists bool) { + v := m.enabled + if v == nil { + return } - for i := range ids { - m.project_tasks[ids[i]] = struct{}{} + return *v, true +} + +// OldEnabled returns the old "enabled" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillMutation) OldEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEnabled: %w", err) } + return oldValue.Enabled, nil } -// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity. -func (m *GitIdentityMutation) ClearProjectTasks() { - m.clearedproject_tasks = true +// ResetEnabled resets all changes to the "enabled" field. +func (m *AgentSkillMutation) ResetEnabled() { + m.enabled = nil } -// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared. -func (m *GitIdentityMutation) ProjectTasksCleared() bool { - return m.clearedproject_tasks +// SetExtensionPackageID sets the "extension_package_id" field. +func (m *AgentSkillMutation) SetExtensionPackageID(s string) { + m.extension_package_id = &s } -// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs. -func (m *GitIdentityMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) { - if m.removedproject_tasks == nil { - m.removedproject_tasks = make(map[uuid.UUID]struct{}) +// ExtensionPackageID returns the value of the "extension_package_id" field in the mutation. +func (m *AgentSkillMutation) ExtensionPackageID() (r string, exists bool) { + v := m.extension_package_id + if v == nil { + return } - for i := range ids { - delete(m.project_tasks, ids[i]) - m.removedproject_tasks[ids[i]] = struct{}{} + return *v, true +} + +// OldExtensionPackageID returns the old "extension_package_id" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillMutation) OldExtensionPackageID(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExtensionPackageID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExtensionPackageID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExtensionPackageID: %w", err) } + return oldValue.ExtensionPackageID, nil } -// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity. -func (m *GitIdentityMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) { - for id := range m.removedproject_tasks { - ids = append(ids, id) +// ClearExtensionPackageID clears the value of the "extension_package_id" field. +func (m *AgentSkillMutation) ClearExtensionPackageID() { + m.extension_package_id = nil + m.clearedFields[agentskill.FieldExtensionPackageID] = struct{}{} +} + +// ExtensionPackageIDCleared returns if the "extension_package_id" field was cleared in this mutation. +func (m *AgentSkillMutation) ExtensionPackageIDCleared() bool { + _, ok := m.clearedFields[agentskill.FieldExtensionPackageID] + return ok +} + +// ResetExtensionPackageID resets all changes to the "extension_package_id" field. +func (m *AgentSkillMutation) ResetExtensionPackageID() { + m.extension_package_id = nil + delete(m.clearedFields, agentskill.FieldExtensionPackageID) +} + +// SetAdminDescription sets the "admin_description" field. +func (m *AgentSkillMutation) SetAdminDescription(s string) { + m.admin_description = &s +} + +// AdminDescription returns the value of the "admin_description" field in the mutation. +func (m *AgentSkillMutation) AdminDescription() (r string, exists bool) { + v := m.admin_description + if v == nil { + return } - return + return *v, true } -// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation. -func (m *GitIdentityMutation) ProjectTasksIDs() (ids []uuid.UUID) { - for id := range m.project_tasks { - ids = append(ids, id) +// OldAdminDescription returns the old "admin_description" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillMutation) OldAdminDescription(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAdminDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAdminDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAdminDescription: %w", err) + } + return oldValue.AdminDescription, nil +} + +// ClearAdminDescription clears the value of the "admin_description" field. +func (m *AgentSkillMutation) ClearAdminDescription() { + m.admin_description = nil + m.clearedFields[agentskill.FieldAdminDescription] = struct{}{} +} + +// AdminDescriptionCleared returns if the "admin_description" field was cleared in this mutation. +func (m *AgentSkillMutation) AdminDescriptionCleared() bool { + _, ok := m.clearedFields[agentskill.FieldAdminDescription] + return ok +} + +// ResetAdminDescription resets all changes to the "admin_description" field. +func (m *AgentSkillMutation) ResetAdminDescription() { + m.admin_description = nil + delete(m.clearedFields, agentskill.FieldAdminDescription) +} + +// SetAdminTags sets the "admin_tags" field. +func (m *AgentSkillMutation) SetAdminTags(s []string) { + m.admin_tags = &s + m.appendadmin_tags = nil +} + +// AdminTags returns the value of the "admin_tags" field in the mutation. +func (m *AgentSkillMutation) AdminTags() (r []string, exists bool) { + v := m.admin_tags + if v == nil { + return + } + return *v, true +} + +// OldAdminTags returns the old "admin_tags" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillMutation) OldAdminTags(ctx context.Context) (v []string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAdminTags is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAdminTags requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAdminTags: %w", err) + } + return oldValue.AdminTags, nil +} + +// AppendAdminTags adds s to the "admin_tags" field. +func (m *AgentSkillMutation) AppendAdminTags(s []string) { + m.appendadmin_tags = append(m.appendadmin_tags, s...) +} + +// AppendedAdminTags returns the list of values that were appended to the "admin_tags" field in this mutation. +func (m *AgentSkillMutation) AppendedAdminTags() ([]string, bool) { + if len(m.appendadmin_tags) == 0 { + return nil, false + } + return m.appendadmin_tags, true +} + +// ClearAdminTags clears the value of the "admin_tags" field. +func (m *AgentSkillMutation) ClearAdminTags() { + m.admin_tags = nil + m.appendadmin_tags = nil + m.clearedFields[agentskill.FieldAdminTags] = struct{}{} +} + +// AdminTagsCleared returns if the "admin_tags" field was cleared in this mutation. +func (m *AgentSkillMutation) AdminTagsCleared() bool { + _, ok := m.clearedFields[agentskill.FieldAdminTags] + return ok +} + +// ResetAdminTags resets all changes to the "admin_tags" field. +func (m *AgentSkillMutation) ResetAdminTags() { + m.admin_tags = nil + m.appendadmin_tags = nil + delete(m.clearedFields, agentskill.FieldAdminTags) +} + +// SetCreatedAt sets the "created_at" field. +func (m *AgentSkillMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AgentSkillMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *AgentSkillMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *AgentSkillMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *AgentSkillMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the AgentSkill entity. +// If the AgentSkill object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *AgentSkillMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// ClearRepo clears the "repo" edge to the AgentSkillRepo entity. +func (m *AgentSkillMutation) ClearRepo() { + m.clearedrepo = true + m.clearedFields[agentskill.FieldRepoID] = struct{}{} +} + +// RepoCleared reports if the "repo" edge to the AgentSkillRepo entity was cleared. +func (m *AgentSkillMutation) RepoCleared() bool { + return m.clearedrepo +} + +// RepoIDs returns the "repo" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// RepoID instead. It exists only for internal usage by the builders. +func (m *AgentSkillMutation) RepoIDs() (ids []uuid.UUID) { + if id := m.repo; id != nil { + ids = append(ids, *id) } return } -// ResetProjectTasks resets all changes to the "project_tasks" edge. -func (m *GitIdentityMutation) ResetProjectTasks() { - m.project_tasks = nil - m.clearedproject_tasks = false - m.removedproject_tasks = nil +// ResetRepo resets all changes to the "repo" edge. +func (m *AgentSkillMutation) ResetRepo() { + m.repo = nil + m.clearedrepo = false } -// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids. -func (m *GitIdentityMutation) AddVMIDs(ids ...string) { - if m.vms == nil { - m.vms = make(map[string]struct{}) +// AddVersionIDs adds the "versions" edge to the AgentSkillVersion entity by ids. +func (m *AgentSkillMutation) AddVersionIDs(ids ...uuid.UUID) { + if m.versions == nil { + m.versions = make(map[uuid.UUID]struct{}) } for i := range ids { - m.vms[ids[i]] = struct{}{} + m.versions[ids[i]] = struct{}{} } } -// ClearVms clears the "vms" edge to the VirtualMachine entity. -func (m *GitIdentityMutation) ClearVms() { - m.clearedvms = true +// ClearVersions clears the "versions" edge to the AgentSkillVersion entity. +func (m *AgentSkillMutation) ClearVersions() { + m.clearedversions = true } -// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared. -func (m *GitIdentityMutation) VmsCleared() bool { - return m.clearedvms +// VersionsCleared reports if the "versions" edge to the AgentSkillVersion entity was cleared. +func (m *AgentSkillMutation) VersionsCleared() bool { + return m.clearedversions } -// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs. -func (m *GitIdentityMutation) RemoveVMIDs(ids ...string) { - if m.removedvms == nil { - m.removedvms = make(map[string]struct{}) +// RemoveVersionIDs removes the "versions" edge to the AgentSkillVersion entity by IDs. +func (m *AgentSkillMutation) RemoveVersionIDs(ids ...uuid.UUID) { + if m.removedversions == nil { + m.removedversions = make(map[uuid.UUID]struct{}) } for i := range ids { - delete(m.vms, ids[i]) - m.removedvms[ids[i]] = struct{}{} + delete(m.versions, ids[i]) + m.removedversions[ids[i]] = struct{}{} } } -// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity. -func (m *GitIdentityMutation) RemovedVmsIDs() (ids []string) { - for id := range m.removedvms { +// RemovedVersions returns the removed IDs of the "versions" edge to the AgentSkillVersion entity. +func (m *AgentSkillMutation) RemovedVersionsIDs() (ids []uuid.UUID) { + for id := range m.removedversions { ids = append(ids, id) } return } -// VmsIDs returns the "vms" edge IDs in the mutation. -func (m *GitIdentityMutation) VmsIDs() (ids []string) { - for id := range m.vms { +// VersionsIDs returns the "versions" edge IDs in the mutation. +func (m *AgentSkillMutation) VersionsIDs() (ids []uuid.UUID) { + for id := range m.versions { ids = append(ids, id) } return } -// ResetVms resets all changes to the "vms" edge. -func (m *GitIdentityMutation) ResetVms() { - m.vms = nil - m.clearedvms = false - m.removedvms = nil +// ResetVersions resets all changes to the "versions" edge. +func (m *AgentSkillMutation) ResetVersions() { + m.versions = nil + m.clearedversions = false + m.removedversions = nil } -// Where appends a list predicates to the GitIdentityMutation builder. -func (m *GitIdentityMutation) Where(ps ...predicate.GitIdentity) { +// Where appends a list predicates to the AgentSkillMutation builder. +func (m *AgentSkillMutation) Where(ps ...predicate.AgentSkill) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the GitIdentityMutation builder. Using this method, +// WhereP appends storage-level predicates to the AgentSkillMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *GitIdentityMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.GitIdentity, len(ps)) +func (m *AgentSkillMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.AgentSkill, len(ps)) for i := range ps { p[i] = ps[i] } @@ -4191,66 +5800,72 @@ func (m *GitIdentityMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *GitIdentityMutation) Op() Op { +func (m *AgentSkillMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *GitIdentityMutation) SetOp(op Op) { +func (m *AgentSkillMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (GitIdentity). -func (m *GitIdentityMutation) Type() string { +// Type returns the node type of this mutation (AgentSkill). +func (m *AgentSkillMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *GitIdentityMutation) Fields() []string { - fields := make([]string, 0, 14) - if m.deleted_at != nil { - fields = append(fields, gitidentity.FieldDeletedAt) +func (m *AgentSkillMutation) Fields() []string { + fields := make([]string, 0, 16) + if m.repo != nil { + fields = append(fields, agentskill.FieldRepoID) } - if m.user != nil { - fields = append(fields, gitidentity.FieldUserID) + if m.name != nil { + fields = append(fields, agentskill.FieldName) } - if m.platform != nil { - fields = append(fields, gitidentity.FieldPlatform) + if m.description != nil { + fields = append(fields, agentskill.FieldDescription) } - if m.base_url != nil { - fields = append(fields, gitidentity.FieldBaseURL) + if m.scope_type != nil { + fields = append(fields, agentskill.FieldScopeType) } - if m.access_token != nil { - fields = append(fields, gitidentity.FieldAccessToken) + if m.scope_id != nil { + fields = append(fields, agentskill.FieldScopeID) } - if m.username != nil { - fields = append(fields, gitidentity.FieldUsername) + if m.created_by != nil { + fields = append(fields, agentskill.FieldCreatedBy) } - if m.email != nil { - fields = append(fields, gitidentity.FieldEmail) + if m.active_version_id != nil { + fields = append(fields, agentskill.FieldActiveVersionID) } - if m.installation_id != nil { - fields = append(fields, gitidentity.FieldInstallationID) + if m.is_force_delivery != nil { + fields = append(fields, agentskill.FieldIsForceDelivery) } - if m.organization_id != nil { - fields = append(fields, gitidentity.FieldOrganizationID) + if m.is_orphan != nil { + fields = append(fields, agentskill.FieldIsOrphan) } - if m.remark != nil { - fields = append(fields, gitidentity.FieldRemark) + if m.is_deleted != nil { + fields = append(fields, agentskill.FieldIsDeleted) } - if m.oauth_refresh_token != nil { - fields = append(fields, gitidentity.FieldOauthRefreshToken) + if m.enabled != nil { + fields = append(fields, agentskill.FieldEnabled) } - if m.oauth_expires_at != nil { - fields = append(fields, gitidentity.FieldOauthExpiresAt) + if m.extension_package_id != nil { + fields = append(fields, agentskill.FieldExtensionPackageID) + } + if m.admin_description != nil { + fields = append(fields, agentskill.FieldAdminDescription) + } + if m.admin_tags != nil { + fields = append(fields, agentskill.FieldAdminTags) } if m.created_at != nil { - fields = append(fields, gitidentity.FieldCreatedAt) + fields = append(fields, agentskill.FieldCreatedAt) } if m.updated_at != nil { - fields = append(fields, gitidentity.FieldUpdatedAt) + fields = append(fields, agentskill.FieldUpdatedAt) } return fields } @@ -4258,35 +5873,39 @@ func (m *GitIdentityMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *GitIdentityMutation) Field(name string) (ent.Value, bool) { +func (m *AgentSkillMutation) Field(name string) (ent.Value, bool) { switch name { - case gitidentity.FieldDeletedAt: - return m.DeletedAt() - case gitidentity.FieldUserID: - return m.UserID() - case gitidentity.FieldPlatform: - return m.Platform() - case gitidentity.FieldBaseURL: - return m.BaseURL() - case gitidentity.FieldAccessToken: - return m.AccessToken() - case gitidentity.FieldUsername: - return m.Username() - case gitidentity.FieldEmail: - return m.Email() - case gitidentity.FieldInstallationID: - return m.InstallationID() - case gitidentity.FieldOrganizationID: - return m.OrganizationID() - case gitidentity.FieldRemark: - return m.Remark() - case gitidentity.FieldOauthRefreshToken: - return m.OauthRefreshToken() - case gitidentity.FieldOauthExpiresAt: - return m.OauthExpiresAt() - case gitidentity.FieldCreatedAt: + case agentskill.FieldRepoID: + return m.RepoID() + case agentskill.FieldName: + return m.Name() + case agentskill.FieldDescription: + return m.Description() + case agentskill.FieldScopeType: + return m.ScopeType() + case agentskill.FieldScopeID: + return m.ScopeID() + case agentskill.FieldCreatedBy: + return m.CreatedBy() + case agentskill.FieldActiveVersionID: + return m.ActiveVersionID() + case agentskill.FieldIsForceDelivery: + return m.IsForceDelivery() + case agentskill.FieldIsOrphan: + return m.IsOrphan() + case agentskill.FieldIsDeleted: + return m.IsDeleted() + case agentskill.FieldEnabled: + return m.Enabled() + case agentskill.FieldExtensionPackageID: + return m.ExtensionPackageID() + case agentskill.FieldAdminDescription: + return m.AdminDescription() + case agentskill.FieldAdminTags: + return m.AdminTags() + case agentskill.FieldCreatedAt: return m.CreatedAt() - case gitidentity.FieldUpdatedAt: + case agentskill.FieldUpdatedAt: return m.UpdatedAt() } return nil, false @@ -4295,137 +5914,155 @@ func (m *GitIdentityMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *GitIdentityMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *AgentSkillMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case gitidentity.FieldDeletedAt: - return m.OldDeletedAt(ctx) - case gitidentity.FieldUserID: - return m.OldUserID(ctx) - case gitidentity.FieldPlatform: - return m.OldPlatform(ctx) - case gitidentity.FieldBaseURL: - return m.OldBaseURL(ctx) - case gitidentity.FieldAccessToken: - return m.OldAccessToken(ctx) - case gitidentity.FieldUsername: - return m.OldUsername(ctx) - case gitidentity.FieldEmail: - return m.OldEmail(ctx) - case gitidentity.FieldInstallationID: - return m.OldInstallationID(ctx) - case gitidentity.FieldOrganizationID: - return m.OldOrganizationID(ctx) - case gitidentity.FieldRemark: - return m.OldRemark(ctx) - case gitidentity.FieldOauthRefreshToken: - return m.OldOauthRefreshToken(ctx) - case gitidentity.FieldOauthExpiresAt: - return m.OldOauthExpiresAt(ctx) - case gitidentity.FieldCreatedAt: + case agentskill.FieldRepoID: + return m.OldRepoID(ctx) + case agentskill.FieldName: + return m.OldName(ctx) + case agentskill.FieldDescription: + return m.OldDescription(ctx) + case agentskill.FieldScopeType: + return m.OldScopeType(ctx) + case agentskill.FieldScopeID: + return m.OldScopeID(ctx) + case agentskill.FieldCreatedBy: + return m.OldCreatedBy(ctx) + case agentskill.FieldActiveVersionID: + return m.OldActiveVersionID(ctx) + case agentskill.FieldIsForceDelivery: + return m.OldIsForceDelivery(ctx) + case agentskill.FieldIsOrphan: + return m.OldIsOrphan(ctx) + case agentskill.FieldIsDeleted: + return m.OldIsDeleted(ctx) + case agentskill.FieldEnabled: + return m.OldEnabled(ctx) + case agentskill.FieldExtensionPackageID: + return m.OldExtensionPackageID(ctx) + case agentskill.FieldAdminDescription: + return m.OldAdminDescription(ctx) + case agentskill.FieldAdminTags: + return m.OldAdminTags(ctx) + case agentskill.FieldCreatedAt: return m.OldCreatedAt(ctx) - case gitidentity.FieldUpdatedAt: + case agentskill.FieldUpdatedAt: return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown GitIdentity field %s", name) + return nil, fmt.Errorf("unknown AgentSkill field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *GitIdentityMutation) SetField(name string, value ent.Value) error { +func (m *AgentSkillMutation) SetField(name string, value ent.Value) error { switch name { - case gitidentity.FieldDeletedAt: - v, ok := value.(time.Time) + case agentskill.FieldRepoID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDeletedAt(v) + m.SetRepoID(v) return nil - case gitidentity.FieldUserID: - v, ok := value.(uuid.UUID) + case agentskill.FieldName: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) + m.SetName(v) return nil - case gitidentity.FieldPlatform: - v, ok := value.(consts.GitPlatform) + case agentskill.FieldDescription: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPlatform(v) + m.SetDescription(v) return nil - case gitidentity.FieldBaseURL: - v, ok := value.(string) + case agentskill.FieldScopeType: + v, ok := value.(agentskill.ScopeType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetBaseURL(v) + m.SetScopeType(v) return nil - case gitidentity.FieldAccessToken: + case agentskill.FieldScopeID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetAccessToken(v) + m.SetScopeID(v) return nil - case gitidentity.FieldUsername: - v, ok := value.(string) + case agentskill.FieldCreatedBy: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUsername(v) + m.SetCreatedBy(v) return nil - case gitidentity.FieldEmail: - v, ok := value.(string) + case agentskill.FieldActiveVersionID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetEmail(v) + m.SetActiveVersionID(v) return nil - case gitidentity.FieldInstallationID: - v, ok := value.(int64) + case agentskill.FieldIsForceDelivery: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInstallationID(v) + m.SetIsForceDelivery(v) return nil - case gitidentity.FieldOrganizationID: - v, ok := value.(string) + case agentskill.FieldIsOrphan: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOrganizationID(v) + m.SetIsOrphan(v) return nil - case gitidentity.FieldRemark: - v, ok := value.(string) + case agentskill.FieldIsDeleted: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRemark(v) + m.SetIsDeleted(v) return nil - case gitidentity.FieldOauthRefreshToken: - v, ok := value.(string) + case agentskill.FieldEnabled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOauthRefreshToken(v) + m.SetEnabled(v) return nil - case gitidentity.FieldOauthExpiresAt: - v, ok := value.(time.Time) + case agentskill.FieldExtensionPackageID: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOauthExpiresAt(v) + m.SetExtensionPackageID(v) return nil - case gitidentity.FieldCreatedAt: - v, ok := value.(time.Time) + case agentskill.FieldAdminDescription: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreatedAt(v) + m.SetAdminDescription(v) return nil - case gitidentity.FieldUpdatedAt: + case agentskill.FieldAdminTags: + v, ok := value.([]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAdminTags(v) + return nil + case agentskill.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case agentskill.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) @@ -4433,219 +6070,162 @@ func (m *GitIdentityMutation) SetField(name string, value ent.Value) error { m.SetUpdatedAt(v) return nil } - return fmt.Errorf("unknown GitIdentity field %s", name) + return fmt.Errorf("unknown AgentSkill field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *GitIdentityMutation) AddedFields() []string { - var fields []string - if m.addinstallation_id != nil { - fields = append(fields, gitidentity.FieldInstallationID) - } - return fields +func (m *AgentSkillMutation) AddedFields() []string { + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *GitIdentityMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case gitidentity.FieldInstallationID: - return m.AddedInstallationID() - } +func (m *AgentSkillMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *GitIdentityMutation) AddField(name string, value ent.Value) error { +func (m *AgentSkillMutation) AddField(name string, value ent.Value) error { switch name { - case gitidentity.FieldInstallationID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddInstallationID(v) - return nil } - return fmt.Errorf("unknown GitIdentity numeric field %s", name) + return fmt.Errorf("unknown AgentSkill numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *GitIdentityMutation) ClearedFields() []string { +func (m *AgentSkillMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(gitidentity.FieldDeletedAt) { - fields = append(fields, gitidentity.FieldDeletedAt) - } - if m.FieldCleared(gitidentity.FieldBaseURL) { - fields = append(fields, gitidentity.FieldBaseURL) - } - if m.FieldCleared(gitidentity.FieldAccessToken) { - fields = append(fields, gitidentity.FieldAccessToken) - } - if m.FieldCleared(gitidentity.FieldUsername) { - fields = append(fields, gitidentity.FieldUsername) - } - if m.FieldCleared(gitidentity.FieldEmail) { - fields = append(fields, gitidentity.FieldEmail) + if m.FieldCleared(agentskill.FieldDescription) { + fields = append(fields, agentskill.FieldDescription) } - if m.FieldCleared(gitidentity.FieldInstallationID) { - fields = append(fields, gitidentity.FieldInstallationID) - } - if m.FieldCleared(gitidentity.FieldOrganizationID) { - fields = append(fields, gitidentity.FieldOrganizationID) + if m.FieldCleared(agentskill.FieldActiveVersionID) { + fields = append(fields, agentskill.FieldActiveVersionID) } - if m.FieldCleared(gitidentity.FieldRemark) { - fields = append(fields, gitidentity.FieldRemark) + if m.FieldCleared(agentskill.FieldExtensionPackageID) { + fields = append(fields, agentskill.FieldExtensionPackageID) } - if m.FieldCleared(gitidentity.FieldOauthRefreshToken) { - fields = append(fields, gitidentity.FieldOauthRefreshToken) + if m.FieldCleared(agentskill.FieldAdminDescription) { + fields = append(fields, agentskill.FieldAdminDescription) } - if m.FieldCleared(gitidentity.FieldOauthExpiresAt) { - fields = append(fields, gitidentity.FieldOauthExpiresAt) + if m.FieldCleared(agentskill.FieldAdminTags) { + fields = append(fields, agentskill.FieldAdminTags) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *GitIdentityMutation) FieldCleared(name string) bool { +func (m *AgentSkillMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *GitIdentityMutation) ClearField(name string) error { +func (m *AgentSkillMutation) ClearField(name string) error { switch name { - case gitidentity.FieldDeletedAt: - m.ClearDeletedAt() - return nil - case gitidentity.FieldBaseURL: - m.ClearBaseURL() - return nil - case gitidentity.FieldAccessToken: - m.ClearAccessToken() - return nil - case gitidentity.FieldUsername: - m.ClearUsername() - return nil - case gitidentity.FieldEmail: - m.ClearEmail() - return nil - case gitidentity.FieldInstallationID: - m.ClearInstallationID() + case agentskill.FieldDescription: + m.ClearDescription() return nil - case gitidentity.FieldOrganizationID: - m.ClearOrganizationID() + case agentskill.FieldActiveVersionID: + m.ClearActiveVersionID() return nil - case gitidentity.FieldRemark: - m.ClearRemark() + case agentskill.FieldExtensionPackageID: + m.ClearExtensionPackageID() return nil - case gitidentity.FieldOauthRefreshToken: - m.ClearOauthRefreshToken() + case agentskill.FieldAdminDescription: + m.ClearAdminDescription() return nil - case gitidentity.FieldOauthExpiresAt: - m.ClearOauthExpiresAt() + case agentskill.FieldAdminTags: + m.ClearAdminTags() return nil } - return fmt.Errorf("unknown GitIdentity nullable field %s", name) + return fmt.Errorf("unknown AgentSkill nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *GitIdentityMutation) ResetField(name string) error { +func (m *AgentSkillMutation) ResetField(name string) error { switch name { - case gitidentity.FieldDeletedAt: - m.ResetDeletedAt() + case agentskill.FieldRepoID: + m.ResetRepoID() return nil - case gitidentity.FieldUserID: - m.ResetUserID() + case agentskill.FieldName: + m.ResetName() return nil - case gitidentity.FieldPlatform: - m.ResetPlatform() + case agentskill.FieldDescription: + m.ResetDescription() return nil - case gitidentity.FieldBaseURL: - m.ResetBaseURL() + case agentskill.FieldScopeType: + m.ResetScopeType() return nil - case gitidentity.FieldAccessToken: - m.ResetAccessToken() + case agentskill.FieldScopeID: + m.ResetScopeID() return nil - case gitidentity.FieldUsername: - m.ResetUsername() + case agentskill.FieldCreatedBy: + m.ResetCreatedBy() return nil - case gitidentity.FieldEmail: - m.ResetEmail() + case agentskill.FieldActiveVersionID: + m.ResetActiveVersionID() return nil - case gitidentity.FieldInstallationID: - m.ResetInstallationID() + case agentskill.FieldIsForceDelivery: + m.ResetIsForceDelivery() return nil - case gitidentity.FieldOrganizationID: - m.ResetOrganizationID() + case agentskill.FieldIsOrphan: + m.ResetIsOrphan() return nil - case gitidentity.FieldRemark: - m.ResetRemark() + case agentskill.FieldIsDeleted: + m.ResetIsDeleted() return nil - case gitidentity.FieldOauthRefreshToken: - m.ResetOauthRefreshToken() + case agentskill.FieldEnabled: + m.ResetEnabled() return nil - case gitidentity.FieldOauthExpiresAt: - m.ResetOauthExpiresAt() + case agentskill.FieldExtensionPackageID: + m.ResetExtensionPackageID() return nil - case gitidentity.FieldCreatedAt: + case agentskill.FieldAdminDescription: + m.ResetAdminDescription() + return nil + case agentskill.FieldAdminTags: + m.ResetAdminTags() + return nil + case agentskill.FieldCreatedAt: m.ResetCreatedAt() return nil - case gitidentity.FieldUpdatedAt: + case agentskill.FieldUpdatedAt: m.ResetUpdatedAt() return nil } - return fmt.Errorf("unknown GitIdentity field %s", name) + return fmt.Errorf("unknown AgentSkill field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *GitIdentityMutation) AddedEdges() []string { - edges := make([]string, 0, 4) - if m.user != nil { - edges = append(edges, gitidentity.EdgeUser) - } - if m.projects != nil { - edges = append(edges, gitidentity.EdgeProjects) - } - if m.project_tasks != nil { - edges = append(edges, gitidentity.EdgeProjectTasks) +func (m *AgentSkillMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.repo != nil { + edges = append(edges, agentskill.EdgeRepo) } - if m.vms != nil { - edges = append(edges, gitidentity.EdgeVms) + if m.versions != nil { + edges = append(edges, agentskill.EdgeVersions) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *GitIdentityMutation) AddedIDs(name string) []ent.Value { +func (m *AgentSkillMutation) AddedIDs(name string) []ent.Value { switch name { - case gitidentity.EdgeUser: - if id := m.user; id != nil { + case agentskill.EdgeRepo: + if id := m.repo; id != nil { return []ent.Value{*id} } - case gitidentity.EdgeProjects: - ids := make([]ent.Value, 0, len(m.projects)) - for id := range m.projects { - ids = append(ids, id) - } - return ids - case gitidentity.EdgeProjectTasks: - ids := make([]ent.Value, 0, len(m.project_tasks)) - for id := range m.project_tasks { - ids = append(ids, id) - } - return ids - case gitidentity.EdgeVms: - ids := make([]ent.Value, 0, len(m.vms)) - for id := range m.vms { + case agentskill.EdgeVersions: + ids := make([]ent.Value, 0, len(m.versions)) + for id := range m.versions { ids = append(ids, id) } return ids @@ -4654,39 +6234,21 @@ func (m *GitIdentityMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *GitIdentityMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - if m.removedprojects != nil { - edges = append(edges, gitidentity.EdgeProjects) - } - if m.removedproject_tasks != nil { - edges = append(edges, gitidentity.EdgeProjectTasks) - } - if m.removedvms != nil { - edges = append(edges, gitidentity.EdgeVms) +func (m *AgentSkillMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedversions != nil { + edges = append(edges, agentskill.EdgeVersions) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *GitIdentityMutation) RemovedIDs(name string) []ent.Value { +func (m *AgentSkillMutation) RemovedIDs(name string) []ent.Value { switch name { - case gitidentity.EdgeProjects: - ids := make([]ent.Value, 0, len(m.removedprojects)) - for id := range m.removedprojects { - ids = append(ids, id) - } - return ids - case gitidentity.EdgeProjectTasks: - ids := make([]ent.Value, 0, len(m.removedproject_tasks)) - for id := range m.removedproject_tasks { - ids = append(ids, id) - } - return ids - case gitidentity.EdgeVms: - ids := make([]ent.Value, 0, len(m.removedvms)) - for id := range m.removedvms { + case agentskill.EdgeVersions: + ids := make([]ent.Value, 0, len(m.removedversions)) + for id := range m.removedversions { ids = append(ids, id) } return ids @@ -4695,107 +6257,82 @@ func (m *GitIdentityMutation) RemovedIDs(name string) []ent.Value { } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *GitIdentityMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) - if m.cleareduser { - edges = append(edges, gitidentity.EdgeUser) - } - if m.clearedprojects { - edges = append(edges, gitidentity.EdgeProjects) - } - if m.clearedproject_tasks { - edges = append(edges, gitidentity.EdgeProjectTasks) +func (m *AgentSkillMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedrepo { + edges = append(edges, agentskill.EdgeRepo) } - if m.clearedvms { - edges = append(edges, gitidentity.EdgeVms) + if m.clearedversions { + edges = append(edges, agentskill.EdgeVersions) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *GitIdentityMutation) EdgeCleared(name string) bool { +func (m *AgentSkillMutation) EdgeCleared(name string) bool { switch name { - case gitidentity.EdgeUser: - return m.cleareduser - case gitidentity.EdgeProjects: - return m.clearedprojects - case gitidentity.EdgeProjectTasks: - return m.clearedproject_tasks - case gitidentity.EdgeVms: - return m.clearedvms + case agentskill.EdgeRepo: + return m.clearedrepo + case agentskill.EdgeVersions: + return m.clearedversions } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *GitIdentityMutation) ClearEdge(name string) error { +func (m *AgentSkillMutation) ClearEdge(name string) error { switch name { - case gitidentity.EdgeUser: - m.ClearUser() + case agentskill.EdgeRepo: + m.ClearRepo() return nil } - return fmt.Errorf("unknown GitIdentity unique edge %s", name) + return fmt.Errorf("unknown AgentSkill unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *GitIdentityMutation) ResetEdge(name string) error { +func (m *AgentSkillMutation) ResetEdge(name string) error { switch name { - case gitidentity.EdgeUser: - m.ResetUser() - return nil - case gitidentity.EdgeProjects: - m.ResetProjects() - return nil - case gitidentity.EdgeProjectTasks: - m.ResetProjectTasks() + case agentskill.EdgeRepo: + m.ResetRepo() return nil - case gitidentity.EdgeVms: - m.ResetVms() + case agentskill.EdgeVersions: + m.ResetVersions() return nil } - return fmt.Errorf("unknown GitIdentity edge %s", name) + return fmt.Errorf("unknown AgentSkill edge %s", name) } -// GitTaskMutation represents an operation that mutates the GitTask nodes in the graph. -type GitTaskMutation struct { +// AgentSkillGroupBindingMutation represents an operation that mutates the AgentSkillGroupBinding nodes in the graph. +type AgentSkillGroupBindingMutation struct { config - op Op - typ string - id *uuid.UUID - repo_id *uuid.UUID - subject_type *string - subject_id *string - subject_number *int - addsubject_number *int - subject_url *string - subject_title *string - prompt_id *string - show_url *string - github_installation_id *int64 - addgithub_installation_id *int64 - created_at *time.Time - clearedFields map[string]struct{} - task *uuid.UUID - clearedtask bool - done bool - oldValue func(context.Context) (*GitTask, error) - predicates []predicate.GitTask + op Op + typ string + id *uuid.UUID + created_at *time.Time + clearedFields map[string]struct{} + skill *uuid.UUID + clearedskill bool + group *uuid.UUID + clearedgroup bool + done bool + oldValue func(context.Context) (*AgentSkillGroupBinding, error) + predicates []predicate.AgentSkillGroupBinding } -var _ ent.Mutation = (*GitTaskMutation)(nil) +var _ ent.Mutation = (*AgentSkillGroupBindingMutation)(nil) -// gittaskOption allows management of the mutation configuration using functional options. -type gittaskOption func(*GitTaskMutation) +// agentskillgroupbindingOption allows management of the mutation configuration using functional options. +type agentskillgroupbindingOption func(*AgentSkillGroupBindingMutation) -// newGitTaskMutation creates new mutation for the GitTask entity. -func newGitTaskMutation(c config, op Op, opts ...gittaskOption) *GitTaskMutation { - m := &GitTaskMutation{ +// newAgentSkillGroupBindingMutation creates new mutation for the AgentSkillGroupBinding entity. +func newAgentSkillGroupBindingMutation(c config, op Op, opts ...agentskillgroupbindingOption) *AgentSkillGroupBindingMutation { + m := &AgentSkillGroupBindingMutation{ config: c, op: op, - typ: TypeGitTask, + typ: TypeAgentSkillGroupBinding, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -4804,20 +6341,20 @@ func newGitTaskMutation(c config, op Op, opts ...gittaskOption) *GitTaskMutation return m } -// withGitTaskID sets the ID field of the mutation. -func withGitTaskID(id uuid.UUID) gittaskOption { - return func(m *GitTaskMutation) { +// withAgentSkillGroupBindingID sets the ID field of the mutation. +func withAgentSkillGroupBindingID(id uuid.UUID) agentskillgroupbindingOption { + return func(m *AgentSkillGroupBindingMutation) { var ( err error once sync.Once - value *GitTask + value *AgentSkillGroupBinding ) - m.oldValue = func(ctx context.Context) (*GitTask, error) { + m.oldValue = func(ctx context.Context) (*AgentSkillGroupBinding, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().GitTask.Get(ctx, id) + value, err = m.Client().AgentSkillGroupBinding.Get(ctx, id) } }) return value, err @@ -4826,10 +6363,10 @@ func withGitTaskID(id uuid.UUID) gittaskOption { } } -// withGitTask sets the old GitTask of the mutation. -func withGitTask(node *GitTask) gittaskOption { - return func(m *GitTaskMutation) { - m.oldValue = func(context.Context) (*GitTask, error) { +// withAgentSkillGroupBinding sets the old AgentSkillGroupBinding of the mutation. +func withAgentSkillGroupBinding(node *AgentSkillGroupBinding) agentskillgroupbindingOption { + return func(m *AgentSkillGroupBindingMutation) { + m.oldValue = func(context.Context) (*AgentSkillGroupBinding, error) { return node, nil } m.id = &node.ID @@ -4838,7 +6375,7 @@ func withGitTask(node *GitTask) gittaskOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m GitTaskMutation) Client() *Client { +func (m AgentSkillGroupBindingMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -4846,7 +6383,7 @@ func (m GitTaskMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m GitTaskMutation) Tx() (*Tx, error) { +func (m AgentSkillGroupBindingMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -4856,14 +6393,14 @@ func (m GitTaskMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of GitTask entities. -func (m *GitTaskMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of AgentSkillGroupBinding entities. +func (m *AgentSkillGroupBindingMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *GitTaskMutation) ID() (id uuid.UUID, exists bool) { +func (m *AgentSkillGroupBindingMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -4874,7 +6411,7 @@ func (m *GitTaskMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *GitTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *AgentSkillGroupBindingMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -4883,590 +6420,1159 @@ func (m *GitTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().GitTask.Query().Where(m.predicates...).IDs(ctx) + return m.Client().AgentSkillGroupBinding.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetTaskID sets the "task_id" field. -func (m *GitTaskMutation) SetTaskID(u uuid.UUID) { - m.task = &u +// SetSkillID sets the "skill_id" field. +func (m *AgentSkillGroupBindingMutation) SetSkillID(u uuid.UUID) { + m.skill = &u } -// TaskID returns the value of the "task_id" field in the mutation. -func (m *GitTaskMutation) TaskID() (r uuid.UUID, exists bool) { - v := m.task +// SkillID returns the value of the "skill_id" field in the mutation. +func (m *AgentSkillGroupBindingMutation) SkillID() (r uuid.UUID, exists bool) { + v := m.skill if v == nil { return } return *v, true } -// OldTaskID returns the old "task_id" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// OldSkillID returns the old "skill_id" field's value of the AgentSkillGroupBinding entity. +// If the AgentSkillGroupBinding object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AgentSkillGroupBindingMutation) OldSkillID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTaskID is only allowed on UpdateOne operations") + return v, errors.New("OldSkillID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTaskID requires an ID field in the mutation") + return v, errors.New("OldSkillID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTaskID: %w", err) + return v, fmt.Errorf("querying old value for OldSkillID: %w", err) } - return oldValue.TaskID, nil + return oldValue.SkillID, nil } -// ResetTaskID resets all changes to the "task_id" field. -func (m *GitTaskMutation) ResetTaskID() { - m.task = nil +// ResetSkillID resets all changes to the "skill_id" field. +func (m *AgentSkillGroupBindingMutation) ResetSkillID() { + m.skill = nil } -// SetRepoID sets the "repo_id" field. -func (m *GitTaskMutation) SetRepoID(u uuid.UUID) { - m.repo_id = &u +// SetGroupID sets the "group_id" field. +func (m *AgentSkillGroupBindingMutation) SetGroupID(u uuid.UUID) { + m.group = &u } -// RepoID returns the value of the "repo_id" field in the mutation. -func (m *GitTaskMutation) RepoID() (r uuid.UUID, exists bool) { - v := m.repo_id +// GroupID returns the value of the "group_id" field in the mutation. +func (m *AgentSkillGroupBindingMutation) GroupID() (r uuid.UUID, exists bool) { + v := m.group if v == nil { return } return *v, true } -// OldRepoID returns the old "repo_id" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// OldGroupID returns the old "group_id" field's value of the AgentSkillGroupBinding entity. +// If the AgentSkillGroupBinding object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldRepoID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AgentSkillGroupBindingMutation) OldGroupID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRepoID is only allowed on UpdateOne operations") + return v, errors.New("OldGroupID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRepoID requires an ID field in the mutation") + return v, errors.New("OldGroupID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRepoID: %w", err) + return v, fmt.Errorf("querying old value for OldGroupID: %w", err) } - return oldValue.RepoID, nil -} - -// ClearRepoID clears the value of the "repo_id" field. -func (m *GitTaskMutation) ClearRepoID() { - m.repo_id = nil - m.clearedFields[gittask.FieldRepoID] = struct{}{} -} - -// RepoIDCleared returns if the "repo_id" field was cleared in this mutation. -func (m *GitTaskMutation) RepoIDCleared() bool { - _, ok := m.clearedFields[gittask.FieldRepoID] - return ok + return oldValue.GroupID, nil } -// ResetRepoID resets all changes to the "repo_id" field. -func (m *GitTaskMutation) ResetRepoID() { - m.repo_id = nil - delete(m.clearedFields, gittask.FieldRepoID) +// ResetGroupID resets all changes to the "group_id" field. +func (m *AgentSkillGroupBindingMutation) ResetGroupID() { + m.group = nil } -// SetSubjectType sets the "subject_type" field. -func (m *GitTaskMutation) SetSubjectType(s string) { - m.subject_type = &s +// SetCreatedAt sets the "created_at" field. +func (m *AgentSkillGroupBindingMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// SubjectType returns the value of the "subject_type" field in the mutation. -func (m *GitTaskMutation) SubjectType() (r string, exists bool) { - v := m.subject_type +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AgentSkillGroupBindingMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldSubjectType returns the old "subject_type" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the AgentSkillGroupBinding entity. +// If the AgentSkillGroupBinding object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldSubjectType(ctx context.Context) (v string, err error) { +func (m *AgentSkillGroupBindingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSubjectType is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSubjectType requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSubjectType: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.SubjectType, nil + return oldValue.CreatedAt, nil } -// ResetSubjectType resets all changes to the "subject_type" field. -func (m *GitTaskMutation) ResetSubjectType() { - m.subject_type = nil +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *AgentSkillGroupBindingMutation) ResetCreatedAt() { + m.created_at = nil } -// SetSubjectID sets the "subject_id" field. -func (m *GitTaskMutation) SetSubjectID(s string) { - m.subject_id = &s +// ClearSkill clears the "skill" edge to the AgentSkill entity. +func (m *AgentSkillGroupBindingMutation) ClearSkill() { + m.clearedskill = true + m.clearedFields[agentskillgroupbinding.FieldSkillID] = struct{}{} } -// SubjectID returns the value of the "subject_id" field in the mutation. -func (m *GitTaskMutation) SubjectID() (r string, exists bool) { - v := m.subject_id - if v == nil { - return - } - return *v, true +// SkillCleared reports if the "skill" edge to the AgentSkill entity was cleared. +func (m *AgentSkillGroupBindingMutation) SkillCleared() bool { + return m.clearedskill } -// OldSubjectID returns the old "subject_id" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldSubjectID(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSubjectID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSubjectID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSubjectID: %w", err) +// SkillIDs returns the "skill" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// SkillID instead. It exists only for internal usage by the builders. +func (m *AgentSkillGroupBindingMutation) SkillIDs() (ids []uuid.UUID) { + if id := m.skill; id != nil { + ids = append(ids, *id) } - return oldValue.SubjectID, nil -} - -// ClearSubjectID clears the value of the "subject_id" field. -func (m *GitTaskMutation) ClearSubjectID() { - m.subject_id = nil - m.clearedFields[gittask.FieldSubjectID] = struct{}{} + return } -// SubjectIDCleared returns if the "subject_id" field was cleared in this mutation. -func (m *GitTaskMutation) SubjectIDCleared() bool { - _, ok := m.clearedFields[gittask.FieldSubjectID] - return ok +// ResetSkill resets all changes to the "skill" edge. +func (m *AgentSkillGroupBindingMutation) ResetSkill() { + m.skill = nil + m.clearedskill = false } -// ResetSubjectID resets all changes to the "subject_id" field. -func (m *GitTaskMutation) ResetSubjectID() { - m.subject_id = nil - delete(m.clearedFields, gittask.FieldSubjectID) +// ClearGroup clears the "group" edge to the TeamGroup entity. +func (m *AgentSkillGroupBindingMutation) ClearGroup() { + m.clearedgroup = true + m.clearedFields[agentskillgroupbinding.FieldGroupID] = struct{}{} } -// SetSubjectNumber sets the "subject_number" field. -func (m *GitTaskMutation) SetSubjectNumber(i int) { - m.subject_number = &i - m.addsubject_number = nil +// GroupCleared reports if the "group" edge to the TeamGroup entity was cleared. +func (m *AgentSkillGroupBindingMutation) GroupCleared() bool { + return m.clearedgroup } -// SubjectNumber returns the value of the "subject_number" field in the mutation. -func (m *GitTaskMutation) SubjectNumber() (r int, exists bool) { - v := m.subject_number - if v == nil { - return +// GroupIDs returns the "group" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// GroupID instead. It exists only for internal usage by the builders. +func (m *AgentSkillGroupBindingMutation) GroupIDs() (ids []uuid.UUID) { + if id := m.group; id != nil { + ids = append(ids, *id) } - return *v, true + return } -// OldSubjectNumber returns the old "subject_number" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldSubjectNumber(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSubjectNumber is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSubjectNumber requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSubjectNumber: %w", err) - } - return oldValue.SubjectNumber, nil +// ResetGroup resets all changes to the "group" edge. +func (m *AgentSkillGroupBindingMutation) ResetGroup() { + m.group = nil + m.clearedgroup = false } -// AddSubjectNumber adds i to the "subject_number" field. -func (m *GitTaskMutation) AddSubjectNumber(i int) { - if m.addsubject_number != nil { - *m.addsubject_number += i - } else { - m.addsubject_number = &i - } +// Where appends a list predicates to the AgentSkillGroupBindingMutation builder. +func (m *AgentSkillGroupBindingMutation) Where(ps ...predicate.AgentSkillGroupBinding) { + m.predicates = append(m.predicates, ps...) } -// AddedSubjectNumber returns the value that was added to the "subject_number" field in this mutation. -func (m *GitTaskMutation) AddedSubjectNumber() (r int, exists bool) { - v := m.addsubject_number - if v == nil { - return +// WhereP appends storage-level predicates to the AgentSkillGroupBindingMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *AgentSkillGroupBindingMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.AgentSkillGroupBinding, len(ps)) + for i := range ps { + p[i] = ps[i] } - return *v, true + m.Where(p...) } -// ClearSubjectNumber clears the value of the "subject_number" field. -func (m *GitTaskMutation) ClearSubjectNumber() { - m.subject_number = nil - m.addsubject_number = nil - m.clearedFields[gittask.FieldSubjectNumber] = struct{}{} +// Op returns the operation name. +func (m *AgentSkillGroupBindingMutation) Op() Op { + return m.op } -// SubjectNumberCleared returns if the "subject_number" field was cleared in this mutation. -func (m *GitTaskMutation) SubjectNumberCleared() bool { - _, ok := m.clearedFields[gittask.FieldSubjectNumber] - return ok +// SetOp allows setting the mutation operation. +func (m *AgentSkillGroupBindingMutation) SetOp(op Op) { + m.op = op } -// ResetSubjectNumber resets all changes to the "subject_number" field. -func (m *GitTaskMutation) ResetSubjectNumber() { - m.subject_number = nil - m.addsubject_number = nil - delete(m.clearedFields, gittask.FieldSubjectNumber) +// Type returns the node type of this mutation (AgentSkillGroupBinding). +func (m *AgentSkillGroupBindingMutation) Type() string { + return m.typ } -// SetSubjectURL sets the "subject_url" field. -func (m *GitTaskMutation) SetSubjectURL(s string) { - m.subject_url = &s +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *AgentSkillGroupBindingMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.skill != nil { + fields = append(fields, agentskillgroupbinding.FieldSkillID) + } + if m.group != nil { + fields = append(fields, agentskillgroupbinding.FieldGroupID) + } + if m.created_at != nil { + fields = append(fields, agentskillgroupbinding.FieldCreatedAt) + } + return fields } -// SubjectURL returns the value of the "subject_url" field in the mutation. -func (m *GitTaskMutation) SubjectURL() (r string, exists bool) { - v := m.subject_url - if v == nil { - return - } +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *AgentSkillGroupBindingMutation) Field(name string) (ent.Value, bool) { + switch name { + case agentskillgroupbinding.FieldSkillID: + return m.SkillID() + case agentskillgroupbinding.FieldGroupID: + return m.GroupID() + case agentskillgroupbinding.FieldCreatedAt: + return m.CreatedAt() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *AgentSkillGroupBindingMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case agentskillgroupbinding.FieldSkillID: + return m.OldSkillID(ctx) + case agentskillgroupbinding.FieldGroupID: + return m.OldGroupID(ctx) + case agentskillgroupbinding.FieldCreatedAt: + return m.OldCreatedAt(ctx) + } + return nil, fmt.Errorf("unknown AgentSkillGroupBinding field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AgentSkillGroupBindingMutation) SetField(name string, value ent.Value) error { + switch name { + case agentskillgroupbinding.FieldSkillID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSkillID(v) + return nil + case agentskillgroupbinding.FieldGroupID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGroupID(v) + return nil + case agentskillgroupbinding.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + } + return fmt.Errorf("unknown AgentSkillGroupBinding field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *AgentSkillGroupBindingMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *AgentSkillGroupBindingMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AgentSkillGroupBindingMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown AgentSkillGroupBinding numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *AgentSkillGroupBindingMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *AgentSkillGroupBindingMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *AgentSkillGroupBindingMutation) ClearField(name string) error { + return fmt.Errorf("unknown AgentSkillGroupBinding nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *AgentSkillGroupBindingMutation) ResetField(name string) error { + switch name { + case agentskillgroupbinding.FieldSkillID: + m.ResetSkillID() + return nil + case agentskillgroupbinding.FieldGroupID: + m.ResetGroupID() + return nil + case agentskillgroupbinding.FieldCreatedAt: + m.ResetCreatedAt() + return nil + } + return fmt.Errorf("unknown AgentSkillGroupBinding field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *AgentSkillGroupBindingMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.skill != nil { + edges = append(edges, agentskillgroupbinding.EdgeSkill) + } + if m.group != nil { + edges = append(edges, agentskillgroupbinding.EdgeGroup) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *AgentSkillGroupBindingMutation) AddedIDs(name string) []ent.Value { + switch name { + case agentskillgroupbinding.EdgeSkill: + if id := m.skill; id != nil { + return []ent.Value{*id} + } + case agentskillgroupbinding.EdgeGroup: + if id := m.group; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *AgentSkillGroupBindingMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *AgentSkillGroupBindingMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *AgentSkillGroupBindingMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedskill { + edges = append(edges, agentskillgroupbinding.EdgeSkill) + } + if m.clearedgroup { + edges = append(edges, agentskillgroupbinding.EdgeGroup) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *AgentSkillGroupBindingMutation) EdgeCleared(name string) bool { + switch name { + case agentskillgroupbinding.EdgeSkill: + return m.clearedskill + case agentskillgroupbinding.EdgeGroup: + return m.clearedgroup + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *AgentSkillGroupBindingMutation) ClearEdge(name string) error { + switch name { + case agentskillgroupbinding.EdgeSkill: + m.ClearSkill() + return nil + case agentskillgroupbinding.EdgeGroup: + m.ClearGroup() + return nil + } + return fmt.Errorf("unknown AgentSkillGroupBinding unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *AgentSkillGroupBindingMutation) ResetEdge(name string) error { + switch name { + case agentskillgroupbinding.EdgeSkill: + m.ResetSkill() + return nil + case agentskillgroupbinding.EdgeGroup: + m.ResetGroup() + return nil + } + return fmt.Errorf("unknown AgentSkillGroupBinding edge %s", name) +} + +// AgentSkillRepoMutation represents an operation that mutates the AgentSkillRepo nodes in the graph. +type AgentSkillRepoMutation struct { + config + op Op + typ string + id *uuid.UUID + name *string + scope_type *agentskillrepo.ScopeType + scope_id *string + created_by *uuid.UUID + source_type *agentskillrepo.SourceType + github_url *string + ref_type *agentskillrepo.RefType + ref_value *string + last_upload_filename *string + last_upload_at *time.Time + is_deleted *bool + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + skills map[uuid.UUID]struct{} + removedskills map[uuid.UUID]struct{} + clearedskills bool + done bool + oldValue func(context.Context) (*AgentSkillRepo, error) + predicates []predicate.AgentSkillRepo +} + +var _ ent.Mutation = (*AgentSkillRepoMutation)(nil) + +// agentskillrepoOption allows management of the mutation configuration using functional options. +type agentskillrepoOption func(*AgentSkillRepoMutation) + +// newAgentSkillRepoMutation creates new mutation for the AgentSkillRepo entity. +func newAgentSkillRepoMutation(c config, op Op, opts ...agentskillrepoOption) *AgentSkillRepoMutation { + m := &AgentSkillRepoMutation{ + config: c, + op: op, + typ: TypeAgentSkillRepo, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withAgentSkillRepoID sets the ID field of the mutation. +func withAgentSkillRepoID(id uuid.UUID) agentskillrepoOption { + return func(m *AgentSkillRepoMutation) { + var ( + err error + once sync.Once + value *AgentSkillRepo + ) + m.oldValue = func(ctx context.Context) (*AgentSkillRepo, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().AgentSkillRepo.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withAgentSkillRepo sets the old AgentSkillRepo of the mutation. +func withAgentSkillRepo(node *AgentSkillRepo) agentskillrepoOption { + return func(m *AgentSkillRepoMutation) { + m.oldValue = func(context.Context) (*AgentSkillRepo, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m AgentSkillRepoMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m AgentSkillRepoMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of AgentSkillRepo entities. +func (m *AgentSkillRepoMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *AgentSkillRepoMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *AgentSkillRepoMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().AgentSkillRepo.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetName sets the "name" field. +func (m *AgentSkillRepoMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *AgentSkillRepoMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } return *v, true } -// OldSubjectURL returns the old "subject_url" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldSubjectURL(ctx context.Context) (v string, err error) { +func (m *AgentSkillRepoMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSubjectURL is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSubjectURL requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSubjectURL: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.SubjectURL, nil + return oldValue.Name, nil } -// ClearSubjectURL clears the value of the "subject_url" field. -func (m *GitTaskMutation) ClearSubjectURL() { - m.subject_url = nil - m.clearedFields[gittask.FieldSubjectURL] = struct{}{} +// ResetName resets all changes to the "name" field. +func (m *AgentSkillRepoMutation) ResetName() { + m.name = nil } -// SubjectURLCleared returns if the "subject_url" field was cleared in this mutation. -func (m *GitTaskMutation) SubjectURLCleared() bool { - _, ok := m.clearedFields[gittask.FieldSubjectURL] - return ok +// SetScopeType sets the "scope_type" field. +func (m *AgentSkillRepoMutation) SetScopeType(at agentskillrepo.ScopeType) { + m.scope_type = &at } -// ResetSubjectURL resets all changes to the "subject_url" field. -func (m *GitTaskMutation) ResetSubjectURL() { - m.subject_url = nil - delete(m.clearedFields, gittask.FieldSubjectURL) +// ScopeType returns the value of the "scope_type" field in the mutation. +func (m *AgentSkillRepoMutation) ScopeType() (r agentskillrepo.ScopeType, exists bool) { + v := m.scope_type + if v == nil { + return + } + return *v, true } -// SetSubjectTitle sets the "subject_title" field. -func (m *GitTaskMutation) SetSubjectTitle(s string) { - m.subject_title = &s +// OldScopeType returns the old "scope_type" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillRepoMutation) OldScopeType(ctx context.Context) (v agentskillrepo.ScopeType, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldScopeType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldScopeType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldScopeType: %w", err) + } + return oldValue.ScopeType, nil } -// SubjectTitle returns the value of the "subject_title" field in the mutation. -func (m *GitTaskMutation) SubjectTitle() (r string, exists bool) { - v := m.subject_title +// ResetScopeType resets all changes to the "scope_type" field. +func (m *AgentSkillRepoMutation) ResetScopeType() { + m.scope_type = nil +} + +// SetScopeID sets the "scope_id" field. +func (m *AgentSkillRepoMutation) SetScopeID(s string) { + m.scope_id = &s +} + +// ScopeID returns the value of the "scope_id" field in the mutation. +func (m *AgentSkillRepoMutation) ScopeID() (r string, exists bool) { + v := m.scope_id if v == nil { return } return *v, true } -// OldSubjectTitle returns the old "subject_title" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// OldScopeID returns the old "scope_id" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldSubjectTitle(ctx context.Context) (v string, err error) { +func (m *AgentSkillRepoMutation) OldScopeID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSubjectTitle is only allowed on UpdateOne operations") + return v, errors.New("OldScopeID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSubjectTitle requires an ID field in the mutation") + return v, errors.New("OldScopeID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSubjectTitle: %w", err) + return v, fmt.Errorf("querying old value for OldScopeID: %w", err) } - return oldValue.SubjectTitle, nil + return oldValue.ScopeID, nil } -// ClearSubjectTitle clears the value of the "subject_title" field. -func (m *GitTaskMutation) ClearSubjectTitle() { - m.subject_title = nil - m.clearedFields[gittask.FieldSubjectTitle] = struct{}{} +// ResetScopeID resets all changes to the "scope_id" field. +func (m *AgentSkillRepoMutation) ResetScopeID() { + m.scope_id = nil } -// SubjectTitleCleared returns if the "subject_title" field was cleared in this mutation. -func (m *GitTaskMutation) SubjectTitleCleared() bool { - _, ok := m.clearedFields[gittask.FieldSubjectTitle] - return ok +// SetCreatedBy sets the "created_by" field. +func (m *AgentSkillRepoMutation) SetCreatedBy(u uuid.UUID) { + m.created_by = &u } -// ResetSubjectTitle resets all changes to the "subject_title" field. -func (m *GitTaskMutation) ResetSubjectTitle() { - m.subject_title = nil - delete(m.clearedFields, gittask.FieldSubjectTitle) +// CreatedBy returns the value of the "created_by" field in the mutation. +func (m *AgentSkillRepoMutation) CreatedBy() (r uuid.UUID, exists bool) { + v := m.created_by + if v == nil { + return + } + return *v, true } -// SetPromptID sets the "prompt_id" field. -func (m *GitTaskMutation) SetPromptID(s string) { - m.prompt_id = &s +// OldCreatedBy returns the old "created_by" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillRepoMutation) OldCreatedBy(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedBy requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err) + } + return oldValue.CreatedBy, nil } -// PromptID returns the value of the "prompt_id" field in the mutation. -func (m *GitTaskMutation) PromptID() (r string, exists bool) { - v := m.prompt_id +// ResetCreatedBy resets all changes to the "created_by" field. +func (m *AgentSkillRepoMutation) ResetCreatedBy() { + m.created_by = nil +} + +// SetSourceType sets the "source_type" field. +func (m *AgentSkillRepoMutation) SetSourceType(at agentskillrepo.SourceType) { + m.source_type = &at +} + +// SourceType returns the value of the "source_type" field in the mutation. +func (m *AgentSkillRepoMutation) SourceType() (r agentskillrepo.SourceType, exists bool) { + v := m.source_type if v == nil { return } return *v, true } -// OldPromptID returns the old "prompt_id" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// OldSourceType returns the old "source_type" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldPromptID(ctx context.Context) (v string, err error) { +func (m *AgentSkillRepoMutation) OldSourceType(ctx context.Context) (v agentskillrepo.SourceType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPromptID is only allowed on UpdateOne operations") + return v, errors.New("OldSourceType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPromptID requires an ID field in the mutation") + return v, errors.New("OldSourceType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPromptID: %w", err) + return v, fmt.Errorf("querying old value for OldSourceType: %w", err) } - return oldValue.PromptID, nil + return oldValue.SourceType, nil } -// ClearPromptID clears the value of the "prompt_id" field. -func (m *GitTaskMutation) ClearPromptID() { - m.prompt_id = nil - m.clearedFields[gittask.FieldPromptID] = struct{}{} +// ResetSourceType resets all changes to the "source_type" field. +func (m *AgentSkillRepoMutation) ResetSourceType() { + m.source_type = nil } -// PromptIDCleared returns if the "prompt_id" field was cleared in this mutation. -func (m *GitTaskMutation) PromptIDCleared() bool { - _, ok := m.clearedFields[gittask.FieldPromptID] +// SetGithubURL sets the "github_url" field. +func (m *AgentSkillRepoMutation) SetGithubURL(s string) { + m.github_url = &s +} + +// GithubURL returns the value of the "github_url" field in the mutation. +func (m *AgentSkillRepoMutation) GithubURL() (r string, exists bool) { + v := m.github_url + if v == nil { + return + } + return *v, true +} + +// OldGithubURL returns the old "github_url" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillRepoMutation) OldGithubURL(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGithubURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGithubURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGithubURL: %w", err) + } + return oldValue.GithubURL, nil +} + +// ClearGithubURL clears the value of the "github_url" field. +func (m *AgentSkillRepoMutation) ClearGithubURL() { + m.github_url = nil + m.clearedFields[agentskillrepo.FieldGithubURL] = struct{}{} +} + +// GithubURLCleared returns if the "github_url" field was cleared in this mutation. +func (m *AgentSkillRepoMutation) GithubURLCleared() bool { + _, ok := m.clearedFields[agentskillrepo.FieldGithubURL] return ok } -// ResetPromptID resets all changes to the "prompt_id" field. -func (m *GitTaskMutation) ResetPromptID() { - m.prompt_id = nil - delete(m.clearedFields, gittask.FieldPromptID) +// ResetGithubURL resets all changes to the "github_url" field. +func (m *AgentSkillRepoMutation) ResetGithubURL() { + m.github_url = nil + delete(m.clearedFields, agentskillrepo.FieldGithubURL) } -// SetShowURL sets the "show_url" field. -func (m *GitTaskMutation) SetShowURL(s string) { - m.show_url = &s +// SetRefType sets the "ref_type" field. +func (m *AgentSkillRepoMutation) SetRefType(at agentskillrepo.RefType) { + m.ref_type = &at } -// ShowURL returns the value of the "show_url" field in the mutation. -func (m *GitTaskMutation) ShowURL() (r string, exists bool) { - v := m.show_url +// RefType returns the value of the "ref_type" field in the mutation. +func (m *AgentSkillRepoMutation) RefType() (r agentskillrepo.RefType, exists bool) { + v := m.ref_type if v == nil { return } return *v, true } -// OldShowURL returns the old "show_url" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// OldRefType returns the old "ref_type" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldShowURL(ctx context.Context) (v string, err error) { +func (m *AgentSkillRepoMutation) OldRefType(ctx context.Context) (v *agentskillrepo.RefType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldShowURL is only allowed on UpdateOne operations") + return v, errors.New("OldRefType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldShowURL requires an ID field in the mutation") + return v, errors.New("OldRefType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldShowURL: %w", err) + return v, fmt.Errorf("querying old value for OldRefType: %w", err) } - return oldValue.ShowURL, nil + return oldValue.RefType, nil } -// ClearShowURL clears the value of the "show_url" field. -func (m *GitTaskMutation) ClearShowURL() { - m.show_url = nil - m.clearedFields[gittask.FieldShowURL] = struct{}{} +// ClearRefType clears the value of the "ref_type" field. +func (m *AgentSkillRepoMutation) ClearRefType() { + m.ref_type = nil + m.clearedFields[agentskillrepo.FieldRefType] = struct{}{} } -// ShowURLCleared returns if the "show_url" field was cleared in this mutation. -func (m *GitTaskMutation) ShowURLCleared() bool { - _, ok := m.clearedFields[gittask.FieldShowURL] +// RefTypeCleared returns if the "ref_type" field was cleared in this mutation. +func (m *AgentSkillRepoMutation) RefTypeCleared() bool { + _, ok := m.clearedFields[agentskillrepo.FieldRefType] return ok } -// ResetShowURL resets all changes to the "show_url" field. -func (m *GitTaskMutation) ResetShowURL() { - m.show_url = nil - delete(m.clearedFields, gittask.FieldShowURL) +// ResetRefType resets all changes to the "ref_type" field. +func (m *AgentSkillRepoMutation) ResetRefType() { + m.ref_type = nil + delete(m.clearedFields, agentskillrepo.FieldRefType) } -// SetGithubInstallationID sets the "github_installation_id" field. -func (m *GitTaskMutation) SetGithubInstallationID(i int64) { - m.github_installation_id = &i - m.addgithub_installation_id = nil +// SetRefValue sets the "ref_value" field. +func (m *AgentSkillRepoMutation) SetRefValue(s string) { + m.ref_value = &s } -// GithubInstallationID returns the value of the "github_installation_id" field in the mutation. -func (m *GitTaskMutation) GithubInstallationID() (r int64, exists bool) { - v := m.github_installation_id +// RefValue returns the value of the "ref_value" field in the mutation. +func (m *AgentSkillRepoMutation) RefValue() (r string, exists bool) { + v := m.ref_value if v == nil { return } return *v, true } -// OldGithubInstallationID returns the old "github_installation_id" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// OldRefValue returns the old "ref_value" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldGithubInstallationID(ctx context.Context) (v int64, err error) { +func (m *AgentSkillRepoMutation) OldRefValue(ctx context.Context) (v *string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldGithubInstallationID is only allowed on UpdateOne operations") + return v, errors.New("OldRefValue is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldGithubInstallationID requires an ID field in the mutation") + return v, errors.New("OldRefValue requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldGithubInstallationID: %w", err) + return v, fmt.Errorf("querying old value for OldRefValue: %w", err) } - return oldValue.GithubInstallationID, nil + return oldValue.RefValue, nil } -// AddGithubInstallationID adds i to the "github_installation_id" field. -func (m *GitTaskMutation) AddGithubInstallationID(i int64) { - if m.addgithub_installation_id != nil { - *m.addgithub_installation_id += i - } else { - m.addgithub_installation_id = &i - } +// ClearRefValue clears the value of the "ref_value" field. +func (m *AgentSkillRepoMutation) ClearRefValue() { + m.ref_value = nil + m.clearedFields[agentskillrepo.FieldRefValue] = struct{}{} } -// AddedGithubInstallationID returns the value that was added to the "github_installation_id" field in this mutation. -func (m *GitTaskMutation) AddedGithubInstallationID() (r int64, exists bool) { - v := m.addgithub_installation_id +// RefValueCleared returns if the "ref_value" field was cleared in this mutation. +func (m *AgentSkillRepoMutation) RefValueCleared() bool { + _, ok := m.clearedFields[agentskillrepo.FieldRefValue] + return ok +} + +// ResetRefValue resets all changes to the "ref_value" field. +func (m *AgentSkillRepoMutation) ResetRefValue() { + m.ref_value = nil + delete(m.clearedFields, agentskillrepo.FieldRefValue) +} + +// SetLastUploadFilename sets the "last_upload_filename" field. +func (m *AgentSkillRepoMutation) SetLastUploadFilename(s string) { + m.last_upload_filename = &s +} + +// LastUploadFilename returns the value of the "last_upload_filename" field in the mutation. +func (m *AgentSkillRepoMutation) LastUploadFilename() (r string, exists bool) { + v := m.last_upload_filename if v == nil { return } return *v, true } -// ClearGithubInstallationID clears the value of the "github_installation_id" field. -func (m *GitTaskMutation) ClearGithubInstallationID() { - m.github_installation_id = nil - m.addgithub_installation_id = nil - m.clearedFields[gittask.FieldGithubInstallationID] = struct{}{} +// OldLastUploadFilename returns the old "last_upload_filename" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillRepoMutation) OldLastUploadFilename(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastUploadFilename is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastUploadFilename requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastUploadFilename: %w", err) + } + return oldValue.LastUploadFilename, nil } -// GithubInstallationIDCleared returns if the "github_installation_id" field was cleared in this mutation. -func (m *GitTaskMutation) GithubInstallationIDCleared() bool { - _, ok := m.clearedFields[gittask.FieldGithubInstallationID] +// ClearLastUploadFilename clears the value of the "last_upload_filename" field. +func (m *AgentSkillRepoMutation) ClearLastUploadFilename() { + m.last_upload_filename = nil + m.clearedFields[agentskillrepo.FieldLastUploadFilename] = struct{}{} +} + +// LastUploadFilenameCleared returns if the "last_upload_filename" field was cleared in this mutation. +func (m *AgentSkillRepoMutation) LastUploadFilenameCleared() bool { + _, ok := m.clearedFields[agentskillrepo.FieldLastUploadFilename] return ok } -// ResetGithubInstallationID resets all changes to the "github_installation_id" field. -func (m *GitTaskMutation) ResetGithubInstallationID() { - m.github_installation_id = nil - m.addgithub_installation_id = nil - delete(m.clearedFields, gittask.FieldGithubInstallationID) +// ResetLastUploadFilename resets all changes to the "last_upload_filename" field. +func (m *AgentSkillRepoMutation) ResetLastUploadFilename() { + m.last_upload_filename = nil + delete(m.clearedFields, agentskillrepo.FieldLastUploadFilename) } -// SetCreatedAt sets the "created_at" field. -func (m *GitTaskMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// SetLastUploadAt sets the "last_upload_at" field. +func (m *AgentSkillRepoMutation) SetLastUploadAt(t time.Time) { + m.last_upload_at = &t } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *GitTaskMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// LastUploadAt returns the value of the "last_upload_at" field in the mutation. +func (m *AgentSkillRepoMutation) LastUploadAt() (r time.Time, exists bool) { + v := m.last_upload_at if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the GitTask entity. -// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// OldLastUploadAt returns the old "last_upload_at" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GitTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentSkillRepoMutation) OldLastUploadAt(ctx context.Context) (v *time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldLastUploadAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + return v, errors.New("OldLastUploadAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldLastUploadAt: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.LastUploadAt, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *GitTaskMutation) ResetCreatedAt() { - m.created_at = nil +// ClearLastUploadAt clears the value of the "last_upload_at" field. +func (m *AgentSkillRepoMutation) ClearLastUploadAt() { + m.last_upload_at = nil + m.clearedFields[agentskillrepo.FieldLastUploadAt] = struct{}{} } -// ClearTask clears the "task" edge to the Task entity. -func (m *GitTaskMutation) ClearTask() { - m.clearedtask = true - m.clearedFields[gittask.FieldTaskID] = struct{}{} +// LastUploadAtCleared returns if the "last_upload_at" field was cleared in this mutation. +func (m *AgentSkillRepoMutation) LastUploadAtCleared() bool { + _, ok := m.clearedFields[agentskillrepo.FieldLastUploadAt] + return ok } -// TaskCleared reports if the "task" edge to the Task entity was cleared. -func (m *GitTaskMutation) TaskCleared() bool { - return m.clearedtask +// ResetLastUploadAt resets all changes to the "last_upload_at" field. +func (m *AgentSkillRepoMutation) ResetLastUploadAt() { + m.last_upload_at = nil + delete(m.clearedFields, agentskillrepo.FieldLastUploadAt) } -// TaskIDs returns the "task" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TaskID instead. It exists only for internal usage by the builders. -func (m *GitTaskMutation) TaskIDs() (ids []uuid.UUID) { - if id := m.task; id != nil { - ids = append(ids, *id) +// SetIsDeleted sets the "is_deleted" field. +func (m *AgentSkillRepoMutation) SetIsDeleted(b bool) { + m.is_deleted = &b +} + +// IsDeleted returns the value of the "is_deleted" field in the mutation. +func (m *AgentSkillRepoMutation) IsDeleted() (r bool, exists bool) { + v := m.is_deleted + if v == nil { + return } - return + return *v, true } -// ResetTask resets all changes to the "task" edge. -func (m *GitTaskMutation) ResetTask() { - m.task = nil - m.clearedtask = false +// OldIsDeleted returns the old "is_deleted" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillRepoMutation) OldIsDeleted(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsDeleted is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsDeleted requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsDeleted: %w", err) + } + return oldValue.IsDeleted, nil } -// Where appends a list predicates to the GitTaskMutation builder. -func (m *GitTaskMutation) Where(ps ...predicate.GitTask) { +// ResetIsDeleted resets all changes to the "is_deleted" field. +func (m *AgentSkillRepoMutation) ResetIsDeleted() { + m.is_deleted = nil +} + +// SetCreatedAt sets the "created_at" field. +func (m *AgentSkillRepoMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AgentSkillRepoMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillRepoMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *AgentSkillRepoMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *AgentSkillRepoMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *AgentSkillRepoMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the AgentSkillRepo entity. +// If the AgentSkillRepo object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSkillRepoMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *AgentSkillRepoMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// AddSkillIDs adds the "skills" edge to the AgentSkill entity by ids. +func (m *AgentSkillRepoMutation) AddSkillIDs(ids ...uuid.UUID) { + if m.skills == nil { + m.skills = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.skills[ids[i]] = struct{}{} + } +} + +// ClearSkills clears the "skills" edge to the AgentSkill entity. +func (m *AgentSkillRepoMutation) ClearSkills() { + m.clearedskills = true +} + +// SkillsCleared reports if the "skills" edge to the AgentSkill entity was cleared. +func (m *AgentSkillRepoMutation) SkillsCleared() bool { + return m.clearedskills +} + +// RemoveSkillIDs removes the "skills" edge to the AgentSkill entity by IDs. +func (m *AgentSkillRepoMutation) RemoveSkillIDs(ids ...uuid.UUID) { + if m.removedskills == nil { + m.removedskills = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.skills, ids[i]) + m.removedskills[ids[i]] = struct{}{} + } +} + +// RemovedSkills returns the removed IDs of the "skills" edge to the AgentSkill entity. +func (m *AgentSkillRepoMutation) RemovedSkillsIDs() (ids []uuid.UUID) { + for id := range m.removedskills { + ids = append(ids, id) + } + return +} + +// SkillsIDs returns the "skills" edge IDs in the mutation. +func (m *AgentSkillRepoMutation) SkillsIDs() (ids []uuid.UUID) { + for id := range m.skills { + ids = append(ids, id) + } + return +} + +// ResetSkills resets all changes to the "skills" edge. +func (m *AgentSkillRepoMutation) ResetSkills() { + m.skills = nil + m.clearedskills = false + m.removedskills = nil +} + +// Where appends a list predicates to the AgentSkillRepoMutation builder. +func (m *AgentSkillRepoMutation) Where(ps ...predicate.AgentSkillRepo) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the GitTaskMutation builder. Using this method, +// WhereP appends storage-level predicates to the AgentSkillRepoMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *GitTaskMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.GitTask, len(ps)) +func (m *AgentSkillRepoMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.AgentSkillRepo, len(ps)) for i := range ps { p[i] = ps[i] } @@ -5474,57 +7580,63 @@ func (m *GitTaskMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *GitTaskMutation) Op() Op { +func (m *AgentSkillRepoMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *GitTaskMutation) SetOp(op Op) { +func (m *AgentSkillRepoMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (GitTask). -func (m *GitTaskMutation) Type() string { +// Type returns the node type of this mutation (AgentSkillRepo). +func (m *AgentSkillRepoMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *GitTaskMutation) Fields() []string { - fields := make([]string, 0, 11) - if m.task != nil { - fields = append(fields, gittask.FieldTaskID) +func (m *AgentSkillRepoMutation) Fields() []string { + fields := make([]string, 0, 13) + if m.name != nil { + fields = append(fields, agentskillrepo.FieldName) } - if m.repo_id != nil { - fields = append(fields, gittask.FieldRepoID) + if m.scope_type != nil { + fields = append(fields, agentskillrepo.FieldScopeType) } - if m.subject_type != nil { - fields = append(fields, gittask.FieldSubjectType) + if m.scope_id != nil { + fields = append(fields, agentskillrepo.FieldScopeID) } - if m.subject_id != nil { - fields = append(fields, gittask.FieldSubjectID) + if m.created_by != nil { + fields = append(fields, agentskillrepo.FieldCreatedBy) } - if m.subject_number != nil { - fields = append(fields, gittask.FieldSubjectNumber) + if m.source_type != nil { + fields = append(fields, agentskillrepo.FieldSourceType) } - if m.subject_url != nil { - fields = append(fields, gittask.FieldSubjectURL) + if m.github_url != nil { + fields = append(fields, agentskillrepo.FieldGithubURL) } - if m.subject_title != nil { - fields = append(fields, gittask.FieldSubjectTitle) + if m.ref_type != nil { + fields = append(fields, agentskillrepo.FieldRefType) } - if m.prompt_id != nil { - fields = append(fields, gittask.FieldPromptID) + if m.ref_value != nil { + fields = append(fields, agentskillrepo.FieldRefValue) } - if m.show_url != nil { - fields = append(fields, gittask.FieldShowURL) + if m.last_upload_filename != nil { + fields = append(fields, agentskillrepo.FieldLastUploadFilename) } - if m.github_installation_id != nil { - fields = append(fields, gittask.FieldGithubInstallationID) + if m.last_upload_at != nil { + fields = append(fields, agentskillrepo.FieldLastUploadAt) + } + if m.is_deleted != nil { + fields = append(fields, agentskillrepo.FieldIsDeleted) } if m.created_at != nil { - fields = append(fields, gittask.FieldCreatedAt) + fields = append(fields, agentskillrepo.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, agentskillrepo.FieldUpdatedAt) } return fields } @@ -5532,30 +7644,34 @@ func (m *GitTaskMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *GitTaskMutation) Field(name string) (ent.Value, bool) { +func (m *AgentSkillRepoMutation) Field(name string) (ent.Value, bool) { switch name { - case gittask.FieldTaskID: - return m.TaskID() - case gittask.FieldRepoID: - return m.RepoID() - case gittask.FieldSubjectType: - return m.SubjectType() - case gittask.FieldSubjectID: - return m.SubjectID() - case gittask.FieldSubjectNumber: - return m.SubjectNumber() - case gittask.FieldSubjectURL: - return m.SubjectURL() - case gittask.FieldSubjectTitle: - return m.SubjectTitle() - case gittask.FieldPromptID: - return m.PromptID() - case gittask.FieldShowURL: - return m.ShowURL() - case gittask.FieldGithubInstallationID: - return m.GithubInstallationID() - case gittask.FieldCreatedAt: + case agentskillrepo.FieldName: + return m.Name() + case agentskillrepo.FieldScopeType: + return m.ScopeType() + case agentskillrepo.FieldScopeID: + return m.ScopeID() + case agentskillrepo.FieldCreatedBy: + return m.CreatedBy() + case agentskillrepo.FieldSourceType: + return m.SourceType() + case agentskillrepo.FieldGithubURL: + return m.GithubURL() + case agentskillrepo.FieldRefType: + return m.RefType() + case agentskillrepo.FieldRefValue: + return m.RefValue() + case agentskillrepo.FieldLastUploadFilename: + return m.LastUploadFilename() + case agentskillrepo.FieldLastUploadAt: + return m.LastUploadAt() + case agentskillrepo.FieldIsDeleted: + return m.IsDeleted() + case agentskillrepo.FieldCreatedAt: return m.CreatedAt() + case agentskillrepo.FieldUpdatedAt: + return m.UpdatedAt() } return nil, false } @@ -5563,410 +7679,372 @@ func (m *GitTaskMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *GitTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *AgentSkillRepoMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case gittask.FieldTaskID: - return m.OldTaskID(ctx) - case gittask.FieldRepoID: - return m.OldRepoID(ctx) - case gittask.FieldSubjectType: - return m.OldSubjectType(ctx) - case gittask.FieldSubjectID: - return m.OldSubjectID(ctx) - case gittask.FieldSubjectNumber: - return m.OldSubjectNumber(ctx) - case gittask.FieldSubjectURL: - return m.OldSubjectURL(ctx) - case gittask.FieldSubjectTitle: - return m.OldSubjectTitle(ctx) - case gittask.FieldPromptID: - return m.OldPromptID(ctx) - case gittask.FieldShowURL: - return m.OldShowURL(ctx) - case gittask.FieldGithubInstallationID: - return m.OldGithubInstallationID(ctx) - case gittask.FieldCreatedAt: + case agentskillrepo.FieldName: + return m.OldName(ctx) + case agentskillrepo.FieldScopeType: + return m.OldScopeType(ctx) + case agentskillrepo.FieldScopeID: + return m.OldScopeID(ctx) + case agentskillrepo.FieldCreatedBy: + return m.OldCreatedBy(ctx) + case agentskillrepo.FieldSourceType: + return m.OldSourceType(ctx) + case agentskillrepo.FieldGithubURL: + return m.OldGithubURL(ctx) + case agentskillrepo.FieldRefType: + return m.OldRefType(ctx) + case agentskillrepo.FieldRefValue: + return m.OldRefValue(ctx) + case agentskillrepo.FieldLastUploadFilename: + return m.OldLastUploadFilename(ctx) + case agentskillrepo.FieldLastUploadAt: + return m.OldLastUploadAt(ctx) + case agentskillrepo.FieldIsDeleted: + return m.OldIsDeleted(ctx) + case agentskillrepo.FieldCreatedAt: return m.OldCreatedAt(ctx) + case agentskillrepo.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown GitTask field %s", name) + return nil, fmt.Errorf("unknown AgentSkillRepo field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *GitTaskMutation) SetField(name string, value ent.Value) error { +func (m *AgentSkillRepoMutation) SetField(name string, value ent.Value) error { switch name { - case gittask.FieldTaskID: - v, ok := value.(uuid.UUID) + case agentskillrepo.FieldName: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetTaskID(v) + m.SetName(v) return nil - case gittask.FieldRepoID: - v, ok := value.(uuid.UUID) + case agentskillrepo.FieldScopeType: + v, ok := value.(agentskillrepo.ScopeType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRepoID(v) + m.SetScopeType(v) return nil - case gittask.FieldSubjectType: + case agentskillrepo.FieldScopeID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSubjectType(v) + m.SetScopeID(v) return nil - case gittask.FieldSubjectID: - v, ok := value.(string) + case agentskillrepo.FieldCreatedBy: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSubjectID(v) + m.SetCreatedBy(v) return nil - case gittask.FieldSubjectNumber: - v, ok := value.(int) + case agentskillrepo.FieldSourceType: + v, ok := value.(agentskillrepo.SourceType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSubjectNumber(v) + m.SetSourceType(v) return nil - case gittask.FieldSubjectURL: + case agentskillrepo.FieldGithubURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSubjectURL(v) + m.SetGithubURL(v) return nil - case gittask.FieldSubjectTitle: - v, ok := value.(string) + case agentskillrepo.FieldRefType: + v, ok := value.(agentskillrepo.RefType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSubjectTitle(v) + m.SetRefType(v) return nil - case gittask.FieldPromptID: + case agentskillrepo.FieldRefValue: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPromptID(v) + m.SetRefValue(v) return nil - case gittask.FieldShowURL: + case agentskillrepo.FieldLastUploadFilename: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetShowURL(v) + m.SetLastUploadFilename(v) return nil - case gittask.FieldGithubInstallationID: - v, ok := value.(int64) + case agentskillrepo.FieldLastUploadAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetGithubInstallationID(v) + m.SetLastUploadAt(v) return nil - case gittask.FieldCreatedAt: + case agentskillrepo.FieldIsDeleted: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsDeleted(v) + return nil + case agentskillrepo.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil + case agentskillrepo.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil } - return fmt.Errorf("unknown GitTask field %s", name) + return fmt.Errorf("unknown AgentSkillRepo field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *GitTaskMutation) AddedFields() []string { - var fields []string - if m.addsubject_number != nil { - fields = append(fields, gittask.FieldSubjectNumber) - } - if m.addgithub_installation_id != nil { - fields = append(fields, gittask.FieldGithubInstallationID) - } - return fields +func (m *AgentSkillRepoMutation) AddedFields() []string { + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *GitTaskMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case gittask.FieldSubjectNumber: - return m.AddedSubjectNumber() - case gittask.FieldGithubInstallationID: - return m.AddedGithubInstallationID() - } +func (m *AgentSkillRepoMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *GitTaskMutation) AddField(name string, value ent.Value) error { +func (m *AgentSkillRepoMutation) AddField(name string, value ent.Value) error { switch name { - case gittask.FieldSubjectNumber: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSubjectNumber(v) - return nil - case gittask.FieldGithubInstallationID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddGithubInstallationID(v) - return nil } - return fmt.Errorf("unknown GitTask numeric field %s", name) + return fmt.Errorf("unknown AgentSkillRepo numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *GitTaskMutation) ClearedFields() []string { +func (m *AgentSkillRepoMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(gittask.FieldRepoID) { - fields = append(fields, gittask.FieldRepoID) - } - if m.FieldCleared(gittask.FieldSubjectID) { - fields = append(fields, gittask.FieldSubjectID) - } - if m.FieldCleared(gittask.FieldSubjectNumber) { - fields = append(fields, gittask.FieldSubjectNumber) - } - if m.FieldCleared(gittask.FieldSubjectURL) { - fields = append(fields, gittask.FieldSubjectURL) + if m.FieldCleared(agentskillrepo.FieldGithubURL) { + fields = append(fields, agentskillrepo.FieldGithubURL) } - if m.FieldCleared(gittask.FieldSubjectTitle) { - fields = append(fields, gittask.FieldSubjectTitle) + if m.FieldCleared(agentskillrepo.FieldRefType) { + fields = append(fields, agentskillrepo.FieldRefType) } - if m.FieldCleared(gittask.FieldPromptID) { - fields = append(fields, gittask.FieldPromptID) + if m.FieldCleared(agentskillrepo.FieldRefValue) { + fields = append(fields, agentskillrepo.FieldRefValue) } - if m.FieldCleared(gittask.FieldShowURL) { - fields = append(fields, gittask.FieldShowURL) + if m.FieldCleared(agentskillrepo.FieldLastUploadFilename) { + fields = append(fields, agentskillrepo.FieldLastUploadFilename) } - if m.FieldCleared(gittask.FieldGithubInstallationID) { - fields = append(fields, gittask.FieldGithubInstallationID) + if m.FieldCleared(agentskillrepo.FieldLastUploadAt) { + fields = append(fields, agentskillrepo.FieldLastUploadAt) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *GitTaskMutation) FieldCleared(name string) bool { +func (m *AgentSkillRepoMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *GitTaskMutation) ClearField(name string) error { +func (m *AgentSkillRepoMutation) ClearField(name string) error { switch name { - case gittask.FieldRepoID: - m.ClearRepoID() - return nil - case gittask.FieldSubjectID: - m.ClearSubjectID() - return nil - case gittask.FieldSubjectNumber: - m.ClearSubjectNumber() - return nil - case gittask.FieldSubjectURL: - m.ClearSubjectURL() + case agentskillrepo.FieldGithubURL: + m.ClearGithubURL() return nil - case gittask.FieldSubjectTitle: - m.ClearSubjectTitle() + case agentskillrepo.FieldRefType: + m.ClearRefType() return nil - case gittask.FieldPromptID: - m.ClearPromptID() + case agentskillrepo.FieldRefValue: + m.ClearRefValue() return nil - case gittask.FieldShowURL: - m.ClearShowURL() + case agentskillrepo.FieldLastUploadFilename: + m.ClearLastUploadFilename() return nil - case gittask.FieldGithubInstallationID: - m.ClearGithubInstallationID() + case agentskillrepo.FieldLastUploadAt: + m.ClearLastUploadAt() return nil } - return fmt.Errorf("unknown GitTask nullable field %s", name) + return fmt.Errorf("unknown AgentSkillRepo nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *GitTaskMutation) ResetField(name string) error { +func (m *AgentSkillRepoMutation) ResetField(name string) error { switch name { - case gittask.FieldTaskID: - m.ResetTaskID() + case agentskillrepo.FieldName: + m.ResetName() return nil - case gittask.FieldRepoID: - m.ResetRepoID() + case agentskillrepo.FieldScopeType: + m.ResetScopeType() return nil - case gittask.FieldSubjectType: - m.ResetSubjectType() + case agentskillrepo.FieldScopeID: + m.ResetScopeID() return nil - case gittask.FieldSubjectID: - m.ResetSubjectID() + case agentskillrepo.FieldCreatedBy: + m.ResetCreatedBy() return nil - case gittask.FieldSubjectNumber: - m.ResetSubjectNumber() + case agentskillrepo.FieldSourceType: + m.ResetSourceType() return nil - case gittask.FieldSubjectURL: - m.ResetSubjectURL() + case agentskillrepo.FieldGithubURL: + m.ResetGithubURL() return nil - case gittask.FieldSubjectTitle: - m.ResetSubjectTitle() + case agentskillrepo.FieldRefType: + m.ResetRefType() return nil - case gittask.FieldPromptID: - m.ResetPromptID() + case agentskillrepo.FieldRefValue: + m.ResetRefValue() return nil - case gittask.FieldShowURL: - m.ResetShowURL() + case agentskillrepo.FieldLastUploadFilename: + m.ResetLastUploadFilename() return nil - case gittask.FieldGithubInstallationID: - m.ResetGithubInstallationID() + case agentskillrepo.FieldLastUploadAt: + m.ResetLastUploadAt() return nil - case gittask.FieldCreatedAt: + case agentskillrepo.FieldIsDeleted: + m.ResetIsDeleted() + return nil + case agentskillrepo.FieldCreatedAt: m.ResetCreatedAt() return nil + case agentskillrepo.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil } - return fmt.Errorf("unknown GitTask field %s", name) + return fmt.Errorf("unknown AgentSkillRepo field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *GitTaskMutation) AddedEdges() []string { +func (m *AgentSkillRepoMutation) AddedEdges() []string { edges := make([]string, 0, 1) - if m.task != nil { - edges = append(edges, gittask.EdgeTask) + if m.skills != nil { + edges = append(edges, agentskillrepo.EdgeSkills) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *GitTaskMutation) AddedIDs(name string) []ent.Value { +func (m *AgentSkillRepoMutation) AddedIDs(name string) []ent.Value { switch name { - case gittask.EdgeTask: - if id := m.task; id != nil { - return []ent.Value{*id} + case agentskillrepo.EdgeSkills: + ids := make([]ent.Value, 0, len(m.skills)) + for id := range m.skills { + ids = append(ids, id) } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *GitTaskMutation) RemovedEdges() []string { +func (m *AgentSkillRepoMutation) RemovedEdges() []string { edges := make([]string, 0, 1) + if m.removedskills != nil { + edges = append(edges, agentskillrepo.EdgeSkills) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *GitTaskMutation) RemovedIDs(name string) []ent.Value { +func (m *AgentSkillRepoMutation) RemovedIDs(name string) []ent.Value { + switch name { + case agentskillrepo.EdgeSkills: + ids := make([]ent.Value, 0, len(m.removedskills)) + for id := range m.removedskills { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *GitTaskMutation) ClearedEdges() []string { +func (m *AgentSkillRepoMutation) ClearedEdges() []string { edges := make([]string, 0, 1) - if m.clearedtask { - edges = append(edges, gittask.EdgeTask) + if m.clearedskills { + edges = append(edges, agentskillrepo.EdgeSkills) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *GitTaskMutation) EdgeCleared(name string) bool { +func (m *AgentSkillRepoMutation) EdgeCleared(name string) bool { switch name { - case gittask.EdgeTask: - return m.clearedtask + case agentskillrepo.EdgeSkills: + return m.clearedskills } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *GitTaskMutation) ClearEdge(name string) error { +func (m *AgentSkillRepoMutation) ClearEdge(name string) error { switch name { - case gittask.EdgeTask: - m.ClearTask() - return nil } - return fmt.Errorf("unknown GitTask unique edge %s", name) + return fmt.Errorf("unknown AgentSkillRepo unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *GitTaskMutation) ResetEdge(name string) error { +func (m *AgentSkillRepoMutation) ResetEdge(name string) error { switch name { - case gittask.EdgeTask: - m.ResetTask() + case agentskillrepo.EdgeSkills: + m.ResetSkills() return nil } - return fmt.Errorf("unknown GitTask edge %s", name) + return fmt.Errorf("unknown AgentSkillRepo edge %s", name) } -// HostMutation represents an operation that mutates the Host nodes in the graph. -type HostMutation struct { +// AgentSkillVersionMutation represents an operation that mutates the AgentSkillVersion nodes in the graph. +type AgentSkillVersionMutation struct { config - op Op - typ string - id *string - deleted_at *time.Time - hostname *string - arch *string - cores *int - addcores *int - weight *int - addweight *int - memory *int64 - addmemory *int64 - disk *int64 - adddisk *int64 - os *string - external_ip *string - internal_ip *string - version *string - machine_id *string - remark *string - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - vms map[string]struct{} - removedvms map[string]struct{} - clearedvms bool - user *uuid.UUID - cleareduser bool - groups map[uuid.UUID]struct{} - removedgroups map[uuid.UUID]struct{} - clearedgroups bool - git_bots map[uuid.UUID]struct{} - removedgit_bots map[uuid.UUID]struct{} - clearedgit_bots bool - team_group_hosts map[uuid.UUID]struct{} - removedteam_group_hosts map[uuid.UUID]struct{} - clearedteam_group_hosts bool - done bool - oldValue func(context.Context) (*Host, error) - predicates []predicate.Host + op Op + typ string + id *uuid.UUID + version *string + s3_key *string + parsed_meta *types.SkillParsedMeta + created_at *time.Time + clearedFields map[string]struct{} + skill *uuid.UUID + clearedskill bool + done bool + oldValue func(context.Context) (*AgentSkillVersion, error) + predicates []predicate.AgentSkillVersion } -var _ ent.Mutation = (*HostMutation)(nil) +var _ ent.Mutation = (*AgentSkillVersionMutation)(nil) -// hostOption allows management of the mutation configuration using functional options. -type hostOption func(*HostMutation) +// agentskillversionOption allows management of the mutation configuration using functional options. +type agentskillversionOption func(*AgentSkillVersionMutation) -// newHostMutation creates new mutation for the Host entity. -func newHostMutation(c config, op Op, opts ...hostOption) *HostMutation { - m := &HostMutation{ +// newAgentSkillVersionMutation creates new mutation for the AgentSkillVersion entity. +func newAgentSkillVersionMutation(c config, op Op, opts ...agentskillversionOption) *AgentSkillVersionMutation { + m := &AgentSkillVersionMutation{ config: c, op: op, - typ: TypeHost, + typ: TypeAgentSkillVersion, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -5975,20 +8053,20 @@ func newHostMutation(c config, op Op, opts ...hostOption) *HostMutation { return m } -// withHostID sets the ID field of the mutation. -func withHostID(id string) hostOption { - return func(m *HostMutation) { +// withAgentSkillVersionID sets the ID field of the mutation. +func withAgentSkillVersionID(id uuid.UUID) agentskillversionOption { + return func(m *AgentSkillVersionMutation) { var ( err error once sync.Once - value *Host + value *AgentSkillVersion ) - m.oldValue = func(ctx context.Context) (*Host, error) { + m.oldValue = func(ctx context.Context) (*AgentSkillVersion, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Host.Get(ctx, id) + value, err = m.Client().AgentSkillVersion.Get(ctx, id) } }) return value, err @@ -5997,10 +8075,10 @@ func withHostID(id string) hostOption { } } -// withHost sets the old Host of the mutation. -func withHost(node *Host) hostOption { - return func(m *HostMutation) { - m.oldValue = func(context.Context) (*Host, error) { +// withAgentSkillVersion sets the old AgentSkillVersion of the mutation. +func withAgentSkillVersion(node *AgentSkillVersion) agentskillversionOption { + return func(m *AgentSkillVersionMutation) { + m.oldValue = func(context.Context) (*AgentSkillVersion, error) { return node, nil } m.id = &node.ID @@ -6009,7 +8087,7 @@ func withHost(node *Host) hostOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m HostMutation) Client() *Client { +func (m AgentSkillVersionMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -6017,7 +8095,7 @@ func (m HostMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m HostMutation) Tx() (*Tx, error) { +func (m AgentSkillVersionMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -6027,14 +8105,14 @@ func (m HostMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Host entities. -func (m *HostMutation) SetID(id string) { +// operation is only accepted on creation of AgentSkillVersion entities. +func (m *AgentSkillVersionMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *HostMutation) ID() (id string, exists bool) { +func (m *AgentSkillVersionMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -6045,1088 +8123,1250 @@ func (m *HostMutation) ID() (id string, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *HostMutation) IDs(ctx context.Context) ([]string, error) { +func (m *AgentSkillVersionMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []string{id}, nil + return []uuid.UUID{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Host.Query().Where(m.predicates...).IDs(ctx) + return m.Client().AgentSkillVersion.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetDeletedAt sets the "deleted_at" field. -func (m *HostMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t +// SetResourceID sets the "resource_id" field. +func (m *AgentSkillVersionMutation) SetResourceID(u uuid.UUID) { + m.skill = &u } -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *HostMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at +// ResourceID returns the value of the "resource_id" field in the mutation. +func (m *AgentSkillVersionMutation) ResourceID() (r uuid.UUID, exists bool) { + v := m.skill if v == nil { return } return *v, true } -// OldDeletedAt returns the old "deleted_at" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldResourceID returns the old "resource_id" field's value of the AgentSkillVersion entity. +// If the AgentSkillVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentSkillVersionMutation) OldResourceID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + return v, errors.New("OldResourceID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") + return v, errors.New("OldResourceID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + return v, fmt.Errorf("querying old value for OldResourceID: %w", err) } - return oldValue.DeletedAt, nil -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *HostMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[host.FieldDeletedAt] = struct{}{} -} - -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *HostMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[host.FieldDeletedAt] - return ok + return oldValue.ResourceID, nil } -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *HostMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, host.FieldDeletedAt) +// ResetResourceID resets all changes to the "resource_id" field. +func (m *AgentSkillVersionMutation) ResetResourceID() { + m.skill = nil } -// SetUserID sets the "user_id" field. -func (m *HostMutation) SetUserID(u uuid.UUID) { - m.user = &u +// SetVersion sets the "version" field. +func (m *AgentSkillVersionMutation) SetVersion(s string) { + m.version = &s } -// UserID returns the value of the "user_id" field in the mutation. -func (m *HostMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user +// Version returns the value of the "version" field in the mutation. +func (m *AgentSkillVersionMutation) Version() (r string, exists bool) { + v := m.version if v == nil { return } return *v, true } -// OldUserID returns the old "user_id" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldVersion returns the old "version" field's value of the AgentSkillVersion entity. +// If the AgentSkillVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AgentSkillVersionMutation) OldVersion(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") + return v, errors.New("OldVersion is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") + return v, errors.New("OldVersion requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + return v, fmt.Errorf("querying old value for OldVersion: %w", err) } - return oldValue.UserID, nil + return oldValue.Version, nil } -// ResetUserID resets all changes to the "user_id" field. -func (m *HostMutation) ResetUserID() { - m.user = nil +// ResetVersion resets all changes to the "version" field. +func (m *AgentSkillVersionMutation) ResetVersion() { + m.version = nil } -// SetHostname sets the "hostname" field. -func (m *HostMutation) SetHostname(s string) { - m.hostname = &s +// SetS3Key sets the "s3_key" field. +func (m *AgentSkillVersionMutation) SetS3Key(s string) { + m.s3_key = &s } -// Hostname returns the value of the "hostname" field in the mutation. -func (m *HostMutation) Hostname() (r string, exists bool) { - v := m.hostname +// S3Key returns the value of the "s3_key" field in the mutation. +func (m *AgentSkillVersionMutation) S3Key() (r string, exists bool) { + v := m.s3_key if v == nil { return } return *v, true } -// OldHostname returns the old "hostname" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldS3Key returns the old "s3_key" field's value of the AgentSkillVersion entity. +// If the AgentSkillVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldHostname(ctx context.Context) (v string, err error) { +func (m *AgentSkillVersionMutation) OldS3Key(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHostname is only allowed on UpdateOne operations") + return v, errors.New("OldS3Key is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHostname requires an ID field in the mutation") + return v, errors.New("OldS3Key requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldHostname: %w", err) + return v, fmt.Errorf("querying old value for OldS3Key: %w", err) } - return oldValue.Hostname, nil -} - -// ClearHostname clears the value of the "hostname" field. -func (m *HostMutation) ClearHostname() { - m.hostname = nil - m.clearedFields[host.FieldHostname] = struct{}{} -} - -// HostnameCleared returns if the "hostname" field was cleared in this mutation. -func (m *HostMutation) HostnameCleared() bool { - _, ok := m.clearedFields[host.FieldHostname] - return ok + return oldValue.S3Key, nil } -// ResetHostname resets all changes to the "hostname" field. -func (m *HostMutation) ResetHostname() { - m.hostname = nil - delete(m.clearedFields, host.FieldHostname) +// ResetS3Key resets all changes to the "s3_key" field. +func (m *AgentSkillVersionMutation) ResetS3Key() { + m.s3_key = nil } -// SetArch sets the "arch" field. -func (m *HostMutation) SetArch(s string) { - m.arch = &s +// SetParsedMeta sets the "parsed_meta" field. +func (m *AgentSkillVersionMutation) SetParsedMeta(tpm types.SkillParsedMeta) { + m.parsed_meta = &tpm } -// Arch returns the value of the "arch" field in the mutation. -func (m *HostMutation) Arch() (r string, exists bool) { - v := m.arch +// ParsedMeta returns the value of the "parsed_meta" field in the mutation. +func (m *AgentSkillVersionMutation) ParsedMeta() (r types.SkillParsedMeta, exists bool) { + v := m.parsed_meta if v == nil { return } return *v, true } -// OldArch returns the old "arch" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldParsedMeta returns the old "parsed_meta" field's value of the AgentSkillVersion entity. +// If the AgentSkillVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldArch(ctx context.Context) (v string, err error) { +func (m *AgentSkillVersionMutation) OldParsedMeta(ctx context.Context) (v types.SkillParsedMeta, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldArch is only allowed on UpdateOne operations") + return v, errors.New("OldParsedMeta is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldArch requires an ID field in the mutation") + return v, errors.New("OldParsedMeta requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldArch: %w", err) + return v, fmt.Errorf("querying old value for OldParsedMeta: %w", err) } - return oldValue.Arch, nil + return oldValue.ParsedMeta, nil } -// ClearArch clears the value of the "arch" field. -func (m *HostMutation) ClearArch() { - m.arch = nil - m.clearedFields[host.FieldArch] = struct{}{} +// ClearParsedMeta clears the value of the "parsed_meta" field. +func (m *AgentSkillVersionMutation) ClearParsedMeta() { + m.parsed_meta = nil + m.clearedFields[agentskillversion.FieldParsedMeta] = struct{}{} } -// ArchCleared returns if the "arch" field was cleared in this mutation. -func (m *HostMutation) ArchCleared() bool { - _, ok := m.clearedFields[host.FieldArch] +// ParsedMetaCleared returns if the "parsed_meta" field was cleared in this mutation. +func (m *AgentSkillVersionMutation) ParsedMetaCleared() bool { + _, ok := m.clearedFields[agentskillversion.FieldParsedMeta] return ok } -// ResetArch resets all changes to the "arch" field. -func (m *HostMutation) ResetArch() { - m.arch = nil - delete(m.clearedFields, host.FieldArch) +// ResetParsedMeta resets all changes to the "parsed_meta" field. +func (m *AgentSkillVersionMutation) ResetParsedMeta() { + m.parsed_meta = nil + delete(m.clearedFields, agentskillversion.FieldParsedMeta) } -// SetCores sets the "cores" field. -func (m *HostMutation) SetCores(i int) { - m.cores = &i - m.addcores = nil +// SetCreatedAt sets the "created_at" field. +func (m *AgentSkillVersionMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// Cores returns the value of the "cores" field in the mutation. -func (m *HostMutation) Cores() (r int, exists bool) { - v := m.cores +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AgentSkillVersionMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldCores returns the old "cores" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the AgentSkillVersion entity. +// If the AgentSkillVersion object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldCores(ctx context.Context) (v int, err error) { +func (m *AgentSkillVersionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCores is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCores requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCores: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.Cores, nil + return oldValue.CreatedAt, nil } -// AddCores adds i to the "cores" field. -func (m *HostMutation) AddCores(i int) { - if m.addcores != nil { - *m.addcores += i - } else { - m.addcores = &i +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *AgentSkillVersionMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetSkillID sets the "skill" edge to the AgentSkill entity by id. +func (m *AgentSkillVersionMutation) SetSkillID(id uuid.UUID) { + m.skill = &id +} + +// ClearSkill clears the "skill" edge to the AgentSkill entity. +func (m *AgentSkillVersionMutation) ClearSkill() { + m.clearedskill = true + m.clearedFields[agentskillversion.FieldResourceID] = struct{}{} +} + +// SkillCleared reports if the "skill" edge to the AgentSkill entity was cleared. +func (m *AgentSkillVersionMutation) SkillCleared() bool { + return m.clearedskill +} + +// SkillID returns the "skill" edge ID in the mutation. +func (m *AgentSkillVersionMutation) SkillID() (id uuid.UUID, exists bool) { + if m.skill != nil { + return *m.skill, true } + return } -// AddedCores returns the value that was added to the "cores" field in this mutation. -func (m *HostMutation) AddedCores() (r int, exists bool) { - v := m.addcores - if v == nil { - return +// SkillIDs returns the "skill" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// SkillID instead. It exists only for internal usage by the builders. +func (m *AgentSkillVersionMutation) SkillIDs() (ids []uuid.UUID) { + if id := m.skill; id != nil { + ids = append(ids, *id) } - return *v, true + return } -// ClearCores clears the value of the "cores" field. -func (m *HostMutation) ClearCores() { - m.cores = nil - m.addcores = nil - m.clearedFields[host.FieldCores] = struct{}{} +// ResetSkill resets all changes to the "skill" edge. +func (m *AgentSkillVersionMutation) ResetSkill() { + m.skill = nil + m.clearedskill = false } -// CoresCleared returns if the "cores" field was cleared in this mutation. -func (m *HostMutation) CoresCleared() bool { - _, ok := m.clearedFields[host.FieldCores] - return ok +// Where appends a list predicates to the AgentSkillVersionMutation builder. +func (m *AgentSkillVersionMutation) Where(ps ...predicate.AgentSkillVersion) { + m.predicates = append(m.predicates, ps...) } -// ResetCores resets all changes to the "cores" field. -func (m *HostMutation) ResetCores() { - m.cores = nil - m.addcores = nil - delete(m.clearedFields, host.FieldCores) +// WhereP appends storage-level predicates to the AgentSkillVersionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *AgentSkillVersionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.AgentSkillVersion, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) } -// SetWeight sets the "weight" field. -func (m *HostMutation) SetWeight(i int) { - m.weight = &i - m.addweight = nil +// Op returns the operation name. +func (m *AgentSkillVersionMutation) Op() Op { + return m.op } -// Weight returns the value of the "weight" field in the mutation. -func (m *HostMutation) Weight() (r int, exists bool) { - v := m.weight - if v == nil { - return - } - return *v, true +// SetOp allows setting the mutation operation. +func (m *AgentSkillVersionMutation) SetOp(op Op) { + m.op = op } -// OldWeight returns the old "weight" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldWeight(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWeight is only allowed on UpdateOne operations") +// Type returns the node type of this mutation (AgentSkillVersion). +func (m *AgentSkillVersionMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *AgentSkillVersionMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.skill != nil { + fields = append(fields, agentskillversion.FieldResourceID) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWeight requires an ID field in the mutation") + if m.version != nil { + fields = append(fields, agentskillversion.FieldVersion) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldWeight: %w", err) + if m.s3_key != nil { + fields = append(fields, agentskillversion.FieldS3Key) } - return oldValue.Weight, nil + if m.parsed_meta != nil { + fields = append(fields, agentskillversion.FieldParsedMeta) + } + if m.created_at != nil { + fields = append(fields, agentskillversion.FieldCreatedAt) + } + return fields } -// AddWeight adds i to the "weight" field. -func (m *HostMutation) AddWeight(i int) { - if m.addweight != nil { - *m.addweight += i - } else { - m.addweight = &i +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *AgentSkillVersionMutation) Field(name string) (ent.Value, bool) { + switch name { + case agentskillversion.FieldResourceID: + return m.ResourceID() + case agentskillversion.FieldVersion: + return m.Version() + case agentskillversion.FieldS3Key: + return m.S3Key() + case agentskillversion.FieldParsedMeta: + return m.ParsedMeta() + case agentskillversion.FieldCreatedAt: + return m.CreatedAt() } + return nil, false } -// AddedWeight returns the value that was added to the "weight" field in this mutation. -func (m *HostMutation) AddedWeight() (r int, exists bool) { - v := m.addweight - if v == nil { - return +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *AgentSkillVersionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case agentskillversion.FieldResourceID: + return m.OldResourceID(ctx) + case agentskillversion.FieldVersion: + return m.OldVersion(ctx) + case agentskillversion.FieldS3Key: + return m.OldS3Key(ctx) + case agentskillversion.FieldParsedMeta: + return m.OldParsedMeta(ctx) + case agentskillversion.FieldCreatedAt: + return m.OldCreatedAt(ctx) } - return *v, true + return nil, fmt.Errorf("unknown AgentSkillVersion field %s", name) } -// ResetWeight resets all changes to the "weight" field. -func (m *HostMutation) ResetWeight() { - m.weight = nil - m.addweight = nil +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AgentSkillVersionMutation) SetField(name string, value ent.Value) error { + switch name { + case agentskillversion.FieldResourceID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetResourceID(v) + return nil + case agentskillversion.FieldVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersion(v) + return nil + case agentskillversion.FieldS3Key: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetS3Key(v) + return nil + case agentskillversion.FieldParsedMeta: + v, ok := value.(types.SkillParsedMeta) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetParsedMeta(v) + return nil + case agentskillversion.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + } + return fmt.Errorf("unknown AgentSkillVersion field %s", name) } -// SetMemory sets the "memory" field. -func (m *HostMutation) SetMemory(i int64) { - m.memory = &i - m.addmemory = nil +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *AgentSkillVersionMutation) AddedFields() []string { + return nil } -// Memory returns the value of the "memory" field in the mutation. -func (m *HostMutation) Memory() (r int64, exists bool) { - v := m.memory - if v == nil { - return +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *AgentSkillVersionMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AgentSkillVersionMutation) AddField(name string, value ent.Value) error { + switch name { } - return *v, true + return fmt.Errorf("unknown AgentSkillVersion numeric field %s", name) } -// OldMemory returns the old "memory" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldMemory(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMemory is only allowed on UpdateOne operations") +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *AgentSkillVersionMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(agentskillversion.FieldParsedMeta) { + fields = append(fields, agentskillversion.FieldParsedMeta) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMemory requires an ID field in the mutation") + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *AgentSkillVersionMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *AgentSkillVersionMutation) ClearField(name string) error { + switch name { + case agentskillversion.FieldParsedMeta: + m.ClearParsedMeta() + return nil } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMemory: %w", err) + return fmt.Errorf("unknown AgentSkillVersion nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *AgentSkillVersionMutation) ResetField(name string) error { + switch name { + case agentskillversion.FieldResourceID: + m.ResetResourceID() + return nil + case agentskillversion.FieldVersion: + m.ResetVersion() + return nil + case agentskillversion.FieldS3Key: + m.ResetS3Key() + return nil + case agentskillversion.FieldParsedMeta: + m.ResetParsedMeta() + return nil + case agentskillversion.FieldCreatedAt: + m.ResetCreatedAt() + return nil } - return oldValue.Memory, nil + return fmt.Errorf("unknown AgentSkillVersion field %s", name) } -// AddMemory adds i to the "memory" field. -func (m *HostMutation) AddMemory(i int64) { - if m.addmemory != nil { - *m.addmemory += i - } else { - m.addmemory = &i +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *AgentSkillVersionMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.skill != nil { + edges = append(edges, agentskillversion.EdgeSkill) } + return edges } -// AddedMemory returns the value that was added to the "memory" field in this mutation. -func (m *HostMutation) AddedMemory() (r int64, exists bool) { - v := m.addmemory - if v == nil { - return +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *AgentSkillVersionMutation) AddedIDs(name string) []ent.Value { + switch name { + case agentskillversion.EdgeSkill: + if id := m.skill; id != nil { + return []ent.Value{*id} + } } - return *v, true + return nil } -// ClearMemory clears the value of the "memory" field. -func (m *HostMutation) ClearMemory() { - m.memory = nil - m.addmemory = nil - m.clearedFields[host.FieldMemory] = struct{}{} +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *AgentSkillVersionMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges } -// MemoryCleared returns if the "memory" field was cleared in this mutation. -func (m *HostMutation) MemoryCleared() bool { - _, ok := m.clearedFields[host.FieldMemory] - return ok +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *AgentSkillVersionMutation) RemovedIDs(name string) []ent.Value { + return nil } -// ResetMemory resets all changes to the "memory" field. -func (m *HostMutation) ResetMemory() { - m.memory = nil - m.addmemory = nil - delete(m.clearedFields, host.FieldMemory) +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *AgentSkillVersionMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedskill { + edges = append(edges, agentskillversion.EdgeSkill) + } + return edges } -// SetDisk sets the "disk" field. -func (m *HostMutation) SetDisk(i int64) { - m.disk = &i - m.adddisk = nil +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *AgentSkillVersionMutation) EdgeCleared(name string) bool { + switch name { + case agentskillversion.EdgeSkill: + return m.clearedskill + } + return false } -// Disk returns the value of the "disk" field in the mutation. -func (m *HostMutation) Disk() (r int64, exists bool) { - v := m.disk - if v == nil { - return +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *AgentSkillVersionMutation) ClearEdge(name string) error { + switch name { + case agentskillversion.EdgeSkill: + m.ClearSkill() + return nil } - return *v, true + return fmt.Errorf("unknown AgentSkillVersion unique edge %s", name) } -// OldDisk returns the old "disk" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldDisk(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDisk is only allowed on UpdateOne operations") +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *AgentSkillVersionMutation) ResetEdge(name string) error { + switch name { + case agentskillversion.EdgeSkill: + m.ResetSkill() + return nil } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDisk requires an ID field in the mutation") + return fmt.Errorf("unknown AgentSkillVersion edge %s", name) +} + +// AgentSyncJobMutation represents an operation that mutates the AgentSyncJob nodes in the graph. +type AgentSyncJobMutation struct { + config + op Op + typ string + id *uuid.UUID + resource_kind *agentsyncjob.ResourceKind + rule_id *uuid.UUID + repo_id *uuid.UUID + source_type *agentsyncjob.SourceType + status *agentsyncjob.Status + trigger_type *agentsyncjob.TriggerType + triggered_by *uuid.UUID + started_at *time.Time + finished_at *time.Time + errors *types.SyncJobErrors + appenderrors types.SyncJobErrors + result_summary *types.SyncJobResultSummary + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*AgentSyncJob, error) + predicates []predicate.AgentSyncJob +} + +var _ ent.Mutation = (*AgentSyncJobMutation)(nil) + +// agentsyncjobOption allows management of the mutation configuration using functional options. +type agentsyncjobOption func(*AgentSyncJobMutation) + +// newAgentSyncJobMutation creates new mutation for the AgentSyncJob entity. +func newAgentSyncJobMutation(c config, op Op, opts ...agentsyncjobOption) *AgentSyncJobMutation { + m := &AgentSyncJobMutation{ + config: c, + op: op, + typ: TypeAgentSyncJob, + clearedFields: make(map[string]struct{}), } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDisk: %w", err) + for _, opt := range opts { + opt(m) } - return oldValue.Disk, nil + return m } -// AddDisk adds i to the "disk" field. -func (m *HostMutation) AddDisk(i int64) { - if m.adddisk != nil { - *m.adddisk += i - } else { - m.adddisk = &i +// withAgentSyncJobID sets the ID field of the mutation. +func withAgentSyncJobID(id uuid.UUID) agentsyncjobOption { + return func(m *AgentSyncJobMutation) { + var ( + err error + once sync.Once + value *AgentSyncJob + ) + m.oldValue = func(ctx context.Context) (*AgentSyncJob, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().AgentSyncJob.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } } -// AddedDisk returns the value that was added to the "disk" field in this mutation. -func (m *HostMutation) AddedDisk() (r int64, exists bool) { - v := m.adddisk - if v == nil { - return +// withAgentSyncJob sets the old AgentSyncJob of the mutation. +func withAgentSyncJob(node *AgentSyncJob) agentsyncjobOption { + return func(m *AgentSyncJobMutation) { + m.oldValue = func(context.Context) (*AgentSyncJob, error) { + return node, nil + } + m.id = &node.ID } - return *v, true } -// ClearDisk clears the value of the "disk" field. -func (m *HostMutation) ClearDisk() { - m.disk = nil - m.adddisk = nil - m.clearedFields[host.FieldDisk] = struct{}{} +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m AgentSyncJobMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// DiskCleared returns if the "disk" field was cleared in this mutation. -func (m *HostMutation) DiskCleared() bool { - _, ok := m.clearedFields[host.FieldDisk] - return ok +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m AgentSyncJobMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// ResetDisk resets all changes to the "disk" field. -func (m *HostMutation) ResetDisk() { - m.disk = nil - m.adddisk = nil - delete(m.clearedFields, host.FieldDisk) +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of AgentSyncJob entities. +func (m *AgentSyncJobMutation) SetID(id uuid.UUID) { + m.id = &id } -// SetOs sets the "os" field. -func (m *HostMutation) SetOs(s string) { - m.os = &s +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *AgentSyncJobMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true } -// Os returns the value of the "os" field in the mutation. -func (m *HostMutation) Os() (r string, exists bool) { - v := m.os +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *AgentSyncJobMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().AgentSyncJob.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetResourceKind sets the "resource_kind" field. +func (m *AgentSyncJobMutation) SetResourceKind(ak agentsyncjob.ResourceKind) { + m.resource_kind = &ak +} + +// ResourceKind returns the value of the "resource_kind" field in the mutation. +func (m *AgentSyncJobMutation) ResourceKind() (r agentsyncjob.ResourceKind, exists bool) { + v := m.resource_kind if v == nil { return } return *v, true } -// OldOs returns the old "os" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldResourceKind returns the old "resource_kind" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldOs(ctx context.Context) (v string, err error) { +func (m *AgentSyncJobMutation) OldResourceKind(ctx context.Context) (v agentsyncjob.ResourceKind, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOs is only allowed on UpdateOne operations") + return v, errors.New("OldResourceKind is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOs requires an ID field in the mutation") + return v, errors.New("OldResourceKind requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOs: %w", err) + return v, fmt.Errorf("querying old value for OldResourceKind: %w", err) } - return oldValue.Os, nil + return oldValue.ResourceKind, nil } -// ClearOs clears the value of the "os" field. -func (m *HostMutation) ClearOs() { - m.os = nil - m.clearedFields[host.FieldOs] = struct{}{} +// ResetResourceKind resets all changes to the "resource_kind" field. +func (m *AgentSyncJobMutation) ResetResourceKind() { + m.resource_kind = nil } -// OsCleared returns if the "os" field was cleared in this mutation. -func (m *HostMutation) OsCleared() bool { - _, ok := m.clearedFields[host.FieldOs] - return ok -} - -// ResetOs resets all changes to the "os" field. -func (m *HostMutation) ResetOs() { - m.os = nil - delete(m.clearedFields, host.FieldOs) -} - -// SetExternalIP sets the "external_ip" field. -func (m *HostMutation) SetExternalIP(s string) { - m.external_ip = &s +// SetRuleID sets the "rule_id" field. +func (m *AgentSyncJobMutation) SetRuleID(u uuid.UUID) { + m.rule_id = &u } -// ExternalIP returns the value of the "external_ip" field in the mutation. -func (m *HostMutation) ExternalIP() (r string, exists bool) { - v := m.external_ip +// RuleID returns the value of the "rule_id" field in the mutation. +func (m *AgentSyncJobMutation) RuleID() (r uuid.UUID, exists bool) { + v := m.rule_id if v == nil { return } return *v, true } -// OldExternalIP returns the old "external_ip" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldRuleID returns the old "rule_id" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldExternalIP(ctx context.Context) (v string, err error) { +func (m *AgentSyncJobMutation) OldRuleID(ctx context.Context) (v *uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExternalIP is only allowed on UpdateOne operations") + return v, errors.New("OldRuleID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExternalIP requires an ID field in the mutation") + return v, errors.New("OldRuleID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExternalIP: %w", err) + return v, fmt.Errorf("querying old value for OldRuleID: %w", err) } - return oldValue.ExternalIP, nil + return oldValue.RuleID, nil } -// ClearExternalIP clears the value of the "external_ip" field. -func (m *HostMutation) ClearExternalIP() { - m.external_ip = nil - m.clearedFields[host.FieldExternalIP] = struct{}{} +// ClearRuleID clears the value of the "rule_id" field. +func (m *AgentSyncJobMutation) ClearRuleID() { + m.rule_id = nil + m.clearedFields[agentsyncjob.FieldRuleID] = struct{}{} } -// ExternalIPCleared returns if the "external_ip" field was cleared in this mutation. -func (m *HostMutation) ExternalIPCleared() bool { - _, ok := m.clearedFields[host.FieldExternalIP] +// RuleIDCleared returns if the "rule_id" field was cleared in this mutation. +func (m *AgentSyncJobMutation) RuleIDCleared() bool { + _, ok := m.clearedFields[agentsyncjob.FieldRuleID] return ok } -// ResetExternalIP resets all changes to the "external_ip" field. -func (m *HostMutation) ResetExternalIP() { - m.external_ip = nil - delete(m.clearedFields, host.FieldExternalIP) +// ResetRuleID resets all changes to the "rule_id" field. +func (m *AgentSyncJobMutation) ResetRuleID() { + m.rule_id = nil + delete(m.clearedFields, agentsyncjob.FieldRuleID) } -// SetInternalIP sets the "internal_ip" field. -func (m *HostMutation) SetInternalIP(s string) { - m.internal_ip = &s +// SetRepoID sets the "repo_id" field. +func (m *AgentSyncJobMutation) SetRepoID(u uuid.UUID) { + m.repo_id = &u } -// InternalIP returns the value of the "internal_ip" field in the mutation. -func (m *HostMutation) InternalIP() (r string, exists bool) { - v := m.internal_ip +// RepoID returns the value of the "repo_id" field in the mutation. +func (m *AgentSyncJobMutation) RepoID() (r uuid.UUID, exists bool) { + v := m.repo_id if v == nil { return } return *v, true } -// OldInternalIP returns the old "internal_ip" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldRepoID returns the old "repo_id" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldInternalIP(ctx context.Context) (v string, err error) { +func (m *AgentSyncJobMutation) OldRepoID(ctx context.Context) (v *uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInternalIP is only allowed on UpdateOne operations") + return v, errors.New("OldRepoID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInternalIP requires an ID field in the mutation") + return v, errors.New("OldRepoID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInternalIP: %w", err) + return v, fmt.Errorf("querying old value for OldRepoID: %w", err) } - return oldValue.InternalIP, nil + return oldValue.RepoID, nil } -// ClearInternalIP clears the value of the "internal_ip" field. -func (m *HostMutation) ClearInternalIP() { - m.internal_ip = nil - m.clearedFields[host.FieldInternalIP] = struct{}{} +// ClearRepoID clears the value of the "repo_id" field. +func (m *AgentSyncJobMutation) ClearRepoID() { + m.repo_id = nil + m.clearedFields[agentsyncjob.FieldRepoID] = struct{}{} } -// InternalIPCleared returns if the "internal_ip" field was cleared in this mutation. -func (m *HostMutation) InternalIPCleared() bool { - _, ok := m.clearedFields[host.FieldInternalIP] +// RepoIDCleared returns if the "repo_id" field was cleared in this mutation. +func (m *AgentSyncJobMutation) RepoIDCleared() bool { + _, ok := m.clearedFields[agentsyncjob.FieldRepoID] return ok } -// ResetInternalIP resets all changes to the "internal_ip" field. -func (m *HostMutation) ResetInternalIP() { - m.internal_ip = nil - delete(m.clearedFields, host.FieldInternalIP) +// ResetRepoID resets all changes to the "repo_id" field. +func (m *AgentSyncJobMutation) ResetRepoID() { + m.repo_id = nil + delete(m.clearedFields, agentsyncjob.FieldRepoID) } -// SetVersion sets the "version" field. -func (m *HostMutation) SetVersion(s string) { - m.version = &s +// SetSourceType sets the "source_type" field. +func (m *AgentSyncJobMutation) SetSourceType(at agentsyncjob.SourceType) { + m.source_type = &at } -// Version returns the value of the "version" field in the mutation. -func (m *HostMutation) Version() (r string, exists bool) { - v := m.version +// SourceType returns the value of the "source_type" field in the mutation. +func (m *AgentSyncJobMutation) SourceType() (r agentsyncjob.SourceType, exists bool) { + v := m.source_type if v == nil { return } return *v, true } -// OldVersion returns the old "version" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldSourceType returns the old "source_type" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldVersion(ctx context.Context) (v string, err error) { +func (m *AgentSyncJobMutation) OldSourceType(ctx context.Context) (v agentsyncjob.SourceType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVersion is only allowed on UpdateOne operations") + return v, errors.New("OldSourceType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVersion requires an ID field in the mutation") + return v, errors.New("OldSourceType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVersion: %w", err) + return v, fmt.Errorf("querying old value for OldSourceType: %w", err) } - return oldValue.Version, nil -} - -// ClearVersion clears the value of the "version" field. -func (m *HostMutation) ClearVersion() { - m.version = nil - m.clearedFields[host.FieldVersion] = struct{}{} -} - -// VersionCleared returns if the "version" field was cleared in this mutation. -func (m *HostMutation) VersionCleared() bool { - _, ok := m.clearedFields[host.FieldVersion] - return ok + return oldValue.SourceType, nil } -// ResetVersion resets all changes to the "version" field. -func (m *HostMutation) ResetVersion() { - m.version = nil - delete(m.clearedFields, host.FieldVersion) +// ResetSourceType resets all changes to the "source_type" field. +func (m *AgentSyncJobMutation) ResetSourceType() { + m.source_type = nil } -// SetMachineID sets the "machine_id" field. -func (m *HostMutation) SetMachineID(s string) { - m.machine_id = &s +// SetStatus sets the "status" field. +func (m *AgentSyncJobMutation) SetStatus(a agentsyncjob.Status) { + m.status = &a } -// MachineID returns the value of the "machine_id" field in the mutation. -func (m *HostMutation) MachineID() (r string, exists bool) { - v := m.machine_id +// Status returns the value of the "status" field in the mutation. +func (m *AgentSyncJobMutation) Status() (r agentsyncjob.Status, exists bool) { + v := m.status if v == nil { return } return *v, true } -// OldMachineID returns the old "machine_id" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldStatus returns the old "status" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldMachineID(ctx context.Context) (v string, err error) { +func (m *AgentSyncJobMutation) OldStatus(ctx context.Context) (v agentsyncjob.Status, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMachineID is only allowed on UpdateOne operations") + return v, errors.New("OldStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMachineID requires an ID field in the mutation") + return v, errors.New("OldStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldMachineID: %w", err) + return v, fmt.Errorf("querying old value for OldStatus: %w", err) } - return oldValue.MachineID, nil -} - -// ClearMachineID clears the value of the "machine_id" field. -func (m *HostMutation) ClearMachineID() { - m.machine_id = nil - m.clearedFields[host.FieldMachineID] = struct{}{} -} - -// MachineIDCleared returns if the "machine_id" field was cleared in this mutation. -func (m *HostMutation) MachineIDCleared() bool { - _, ok := m.clearedFields[host.FieldMachineID] - return ok + return oldValue.Status, nil } -// ResetMachineID resets all changes to the "machine_id" field. -func (m *HostMutation) ResetMachineID() { - m.machine_id = nil - delete(m.clearedFields, host.FieldMachineID) +// ResetStatus resets all changes to the "status" field. +func (m *AgentSyncJobMutation) ResetStatus() { + m.status = nil } -// SetRemark sets the "remark" field. -func (m *HostMutation) SetRemark(s string) { - m.remark = &s +// SetTriggerType sets the "trigger_type" field. +func (m *AgentSyncJobMutation) SetTriggerType(at agentsyncjob.TriggerType) { + m.trigger_type = &at } -// Remark returns the value of the "remark" field in the mutation. -func (m *HostMutation) Remark() (r string, exists bool) { - v := m.remark +// TriggerType returns the value of the "trigger_type" field in the mutation. +func (m *AgentSyncJobMutation) TriggerType() (r agentsyncjob.TriggerType, exists bool) { + v := m.trigger_type if v == nil { return } return *v, true } -// OldRemark returns the old "remark" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldTriggerType returns the old "trigger_type" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldRemark(ctx context.Context) (v string, err error) { +func (m *AgentSyncJobMutation) OldTriggerType(ctx context.Context) (v agentsyncjob.TriggerType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRemark is only allowed on UpdateOne operations") + return v, errors.New("OldTriggerType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRemark requires an ID field in the mutation") + return v, errors.New("OldTriggerType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRemark: %w", err) + return v, fmt.Errorf("querying old value for OldTriggerType: %w", err) } - return oldValue.Remark, nil -} - -// ClearRemark clears the value of the "remark" field. -func (m *HostMutation) ClearRemark() { - m.remark = nil - m.clearedFields[host.FieldRemark] = struct{}{} + return oldValue.TriggerType, nil } -// RemarkCleared returns if the "remark" field was cleared in this mutation. -func (m *HostMutation) RemarkCleared() bool { - _, ok := m.clearedFields[host.FieldRemark] - return ok -} - -// ResetRemark resets all changes to the "remark" field. -func (m *HostMutation) ResetRemark() { - m.remark = nil - delete(m.clearedFields, host.FieldRemark) +// ResetTriggerType resets all changes to the "trigger_type" field. +func (m *AgentSyncJobMutation) ResetTriggerType() { + m.trigger_type = nil } -// SetCreatedAt sets the "created_at" field. -func (m *HostMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// SetTriggeredBy sets the "triggered_by" field. +func (m *AgentSyncJobMutation) SetTriggeredBy(u uuid.UUID) { + m.triggered_by = &u } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *HostMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// TriggeredBy returns the value of the "triggered_by" field in the mutation. +func (m *AgentSyncJobMutation) TriggeredBy() (r uuid.UUID, exists bool) { + v := m.triggered_by if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldTriggeredBy returns the old "triggered_by" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentSyncJobMutation) OldTriggeredBy(ctx context.Context) (v *uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldTriggeredBy is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + return v, errors.New("OldTriggeredBy requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldTriggeredBy: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.TriggeredBy, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *HostMutation) ResetCreatedAt() { - m.created_at = nil +// ClearTriggeredBy clears the value of the "triggered_by" field. +func (m *AgentSyncJobMutation) ClearTriggeredBy() { + m.triggered_by = nil + m.clearedFields[agentsyncjob.FieldTriggeredBy] = struct{}{} } -// SetUpdatedAt sets the "updated_at" field. -func (m *HostMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t +// TriggeredByCleared returns if the "triggered_by" field was cleared in this mutation. +func (m *AgentSyncJobMutation) TriggeredByCleared() bool { + _, ok := m.clearedFields[agentsyncjob.FieldTriggeredBy] + return ok } -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *HostMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at +// ResetTriggeredBy resets all changes to the "triggered_by" field. +func (m *AgentSyncJobMutation) ResetTriggeredBy() { + m.triggered_by = nil + delete(m.clearedFields, agentsyncjob.FieldTriggeredBy) +} + +// SetStartedAt sets the "started_at" field. +func (m *AgentSyncJobMutation) SetStartedAt(t time.Time) { + m.started_at = &t +} + +// StartedAt returns the value of the "started_at" field in the mutation. +func (m *AgentSyncJobMutation) StartedAt() (r time.Time, exists bool) { + v := m.started_at if v == nil { return } return *v, true } -// OldUpdatedAt returns the old "updated_at" field's value of the Host entity. -// If the Host object wasn't provided to the builder, the object is fetched from the database. +// OldStartedAt returns the old "started_at" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AgentSyncJobMutation) OldStartedAt(ctx context.Context) (v *time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldStartedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + return v, errors.New("OldStartedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldStartedAt: %w", err) } - return oldValue.UpdatedAt, nil + return oldValue.StartedAt, nil } -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *HostMutation) ResetUpdatedAt() { - m.updated_at = nil +// ClearStartedAt clears the value of the "started_at" field. +func (m *AgentSyncJobMutation) ClearStartedAt() { + m.started_at = nil + m.clearedFields[agentsyncjob.FieldStartedAt] = struct{}{} } -// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids. -func (m *HostMutation) AddVMIDs(ids ...string) { - if m.vms == nil { - m.vms = make(map[string]struct{}) - } - for i := range ids { - m.vms[ids[i]] = struct{}{} - } +// StartedAtCleared returns if the "started_at" field was cleared in this mutation. +func (m *AgentSyncJobMutation) StartedAtCleared() bool { + _, ok := m.clearedFields[agentsyncjob.FieldStartedAt] + return ok } -// ClearVms clears the "vms" edge to the VirtualMachine entity. -func (m *HostMutation) ClearVms() { - m.clearedvms = true +// ResetStartedAt resets all changes to the "started_at" field. +func (m *AgentSyncJobMutation) ResetStartedAt() { + m.started_at = nil + delete(m.clearedFields, agentsyncjob.FieldStartedAt) } -// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared. -func (m *HostMutation) VmsCleared() bool { - return m.clearedvms +// SetFinishedAt sets the "finished_at" field. +func (m *AgentSyncJobMutation) SetFinishedAt(t time.Time) { + m.finished_at = &t } -// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs. -func (m *HostMutation) RemoveVMIDs(ids ...string) { - if m.removedvms == nil { - m.removedvms = make(map[string]struct{}) - } - for i := range ids { - delete(m.vms, ids[i]) - m.removedvms[ids[i]] = struct{}{} +// FinishedAt returns the value of the "finished_at" field in the mutation. +func (m *AgentSyncJobMutation) FinishedAt() (r time.Time, exists bool) { + v := m.finished_at + if v == nil { + return } + return *v, true } -// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity. -func (m *HostMutation) RemovedVmsIDs() (ids []string) { - for id := range m.removedvms { - ids = append(ids, id) +// OldFinishedAt returns the old "finished_at" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSyncJobMutation) OldFinishedAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFinishedAt is only allowed on UpdateOne operations") } - return -} - -// VmsIDs returns the "vms" edge IDs in the mutation. -func (m *HostMutation) VmsIDs() (ids []string) { - for id := range m.vms { - ids = append(ids, id) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFinishedAt requires an ID field in the mutation") } - return + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFinishedAt: %w", err) + } + return oldValue.FinishedAt, nil } -// ResetVms resets all changes to the "vms" edge. -func (m *HostMutation) ResetVms() { - m.vms = nil - m.clearedvms = false - m.removedvms = nil +// ClearFinishedAt clears the value of the "finished_at" field. +func (m *AgentSyncJobMutation) ClearFinishedAt() { + m.finished_at = nil + m.clearedFields[agentsyncjob.FieldFinishedAt] = struct{}{} } -// ClearUser clears the "user" edge to the User entity. -func (m *HostMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[host.FieldUserID] = struct{}{} +// FinishedAtCleared returns if the "finished_at" field was cleared in this mutation. +func (m *AgentSyncJobMutation) FinishedAtCleared() bool { + _, ok := m.clearedFields[agentsyncjob.FieldFinishedAt] + return ok } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *HostMutation) UserCleared() bool { - return m.cleareduser +// ResetFinishedAt resets all changes to the "finished_at" field. +func (m *AgentSyncJobMutation) ResetFinishedAt() { + m.finished_at = nil + delete(m.clearedFields, agentsyncjob.FieldFinishedAt) } -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *HostMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { - ids = append(ids, *id) - } - return +// SetErrors sets the "errors" field. +func (m *AgentSyncJobMutation) SetErrors(tje types.SyncJobErrors) { + m.errors = &tje + m.appenderrors = nil } -// ResetUser resets all changes to the "user" edge. -func (m *HostMutation) ResetUser() { - m.user = nil - m.cleareduser = false +// Errors returns the value of the "errors" field in the mutation. +func (m *AgentSyncJobMutation) Errors() (r types.SyncJobErrors, exists bool) { + v := m.errors + if v == nil { + return + } + return *v, true } -// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids. -func (m *HostMutation) AddGroupIDs(ids ...uuid.UUID) { - if m.groups == nil { - m.groups = make(map[uuid.UUID]struct{}) +// OldErrors returns the old "errors" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSyncJobMutation) OldErrors(ctx context.Context) (v types.SyncJobErrors, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldErrors is only allowed on UpdateOne operations") } - for i := range ids { - m.groups[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldErrors requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldErrors: %w", err) } + return oldValue.Errors, nil } -// ClearGroups clears the "groups" edge to the TeamGroup entity. -func (m *HostMutation) ClearGroups() { - m.clearedgroups = true +// AppendErrors adds tje to the "errors" field. +func (m *AgentSyncJobMutation) AppendErrors(tje types.SyncJobErrors) { + m.appenderrors = append(m.appenderrors, tje...) } -// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared. -func (m *HostMutation) GroupsCleared() bool { - return m.clearedgroups +// AppendedErrors returns the list of values that were appended to the "errors" field in this mutation. +func (m *AgentSyncJobMutation) AppendedErrors() (types.SyncJobErrors, bool) { + if len(m.appenderrors) == 0 { + return nil, false + } + return m.appenderrors, true } -// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs. -func (m *HostMutation) RemoveGroupIDs(ids ...uuid.UUID) { - if m.removedgroups == nil { - m.removedgroups = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.groups, ids[i]) - m.removedgroups[ids[i]] = struct{}{} - } +// ClearErrors clears the value of the "errors" field. +func (m *AgentSyncJobMutation) ClearErrors() { + m.errors = nil + m.appenderrors = nil + m.clearedFields[agentsyncjob.FieldErrors] = struct{}{} } -// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity. -func (m *HostMutation) RemovedGroupsIDs() (ids []uuid.UUID) { - for id := range m.removedgroups { - ids = append(ids, id) - } - return +// ErrorsCleared returns if the "errors" field was cleared in this mutation. +func (m *AgentSyncJobMutation) ErrorsCleared() bool { + _, ok := m.clearedFields[agentsyncjob.FieldErrors] + return ok } -// GroupsIDs returns the "groups" edge IDs in the mutation. -func (m *HostMutation) GroupsIDs() (ids []uuid.UUID) { - for id := range m.groups { - ids = append(ids, id) - } - return +// ResetErrors resets all changes to the "errors" field. +func (m *AgentSyncJobMutation) ResetErrors() { + m.errors = nil + m.appenderrors = nil + delete(m.clearedFields, agentsyncjob.FieldErrors) } -// ResetGroups resets all changes to the "groups" edge. -func (m *HostMutation) ResetGroups() { - m.groups = nil - m.clearedgroups = false - m.removedgroups = nil +// SetResultSummary sets the "result_summary" field. +func (m *AgentSyncJobMutation) SetResultSummary(tjrs types.SyncJobResultSummary) { + m.result_summary = &tjrs } -// AddGitBotIDs adds the "git_bots" edge to the GitBot entity by ids. -func (m *HostMutation) AddGitBotIDs(ids ...uuid.UUID) { - if m.git_bots == nil { - m.git_bots = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.git_bots[ids[i]] = struct{}{} +// ResultSummary returns the value of the "result_summary" field in the mutation. +func (m *AgentSyncJobMutation) ResultSummary() (r types.SyncJobResultSummary, exists bool) { + v := m.result_summary + if v == nil { + return } + return *v, true } -// ClearGitBots clears the "git_bots" edge to the GitBot entity. -func (m *HostMutation) ClearGitBots() { - m.clearedgit_bots = true +// OldResultSummary returns the old "result_summary" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSyncJobMutation) OldResultSummary(ctx context.Context) (v types.SyncJobResultSummary, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldResultSummary is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldResultSummary requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldResultSummary: %w", err) + } + return oldValue.ResultSummary, nil } -// GitBotsCleared reports if the "git_bots" edge to the GitBot entity was cleared. -func (m *HostMutation) GitBotsCleared() bool { - return m.clearedgit_bots +// ClearResultSummary clears the value of the "result_summary" field. +func (m *AgentSyncJobMutation) ClearResultSummary() { + m.result_summary = nil + m.clearedFields[agentsyncjob.FieldResultSummary] = struct{}{} } -// RemoveGitBotIDs removes the "git_bots" edge to the GitBot entity by IDs. -func (m *HostMutation) RemoveGitBotIDs(ids ...uuid.UUID) { - if m.removedgit_bots == nil { - m.removedgit_bots = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.git_bots, ids[i]) - m.removedgit_bots[ids[i]] = struct{}{} - } +// ResultSummaryCleared returns if the "result_summary" field was cleared in this mutation. +func (m *AgentSyncJobMutation) ResultSummaryCleared() bool { + _, ok := m.clearedFields[agentsyncjob.FieldResultSummary] + return ok } -// RemovedGitBots returns the removed IDs of the "git_bots" edge to the GitBot entity. -func (m *HostMutation) RemovedGitBotsIDs() (ids []uuid.UUID) { - for id := range m.removedgit_bots { - ids = append(ids, id) - } - return +// ResetResultSummary resets all changes to the "result_summary" field. +func (m *AgentSyncJobMutation) ResetResultSummary() { + m.result_summary = nil + delete(m.clearedFields, agentsyncjob.FieldResultSummary) } -// GitBotsIDs returns the "git_bots" edge IDs in the mutation. -func (m *HostMutation) GitBotsIDs() (ids []uuid.UUID) { - for id := range m.git_bots { - ids = append(ids, id) - } - return +// SetCreatedAt sets the "created_at" field. +func (m *AgentSyncJobMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// ResetGitBots resets all changes to the "git_bots" edge. -func (m *HostMutation) ResetGitBots() { - m.git_bots = nil - m.clearedgit_bots = false - m.removedgit_bots = nil +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AgentSyncJobMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true } -// AddTeamGroupHostIDs adds the "team_group_hosts" edge to the TeamGroupHost entity by ids. -func (m *HostMutation) AddTeamGroupHostIDs(ids ...uuid.UUID) { - if m.team_group_hosts == nil { - m.team_group_hosts = make(map[uuid.UUID]struct{}) +// OldCreatedAt returns the old "created_at" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSyncJobMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } - for i := range ids { - m.team_group_hosts[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } + return oldValue.CreatedAt, nil } -// ClearTeamGroupHosts clears the "team_group_hosts" edge to the TeamGroupHost entity. -func (m *HostMutation) ClearTeamGroupHosts() { - m.clearedteam_group_hosts = true +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *AgentSyncJobMutation) ResetCreatedAt() { + m.created_at = nil } -// TeamGroupHostsCleared reports if the "team_group_hosts" edge to the TeamGroupHost entity was cleared. -func (m *HostMutation) TeamGroupHostsCleared() bool { - return m.clearedteam_group_hosts +// SetUpdatedAt sets the "updated_at" field. +func (m *AgentSyncJobMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t } -// RemoveTeamGroupHostIDs removes the "team_group_hosts" edge to the TeamGroupHost entity by IDs. -func (m *HostMutation) RemoveTeamGroupHostIDs(ids ...uuid.UUID) { - if m.removedteam_group_hosts == nil { - m.removedteam_group_hosts = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.team_group_hosts, ids[i]) - m.removedteam_group_hosts[ids[i]] = struct{}{} +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *AgentSyncJobMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return } + return *v, true } -// RemovedTeamGroupHosts returns the removed IDs of the "team_group_hosts" edge to the TeamGroupHost entity. -func (m *HostMutation) RemovedTeamGroupHostsIDs() (ids []uuid.UUID) { - for id := range m.removedteam_group_hosts { - ids = append(ids, id) +// OldUpdatedAt returns the old "updated_at" field's value of the AgentSyncJob entity. +// If the AgentSyncJob object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AgentSyncJobMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } - return -} - -// TeamGroupHostsIDs returns the "team_group_hosts" edge IDs in the mutation. -func (m *HostMutation) TeamGroupHostsIDs() (ids []uuid.UUID) { - for id := range m.team_group_hosts { - ids = append(ids, id) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } - return + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil } -// ResetTeamGroupHosts resets all changes to the "team_group_hosts" edge. -func (m *HostMutation) ResetTeamGroupHosts() { - m.team_group_hosts = nil - m.clearedteam_group_hosts = false - m.removedteam_group_hosts = nil +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *AgentSyncJobMutation) ResetUpdatedAt() { + m.updated_at = nil } -// Where appends a list predicates to the HostMutation builder. -func (m *HostMutation) Where(ps ...predicate.Host) { +// Where appends a list predicates to the AgentSyncJobMutation builder. +func (m *AgentSyncJobMutation) Where(ps ...predicate.AgentSyncJob) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the HostMutation builder. Using this method, +// WhereP appends storage-level predicates to the AgentSyncJobMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *HostMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Host, len(ps)) +func (m *AgentSyncJobMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.AgentSyncJob, len(ps)) for i := range ps { p[i] = ps[i] } @@ -7134,72 +9374,63 @@ func (m *HostMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *HostMutation) Op() Op { +func (m *AgentSyncJobMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *HostMutation) SetOp(op Op) { +func (m *AgentSyncJobMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Host). -func (m *HostMutation) Type() string { +// Type returns the node type of this mutation (AgentSyncJob). +func (m *AgentSyncJobMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *HostMutation) Fields() []string { - fields := make([]string, 0, 16) - if m.deleted_at != nil { - fields = append(fields, host.FieldDeletedAt) - } - if m.user != nil { - fields = append(fields, host.FieldUserID) - } - if m.hostname != nil { - fields = append(fields, host.FieldHostname) - } - if m.arch != nil { - fields = append(fields, host.FieldArch) +func (m *AgentSyncJobMutation) Fields() []string { + fields := make([]string, 0, 13) + if m.resource_kind != nil { + fields = append(fields, agentsyncjob.FieldResourceKind) } - if m.cores != nil { - fields = append(fields, host.FieldCores) + if m.rule_id != nil { + fields = append(fields, agentsyncjob.FieldRuleID) } - if m.weight != nil { - fields = append(fields, host.FieldWeight) + if m.repo_id != nil { + fields = append(fields, agentsyncjob.FieldRepoID) } - if m.memory != nil { - fields = append(fields, host.FieldMemory) + if m.source_type != nil { + fields = append(fields, agentsyncjob.FieldSourceType) } - if m.disk != nil { - fields = append(fields, host.FieldDisk) + if m.status != nil { + fields = append(fields, agentsyncjob.FieldStatus) } - if m.os != nil { - fields = append(fields, host.FieldOs) + if m.trigger_type != nil { + fields = append(fields, agentsyncjob.FieldTriggerType) } - if m.external_ip != nil { - fields = append(fields, host.FieldExternalIP) + if m.triggered_by != nil { + fields = append(fields, agentsyncjob.FieldTriggeredBy) } - if m.internal_ip != nil { - fields = append(fields, host.FieldInternalIP) + if m.started_at != nil { + fields = append(fields, agentsyncjob.FieldStartedAt) } - if m.version != nil { - fields = append(fields, host.FieldVersion) + if m.finished_at != nil { + fields = append(fields, agentsyncjob.FieldFinishedAt) } - if m.machine_id != nil { - fields = append(fields, host.FieldMachineID) + if m.errors != nil { + fields = append(fields, agentsyncjob.FieldErrors) } - if m.remark != nil { - fields = append(fields, host.FieldRemark) + if m.result_summary != nil { + fields = append(fields, agentsyncjob.FieldResultSummary) } if m.created_at != nil { - fields = append(fields, host.FieldCreatedAt) + fields = append(fields, agentsyncjob.FieldCreatedAt) } if m.updated_at != nil { - fields = append(fields, host.FieldUpdatedAt) + fields = append(fields, agentsyncjob.FieldUpdatedAt) } return fields } @@ -7207,39 +9438,33 @@ func (m *HostMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *HostMutation) Field(name string) (ent.Value, bool) { +func (m *AgentSyncJobMutation) Field(name string) (ent.Value, bool) { switch name { - case host.FieldDeletedAt: - return m.DeletedAt() - case host.FieldUserID: - return m.UserID() - case host.FieldHostname: - return m.Hostname() - case host.FieldArch: - return m.Arch() - case host.FieldCores: - return m.Cores() - case host.FieldWeight: - return m.Weight() - case host.FieldMemory: - return m.Memory() - case host.FieldDisk: - return m.Disk() - case host.FieldOs: - return m.Os() - case host.FieldExternalIP: - return m.ExternalIP() - case host.FieldInternalIP: - return m.InternalIP() - case host.FieldVersion: - return m.Version() - case host.FieldMachineID: - return m.MachineID() - case host.FieldRemark: - return m.Remark() - case host.FieldCreatedAt: + case agentsyncjob.FieldResourceKind: + return m.ResourceKind() + case agentsyncjob.FieldRuleID: + return m.RuleID() + case agentsyncjob.FieldRepoID: + return m.RepoID() + case agentsyncjob.FieldSourceType: + return m.SourceType() + case agentsyncjob.FieldStatus: + return m.Status() + case agentsyncjob.FieldTriggerType: + return m.TriggerType() + case agentsyncjob.FieldTriggeredBy: + return m.TriggeredBy() + case agentsyncjob.FieldStartedAt: + return m.StartedAt() + case agentsyncjob.FieldFinishedAt: + return m.FinishedAt() + case agentsyncjob.FieldErrors: + return m.Errors() + case agentsyncjob.FieldResultSummary: + return m.ResultSummary() + case agentsyncjob.FieldCreatedAt: return m.CreatedAt() - case host.FieldUpdatedAt: + case agentsyncjob.FieldUpdatedAt: return m.UpdatedAt() } return nil, false @@ -7248,155 +9473,128 @@ func (m *HostMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *HostMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *AgentSyncJobMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case host.FieldDeletedAt: - return m.OldDeletedAt(ctx) - case host.FieldUserID: - return m.OldUserID(ctx) - case host.FieldHostname: - return m.OldHostname(ctx) - case host.FieldArch: - return m.OldArch(ctx) - case host.FieldCores: - return m.OldCores(ctx) - case host.FieldWeight: - return m.OldWeight(ctx) - case host.FieldMemory: - return m.OldMemory(ctx) - case host.FieldDisk: - return m.OldDisk(ctx) - case host.FieldOs: - return m.OldOs(ctx) - case host.FieldExternalIP: - return m.OldExternalIP(ctx) - case host.FieldInternalIP: - return m.OldInternalIP(ctx) - case host.FieldVersion: - return m.OldVersion(ctx) - case host.FieldMachineID: - return m.OldMachineID(ctx) - case host.FieldRemark: - return m.OldRemark(ctx) - case host.FieldCreatedAt: + case agentsyncjob.FieldResourceKind: + return m.OldResourceKind(ctx) + case agentsyncjob.FieldRuleID: + return m.OldRuleID(ctx) + case agentsyncjob.FieldRepoID: + return m.OldRepoID(ctx) + case agentsyncjob.FieldSourceType: + return m.OldSourceType(ctx) + case agentsyncjob.FieldStatus: + return m.OldStatus(ctx) + case agentsyncjob.FieldTriggerType: + return m.OldTriggerType(ctx) + case agentsyncjob.FieldTriggeredBy: + return m.OldTriggeredBy(ctx) + case agentsyncjob.FieldStartedAt: + return m.OldStartedAt(ctx) + case agentsyncjob.FieldFinishedAt: + return m.OldFinishedAt(ctx) + case agentsyncjob.FieldErrors: + return m.OldErrors(ctx) + case agentsyncjob.FieldResultSummary: + return m.OldResultSummary(ctx) + case agentsyncjob.FieldCreatedAt: return m.OldCreatedAt(ctx) - case host.FieldUpdatedAt: + case agentsyncjob.FieldUpdatedAt: return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown Host field %s", name) + return nil, fmt.Errorf("unknown AgentSyncJob field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *HostMutation) SetField(name string, value ent.Value) error { +func (m *AgentSyncJobMutation) SetField(name string, value ent.Value) error { switch name { - case host.FieldDeletedAt: - v, ok := value.(time.Time) + case agentsyncjob.FieldResourceKind: + v, ok := value.(agentsyncjob.ResourceKind) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDeletedAt(v) + m.SetResourceKind(v) return nil - case host.FieldUserID: + case agentsyncjob.FieldRuleID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) - return nil - case host.FieldHostname: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHostname(v) - return nil - case host.FieldArch: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetArch(v) - return nil - case host.FieldCores: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCores(v) + m.SetRuleID(v) return nil - case host.FieldWeight: - v, ok := value.(int) + case agentsyncjob.FieldRepoID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetWeight(v) + m.SetRepoID(v) return nil - case host.FieldMemory: - v, ok := value.(int64) + case agentsyncjob.FieldSourceType: + v, ok := value.(agentsyncjob.SourceType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetMemory(v) + m.SetSourceType(v) return nil - case host.FieldDisk: - v, ok := value.(int64) + case agentsyncjob.FieldStatus: + v, ok := value.(agentsyncjob.Status) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDisk(v) + m.SetStatus(v) return nil - case host.FieldOs: - v, ok := value.(string) + case agentsyncjob.FieldTriggerType: + v, ok := value.(agentsyncjob.TriggerType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOs(v) + m.SetTriggerType(v) return nil - case host.FieldExternalIP: - v, ok := value.(string) + case agentsyncjob.FieldTriggeredBy: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetExternalIP(v) + m.SetTriggeredBy(v) return nil - case host.FieldInternalIP: - v, ok := value.(string) + case agentsyncjob.FieldStartedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInternalIP(v) + m.SetStartedAt(v) return nil - case host.FieldVersion: - v, ok := value.(string) + case agentsyncjob.FieldFinishedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetVersion(v) + m.SetFinishedAt(v) return nil - case host.FieldMachineID: - v, ok := value.(string) + case agentsyncjob.FieldErrors: + v, ok := value.(types.SyncJobErrors) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetMachineID(v) + m.SetErrors(v) return nil - case host.FieldRemark: - v, ok := value.(string) + case agentsyncjob.FieldResultSummary: + v, ok := value.(types.SyncJobResultSummary) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRemark(v) + m.SetResultSummary(v) return nil - case host.FieldCreatedAt: + case agentsyncjob.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case host.FieldUpdatedAt: + case agentsyncjob.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) @@ -7404,466 +9602,221 @@ func (m *HostMutation) SetField(name string, value ent.Value) error { m.SetUpdatedAt(v) return nil } - return fmt.Errorf("unknown Host field %s", name) + return fmt.Errorf("unknown AgentSyncJob field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *HostMutation) AddedFields() []string { - var fields []string - if m.addcores != nil { - fields = append(fields, host.FieldCores) - } - if m.addweight != nil { - fields = append(fields, host.FieldWeight) - } - if m.addmemory != nil { - fields = append(fields, host.FieldMemory) - } - if m.adddisk != nil { - fields = append(fields, host.FieldDisk) - } - return fields +func (m *AgentSyncJobMutation) AddedFields() []string { + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *HostMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case host.FieldCores: - return m.AddedCores() - case host.FieldWeight: - return m.AddedWeight() - case host.FieldMemory: - return m.AddedMemory() - case host.FieldDisk: - return m.AddedDisk() - } +func (m *AgentSyncJobMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *HostMutation) AddField(name string, value ent.Value) error { +func (m *AgentSyncJobMutation) AddField(name string, value ent.Value) error { switch name { - case host.FieldCores: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddCores(v) - return nil - case host.FieldWeight: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddWeight(v) - return nil - case host.FieldMemory: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddMemory(v) - return nil - case host.FieldDisk: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddDisk(v) - return nil } - return fmt.Errorf("unknown Host numeric field %s", name) + return fmt.Errorf("unknown AgentSyncJob numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *HostMutation) ClearedFields() []string { +func (m *AgentSyncJobMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(host.FieldDeletedAt) { - fields = append(fields, host.FieldDeletedAt) - } - if m.FieldCleared(host.FieldHostname) { - fields = append(fields, host.FieldHostname) - } - if m.FieldCleared(host.FieldArch) { - fields = append(fields, host.FieldArch) - } - if m.FieldCleared(host.FieldCores) { - fields = append(fields, host.FieldCores) + if m.FieldCleared(agentsyncjob.FieldRuleID) { + fields = append(fields, agentsyncjob.FieldRuleID) } - if m.FieldCleared(host.FieldMemory) { - fields = append(fields, host.FieldMemory) - } - if m.FieldCleared(host.FieldDisk) { - fields = append(fields, host.FieldDisk) - } - if m.FieldCleared(host.FieldOs) { - fields = append(fields, host.FieldOs) + if m.FieldCleared(agentsyncjob.FieldRepoID) { + fields = append(fields, agentsyncjob.FieldRepoID) } - if m.FieldCleared(host.FieldExternalIP) { - fields = append(fields, host.FieldExternalIP) + if m.FieldCleared(agentsyncjob.FieldTriggeredBy) { + fields = append(fields, agentsyncjob.FieldTriggeredBy) } - if m.FieldCleared(host.FieldInternalIP) { - fields = append(fields, host.FieldInternalIP) + if m.FieldCleared(agentsyncjob.FieldStartedAt) { + fields = append(fields, agentsyncjob.FieldStartedAt) } - if m.FieldCleared(host.FieldVersion) { - fields = append(fields, host.FieldVersion) + if m.FieldCleared(agentsyncjob.FieldFinishedAt) { + fields = append(fields, agentsyncjob.FieldFinishedAt) } - if m.FieldCleared(host.FieldMachineID) { - fields = append(fields, host.FieldMachineID) + if m.FieldCleared(agentsyncjob.FieldErrors) { + fields = append(fields, agentsyncjob.FieldErrors) } - if m.FieldCleared(host.FieldRemark) { - fields = append(fields, host.FieldRemark) + if m.FieldCleared(agentsyncjob.FieldResultSummary) { + fields = append(fields, agentsyncjob.FieldResultSummary) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *HostMutation) FieldCleared(name string) bool { +func (m *AgentSyncJobMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *HostMutation) ClearField(name string) error { +func (m *AgentSyncJobMutation) ClearField(name string) error { switch name { - case host.FieldDeletedAt: - m.ClearDeletedAt() - return nil - case host.FieldHostname: - m.ClearHostname() - return nil - case host.FieldArch: - m.ClearArch() - return nil - case host.FieldCores: - m.ClearCores() - return nil - case host.FieldMemory: - m.ClearMemory() - return nil - case host.FieldDisk: - m.ClearDisk() + case agentsyncjob.FieldRuleID: + m.ClearRuleID() return nil - case host.FieldOs: - m.ClearOs() + case agentsyncjob.FieldRepoID: + m.ClearRepoID() return nil - case host.FieldExternalIP: - m.ClearExternalIP() + case agentsyncjob.FieldTriggeredBy: + m.ClearTriggeredBy() return nil - case host.FieldInternalIP: - m.ClearInternalIP() + case agentsyncjob.FieldStartedAt: + m.ClearStartedAt() return nil - case host.FieldVersion: - m.ClearVersion() + case agentsyncjob.FieldFinishedAt: + m.ClearFinishedAt() return nil - case host.FieldMachineID: - m.ClearMachineID() + case agentsyncjob.FieldErrors: + m.ClearErrors() return nil - case host.FieldRemark: - m.ClearRemark() + case agentsyncjob.FieldResultSummary: + m.ClearResultSummary() return nil } - return fmt.Errorf("unknown Host nullable field %s", name) + return fmt.Errorf("unknown AgentSyncJob nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *HostMutation) ResetField(name string) error { +func (m *AgentSyncJobMutation) ResetField(name string) error { switch name { - case host.FieldDeletedAt: - m.ResetDeletedAt() - return nil - case host.FieldUserID: - m.ResetUserID() - return nil - case host.FieldHostname: - m.ResetHostname() + case agentsyncjob.FieldResourceKind: + m.ResetResourceKind() return nil - case host.FieldArch: - m.ResetArch() - return nil - case host.FieldCores: - m.ResetCores() + case agentsyncjob.FieldRuleID: + m.ResetRuleID() return nil - case host.FieldWeight: - m.ResetWeight() + case agentsyncjob.FieldRepoID: + m.ResetRepoID() return nil - case host.FieldMemory: - m.ResetMemory() + case agentsyncjob.FieldSourceType: + m.ResetSourceType() return nil - case host.FieldDisk: - m.ResetDisk() + case agentsyncjob.FieldStatus: + m.ResetStatus() return nil - case host.FieldOs: - m.ResetOs() + case agentsyncjob.FieldTriggerType: + m.ResetTriggerType() return nil - case host.FieldExternalIP: - m.ResetExternalIP() + case agentsyncjob.FieldTriggeredBy: + m.ResetTriggeredBy() return nil - case host.FieldInternalIP: - m.ResetInternalIP() + case agentsyncjob.FieldStartedAt: + m.ResetStartedAt() return nil - case host.FieldVersion: - m.ResetVersion() + case agentsyncjob.FieldFinishedAt: + m.ResetFinishedAt() return nil - case host.FieldMachineID: - m.ResetMachineID() + case agentsyncjob.FieldErrors: + m.ResetErrors() return nil - case host.FieldRemark: - m.ResetRemark() + case agentsyncjob.FieldResultSummary: + m.ResetResultSummary() return nil - case host.FieldCreatedAt: + case agentsyncjob.FieldCreatedAt: m.ResetCreatedAt() return nil - case host.FieldUpdatedAt: + case agentsyncjob.FieldUpdatedAt: m.ResetUpdatedAt() return nil } - return fmt.Errorf("unknown Host field %s", name) + return fmt.Errorf("unknown AgentSyncJob field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *HostMutation) AddedEdges() []string { - edges := make([]string, 0, 5) - if m.vms != nil { - edges = append(edges, host.EdgeVms) - } - if m.user != nil { - edges = append(edges, host.EdgeUser) - } - if m.groups != nil { - edges = append(edges, host.EdgeGroups) - } - if m.git_bots != nil { - edges = append(edges, host.EdgeGitBots) - } - if m.team_group_hosts != nil { - edges = append(edges, host.EdgeTeamGroupHosts) - } +func (m *AgentSyncJobMutation) AddedEdges() []string { + edges := make([]string, 0, 0) return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *HostMutation) AddedIDs(name string) []ent.Value { - switch name { - case host.EdgeVms: - ids := make([]ent.Value, 0, len(m.vms)) - for id := range m.vms { - ids = append(ids, id) - } - return ids - case host.EdgeUser: - if id := m.user; id != nil { - return []ent.Value{*id} - } - case host.EdgeGroups: - ids := make([]ent.Value, 0, len(m.groups)) - for id := range m.groups { - ids = append(ids, id) - } - return ids - case host.EdgeGitBots: - ids := make([]ent.Value, 0, len(m.git_bots)) - for id := range m.git_bots { - ids = append(ids, id) - } - return ids - case host.EdgeTeamGroupHosts: - ids := make([]ent.Value, 0, len(m.team_group_hosts)) - for id := range m.team_group_hosts { - ids = append(ids, id) - } - return ids - } +func (m *AgentSyncJobMutation) AddedIDs(name string) []ent.Value { return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *HostMutation) RemovedEdges() []string { - edges := make([]string, 0, 5) - if m.removedvms != nil { - edges = append(edges, host.EdgeVms) - } - if m.removedgroups != nil { - edges = append(edges, host.EdgeGroups) - } - if m.removedgit_bots != nil { - edges = append(edges, host.EdgeGitBots) - } - if m.removedteam_group_hosts != nil { - edges = append(edges, host.EdgeTeamGroupHosts) - } +func (m *AgentSyncJobMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *HostMutation) RemovedIDs(name string) []ent.Value { - switch name { - case host.EdgeVms: - ids := make([]ent.Value, 0, len(m.removedvms)) - for id := range m.removedvms { - ids = append(ids, id) - } - return ids - case host.EdgeGroups: - ids := make([]ent.Value, 0, len(m.removedgroups)) - for id := range m.removedgroups { - ids = append(ids, id) - } - return ids - case host.EdgeGitBots: - ids := make([]ent.Value, 0, len(m.removedgit_bots)) - for id := range m.removedgit_bots { - ids = append(ids, id) - } - return ids - case host.EdgeTeamGroupHosts: - ids := make([]ent.Value, 0, len(m.removedteam_group_hosts)) - for id := range m.removedteam_group_hosts { - ids = append(ids, id) - } - return ids - } +func (m *AgentSyncJobMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *HostMutation) ClearedEdges() []string { - edges := make([]string, 0, 5) - if m.clearedvms { - edges = append(edges, host.EdgeVms) - } - if m.cleareduser { - edges = append(edges, host.EdgeUser) - } - if m.clearedgroups { - edges = append(edges, host.EdgeGroups) - } - if m.clearedgit_bots { - edges = append(edges, host.EdgeGitBots) - } - if m.clearedteam_group_hosts { - edges = append(edges, host.EdgeTeamGroupHosts) - } +func (m *AgentSyncJobMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *HostMutation) EdgeCleared(name string) bool { - switch name { - case host.EdgeVms: - return m.clearedvms - case host.EdgeUser: - return m.cleareduser - case host.EdgeGroups: - return m.clearedgroups - case host.EdgeGitBots: - return m.clearedgit_bots - case host.EdgeTeamGroupHosts: - return m.clearedteam_group_hosts - } +func (m *AgentSyncJobMutation) EdgeCleared(name string) bool { return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *HostMutation) ClearEdge(name string) error { - switch name { - case host.EdgeUser: - m.ClearUser() - return nil - } - return fmt.Errorf("unknown Host unique edge %s", name) +func (m *AgentSyncJobMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown AgentSyncJob unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *HostMutation) ResetEdge(name string) error { - switch name { - case host.EdgeVms: - m.ResetVms() - return nil - case host.EdgeUser: - m.ResetUser() - return nil - case host.EdgeGroups: - m.ResetGroups() - return nil - case host.EdgeGitBots: - m.ResetGitBots() - return nil - case host.EdgeTeamGroupHosts: - m.ResetTeamGroupHosts() - return nil - } - return fmt.Errorf("unknown Host edge %s", name) +func (m *AgentSyncJobMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown AgentSyncJob edge %s", name) } -// ImageMutation represents an operation that mutates the Image nodes in the graph. -type ImageMutation struct { +// AuditMutation represents an operation that mutates the Audit nodes in the graph. +type AuditMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - name *string - remark *string - extension_package_id *string - extension_image_id *string - extension_version *string - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - user *uuid.UUID - cleareduser bool - teams map[uuid.UUID]struct{} - removedteams map[uuid.UUID]struct{} - clearedteams bool - groups map[uuid.UUID]struct{} - removedgroups map[uuid.UUID]struct{} - clearedgroups bool - project_tasks map[uuid.UUID]struct{} - removedproject_tasks map[uuid.UUID]struct{} - clearedproject_tasks bool - projects map[uuid.UUID]struct{} - removedprojects map[uuid.UUID]struct{} - clearedprojects bool - extension_archives map[uuid.UUID]struct{} - removedextension_archives map[uuid.UUID]struct{} - clearedextension_archives bool - team_images map[uuid.UUID]struct{} - removedteam_images map[uuid.UUID]struct{} - clearedteam_images bool - team_group_images map[uuid.UUID]struct{} - removedteam_group_images map[uuid.UUID]struct{} - clearedteam_group_images bool - done bool - oldValue func(context.Context) (*Image, error) - predicates []predicate.Image + op Op + typ string + id *uuid.UUID + operation *string + source_ip *string + user_agent *string + request *string + response *string + created_at *time.Time + clearedFields map[string]struct{} + user *uuid.UUID + cleareduser bool + done bool + oldValue func(context.Context) (*Audit, error) + predicates []predicate.Audit } -var _ ent.Mutation = (*ImageMutation)(nil) +var _ ent.Mutation = (*AuditMutation)(nil) -// imageOption allows management of the mutation configuration using functional options. -type imageOption func(*ImageMutation) +// auditOption allows management of the mutation configuration using functional options. +type auditOption func(*AuditMutation) -// newImageMutation creates new mutation for the Image entity. -func newImageMutation(c config, op Op, opts ...imageOption) *ImageMutation { - m := &ImageMutation{ +// newAuditMutation creates new mutation for the Audit entity. +func newAuditMutation(c config, op Op, opts ...auditOption) *AuditMutation { + m := &AuditMutation{ config: c, op: op, - typ: TypeImage, + typ: TypeAudit, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -7872,20 +9825,20 @@ func newImageMutation(c config, op Op, opts ...imageOption) *ImageMutation { return m } -// withImageID sets the ID field of the mutation. -func withImageID(id uuid.UUID) imageOption { - return func(m *ImageMutation) { - var ( +// withAuditID sets the ID field of the mutation. +func withAuditID(id uuid.UUID) auditOption { + return func(m *AuditMutation) { + var ( err error once sync.Once - value *Image + value *Audit ) - m.oldValue = func(ctx context.Context) (*Image, error) { + m.oldValue = func(ctx context.Context) (*Audit, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Image.Get(ctx, id) + value, err = m.Client().Audit.Get(ctx, id) } }) return value, err @@ -7894,10 +9847,10 @@ func withImageID(id uuid.UUID) imageOption { } } -// withImage sets the old Image of the mutation. -func withImage(node *Image) imageOption { - return func(m *ImageMutation) { - m.oldValue = func(context.Context) (*Image, error) { +// withAudit sets the old Audit of the mutation. +func withAudit(node *Audit) auditOption { + return func(m *AuditMutation) { + m.oldValue = func(context.Context) (*Audit, error) { return node, nil } m.id = &node.ID @@ -7906,7 +9859,7 @@ func withImage(node *Image) imageOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ImageMutation) Client() *Client { +func (m AuditMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -7914,7 +9867,7 @@ func (m ImageMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ImageMutation) Tx() (*Tx, error) { +func (m AuditMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -7924,14 +9877,14 @@ func (m ImageMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Image entities. -func (m *ImageMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of Audit entities. +func (m *AuditMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ImageMutation) ID() (id uuid.UUID, exists bool) { +func (m *AuditMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -7942,7 +9895,7 @@ func (m *ImageMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ImageMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *AuditMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -7951,68 +9904,19 @@ func (m *ImageMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Image.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Audit.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetDeletedAt sets the "deleted_at" field. -func (m *ImageMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t -} - -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *ImageMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at - if v == nil { - return - } - return *v, true -} - -// OldDeletedAt returns the old "deleted_at" field's value of the Image entity. -// If the Image object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ImageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) - } - return oldValue.DeletedAt, nil -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *ImageMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[image.FieldDeletedAt] = struct{}{} -} - -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *ImageMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[image.FieldDeletedAt] - return ok -} - -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *ImageMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, image.FieldDeletedAt) -} - // SetUserID sets the "user_id" field. -func (m *ImageMutation) SetUserID(u uuid.UUID) { +func (m *AuditMutation) SetUserID(u uuid.UUID) { m.user = &u } // UserID returns the value of the "user_id" field in the mutation. -func (m *ImageMutation) UserID() (r uuid.UUID, exists bool) { +func (m *AuditMutation) UserID() (r uuid.UUID, exists bool) { v := m.user if v == nil { return @@ -8020,10 +9924,10 @@ func (m *ImageMutation) UserID() (r uuid.UUID, exists bool) { return *v, true } -// OldUserID returns the old "user_id" field's value of the Image entity. -// If the Image object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the Audit entity. +// If the Audit object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ImageMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { +func (m *AuditMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUserID is only allowed on UpdateOne operations") } @@ -8038,249 +9942,210 @@ func (m *ImageMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) } // ResetUserID resets all changes to the "user_id" field. -func (m *ImageMutation) ResetUserID() { +func (m *AuditMutation) ResetUserID() { m.user = nil } -// SetName sets the "name" field. -func (m *ImageMutation) SetName(s string) { - m.name = &s +// SetOperation sets the "operation" field. +func (m *AuditMutation) SetOperation(s string) { + m.operation = &s } -// Name returns the value of the "name" field in the mutation. -func (m *ImageMutation) Name() (r string, exists bool) { - v := m.name +// Operation returns the value of the "operation" field in the mutation. +func (m *AuditMutation) Operation() (r string, exists bool) { + v := m.operation if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the Image entity. -// If the Image object wasn't provided to the builder, the object is fetched from the database. +// OldOperation returns the old "operation" field's value of the Audit entity. +// If the Audit object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ImageMutation) OldName(ctx context.Context) (v string, err error) { +func (m *AuditMutation) OldOperation(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldOperation is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldOperation requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldOperation: %w", err) } - return oldValue.Name, nil + return oldValue.Operation, nil } -// ResetName resets all changes to the "name" field. -func (m *ImageMutation) ResetName() { - m.name = nil +// ResetOperation resets all changes to the "operation" field. +func (m *AuditMutation) ResetOperation() { + m.operation = nil } -// SetRemark sets the "remark" field. -func (m *ImageMutation) SetRemark(s string) { - m.remark = &s +// SetSourceIP sets the "source_ip" field. +func (m *AuditMutation) SetSourceIP(s string) { + m.source_ip = &s } -// Remark returns the value of the "remark" field in the mutation. -func (m *ImageMutation) Remark() (r string, exists bool) { - v := m.remark +// SourceIP returns the value of the "source_ip" field in the mutation. +func (m *AuditMutation) SourceIP() (r string, exists bool) { + v := m.source_ip if v == nil { return } return *v, true } -// OldRemark returns the old "remark" field's value of the Image entity. -// If the Image object wasn't provided to the builder, the object is fetched from the database. +// OldSourceIP returns the old "source_ip" field's value of the Audit entity. +// If the Audit object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ImageMutation) OldRemark(ctx context.Context) (v string, err error) { +func (m *AuditMutation) OldSourceIP(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRemark is only allowed on UpdateOne operations") + return v, errors.New("OldSourceIP is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRemark requires an ID field in the mutation") + return v, errors.New("OldSourceIP requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRemark: %w", err) + return v, fmt.Errorf("querying old value for OldSourceIP: %w", err) } - return oldValue.Remark, nil -} - -// ClearRemark clears the value of the "remark" field. -func (m *ImageMutation) ClearRemark() { - m.remark = nil - m.clearedFields[image.FieldRemark] = struct{}{} -} - -// RemarkCleared returns if the "remark" field was cleared in this mutation. -func (m *ImageMutation) RemarkCleared() bool { - _, ok := m.clearedFields[image.FieldRemark] - return ok + return oldValue.SourceIP, nil } -// ResetRemark resets all changes to the "remark" field. -func (m *ImageMutation) ResetRemark() { - m.remark = nil - delete(m.clearedFields, image.FieldRemark) +// ResetSourceIP resets all changes to the "source_ip" field. +func (m *AuditMutation) ResetSourceIP() { + m.source_ip = nil } -// SetExtensionPackageID sets the "extension_package_id" field. -func (m *ImageMutation) SetExtensionPackageID(s string) { - m.extension_package_id = &s +// SetUserAgent sets the "user_agent" field. +func (m *AuditMutation) SetUserAgent(s string) { + m.user_agent = &s } -// ExtensionPackageID returns the value of the "extension_package_id" field in the mutation. -func (m *ImageMutation) ExtensionPackageID() (r string, exists bool) { - v := m.extension_package_id +// UserAgent returns the value of the "user_agent" field in the mutation. +func (m *AuditMutation) UserAgent() (r string, exists bool) { + v := m.user_agent if v == nil { return } return *v, true } -// OldExtensionPackageID returns the old "extension_package_id" field's value of the Image entity. -// If the Image object wasn't provided to the builder, the object is fetched from the database. +// OldUserAgent returns the old "user_agent" field's value of the Audit entity. +// If the Audit object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ImageMutation) OldExtensionPackageID(ctx context.Context) (v string, err error) { +func (m *AuditMutation) OldUserAgent(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExtensionPackageID is only allowed on UpdateOne operations") + return v, errors.New("OldUserAgent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExtensionPackageID requires an ID field in the mutation") + return v, errors.New("OldUserAgent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExtensionPackageID: %w", err) + return v, fmt.Errorf("querying old value for OldUserAgent: %w", err) } - return oldValue.ExtensionPackageID, nil -} - -// ClearExtensionPackageID clears the value of the "extension_package_id" field. -func (m *ImageMutation) ClearExtensionPackageID() { - m.extension_package_id = nil - m.clearedFields[image.FieldExtensionPackageID] = struct{}{} -} - -// ExtensionPackageIDCleared returns if the "extension_package_id" field was cleared in this mutation. -func (m *ImageMutation) ExtensionPackageIDCleared() bool { - _, ok := m.clearedFields[image.FieldExtensionPackageID] - return ok + return oldValue.UserAgent, nil } -// ResetExtensionPackageID resets all changes to the "extension_package_id" field. -func (m *ImageMutation) ResetExtensionPackageID() { - m.extension_package_id = nil - delete(m.clearedFields, image.FieldExtensionPackageID) +// ResetUserAgent resets all changes to the "user_agent" field. +func (m *AuditMutation) ResetUserAgent() { + m.user_agent = nil } -// SetExtensionImageID sets the "extension_image_id" field. -func (m *ImageMutation) SetExtensionImageID(s string) { - m.extension_image_id = &s +// SetRequest sets the "request" field. +func (m *AuditMutation) SetRequest(s string) { + m.request = &s } -// ExtensionImageID returns the value of the "extension_image_id" field in the mutation. -func (m *ImageMutation) ExtensionImageID() (r string, exists bool) { - v := m.extension_image_id +// Request returns the value of the "request" field in the mutation. +func (m *AuditMutation) Request() (r string, exists bool) { + v := m.request if v == nil { return } return *v, true } -// OldExtensionImageID returns the old "extension_image_id" field's value of the Image entity. -// If the Image object wasn't provided to the builder, the object is fetched from the database. +// OldRequest returns the old "request" field's value of the Audit entity. +// If the Audit object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ImageMutation) OldExtensionImageID(ctx context.Context) (v string, err error) { +func (m *AuditMutation) OldRequest(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExtensionImageID is only allowed on UpdateOne operations") + return v, errors.New("OldRequest is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExtensionImageID requires an ID field in the mutation") + return v, errors.New("OldRequest requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExtensionImageID: %w", err) + return v, fmt.Errorf("querying old value for OldRequest: %w", err) } - return oldValue.ExtensionImageID, nil -} - -// ClearExtensionImageID clears the value of the "extension_image_id" field. -func (m *ImageMutation) ClearExtensionImageID() { - m.extension_image_id = nil - m.clearedFields[image.FieldExtensionImageID] = struct{}{} -} - -// ExtensionImageIDCleared returns if the "extension_image_id" field was cleared in this mutation. -func (m *ImageMutation) ExtensionImageIDCleared() bool { - _, ok := m.clearedFields[image.FieldExtensionImageID] - return ok + return oldValue.Request, nil } -// ResetExtensionImageID resets all changes to the "extension_image_id" field. -func (m *ImageMutation) ResetExtensionImageID() { - m.extension_image_id = nil - delete(m.clearedFields, image.FieldExtensionImageID) +// ResetRequest resets all changes to the "request" field. +func (m *AuditMutation) ResetRequest() { + m.request = nil } -// SetExtensionVersion sets the "extension_version" field. -func (m *ImageMutation) SetExtensionVersion(s string) { - m.extension_version = &s +// SetResponse sets the "response" field. +func (m *AuditMutation) SetResponse(s string) { + m.response = &s } -// ExtensionVersion returns the value of the "extension_version" field in the mutation. -func (m *ImageMutation) ExtensionVersion() (r string, exists bool) { - v := m.extension_version +// Response returns the value of the "response" field in the mutation. +func (m *AuditMutation) Response() (r string, exists bool) { + v := m.response if v == nil { return } return *v, true } -// OldExtensionVersion returns the old "extension_version" field's value of the Image entity. -// If the Image object wasn't provided to the builder, the object is fetched from the database. +// OldResponse returns the old "response" field's value of the Audit entity. +// If the Audit object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ImageMutation) OldExtensionVersion(ctx context.Context) (v string, err error) { +func (m *AuditMutation) OldResponse(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExtensionVersion is only allowed on UpdateOne operations") + return v, errors.New("OldResponse is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExtensionVersion requires an ID field in the mutation") + return v, errors.New("OldResponse requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExtensionVersion: %w", err) + return v, fmt.Errorf("querying old value for OldResponse: %w", err) } - return oldValue.ExtensionVersion, nil + return oldValue.Response, nil } -// ClearExtensionVersion clears the value of the "extension_version" field. -func (m *ImageMutation) ClearExtensionVersion() { - m.extension_version = nil - m.clearedFields[image.FieldExtensionVersion] = struct{}{} +// ClearResponse clears the value of the "response" field. +func (m *AuditMutation) ClearResponse() { + m.response = nil + m.clearedFields[audit.FieldResponse] = struct{}{} } -// ExtensionVersionCleared returns if the "extension_version" field was cleared in this mutation. -func (m *ImageMutation) ExtensionVersionCleared() bool { - _, ok := m.clearedFields[image.FieldExtensionVersion] +// ResponseCleared returns if the "response" field was cleared in this mutation. +func (m *AuditMutation) ResponseCleared() bool { + _, ok := m.clearedFields[audit.FieldResponse] return ok } -// ResetExtensionVersion resets all changes to the "extension_version" field. -func (m *ImageMutation) ResetExtensionVersion() { - m.extension_version = nil - delete(m.clearedFields, image.FieldExtensionVersion) +// ResetResponse resets all changes to the "response" field. +func (m *AuditMutation) ResetResponse() { + m.response = nil + delete(m.clearedFields, audit.FieldResponse) } // SetCreatedAt sets the "created_at" field. -func (m *ImageMutation) SetCreatedAt(t time.Time) { +func (m *AuditMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ImageMutation) CreatedAt() (r time.Time, exists bool) { +func (m *AuditMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -8288,10 +10153,10 @@ func (m *ImageMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Image entity. -// If the Image object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the Audit entity. +// If the Audit object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ImageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *AuditMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -8306,61 +10171,25 @@ func (m *ImageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err erro } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *ImageMutation) ResetCreatedAt() { +func (m *AuditMutation) ResetCreatedAt() { m.created_at = nil } -// SetUpdatedAt sets the "updated_at" field. -func (m *ImageMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *ImageMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the Image entity. -// If the Image object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ImageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *ImageMutation) ResetUpdatedAt() { - m.updated_at = nil -} - // ClearUser clears the "user" edge to the User entity. -func (m *ImageMutation) ClearUser() { +func (m *AuditMutation) ClearUser() { m.cleareduser = true - m.clearedFields[image.FieldUserID] = struct{}{} + m.clearedFields[audit.FieldUserID] = struct{}{} } // UserCleared reports if the "user" edge to the User entity was cleared. -func (m *ImageMutation) UserCleared() bool { +func (m *AuditMutation) UserCleared() bool { return m.cleareduser } // UserIDs returns the "user" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // UserID instead. It exists only for internal usage by the builders. -func (m *ImageMutation) UserIDs() (ids []uuid.UUID) { +func (m *AuditMutation) UserIDs() (ids []uuid.UUID) { if id := m.user; id != nil { ids = append(ids, *id) } @@ -8368,986 +10197,374 @@ func (m *ImageMutation) UserIDs() (ids []uuid.UUID) { } // ResetUser resets all changes to the "user" edge. -func (m *ImageMutation) ResetUser() { +func (m *AuditMutation) ResetUser() { m.user = nil m.cleareduser = false } -// AddTeamIDs adds the "teams" edge to the Team entity by ids. -func (m *ImageMutation) AddTeamIDs(ids ...uuid.UUID) { - if m.teams == nil { - m.teams = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.teams[ids[i]] = struct{}{} - } -} - -// ClearTeams clears the "teams" edge to the Team entity. -func (m *ImageMutation) ClearTeams() { - m.clearedteams = true -} - -// TeamsCleared reports if the "teams" edge to the Team entity was cleared. -func (m *ImageMutation) TeamsCleared() bool { - return m.clearedteams +// Where appends a list predicates to the AuditMutation builder. +func (m *AuditMutation) Where(ps ...predicate.Audit) { + m.predicates = append(m.predicates, ps...) } -// RemoveTeamIDs removes the "teams" edge to the Team entity by IDs. -func (m *ImageMutation) RemoveTeamIDs(ids ...uuid.UUID) { - if m.removedteams == nil { - m.removedteams = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.teams, ids[i]) - m.removedteams[ids[i]] = struct{}{} +// WhereP appends storage-level predicates to the AuditMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *AuditMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Audit, len(ps)) + for i := range ps { + p[i] = ps[i] } + m.Where(p...) } -// RemovedTeams returns the removed IDs of the "teams" edge to the Team entity. -func (m *ImageMutation) RemovedTeamsIDs() (ids []uuid.UUID) { - for id := range m.removedteams { - ids = append(ids, id) - } - return +// Op returns the operation name. +func (m *AuditMutation) Op() Op { + return m.op } -// TeamsIDs returns the "teams" edge IDs in the mutation. -func (m *ImageMutation) TeamsIDs() (ids []uuid.UUID) { - for id := range m.teams { - ids = append(ids, id) - } - return +// SetOp allows setting the mutation operation. +func (m *AuditMutation) SetOp(op Op) { + m.op = op } -// ResetTeams resets all changes to the "teams" edge. -func (m *ImageMutation) ResetTeams() { - m.teams = nil - m.clearedteams = false - m.removedteams = nil +// Type returns the node type of this mutation (Audit). +func (m *AuditMutation) Type() string { + return m.typ } -// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids. -func (m *ImageMutation) AddGroupIDs(ids ...uuid.UUID) { - if m.groups == nil { - m.groups = make(map[uuid.UUID]struct{}) +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *AuditMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.user != nil { + fields = append(fields, audit.FieldUserID) } - for i := range ids { - m.groups[ids[i]] = struct{}{} + if m.operation != nil { + fields = append(fields, audit.FieldOperation) } -} - -// ClearGroups clears the "groups" edge to the TeamGroup entity. -func (m *ImageMutation) ClearGroups() { - m.clearedgroups = true -} - -// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared. -func (m *ImageMutation) GroupsCleared() bool { - return m.clearedgroups -} - -// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs. -func (m *ImageMutation) RemoveGroupIDs(ids ...uuid.UUID) { - if m.removedgroups == nil { - m.removedgroups = make(map[uuid.UUID]struct{}) + if m.source_ip != nil { + fields = append(fields, audit.FieldSourceIP) } - for i := range ids { - delete(m.groups, ids[i]) - m.removedgroups[ids[i]] = struct{}{} + if m.user_agent != nil { + fields = append(fields, audit.FieldUserAgent) } -} - -// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity. -func (m *ImageMutation) RemovedGroupsIDs() (ids []uuid.UUID) { - for id := range m.removedgroups { - ids = append(ids, id) + if m.request != nil { + fields = append(fields, audit.FieldRequest) } - return + if m.response != nil { + fields = append(fields, audit.FieldResponse) + } + if m.created_at != nil { + fields = append(fields, audit.FieldCreatedAt) + } + return fields } -// GroupsIDs returns the "groups" edge IDs in the mutation. -func (m *ImageMutation) GroupsIDs() (ids []uuid.UUID) { - for id := range m.groups { - ids = append(ids, id) +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *AuditMutation) Field(name string) (ent.Value, bool) { + switch name { + case audit.FieldUserID: + return m.UserID() + case audit.FieldOperation: + return m.Operation() + case audit.FieldSourceIP: + return m.SourceIP() + case audit.FieldUserAgent: + return m.UserAgent() + case audit.FieldRequest: + return m.Request() + case audit.FieldResponse: + return m.Response() + case audit.FieldCreatedAt: + return m.CreatedAt() } - return -} - -// ResetGroups resets all changes to the "groups" edge. -func (m *ImageMutation) ResetGroups() { - m.groups = nil - m.clearedgroups = false - m.removedgroups = nil -} - -// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids. -func (m *ImageMutation) AddProjectTaskIDs(ids ...uuid.UUID) { - if m.project_tasks == nil { - m.project_tasks = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.project_tasks[ids[i]] = struct{}{} - } -} - -// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity. -func (m *ImageMutation) ClearProjectTasks() { - m.clearedproject_tasks = true -} - -// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared. -func (m *ImageMutation) ProjectTasksCleared() bool { - return m.clearedproject_tasks -} - -// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs. -func (m *ImageMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) { - if m.removedproject_tasks == nil { - m.removedproject_tasks = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.project_tasks, ids[i]) - m.removedproject_tasks[ids[i]] = struct{}{} - } -} - -// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity. -func (m *ImageMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) { - for id := range m.removedproject_tasks { - ids = append(ids, id) - } - return -} - -// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation. -func (m *ImageMutation) ProjectTasksIDs() (ids []uuid.UUID) { - for id := range m.project_tasks { - ids = append(ids, id) - } - return -} - -// ResetProjectTasks resets all changes to the "project_tasks" edge. -func (m *ImageMutation) ResetProjectTasks() { - m.project_tasks = nil - m.clearedproject_tasks = false - m.removedproject_tasks = nil -} - -// AddProjectIDs adds the "projects" edge to the Project entity by ids. -func (m *ImageMutation) AddProjectIDs(ids ...uuid.UUID) { - if m.projects == nil { - m.projects = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.projects[ids[i]] = struct{}{} - } -} - -// ClearProjects clears the "projects" edge to the Project entity. -func (m *ImageMutation) ClearProjects() { - m.clearedprojects = true -} - -// ProjectsCleared reports if the "projects" edge to the Project entity was cleared. -func (m *ImageMutation) ProjectsCleared() bool { - return m.clearedprojects -} - -// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs. -func (m *ImageMutation) RemoveProjectIDs(ids ...uuid.UUID) { - if m.removedprojects == nil { - m.removedprojects = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.projects, ids[i]) - m.removedprojects[ids[i]] = struct{}{} - } -} - -// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity. -func (m *ImageMutation) RemovedProjectsIDs() (ids []uuid.UUID) { - for id := range m.removedprojects { - ids = append(ids, id) - } - return -} - -// ProjectsIDs returns the "projects" edge IDs in the mutation. -func (m *ImageMutation) ProjectsIDs() (ids []uuid.UUID) { - for id := range m.projects { - ids = append(ids, id) - } - return -} - -// ResetProjects resets all changes to the "projects" edge. -func (m *ImageMutation) ResetProjects() { - m.projects = nil - m.clearedprojects = false - m.removedprojects = nil -} - -// AddExtensionArchiveIDs adds the "extension_archives" edge to the TeamExtensionImageArchive entity by ids. -func (m *ImageMutation) AddExtensionArchiveIDs(ids ...uuid.UUID) { - if m.extension_archives == nil { - m.extension_archives = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.extension_archives[ids[i]] = struct{}{} - } -} - -// ClearExtensionArchives clears the "extension_archives" edge to the TeamExtensionImageArchive entity. -func (m *ImageMutation) ClearExtensionArchives() { - m.clearedextension_archives = true -} - -// ExtensionArchivesCleared reports if the "extension_archives" edge to the TeamExtensionImageArchive entity was cleared. -func (m *ImageMutation) ExtensionArchivesCleared() bool { - return m.clearedextension_archives -} - -// RemoveExtensionArchiveIDs removes the "extension_archives" edge to the TeamExtensionImageArchive entity by IDs. -func (m *ImageMutation) RemoveExtensionArchiveIDs(ids ...uuid.UUID) { - if m.removedextension_archives == nil { - m.removedextension_archives = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.extension_archives, ids[i]) - m.removedextension_archives[ids[i]] = struct{}{} - } -} - -// RemovedExtensionArchives returns the removed IDs of the "extension_archives" edge to the TeamExtensionImageArchive entity. -func (m *ImageMutation) RemovedExtensionArchivesIDs() (ids []uuid.UUID) { - for id := range m.removedextension_archives { - ids = append(ids, id) - } - return -} - -// ExtensionArchivesIDs returns the "extension_archives" edge IDs in the mutation. -func (m *ImageMutation) ExtensionArchivesIDs() (ids []uuid.UUID) { - for id := range m.extension_archives { - ids = append(ids, id) - } - return -} - -// ResetExtensionArchives resets all changes to the "extension_archives" edge. -func (m *ImageMutation) ResetExtensionArchives() { - m.extension_archives = nil - m.clearedextension_archives = false - m.removedextension_archives = nil -} - -// AddTeamImageIDs adds the "team_images" edge to the TeamImage entity by ids. -func (m *ImageMutation) AddTeamImageIDs(ids ...uuid.UUID) { - if m.team_images == nil { - m.team_images = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.team_images[ids[i]] = struct{}{} - } -} - -// ClearTeamImages clears the "team_images" edge to the TeamImage entity. -func (m *ImageMutation) ClearTeamImages() { - m.clearedteam_images = true -} - -// TeamImagesCleared reports if the "team_images" edge to the TeamImage entity was cleared. -func (m *ImageMutation) TeamImagesCleared() bool { - return m.clearedteam_images -} - -// RemoveTeamImageIDs removes the "team_images" edge to the TeamImage entity by IDs. -func (m *ImageMutation) RemoveTeamImageIDs(ids ...uuid.UUID) { - if m.removedteam_images == nil { - m.removedteam_images = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.team_images, ids[i]) - m.removedteam_images[ids[i]] = struct{}{} - } -} - -// RemovedTeamImages returns the removed IDs of the "team_images" edge to the TeamImage entity. -func (m *ImageMutation) RemovedTeamImagesIDs() (ids []uuid.UUID) { - for id := range m.removedteam_images { - ids = append(ids, id) - } - return -} - -// TeamImagesIDs returns the "team_images" edge IDs in the mutation. -func (m *ImageMutation) TeamImagesIDs() (ids []uuid.UUID) { - for id := range m.team_images { - ids = append(ids, id) - } - return -} - -// ResetTeamImages resets all changes to the "team_images" edge. -func (m *ImageMutation) ResetTeamImages() { - m.team_images = nil - m.clearedteam_images = false - m.removedteam_images = nil -} - -// AddTeamGroupImageIDs adds the "team_group_images" edge to the TeamGroupImage entity by ids. -func (m *ImageMutation) AddTeamGroupImageIDs(ids ...uuid.UUID) { - if m.team_group_images == nil { - m.team_group_images = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.team_group_images[ids[i]] = struct{}{} - } -} - -// ClearTeamGroupImages clears the "team_group_images" edge to the TeamGroupImage entity. -func (m *ImageMutation) ClearTeamGroupImages() { - m.clearedteam_group_images = true -} - -// TeamGroupImagesCleared reports if the "team_group_images" edge to the TeamGroupImage entity was cleared. -func (m *ImageMutation) TeamGroupImagesCleared() bool { - return m.clearedteam_group_images -} - -// RemoveTeamGroupImageIDs removes the "team_group_images" edge to the TeamGroupImage entity by IDs. -func (m *ImageMutation) RemoveTeamGroupImageIDs(ids ...uuid.UUID) { - if m.removedteam_group_images == nil { - m.removedteam_group_images = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.team_group_images, ids[i]) - m.removedteam_group_images[ids[i]] = struct{}{} - } -} - -// RemovedTeamGroupImages returns the removed IDs of the "team_group_images" edge to the TeamGroupImage entity. -func (m *ImageMutation) RemovedTeamGroupImagesIDs() (ids []uuid.UUID) { - for id := range m.removedteam_group_images { - ids = append(ids, id) - } - return -} - -// TeamGroupImagesIDs returns the "team_group_images" edge IDs in the mutation. -func (m *ImageMutation) TeamGroupImagesIDs() (ids []uuid.UUID) { - for id := range m.team_group_images { - ids = append(ids, id) - } - return -} - -// ResetTeamGroupImages resets all changes to the "team_group_images" edge. -func (m *ImageMutation) ResetTeamGroupImages() { - m.team_group_images = nil - m.clearedteam_group_images = false - m.removedteam_group_images = nil -} - -// Where appends a list predicates to the ImageMutation builder. -func (m *ImageMutation) Where(ps ...predicate.Image) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the ImageMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ImageMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Image, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *ImageMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *ImageMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Image). -func (m *ImageMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *ImageMutation) Fields() []string { - fields := make([]string, 0, 9) - if m.deleted_at != nil { - fields = append(fields, image.FieldDeletedAt) - } - if m.user != nil { - fields = append(fields, image.FieldUserID) - } - if m.name != nil { - fields = append(fields, image.FieldName) - } - if m.remark != nil { - fields = append(fields, image.FieldRemark) - } - if m.extension_package_id != nil { - fields = append(fields, image.FieldExtensionPackageID) - } - if m.extension_image_id != nil { - fields = append(fields, image.FieldExtensionImageID) - } - if m.extension_version != nil { - fields = append(fields, image.FieldExtensionVersion) - } - if m.created_at != nil { - fields = append(fields, image.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, image.FieldUpdatedAt) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *ImageMutation) Field(name string) (ent.Value, bool) { - switch name { - case image.FieldDeletedAt: - return m.DeletedAt() - case image.FieldUserID: - return m.UserID() - case image.FieldName: - return m.Name() - case image.FieldRemark: - return m.Remark() - case image.FieldExtensionPackageID: - return m.ExtensionPackageID() - case image.FieldExtensionImageID: - return m.ExtensionImageID() - case image.FieldExtensionVersion: - return m.ExtensionVersion() - case image.FieldCreatedAt: - return m.CreatedAt() - case image.FieldUpdatedAt: - return m.UpdatedAt() - } - return nil, false + return nil, false } // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ImageMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *AuditMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case image.FieldDeletedAt: - return m.OldDeletedAt(ctx) - case image.FieldUserID: + case audit.FieldUserID: return m.OldUserID(ctx) - case image.FieldName: - return m.OldName(ctx) - case image.FieldRemark: - return m.OldRemark(ctx) - case image.FieldExtensionPackageID: - return m.OldExtensionPackageID(ctx) - case image.FieldExtensionImageID: - return m.OldExtensionImageID(ctx) - case image.FieldExtensionVersion: - return m.OldExtensionVersion(ctx) - case image.FieldCreatedAt: + case audit.FieldOperation: + return m.OldOperation(ctx) + case audit.FieldSourceIP: + return m.OldSourceIP(ctx) + case audit.FieldUserAgent: + return m.OldUserAgent(ctx) + case audit.FieldRequest: + return m.OldRequest(ctx) + case audit.FieldResponse: + return m.OldResponse(ctx) + case audit.FieldCreatedAt: return m.OldCreatedAt(ctx) - case image.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown Image field %s", name) + return nil, fmt.Errorf("unknown Audit field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ImageMutation) SetField(name string, value ent.Value) error { +func (m *AuditMutation) SetField(name string, value ent.Value) error { switch name { - case image.FieldDeletedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDeletedAt(v) - return nil - case image.FieldUserID: + case audit.FieldUserID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUserID(v) return nil - case image.FieldName: + case audit.FieldOperation: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetName(v) + m.SetOperation(v) return nil - case image.FieldRemark: + case audit.FieldSourceIP: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRemark(v) + m.SetSourceIP(v) return nil - case image.FieldExtensionPackageID: + case audit.FieldUserAgent: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetExtensionPackageID(v) + m.SetUserAgent(v) return nil - case image.FieldExtensionImageID: + case audit.FieldRequest: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetExtensionImageID(v) + m.SetRequest(v) return nil - case image.FieldExtensionVersion: + case audit.FieldResponse: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetExtensionVersion(v) + m.SetResponse(v) return nil - case image.FieldCreatedAt: + case audit.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case image.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil } - return fmt.Errorf("unknown Image field %s", name) + return fmt.Errorf("unknown Audit field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ImageMutation) AddedFields() []string { +func (m *AuditMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ImageMutation) AddedField(name string) (ent.Value, bool) { +func (m *AuditMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ImageMutation) AddField(name string, value ent.Value) error { +func (m *AuditMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Image numeric field %s", name) + return fmt.Errorf("unknown Audit numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ImageMutation) ClearedFields() []string { +func (m *AuditMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(image.FieldDeletedAt) { - fields = append(fields, image.FieldDeletedAt) - } - if m.FieldCleared(image.FieldRemark) { - fields = append(fields, image.FieldRemark) - } - if m.FieldCleared(image.FieldExtensionPackageID) { - fields = append(fields, image.FieldExtensionPackageID) - } - if m.FieldCleared(image.FieldExtensionImageID) { - fields = append(fields, image.FieldExtensionImageID) - } - if m.FieldCleared(image.FieldExtensionVersion) { - fields = append(fields, image.FieldExtensionVersion) + if m.FieldCleared(audit.FieldResponse) { + fields = append(fields, audit.FieldResponse) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ImageMutation) FieldCleared(name string) bool { +func (m *AuditMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ImageMutation) ClearField(name string) error { +func (m *AuditMutation) ClearField(name string) error { switch name { - case image.FieldDeletedAt: - m.ClearDeletedAt() - return nil - case image.FieldRemark: - m.ClearRemark() - return nil - case image.FieldExtensionPackageID: - m.ClearExtensionPackageID() - return nil - case image.FieldExtensionImageID: - m.ClearExtensionImageID() - return nil - case image.FieldExtensionVersion: - m.ClearExtensionVersion() + case audit.FieldResponse: + m.ClearResponse() return nil } - return fmt.Errorf("unknown Image nullable field %s", name) + return fmt.Errorf("unknown Audit nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ImageMutation) ResetField(name string) error { +func (m *AuditMutation) ResetField(name string) error { switch name { - case image.FieldDeletedAt: - m.ResetDeletedAt() - return nil - case image.FieldUserID: + case audit.FieldUserID: m.ResetUserID() return nil - case image.FieldName: - m.ResetName() - return nil - case image.FieldRemark: - m.ResetRemark() + case audit.FieldOperation: + m.ResetOperation() return nil - case image.FieldExtensionPackageID: - m.ResetExtensionPackageID() + case audit.FieldSourceIP: + m.ResetSourceIP() return nil - case image.FieldExtensionImageID: - m.ResetExtensionImageID() + case audit.FieldUserAgent: + m.ResetUserAgent() return nil - case image.FieldExtensionVersion: - m.ResetExtensionVersion() + case audit.FieldRequest: + m.ResetRequest() return nil - case image.FieldCreatedAt: - m.ResetCreatedAt() + case audit.FieldResponse: + m.ResetResponse() return nil - case image.FieldUpdatedAt: - m.ResetUpdatedAt() + case audit.FieldCreatedAt: + m.ResetCreatedAt() return nil } - return fmt.Errorf("unknown Image field %s", name) + return fmt.Errorf("unknown Audit field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ImageMutation) AddedEdges() []string { - edges := make([]string, 0, 8) +func (m *AuditMutation) AddedEdges() []string { + edges := make([]string, 0, 1) if m.user != nil { - edges = append(edges, image.EdgeUser) - } - if m.teams != nil { - edges = append(edges, image.EdgeTeams) - } - if m.groups != nil { - edges = append(edges, image.EdgeGroups) - } - if m.project_tasks != nil { - edges = append(edges, image.EdgeProjectTasks) - } - if m.projects != nil { - edges = append(edges, image.EdgeProjects) - } - if m.extension_archives != nil { - edges = append(edges, image.EdgeExtensionArchives) - } - if m.team_images != nil { - edges = append(edges, image.EdgeTeamImages) - } - if m.team_group_images != nil { - edges = append(edges, image.EdgeTeamGroupImages) + edges = append(edges, audit.EdgeUser) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ImageMutation) AddedIDs(name string) []ent.Value { +func (m *AuditMutation) AddedIDs(name string) []ent.Value { switch name { - case image.EdgeUser: + case audit.EdgeUser: if id := m.user; id != nil { return []ent.Value{*id} } - case image.EdgeTeams: - ids := make([]ent.Value, 0, len(m.teams)) - for id := range m.teams { - ids = append(ids, id) - } - return ids - case image.EdgeGroups: - ids := make([]ent.Value, 0, len(m.groups)) - for id := range m.groups { - ids = append(ids, id) - } - return ids - case image.EdgeProjectTasks: - ids := make([]ent.Value, 0, len(m.project_tasks)) - for id := range m.project_tasks { - ids = append(ids, id) - } - return ids - case image.EdgeProjects: - ids := make([]ent.Value, 0, len(m.projects)) - for id := range m.projects { - ids = append(ids, id) - } - return ids - case image.EdgeExtensionArchives: - ids := make([]ent.Value, 0, len(m.extension_archives)) - for id := range m.extension_archives { - ids = append(ids, id) - } - return ids - case image.EdgeTeamImages: - ids := make([]ent.Value, 0, len(m.team_images)) - for id := range m.team_images { - ids = append(ids, id) - } - return ids - case image.EdgeTeamGroupImages: - ids := make([]ent.Value, 0, len(m.team_group_images)) - for id := range m.team_group_images { - ids = append(ids, id) - } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ImageMutation) RemovedEdges() []string { - edges := make([]string, 0, 8) - if m.removedteams != nil { - edges = append(edges, image.EdgeTeams) - } - if m.removedgroups != nil { - edges = append(edges, image.EdgeGroups) - } - if m.removedproject_tasks != nil { - edges = append(edges, image.EdgeProjectTasks) - } - if m.removedprojects != nil { - edges = append(edges, image.EdgeProjects) - } - if m.removedextension_archives != nil { - edges = append(edges, image.EdgeExtensionArchives) - } - if m.removedteam_images != nil { - edges = append(edges, image.EdgeTeamImages) - } - if m.removedteam_group_images != nil { - edges = append(edges, image.EdgeTeamGroupImages) - } +func (m *AuditMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ImageMutation) RemovedIDs(name string) []ent.Value { - switch name { - case image.EdgeTeams: - ids := make([]ent.Value, 0, len(m.removedteams)) - for id := range m.removedteams { - ids = append(ids, id) - } - return ids - case image.EdgeGroups: - ids := make([]ent.Value, 0, len(m.removedgroups)) - for id := range m.removedgroups { - ids = append(ids, id) - } - return ids - case image.EdgeProjectTasks: - ids := make([]ent.Value, 0, len(m.removedproject_tasks)) - for id := range m.removedproject_tasks { - ids = append(ids, id) - } - return ids - case image.EdgeProjects: - ids := make([]ent.Value, 0, len(m.removedprojects)) - for id := range m.removedprojects { - ids = append(ids, id) - } - return ids - case image.EdgeExtensionArchives: - ids := make([]ent.Value, 0, len(m.removedextension_archives)) - for id := range m.removedextension_archives { - ids = append(ids, id) - } - return ids - case image.EdgeTeamImages: - ids := make([]ent.Value, 0, len(m.removedteam_images)) - for id := range m.removedteam_images { - ids = append(ids, id) - } - return ids - case image.EdgeTeamGroupImages: - ids := make([]ent.Value, 0, len(m.removedteam_group_images)) - for id := range m.removedteam_group_images { - ids = append(ids, id) - } - return ids - } +func (m *AuditMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ImageMutation) ClearedEdges() []string { - edges := make([]string, 0, 8) +func (m *AuditMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) if m.cleareduser { - edges = append(edges, image.EdgeUser) - } - if m.clearedteams { - edges = append(edges, image.EdgeTeams) - } - if m.clearedgroups { - edges = append(edges, image.EdgeGroups) - } - if m.clearedproject_tasks { - edges = append(edges, image.EdgeProjectTasks) - } - if m.clearedprojects { - edges = append(edges, image.EdgeProjects) - } - if m.clearedextension_archives { - edges = append(edges, image.EdgeExtensionArchives) - } - if m.clearedteam_images { - edges = append(edges, image.EdgeTeamImages) - } - if m.clearedteam_group_images { - edges = append(edges, image.EdgeTeamGroupImages) + edges = append(edges, audit.EdgeUser) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ImageMutation) EdgeCleared(name string) bool { +func (m *AuditMutation) EdgeCleared(name string) bool { switch name { - case image.EdgeUser: + case audit.EdgeUser: return m.cleareduser - case image.EdgeTeams: - return m.clearedteams - case image.EdgeGroups: - return m.clearedgroups - case image.EdgeProjectTasks: - return m.clearedproject_tasks - case image.EdgeProjects: - return m.clearedprojects - case image.EdgeExtensionArchives: - return m.clearedextension_archives - case image.EdgeTeamImages: - return m.clearedteam_images - case image.EdgeTeamGroupImages: - return m.clearedteam_group_images } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ImageMutation) ClearEdge(name string) error { +func (m *AuditMutation) ClearEdge(name string) error { switch name { - case image.EdgeUser: + case audit.EdgeUser: m.ClearUser() return nil } - return fmt.Errorf("unknown Image unique edge %s", name) + return fmt.Errorf("unknown Audit unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ImageMutation) ResetEdge(name string) error { +func (m *AuditMutation) ResetEdge(name string) error { switch name { - case image.EdgeUser: + case audit.EdgeUser: m.ResetUser() return nil - case image.EdgeTeams: - m.ResetTeams() - return nil - case image.EdgeGroups: - m.ResetGroups() - return nil - case image.EdgeProjectTasks: - m.ResetProjectTasks() - return nil - case image.EdgeProjects: - m.ResetProjects() - return nil - case image.EdgeExtensionArchives: - m.ResetExtensionArchives() - return nil - case image.EdgeTeamImages: - m.ResetTeamImages() - return nil - case image.EdgeTeamGroupImages: - m.ResetTeamGroupImages() - return nil } - return fmt.Errorf("unknown Image edge %s", name) + return fmt.Errorf("unknown Audit edge %s", name) } -// MCPToolMutation represents an operation that mutates the MCPTool nodes in the graph. -type MCPToolMutation struct { +// GitBotMutation represents an operation that mutates the GitBot nodes in the graph. +type GitBotMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - name *string - namespaced_name *string - scope *mcptool.Scope - user_id *uuid.UUID - description *string - input_schema *map[string]interface{} - price *int64 - addprice *int64 - enabled *bool - version_hash *string - synced_at *time.Time - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - upstream *uuid.UUID - clearedupstream bool - done bool - oldValue func(context.Context) (*MCPTool, error) - predicates []predicate.MCPTool + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + user_id *uuid.UUID + name *string + token *string + secret_token *string + platform *consts.GitPlatform + created_at *time.Time + clearedFields map[string]struct{} + git_bot_tasks map[uuid.UUID]struct{} + removedgit_bot_tasks map[uuid.UUID]struct{} + clearedgit_bot_tasks bool + host *string + clearedhost bool + users map[uuid.UUID]struct{} + removedusers map[uuid.UUID]struct{} + clearedusers bool + projects map[uuid.UUID]struct{} + removedprojects map[uuid.UUID]struct{} + clearedprojects bool + git_bot_users map[uuid.UUID]struct{} + removedgit_bot_users map[uuid.UUID]struct{} + clearedgit_bot_users bool + project_git_bots map[uuid.UUID]struct{} + removedproject_git_bots map[uuid.UUID]struct{} + clearedproject_git_bots bool + done bool + oldValue func(context.Context) (*GitBot, error) + predicates []predicate.GitBot } -var _ ent.Mutation = (*MCPToolMutation)(nil) +var _ ent.Mutation = (*GitBotMutation)(nil) -// mcptoolOption allows management of the mutation configuration using functional options. -type mcptoolOption func(*MCPToolMutation) +// gitbotOption allows management of the mutation configuration using functional options. +type gitbotOption func(*GitBotMutation) -// newMCPToolMutation creates new mutation for the MCPTool entity. -func newMCPToolMutation(c config, op Op, opts ...mcptoolOption) *MCPToolMutation { - m := &MCPToolMutation{ +// newGitBotMutation creates new mutation for the GitBot entity. +func newGitBotMutation(c config, op Op, opts ...gitbotOption) *GitBotMutation { + m := &GitBotMutation{ config: c, op: op, - typ: TypeMCPTool, + typ: TypeGitBot, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -9356,20 +10573,20 @@ func newMCPToolMutation(c config, op Op, opts ...mcptoolOption) *MCPToolMutation return m } -// withMCPToolID sets the ID field of the mutation. -func withMCPToolID(id uuid.UUID) mcptoolOption { - return func(m *MCPToolMutation) { +// withGitBotID sets the ID field of the mutation. +func withGitBotID(id uuid.UUID) gitbotOption { + return func(m *GitBotMutation) { var ( err error once sync.Once - value *MCPTool + value *GitBot ) - m.oldValue = func(ctx context.Context) (*MCPTool, error) { + m.oldValue = func(ctx context.Context) (*GitBot, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().MCPTool.Get(ctx, id) + value, err = m.Client().GitBot.Get(ctx, id) } }) return value, err @@ -9378,10 +10595,10 @@ func withMCPToolID(id uuid.UUID) mcptoolOption { } } -// withMCPTool sets the old MCPTool of the mutation. -func withMCPTool(node *MCPTool) mcptoolOption { - return func(m *MCPToolMutation) { - m.oldValue = func(context.Context) (*MCPTool, error) { +// withGitBot sets the old GitBot of the mutation. +func withGitBot(node *GitBot) gitbotOption { + return func(m *GitBotMutation) { + m.oldValue = func(context.Context) (*GitBot, error) { return node, nil } m.id = &node.ID @@ -9390,7 +10607,7 @@ func withMCPTool(node *MCPTool) mcptoolOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m MCPToolMutation) Client() *Client { +func (m GitBotMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -9398,7 +10615,7 @@ func (m MCPToolMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m MCPToolMutation) Tx() (*Tx, error) { +func (m GitBotMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -9408,14 +10625,14 @@ func (m MCPToolMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of MCPTool entities. -func (m *MCPToolMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of GitBot entities. +func (m *GitBotMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *MCPToolMutation) ID() (id uuid.UUID, exists bool) { +func (m *GitBotMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -9426,7 +10643,7 @@ func (m *MCPToolMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *MCPToolMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *GitBotMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -9435,19 +10652,19 @@ func (m *MCPToolMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().MCPTool.Query().Where(m.predicates...).IDs(ctx) + return m.Client().GitBot.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetDeletedAt sets the "deleted_at" field. -func (m *MCPToolMutation) SetDeletedAt(t time.Time) { +func (m *GitBotMutation) SetDeletedAt(t time.Time) { m.deleted_at = &t } // DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *MCPToolMutation) DeletedAt() (r time.Time, exists bool) { +func (m *GitBotMutation) DeletedAt() (r time.Time, exists bool) { v := m.deleted_at if v == nil { return @@ -9455,10 +10672,10 @@ func (m *MCPToolMutation) DeletedAt() (r time.Time, exists bool) { return *v, true } -// OldDeletedAt returns the old "deleted_at" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// OldDeletedAt returns the old "deleted_at" field's value of the GitBot entity. +// If the GitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { +func (m *GitBotMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } @@ -9473,66 +10690,66 @@ func (m *MCPToolMutation) OldDeletedAt(ctx context.Context) (v time.Time, err er } // ClearDeletedAt clears the value of the "deleted_at" field. -func (m *MCPToolMutation) ClearDeletedAt() { +func (m *GitBotMutation) ClearDeletedAt() { m.deleted_at = nil - m.clearedFields[mcptool.FieldDeletedAt] = struct{}{} + m.clearedFields[gitbot.FieldDeletedAt] = struct{}{} } // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *MCPToolMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[mcptool.FieldDeletedAt] +func (m *GitBotMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[gitbot.FieldDeletedAt] return ok } // ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *MCPToolMutation) ResetDeletedAt() { +func (m *GitBotMutation) ResetDeletedAt() { m.deleted_at = nil - delete(m.clearedFields, mcptool.FieldDeletedAt) + delete(m.clearedFields, gitbot.FieldDeletedAt) } -// SetUpstreamID sets the "upstream_id" field. -func (m *MCPToolMutation) SetUpstreamID(u uuid.UUID) { - m.upstream = &u +// SetUserID sets the "user_id" field. +func (m *GitBotMutation) SetUserID(u uuid.UUID) { + m.user_id = &u } -// UpstreamID returns the value of the "upstream_id" field in the mutation. -func (m *MCPToolMutation) UpstreamID() (r uuid.UUID, exists bool) { - v := m.upstream +// UserID returns the value of the "user_id" field in the mutation. +func (m *GitBotMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user_id if v == nil { return } return *v, true } -// OldUpstreamID returns the old "upstream_id" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the GitBot entity. +// If the GitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldUpstreamID(ctx context.Context) (v uuid.UUID, err error) { +func (m *GitBotMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpstreamID is only allowed on UpdateOne operations") + return v, errors.New("OldUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpstreamID requires an ID field in the mutation") + return v, errors.New("OldUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpstreamID: %w", err) + return v, fmt.Errorf("querying old value for OldUserID: %w", err) } - return oldValue.UpstreamID, nil + return oldValue.UserID, nil } -// ResetUpstreamID resets all changes to the "upstream_id" field. -func (m *MCPToolMutation) ResetUpstreamID() { - m.upstream = nil +// ResetUserID resets all changes to the "user_id" field. +func (m *GitBotMutation) ResetUserID() { + m.user_id = nil } // SetName sets the "name" field. -func (m *MCPToolMutation) SetName(s string) { +func (m *GitBotMutation) SetName(s string) { m.name = &s } // Name returns the value of the "name" field in the mutation. -func (m *MCPToolMutation) Name() (r string, exists bool) { +func (m *GitBotMutation) Name() (r string, exists bool) { v := m.name if v == nil { return @@ -9540,10 +10757,10 @@ func (m *MCPToolMutation) Name() (r string, exists bool) { return *v, true } -// OldName returns the old "name" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the GitBot entity. +// If the GitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldName(ctx context.Context) (v string, err error) { +func (m *GitBotMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldName is only allowed on UpdateOne operations") } @@ -9557,528 +10774,536 @@ func (m *MCPToolMutation) OldName(ctx context.Context) (v string, err error) { return oldValue.Name, nil } +// ClearName clears the value of the "name" field. +func (m *GitBotMutation) ClearName() { + m.name = nil + m.clearedFields[gitbot.FieldName] = struct{}{} +} + +// NameCleared returns if the "name" field was cleared in this mutation. +func (m *GitBotMutation) NameCleared() bool { + _, ok := m.clearedFields[gitbot.FieldName] + return ok +} + // ResetName resets all changes to the "name" field. -func (m *MCPToolMutation) ResetName() { +func (m *GitBotMutation) ResetName() { m.name = nil + delete(m.clearedFields, gitbot.FieldName) } -// SetNamespacedName sets the "namespaced_name" field. -func (m *MCPToolMutation) SetNamespacedName(s string) { - m.namespaced_name = &s +// SetHostID sets the "host_id" field. +func (m *GitBotMutation) SetHostID(s string) { + m.host = &s } -// NamespacedName returns the value of the "namespaced_name" field in the mutation. -func (m *MCPToolMutation) NamespacedName() (r string, exists bool) { - v := m.namespaced_name +// HostID returns the value of the "host_id" field in the mutation. +func (m *GitBotMutation) HostID() (r string, exists bool) { + v := m.host if v == nil { return } return *v, true } -// OldNamespacedName returns the old "namespaced_name" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// OldHostID returns the old "host_id" field's value of the GitBot entity. +// If the GitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldNamespacedName(ctx context.Context) (v string, err error) { +func (m *GitBotMutation) OldHostID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNamespacedName is only allowed on UpdateOne operations") + return v, errors.New("OldHostID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNamespacedName requires an ID field in the mutation") + return v, errors.New("OldHostID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldNamespacedName: %w", err) + return v, fmt.Errorf("querying old value for OldHostID: %w", err) } - return oldValue.NamespacedName, nil + return oldValue.HostID, nil } -// ResetNamespacedName resets all changes to the "namespaced_name" field. -func (m *MCPToolMutation) ResetNamespacedName() { - m.namespaced_name = nil +// ResetHostID resets all changes to the "host_id" field. +func (m *GitBotMutation) ResetHostID() { + m.host = nil } -// SetScope sets the "scope" field. -func (m *MCPToolMutation) SetScope(value mcptool.Scope) { - m.scope = &value +// SetToken sets the "token" field. +func (m *GitBotMutation) SetToken(s string) { + m.token = &s } -// Scope returns the value of the "scope" field in the mutation. -func (m *MCPToolMutation) Scope() (r mcptool.Scope, exists bool) { - v := m.scope +// Token returns the value of the "token" field in the mutation. +func (m *GitBotMutation) Token() (r string, exists bool) { + v := m.token if v == nil { return } return *v, true } -// OldScope returns the old "scope" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// OldToken returns the old "token" field's value of the GitBot entity. +// If the GitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldScope(ctx context.Context) (v mcptool.Scope, err error) { +func (m *GitBotMutation) OldToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldScope is only allowed on UpdateOne operations") + return v, errors.New("OldToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldScope requires an ID field in the mutation") + return v, errors.New("OldToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldScope: %w", err) + return v, fmt.Errorf("querying old value for OldToken: %w", err) } - return oldValue.Scope, nil + return oldValue.Token, nil } -// ResetScope resets all changes to the "scope" field. -func (m *MCPToolMutation) ResetScope() { - m.scope = nil +// ClearToken clears the value of the "token" field. +func (m *GitBotMutation) ClearToken() { + m.token = nil + m.clearedFields[gitbot.FieldToken] = struct{}{} } -// SetUserID sets the "user_id" field. -func (m *MCPToolMutation) SetUserID(u uuid.UUID) { - m.user_id = &u +// TokenCleared returns if the "token" field was cleared in this mutation. +func (m *GitBotMutation) TokenCleared() bool { + _, ok := m.clearedFields[gitbot.FieldToken] + return ok } -// UserID returns the value of the "user_id" field in the mutation. -func (m *MCPToolMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user_id +// ResetToken resets all changes to the "token" field. +func (m *GitBotMutation) ResetToken() { + m.token = nil + delete(m.clearedFields, gitbot.FieldToken) +} + +// SetSecretToken sets the "secret_token" field. +func (m *GitBotMutation) SetSecretToken(s string) { + m.secret_token = &s +} + +// SecretToken returns the value of the "secret_token" field in the mutation. +func (m *GitBotMutation) SecretToken() (r string, exists bool) { + v := m.secret_token if v == nil { return } return *v, true } -// OldUserID returns the old "user_id" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// OldSecretToken returns the old "secret_token" field's value of the GitBot entity. +// If the GitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldUserID(ctx context.Context) (v *uuid.UUID, err error) { +func (m *GitBotMutation) OldSecretToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") + return v, errors.New("OldSecretToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") + return v, errors.New("OldSecretToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + return v, fmt.Errorf("querying old value for OldSecretToken: %w", err) } - return oldValue.UserID, nil + return oldValue.SecretToken, nil } -// ClearUserID clears the value of the "user_id" field. -func (m *MCPToolMutation) ClearUserID() { - m.user_id = nil - m.clearedFields[mcptool.FieldUserID] = struct{}{} +// ClearSecretToken clears the value of the "secret_token" field. +func (m *GitBotMutation) ClearSecretToken() { + m.secret_token = nil + m.clearedFields[gitbot.FieldSecretToken] = struct{}{} } -// UserIDCleared returns if the "user_id" field was cleared in this mutation. -func (m *MCPToolMutation) UserIDCleared() bool { - _, ok := m.clearedFields[mcptool.FieldUserID] +// SecretTokenCleared returns if the "secret_token" field was cleared in this mutation. +func (m *GitBotMutation) SecretTokenCleared() bool { + _, ok := m.clearedFields[gitbot.FieldSecretToken] return ok } -// ResetUserID resets all changes to the "user_id" field. -func (m *MCPToolMutation) ResetUserID() { - m.user_id = nil - delete(m.clearedFields, mcptool.FieldUserID) +// ResetSecretToken resets all changes to the "secret_token" field. +func (m *GitBotMutation) ResetSecretToken() { + m.secret_token = nil + delete(m.clearedFields, gitbot.FieldSecretToken) } -// SetDescription sets the "description" field. -func (m *MCPToolMutation) SetDescription(s string) { - m.description = &s +// SetPlatform sets the "platform" field. +func (m *GitBotMutation) SetPlatform(cp consts.GitPlatform) { + m.platform = &cp } -// Description returns the value of the "description" field in the mutation. -func (m *MCPToolMutation) Description() (r string, exists bool) { - v := m.description +// Platform returns the value of the "platform" field in the mutation. +func (m *GitBotMutation) Platform() (r consts.GitPlatform, exists bool) { + v := m.platform if v == nil { return } return *v, true } -// OldDescription returns the old "description" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// OldPlatform returns the old "platform" field's value of the GitBot entity. +// If the GitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldDescription(ctx context.Context) (v string, err error) { +func (m *GitBotMutation) OldPlatform(ctx context.Context) (v consts.GitPlatform, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") + return v, errors.New("OldPlatform is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + return v, errors.New("OldPlatform requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + return v, fmt.Errorf("querying old value for OldPlatform: %w", err) } - return oldValue.Description, nil -} - -// ClearDescription clears the value of the "description" field. -func (m *MCPToolMutation) ClearDescription() { - m.description = nil - m.clearedFields[mcptool.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *MCPToolMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[mcptool.FieldDescription] - return ok + return oldValue.Platform, nil } -// ResetDescription resets all changes to the "description" field. -func (m *MCPToolMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, mcptool.FieldDescription) +// ResetPlatform resets all changes to the "platform" field. +func (m *GitBotMutation) ResetPlatform() { + m.platform = nil } -// SetInputSchema sets the "input_schema" field. -func (m *MCPToolMutation) SetInputSchema(value map[string]interface{}) { - m.input_schema = &value +// SetCreatedAt sets the "created_at" field. +func (m *GitBotMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// InputSchema returns the value of the "input_schema" field in the mutation. -func (m *MCPToolMutation) InputSchema() (r map[string]interface{}, exists bool) { - v := m.input_schema +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *GitBotMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldInputSchema returns the old "input_schema" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the GitBot entity. +// If the GitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldInputSchema(ctx context.Context) (v map[string]interface{}, err error) { +func (m *GitBotMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInputSchema is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInputSchema requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInputSchema: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.InputSchema, nil + return oldValue.CreatedAt, nil } -// ClearInputSchema clears the value of the "input_schema" field. -func (m *MCPToolMutation) ClearInputSchema() { - m.input_schema = nil - m.clearedFields[mcptool.FieldInputSchema] = struct{}{} +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *GitBotMutation) ResetCreatedAt() { + m.created_at = nil } -// InputSchemaCleared returns if the "input_schema" field was cleared in this mutation. -func (m *MCPToolMutation) InputSchemaCleared() bool { - _, ok := m.clearedFields[mcptool.FieldInputSchema] - return ok +// AddGitBotTaskIDs adds the "git_bot_tasks" edge to the GitBotTask entity by ids. +func (m *GitBotMutation) AddGitBotTaskIDs(ids ...uuid.UUID) { + if m.git_bot_tasks == nil { + m.git_bot_tasks = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.git_bot_tasks[ids[i]] = struct{}{} + } } -// ResetInputSchema resets all changes to the "input_schema" field. -func (m *MCPToolMutation) ResetInputSchema() { - m.input_schema = nil - delete(m.clearedFields, mcptool.FieldInputSchema) +// ClearGitBotTasks clears the "git_bot_tasks" edge to the GitBotTask entity. +func (m *GitBotMutation) ClearGitBotTasks() { + m.clearedgit_bot_tasks = true } -// SetPrice sets the "price" field. -func (m *MCPToolMutation) SetPrice(i int64) { - m.price = &i - m.addprice = nil +// GitBotTasksCleared reports if the "git_bot_tasks" edge to the GitBotTask entity was cleared. +func (m *GitBotMutation) GitBotTasksCleared() bool { + return m.clearedgit_bot_tasks } -// Price returns the value of the "price" field in the mutation. -func (m *MCPToolMutation) Price() (r int64, exists bool) { - v := m.price - if v == nil { - return +// RemoveGitBotTaskIDs removes the "git_bot_tasks" edge to the GitBotTask entity by IDs. +func (m *GitBotMutation) RemoveGitBotTaskIDs(ids ...uuid.UUID) { + if m.removedgit_bot_tasks == nil { + m.removedgit_bot_tasks = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.git_bot_tasks, ids[i]) + m.removedgit_bot_tasks[ids[i]] = struct{}{} } - return *v, true } -// OldPrice returns the old "price" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldPrice(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPrice is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPrice requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPrice: %w", err) +// RemovedGitBotTasks returns the removed IDs of the "git_bot_tasks" edge to the GitBotTask entity. +func (m *GitBotMutation) RemovedGitBotTasksIDs() (ids []uuid.UUID) { + for id := range m.removedgit_bot_tasks { + ids = append(ids, id) } - return oldValue.Price, nil + return } -// AddPrice adds i to the "price" field. -func (m *MCPToolMutation) AddPrice(i int64) { - if m.addprice != nil { - *m.addprice += i - } else { - m.addprice = &i +// GitBotTasksIDs returns the "git_bot_tasks" edge IDs in the mutation. +func (m *GitBotMutation) GitBotTasksIDs() (ids []uuid.UUID) { + for id := range m.git_bot_tasks { + ids = append(ids, id) } + return } -// AddedPrice returns the value that was added to the "price" field in this mutation. -func (m *MCPToolMutation) AddedPrice() (r int64, exists bool) { - v := m.addprice - if v == nil { - return - } - return *v, true +// ResetGitBotTasks resets all changes to the "git_bot_tasks" edge. +func (m *GitBotMutation) ResetGitBotTasks() { + m.git_bot_tasks = nil + m.clearedgit_bot_tasks = false + m.removedgit_bot_tasks = nil } -// ResetPrice resets all changes to the "price" field. -func (m *MCPToolMutation) ResetPrice() { - m.price = nil - m.addprice = nil +// ClearHost clears the "host" edge to the Host entity. +func (m *GitBotMutation) ClearHost() { + m.clearedhost = true + m.clearedFields[gitbot.FieldHostID] = struct{}{} } -// SetEnabled sets the "enabled" field. -func (m *MCPToolMutation) SetEnabled(b bool) { - m.enabled = &b +// HostCleared reports if the "host" edge to the Host entity was cleared. +func (m *GitBotMutation) HostCleared() bool { + return m.clearedhost } -// Enabled returns the value of the "enabled" field in the mutation. -func (m *MCPToolMutation) Enabled() (r bool, exists bool) { - v := m.enabled - if v == nil { - return +// HostIDs returns the "host" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// HostID instead. It exists only for internal usage by the builders. +func (m *GitBotMutation) HostIDs() (ids []string) { + if id := m.host; id != nil { + ids = append(ids, *id) } - return *v, true + return } -// OldEnabled returns the old "enabled" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldEnabled(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEnabled is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEnabled requires an ID field in the mutation") +// ResetHost resets all changes to the "host" edge. +func (m *GitBotMutation) ResetHost() { + m.host = nil + m.clearedhost = false +} + +// AddUserIDs adds the "users" edge to the User entity by ids. +func (m *GitBotMutation) AddUserIDs(ids ...uuid.UUID) { + if m.users == nil { + m.users = make(map[uuid.UUID]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEnabled: %w", err) + for i := range ids { + m.users[ids[i]] = struct{}{} } - return oldValue.Enabled, nil } -// ResetEnabled resets all changes to the "enabled" field. -func (m *MCPToolMutation) ResetEnabled() { - m.enabled = nil +// ClearUsers clears the "users" edge to the User entity. +func (m *GitBotMutation) ClearUsers() { + m.clearedusers = true } -// SetVersionHash sets the "version_hash" field. -func (m *MCPToolMutation) SetVersionHash(s string) { - m.version_hash = &s +// UsersCleared reports if the "users" edge to the User entity was cleared. +func (m *GitBotMutation) UsersCleared() bool { + return m.clearedusers } -// VersionHash returns the value of the "version_hash" field in the mutation. -func (m *MCPToolMutation) VersionHash() (r string, exists bool) { - v := m.version_hash - if v == nil { - return +// RemoveUserIDs removes the "users" edge to the User entity by IDs. +func (m *GitBotMutation) RemoveUserIDs(ids ...uuid.UUID) { + if m.removedusers == nil { + m.removedusers = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.users, ids[i]) + m.removedusers[ids[i]] = struct{}{} } - return *v, true } -// OldVersionHash returns the old "version_hash" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldVersionHash(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVersionHash is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVersionHash requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVersionHash: %w", err) +// RemovedUsers returns the removed IDs of the "users" edge to the User entity. +func (m *GitBotMutation) RemovedUsersIDs() (ids []uuid.UUID) { + for id := range m.removedusers { + ids = append(ids, id) } - return oldValue.VersionHash, nil + return } -// ClearVersionHash clears the value of the "version_hash" field. -func (m *MCPToolMutation) ClearVersionHash() { - m.version_hash = nil - m.clearedFields[mcptool.FieldVersionHash] = struct{}{} +// UsersIDs returns the "users" edge IDs in the mutation. +func (m *GitBotMutation) UsersIDs() (ids []uuid.UUID) { + for id := range m.users { + ids = append(ids, id) + } + return } -// VersionHashCleared returns if the "version_hash" field was cleared in this mutation. -func (m *MCPToolMutation) VersionHashCleared() bool { - _, ok := m.clearedFields[mcptool.FieldVersionHash] - return ok +// ResetUsers resets all changes to the "users" edge. +func (m *GitBotMutation) ResetUsers() { + m.users = nil + m.clearedusers = false + m.removedusers = nil } -// ResetVersionHash resets all changes to the "version_hash" field. -func (m *MCPToolMutation) ResetVersionHash() { - m.version_hash = nil - delete(m.clearedFields, mcptool.FieldVersionHash) +// AddProjectIDs adds the "projects" edge to the Project entity by ids. +func (m *GitBotMutation) AddProjectIDs(ids ...uuid.UUID) { + if m.projects == nil { + m.projects = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.projects[ids[i]] = struct{}{} + } } -// SetSyncedAt sets the "synced_at" field. -func (m *MCPToolMutation) SetSyncedAt(t time.Time) { - m.synced_at = &t +// ClearProjects clears the "projects" edge to the Project entity. +func (m *GitBotMutation) ClearProjects() { + m.clearedprojects = true } -// SyncedAt returns the value of the "synced_at" field in the mutation. -func (m *MCPToolMutation) SyncedAt() (r time.Time, exists bool) { - v := m.synced_at - if v == nil { - return - } - return *v, true +// ProjectsCleared reports if the "projects" edge to the Project entity was cleared. +func (m *GitBotMutation) ProjectsCleared() bool { + return m.clearedprojects } -// OldSyncedAt returns the old "synced_at" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldSyncedAt(ctx context.Context) (v *time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSyncedAt is only allowed on UpdateOne operations") +// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs. +func (m *GitBotMutation) RemoveProjectIDs(ids ...uuid.UUID) { + if m.removedprojects == nil { + m.removedprojects = make(map[uuid.UUID]struct{}) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSyncedAt requires an ID field in the mutation") + for i := range ids { + delete(m.projects, ids[i]) + m.removedprojects[ids[i]] = struct{}{} } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSyncedAt: %w", err) +} + +// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity. +func (m *GitBotMutation) RemovedProjectsIDs() (ids []uuid.UUID) { + for id := range m.removedprojects { + ids = append(ids, id) } - return oldValue.SyncedAt, nil + return } -// ClearSyncedAt clears the value of the "synced_at" field. -func (m *MCPToolMutation) ClearSyncedAt() { - m.synced_at = nil - m.clearedFields[mcptool.FieldSyncedAt] = struct{}{} +// ProjectsIDs returns the "projects" edge IDs in the mutation. +func (m *GitBotMutation) ProjectsIDs() (ids []uuid.UUID) { + for id := range m.projects { + ids = append(ids, id) + } + return } -// SyncedAtCleared returns if the "synced_at" field was cleared in this mutation. -func (m *MCPToolMutation) SyncedAtCleared() bool { - _, ok := m.clearedFields[mcptool.FieldSyncedAt] - return ok +// ResetProjects resets all changes to the "projects" edge. +func (m *GitBotMutation) ResetProjects() { + m.projects = nil + m.clearedprojects = false + m.removedprojects = nil } -// ResetSyncedAt resets all changes to the "synced_at" field. -func (m *MCPToolMutation) ResetSyncedAt() { - m.synced_at = nil - delete(m.clearedFields, mcptool.FieldSyncedAt) +// AddGitBotUserIDs adds the "git_bot_users" edge to the GitBotUser entity by ids. +func (m *GitBotMutation) AddGitBotUserIDs(ids ...uuid.UUID) { + if m.git_bot_users == nil { + m.git_bot_users = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.git_bot_users[ids[i]] = struct{}{} + } } -// SetCreatedAt sets the "created_at" field. -func (m *MCPToolMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// ClearGitBotUsers clears the "git_bot_users" edge to the GitBotUser entity. +func (m *GitBotMutation) ClearGitBotUsers() { + m.clearedgit_bot_users = true } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *MCPToolMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true +// GitBotUsersCleared reports if the "git_bot_users" edge to the GitBotUser entity was cleared. +func (m *GitBotMutation) GitBotUsersCleared() bool { + return m.clearedgit_bot_users } -// OldCreatedAt returns the old "created_at" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") +// RemoveGitBotUserIDs removes the "git_bot_users" edge to the GitBotUser entity by IDs. +func (m *GitBotMutation) RemoveGitBotUserIDs(ids ...uuid.UUID) { + if m.removedgit_bot_users == nil { + m.removedgit_bot_users = make(map[uuid.UUID]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + for i := range ids { + delete(m.git_bot_users, ids[i]) + m.removedgit_bot_users[ids[i]] = struct{}{} } - return oldValue.CreatedAt, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *MCPToolMutation) ResetCreatedAt() { - m.created_at = nil +// RemovedGitBotUsers returns the removed IDs of the "git_bot_users" edge to the GitBotUser entity. +func (m *GitBotMutation) RemovedGitBotUsersIDs() (ids []uuid.UUID) { + for id := range m.removedgit_bot_users { + ids = append(ids, id) + } + return } -// SetUpdatedAt sets the "updated_at" field. -func (m *MCPToolMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t +// GitBotUsersIDs returns the "git_bot_users" edge IDs in the mutation. +func (m *GitBotMutation) GitBotUsersIDs() (ids []uuid.UUID) { + for id := range m.git_bot_users { + ids = append(ids, id) + } + return } -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *MCPToolMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true +// ResetGitBotUsers resets all changes to the "git_bot_users" edge. +func (m *GitBotMutation) ResetGitBotUsers() { + m.git_bot_users = nil + m.clearedgit_bot_users = false + m.removedgit_bot_users = nil } -// OldUpdatedAt returns the old "updated_at" field's value of the MCPTool entity. -// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPToolMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") +// AddProjectGitBotIDs adds the "project_git_bots" edge to the ProjectGitBot entity by ids. +func (m *GitBotMutation) AddProjectGitBotIDs(ids ...uuid.UUID) { + if m.project_git_bots == nil { + m.project_git_bots = make(map[uuid.UUID]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + for i := range ids { + m.project_git_bots[ids[i]] = struct{}{} } - return oldValue.UpdatedAt, nil } -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *MCPToolMutation) ResetUpdatedAt() { - m.updated_at = nil +// ClearProjectGitBots clears the "project_git_bots" edge to the ProjectGitBot entity. +func (m *GitBotMutation) ClearProjectGitBots() { + m.clearedproject_git_bots = true } -// ClearUpstream clears the "upstream" edge to the MCPUpstream entity. -func (m *MCPToolMutation) ClearUpstream() { - m.clearedupstream = true - m.clearedFields[mcptool.FieldUpstreamID] = struct{}{} +// ProjectGitBotsCleared reports if the "project_git_bots" edge to the ProjectGitBot entity was cleared. +func (m *GitBotMutation) ProjectGitBotsCleared() bool { + return m.clearedproject_git_bots } -// UpstreamCleared reports if the "upstream" edge to the MCPUpstream entity was cleared. -func (m *MCPToolMutation) UpstreamCleared() bool { - return m.clearedupstream +// RemoveProjectGitBotIDs removes the "project_git_bots" edge to the ProjectGitBot entity by IDs. +func (m *GitBotMutation) RemoveProjectGitBotIDs(ids ...uuid.UUID) { + if m.removedproject_git_bots == nil { + m.removedproject_git_bots = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.project_git_bots, ids[i]) + m.removedproject_git_bots[ids[i]] = struct{}{} + } } -// UpstreamIDs returns the "upstream" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UpstreamID instead. It exists only for internal usage by the builders. -func (m *MCPToolMutation) UpstreamIDs() (ids []uuid.UUID) { - if id := m.upstream; id != nil { - ids = append(ids, *id) +// RemovedProjectGitBots returns the removed IDs of the "project_git_bots" edge to the ProjectGitBot entity. +func (m *GitBotMutation) RemovedProjectGitBotsIDs() (ids []uuid.UUID) { + for id := range m.removedproject_git_bots { + ids = append(ids, id) } return } -// ResetUpstream resets all changes to the "upstream" edge. -func (m *MCPToolMutation) ResetUpstream() { - m.upstream = nil - m.clearedupstream = false +// ProjectGitBotsIDs returns the "project_git_bots" edge IDs in the mutation. +func (m *GitBotMutation) ProjectGitBotsIDs() (ids []uuid.UUID) { + for id := range m.project_git_bots { + ids = append(ids, id) + } + return } -// Where appends a list predicates to the MCPToolMutation builder. -func (m *MCPToolMutation) Where(ps ...predicate.MCPTool) { +// ResetProjectGitBots resets all changes to the "project_git_bots" edge. +func (m *GitBotMutation) ResetProjectGitBots() { + m.project_git_bots = nil + m.clearedproject_git_bots = false + m.removedproject_git_bots = nil +} + +// Where appends a list predicates to the GitBotMutation builder. +func (m *GitBotMutation) Where(ps ...predicate.GitBot) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the MCPToolMutation builder. Using this method, +// WhereP appends storage-level predicates to the GitBotMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *MCPToolMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.MCPTool, len(ps)) +func (m *GitBotMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.GitBot, len(ps)) for i := range ps { p[i] = ps[i] } @@ -10086,66 +11311,48 @@ func (m *MCPToolMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *MCPToolMutation) Op() Op { +func (m *GitBotMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *MCPToolMutation) SetOp(op Op) { +func (m *GitBotMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (MCPTool). -func (m *MCPToolMutation) Type() string { +// Type returns the node type of this mutation (GitBot). +func (m *GitBotMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *MCPToolMutation) Fields() []string { - fields := make([]string, 0, 14) +func (m *GitBotMutation) Fields() []string { + fields := make([]string, 0, 8) if m.deleted_at != nil { - fields = append(fields, mcptool.FieldDeletedAt) - } - if m.upstream != nil { - fields = append(fields, mcptool.FieldUpstreamID) - } - if m.name != nil { - fields = append(fields, mcptool.FieldName) - } - if m.namespaced_name != nil { - fields = append(fields, mcptool.FieldNamespacedName) - } - if m.scope != nil { - fields = append(fields, mcptool.FieldScope) + fields = append(fields, gitbot.FieldDeletedAt) } if m.user_id != nil { - fields = append(fields, mcptool.FieldUserID) - } - if m.description != nil { - fields = append(fields, mcptool.FieldDescription) + fields = append(fields, gitbot.FieldUserID) } - if m.input_schema != nil { - fields = append(fields, mcptool.FieldInputSchema) + if m.name != nil { + fields = append(fields, gitbot.FieldName) } - if m.price != nil { - fields = append(fields, mcptool.FieldPrice) + if m.host != nil { + fields = append(fields, gitbot.FieldHostID) } - if m.enabled != nil { - fields = append(fields, mcptool.FieldEnabled) + if m.token != nil { + fields = append(fields, gitbot.FieldToken) } - if m.version_hash != nil { - fields = append(fields, mcptool.FieldVersionHash) + if m.secret_token != nil { + fields = append(fields, gitbot.FieldSecretToken) } - if m.synced_at != nil { - fields = append(fields, mcptool.FieldSyncedAt) + if m.platform != nil { + fields = append(fields, gitbot.FieldPlatform) } if m.created_at != nil { - fields = append(fields, mcptool.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, mcptool.FieldUpdatedAt) + fields = append(fields, gitbot.FieldCreatedAt) } return fields } @@ -10153,36 +11360,24 @@ func (m *MCPToolMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *MCPToolMutation) Field(name string) (ent.Value, bool) { +func (m *GitBotMutation) Field(name string) (ent.Value, bool) { switch name { - case mcptool.FieldDeletedAt: + case gitbot.FieldDeletedAt: return m.DeletedAt() - case mcptool.FieldUpstreamID: - return m.UpstreamID() - case mcptool.FieldName: - return m.Name() - case mcptool.FieldNamespacedName: - return m.NamespacedName() - case mcptool.FieldScope: - return m.Scope() - case mcptool.FieldUserID: + case gitbot.FieldUserID: return m.UserID() - case mcptool.FieldDescription: - return m.Description() - case mcptool.FieldInputSchema: - return m.InputSchema() - case mcptool.FieldPrice: - return m.Price() - case mcptool.FieldEnabled: - return m.Enabled() - case mcptool.FieldVersionHash: - return m.VersionHash() - case mcptool.FieldSyncedAt: - return m.SyncedAt() - case mcptool.FieldCreatedAt: + case gitbot.FieldName: + return m.Name() + case gitbot.FieldHostID: + return m.HostID() + case gitbot.FieldToken: + return m.Token() + case gitbot.FieldSecretToken: + return m.SecretToken() + case gitbot.FieldPlatform: + return m.Platform() + case gitbot.FieldCreatedAt: return m.CreatedAt() - case mcptool.FieldUpdatedAt: - return m.UpdatedAt() } return nil, false } @@ -10190,409 +11385,427 @@ func (m *MCPToolMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *MCPToolMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *GitBotMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case mcptool.FieldDeletedAt: + case gitbot.FieldDeletedAt: return m.OldDeletedAt(ctx) - case mcptool.FieldUpstreamID: - return m.OldUpstreamID(ctx) - case mcptool.FieldName: - return m.OldName(ctx) - case mcptool.FieldNamespacedName: - return m.OldNamespacedName(ctx) - case mcptool.FieldScope: - return m.OldScope(ctx) - case mcptool.FieldUserID: + case gitbot.FieldUserID: return m.OldUserID(ctx) - case mcptool.FieldDescription: - return m.OldDescription(ctx) - case mcptool.FieldInputSchema: - return m.OldInputSchema(ctx) - case mcptool.FieldPrice: - return m.OldPrice(ctx) - case mcptool.FieldEnabled: - return m.OldEnabled(ctx) - case mcptool.FieldVersionHash: - return m.OldVersionHash(ctx) - case mcptool.FieldSyncedAt: - return m.OldSyncedAt(ctx) - case mcptool.FieldCreatedAt: + case gitbot.FieldName: + return m.OldName(ctx) + case gitbot.FieldHostID: + return m.OldHostID(ctx) + case gitbot.FieldToken: + return m.OldToken(ctx) + case gitbot.FieldSecretToken: + return m.OldSecretToken(ctx) + case gitbot.FieldPlatform: + return m.OldPlatform(ctx) + case gitbot.FieldCreatedAt: return m.OldCreatedAt(ctx) - case mcptool.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown MCPTool field %s", name) + return nil, fmt.Errorf("unknown GitBot field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *MCPToolMutation) SetField(name string, value ent.Value) error { +func (m *GitBotMutation) SetField(name string, value ent.Value) error { switch name { - case mcptool.FieldDeletedAt: + case gitbot.FieldDeletedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDeletedAt(v) return nil - case mcptool.FieldUpstreamID: + case gitbot.FieldUserID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUpstreamID(v) + m.SetUserID(v) return nil - case mcptool.FieldName: + case gitbot.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetName(v) return nil - case mcptool.FieldNamespacedName: + case gitbot.FieldHostID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetNamespacedName(v) - return nil - case mcptool.FieldScope: - v, ok := value.(mcptool.Scope) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetScope(v) - return nil - case mcptool.FieldUserID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUserID(v) + m.SetHostID(v) return nil - case mcptool.FieldDescription: + case gitbot.FieldToken: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDescription(v) - return nil - case mcptool.FieldInputSchema: - v, ok := value.(map[string]interface{}) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetInputSchema(v) - return nil - case mcptool.FieldPrice: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPrice(v) - return nil - case mcptool.FieldEnabled: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEnabled(v) + m.SetToken(v) return nil - case mcptool.FieldVersionHash: + case gitbot.FieldSecretToken: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetVersionHash(v) + m.SetSecretToken(v) return nil - case mcptool.FieldSyncedAt: - v, ok := value.(time.Time) + case gitbot.FieldPlatform: + v, ok := value.(consts.GitPlatform) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSyncedAt(v) + m.SetPlatform(v) return nil - case mcptool.FieldCreatedAt: + case gitbot.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case mcptool.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil } - return fmt.Errorf("unknown MCPTool field %s", name) + return fmt.Errorf("unknown GitBot field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *MCPToolMutation) AddedFields() []string { - var fields []string - if m.addprice != nil { - fields = append(fields, mcptool.FieldPrice) - } - return fields +func (m *GitBotMutation) AddedFields() []string { + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *MCPToolMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case mcptool.FieldPrice: - return m.AddedPrice() - } +func (m *GitBotMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *MCPToolMutation) AddField(name string, value ent.Value) error { +func (m *GitBotMutation) AddField(name string, value ent.Value) error { switch name { - case mcptool.FieldPrice: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddPrice(v) - return nil } - return fmt.Errorf("unknown MCPTool numeric field %s", name) + return fmt.Errorf("unknown GitBot numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *MCPToolMutation) ClearedFields() []string { +func (m *GitBotMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(mcptool.FieldDeletedAt) { - fields = append(fields, mcptool.FieldDeletedAt) - } - if m.FieldCleared(mcptool.FieldUserID) { - fields = append(fields, mcptool.FieldUserID) - } - if m.FieldCleared(mcptool.FieldDescription) { - fields = append(fields, mcptool.FieldDescription) + if m.FieldCleared(gitbot.FieldDeletedAt) { + fields = append(fields, gitbot.FieldDeletedAt) } - if m.FieldCleared(mcptool.FieldInputSchema) { - fields = append(fields, mcptool.FieldInputSchema) + if m.FieldCleared(gitbot.FieldName) { + fields = append(fields, gitbot.FieldName) } - if m.FieldCleared(mcptool.FieldVersionHash) { - fields = append(fields, mcptool.FieldVersionHash) + if m.FieldCleared(gitbot.FieldToken) { + fields = append(fields, gitbot.FieldToken) } - if m.FieldCleared(mcptool.FieldSyncedAt) { - fields = append(fields, mcptool.FieldSyncedAt) + if m.FieldCleared(gitbot.FieldSecretToken) { + fields = append(fields, gitbot.FieldSecretToken) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *MCPToolMutation) FieldCleared(name string) bool { +func (m *GitBotMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *MCPToolMutation) ClearField(name string) error { +func (m *GitBotMutation) ClearField(name string) error { switch name { - case mcptool.FieldDeletedAt: + case gitbot.FieldDeletedAt: m.ClearDeletedAt() return nil - case mcptool.FieldUserID: - m.ClearUserID() - return nil - case mcptool.FieldDescription: - m.ClearDescription() - return nil - case mcptool.FieldInputSchema: - m.ClearInputSchema() + case gitbot.FieldName: + m.ClearName() return nil - case mcptool.FieldVersionHash: - m.ClearVersionHash() + case gitbot.FieldToken: + m.ClearToken() return nil - case mcptool.FieldSyncedAt: - m.ClearSyncedAt() + case gitbot.FieldSecretToken: + m.ClearSecretToken() return nil } - return fmt.Errorf("unknown MCPTool nullable field %s", name) + return fmt.Errorf("unknown GitBot nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *MCPToolMutation) ResetField(name string) error { +func (m *GitBotMutation) ResetField(name string) error { switch name { - case mcptool.FieldDeletedAt: + case gitbot.FieldDeletedAt: m.ResetDeletedAt() return nil - case mcptool.FieldUpstreamID: - m.ResetUpstreamID() - return nil - case mcptool.FieldName: - m.ResetName() - return nil - case mcptool.FieldNamespacedName: - m.ResetNamespacedName() - return nil - case mcptool.FieldScope: - m.ResetScope() - return nil - case mcptool.FieldUserID: + case gitbot.FieldUserID: m.ResetUserID() return nil - case mcptool.FieldDescription: - m.ResetDescription() - return nil - case mcptool.FieldInputSchema: - m.ResetInputSchema() + case gitbot.FieldName: + m.ResetName() return nil - case mcptool.FieldPrice: - m.ResetPrice() + case gitbot.FieldHostID: + m.ResetHostID() return nil - case mcptool.FieldEnabled: - m.ResetEnabled() + case gitbot.FieldToken: + m.ResetToken() return nil - case mcptool.FieldVersionHash: - m.ResetVersionHash() + case gitbot.FieldSecretToken: + m.ResetSecretToken() return nil - case mcptool.FieldSyncedAt: - m.ResetSyncedAt() + case gitbot.FieldPlatform: + m.ResetPlatform() return nil - case mcptool.FieldCreatedAt: + case gitbot.FieldCreatedAt: m.ResetCreatedAt() return nil - case mcptool.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil } - return fmt.Errorf("unknown MCPTool field %s", name) + return fmt.Errorf("unknown GitBot field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *MCPToolMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.upstream != nil { - edges = append(edges, mcptool.EdgeUpstream) +func (m *GitBotMutation) AddedEdges() []string { + edges := make([]string, 0, 6) + if m.git_bot_tasks != nil { + edges = append(edges, gitbot.EdgeGitBotTasks) + } + if m.host != nil { + edges = append(edges, gitbot.EdgeHost) + } + if m.users != nil { + edges = append(edges, gitbot.EdgeUsers) + } + if m.projects != nil { + edges = append(edges, gitbot.EdgeProjects) + } + if m.git_bot_users != nil { + edges = append(edges, gitbot.EdgeGitBotUsers) + } + if m.project_git_bots != nil { + edges = append(edges, gitbot.EdgeProjectGitBots) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *MCPToolMutation) AddedIDs(name string) []ent.Value { +func (m *GitBotMutation) AddedIDs(name string) []ent.Value { switch name { - case mcptool.EdgeUpstream: - if id := m.upstream; id != nil { + case gitbot.EdgeGitBotTasks: + ids := make([]ent.Value, 0, len(m.git_bot_tasks)) + for id := range m.git_bot_tasks { + ids = append(ids, id) + } + return ids + case gitbot.EdgeHost: + if id := m.host; id != nil { return []ent.Value{*id} } + case gitbot.EdgeUsers: + ids := make([]ent.Value, 0, len(m.users)) + for id := range m.users { + ids = append(ids, id) + } + return ids + case gitbot.EdgeProjects: + ids := make([]ent.Value, 0, len(m.projects)) + for id := range m.projects { + ids = append(ids, id) + } + return ids + case gitbot.EdgeGitBotUsers: + ids := make([]ent.Value, 0, len(m.git_bot_users)) + for id := range m.git_bot_users { + ids = append(ids, id) + } + return ids + case gitbot.EdgeProjectGitBots: + ids := make([]ent.Value, 0, len(m.project_git_bots)) + for id := range m.project_git_bots { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *MCPToolMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) +func (m *GitBotMutation) RemovedEdges() []string { + edges := make([]string, 0, 6) + if m.removedgit_bot_tasks != nil { + edges = append(edges, gitbot.EdgeGitBotTasks) + } + if m.removedusers != nil { + edges = append(edges, gitbot.EdgeUsers) + } + if m.removedprojects != nil { + edges = append(edges, gitbot.EdgeProjects) + } + if m.removedgit_bot_users != nil { + edges = append(edges, gitbot.EdgeGitBotUsers) + } + if m.removedproject_git_bots != nil { + edges = append(edges, gitbot.EdgeProjectGitBots) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *MCPToolMutation) RemovedIDs(name string) []ent.Value { +func (m *GitBotMutation) RemovedIDs(name string) []ent.Value { + switch name { + case gitbot.EdgeGitBotTasks: + ids := make([]ent.Value, 0, len(m.removedgit_bot_tasks)) + for id := range m.removedgit_bot_tasks { + ids = append(ids, id) + } + return ids + case gitbot.EdgeUsers: + ids := make([]ent.Value, 0, len(m.removedusers)) + for id := range m.removedusers { + ids = append(ids, id) + } + return ids + case gitbot.EdgeProjects: + ids := make([]ent.Value, 0, len(m.removedprojects)) + for id := range m.removedprojects { + ids = append(ids, id) + } + return ids + case gitbot.EdgeGitBotUsers: + ids := make([]ent.Value, 0, len(m.removedgit_bot_users)) + for id := range m.removedgit_bot_users { + ids = append(ids, id) + } + return ids + case gitbot.EdgeProjectGitBots: + ids := make([]ent.Value, 0, len(m.removedproject_git_bots)) + for id := range m.removedproject_git_bots { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *MCPToolMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedupstream { - edges = append(edges, mcptool.EdgeUpstream) +func (m *GitBotMutation) ClearedEdges() []string { + edges := make([]string, 0, 6) + if m.clearedgit_bot_tasks { + edges = append(edges, gitbot.EdgeGitBotTasks) + } + if m.clearedhost { + edges = append(edges, gitbot.EdgeHost) + } + if m.clearedusers { + edges = append(edges, gitbot.EdgeUsers) + } + if m.clearedprojects { + edges = append(edges, gitbot.EdgeProjects) + } + if m.clearedgit_bot_users { + edges = append(edges, gitbot.EdgeGitBotUsers) + } + if m.clearedproject_git_bots { + edges = append(edges, gitbot.EdgeProjectGitBots) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *MCPToolMutation) EdgeCleared(name string) bool { +func (m *GitBotMutation) EdgeCleared(name string) bool { switch name { - case mcptool.EdgeUpstream: - return m.clearedupstream + case gitbot.EdgeGitBotTasks: + return m.clearedgit_bot_tasks + case gitbot.EdgeHost: + return m.clearedhost + case gitbot.EdgeUsers: + return m.clearedusers + case gitbot.EdgeProjects: + return m.clearedprojects + case gitbot.EdgeGitBotUsers: + return m.clearedgit_bot_users + case gitbot.EdgeProjectGitBots: + return m.clearedproject_git_bots } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *MCPToolMutation) ClearEdge(name string) error { +func (m *GitBotMutation) ClearEdge(name string) error { switch name { - case mcptool.EdgeUpstream: - m.ClearUpstream() + case gitbot.EdgeHost: + m.ClearHost() return nil } - return fmt.Errorf("unknown MCPTool unique edge %s", name) + return fmt.Errorf("unknown GitBot unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *MCPToolMutation) ResetEdge(name string) error { +func (m *GitBotMutation) ResetEdge(name string) error { switch name { - case mcptool.EdgeUpstream: - m.ResetUpstream() + case gitbot.EdgeGitBotTasks: + m.ResetGitBotTasks() + return nil + case gitbot.EdgeHost: + m.ResetHost() + return nil + case gitbot.EdgeUsers: + m.ResetUsers() + return nil + case gitbot.EdgeProjects: + m.ResetProjects() + return nil + case gitbot.EdgeGitBotUsers: + m.ResetGitBotUsers() + return nil + case gitbot.EdgeProjectGitBots: + m.ResetProjectGitBots() return nil } - return fmt.Errorf("unknown MCPTool edge %s", name) + return fmt.Errorf("unknown GitBot edge %s", name) } -// MCPUpstreamMutation represents an operation that mutates the MCPUpstream nodes in the graph. -type MCPUpstreamMutation struct { +// GitBotTaskMutation represents an operation that mutates the GitBotTask nodes in the graph. +type GitBotTaskMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - name *string - slug *string - scope *mcpupstream.Scope - _type *string - url *string - headers *map[string]string - description *string - enabled *bool - health_status *string - sync_status *string - health_checked_at *time.Time - last_synced_at *time.Time - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - tools map[uuid.UUID]struct{} - removedtools map[uuid.UUID]struct{} - clearedtools bool - user *uuid.UUID - cleareduser bool - done bool - oldValue func(context.Context) (*MCPUpstream, error) - predicates []predicate.MCPUpstream + op Op + typ string + id *uuid.UUID + created_at *time.Time + clearedFields map[string]struct{} + task *uuid.UUID + clearedtask bool + git_bot *uuid.UUID + clearedgit_bot bool + done bool + oldValue func(context.Context) (*GitBotTask, error) + predicates []predicate.GitBotTask } -var _ ent.Mutation = (*MCPUpstreamMutation)(nil) +var _ ent.Mutation = (*GitBotTaskMutation)(nil) -// mcpupstreamOption allows management of the mutation configuration using functional options. -type mcpupstreamOption func(*MCPUpstreamMutation) +// gitbottaskOption allows management of the mutation configuration using functional options. +type gitbottaskOption func(*GitBotTaskMutation) -// newMCPUpstreamMutation creates new mutation for the MCPUpstream entity. -func newMCPUpstreamMutation(c config, op Op, opts ...mcpupstreamOption) *MCPUpstreamMutation { - m := &MCPUpstreamMutation{ +// newGitBotTaskMutation creates new mutation for the GitBotTask entity. +func newGitBotTaskMutation(c config, op Op, opts ...gitbottaskOption) *GitBotTaskMutation { + m := &GitBotTaskMutation{ config: c, op: op, - typ: TypeMCPUpstream, + typ: TypeGitBotTask, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -10601,20 +11814,20 @@ func newMCPUpstreamMutation(c config, op Op, opts ...mcpupstreamOption) *MCPUpst return m } -// withMCPUpstreamID sets the ID field of the mutation. -func withMCPUpstreamID(id uuid.UUID) mcpupstreamOption { - return func(m *MCPUpstreamMutation) { +// withGitBotTaskID sets the ID field of the mutation. +func withGitBotTaskID(id uuid.UUID) gitbottaskOption { + return func(m *GitBotTaskMutation) { var ( err error once sync.Once - value *MCPUpstream + value *GitBotTask ) - m.oldValue = func(ctx context.Context) (*MCPUpstream, error) { + m.oldValue = func(ctx context.Context) (*GitBotTask, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().MCPUpstream.Get(ctx, id) + value, err = m.Client().GitBotTask.Get(ctx, id) } }) return value, err @@ -10623,10 +11836,10 @@ func withMCPUpstreamID(id uuid.UUID) mcpupstreamOption { } } -// withMCPUpstream sets the old MCPUpstream of the mutation. -func withMCPUpstream(node *MCPUpstream) mcpupstreamOption { - return func(m *MCPUpstreamMutation) { - m.oldValue = func(context.Context) (*MCPUpstream, error) { +// withGitBotTask sets the old GitBotTask of the mutation. +func withGitBotTask(node *GitBotTask) gitbottaskOption { + return func(m *GitBotTaskMutation) { + m.oldValue = func(context.Context) (*GitBotTask, error) { return node, nil } m.id = &node.ID @@ -10635,7 +11848,7 @@ func withMCPUpstream(node *MCPUpstream) mcpupstreamOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m MCPUpstreamMutation) Client() *Client { +func (m GitBotTaskMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -10643,7 +11856,7 @@ func (m MCPUpstreamMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m MCPUpstreamMutation) Tx() (*Tx, error) { +func (m GitBotTaskMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -10653,14 +11866,14 @@ func (m MCPUpstreamMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of MCPUpstream entities. -func (m *MCPUpstreamMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of GitBotTask entities. +func (m *GitBotTaskMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *MCPUpstreamMutation) ID() (id uuid.UUID, exists bool) { +func (m *GitBotTaskMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -10671,7 +11884,7 @@ func (m *MCPUpstreamMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *MCPUpstreamMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *GitBotTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -10680,601 +11893,631 @@ func (m *MCPUpstreamMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().MCPUpstream.Query().Where(m.predicates...).IDs(ctx) + return m.Client().GitBotTask.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetDeletedAt sets the "deleted_at" field. -func (m *MCPUpstreamMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t +// SetGitBotID sets the "git_bot_id" field. +func (m *GitBotTaskMutation) SetGitBotID(u uuid.UUID) { + m.git_bot = &u } -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *MCPUpstreamMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at +// GitBotID returns the value of the "git_bot_id" field in the mutation. +func (m *GitBotTaskMutation) GitBotID() (r uuid.UUID, exists bool) { + v := m.git_bot if v == nil { return } return *v, true } -// OldDeletedAt returns the old "deleted_at" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// OldGitBotID returns the old "git_bot_id" field's value of the GitBotTask entity. +// If the GitBotTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { +func (m *GitBotTaskMutation) OldGitBotID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + return v, errors.New("OldGitBotID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") + return v, errors.New("OldGitBotID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + return v, fmt.Errorf("querying old value for OldGitBotID: %w", err) } - return oldValue.DeletedAt, nil -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *MCPUpstreamMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[mcpupstream.FieldDeletedAt] = struct{}{} -} - -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *MCPUpstreamMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[mcpupstream.FieldDeletedAt] - return ok + return oldValue.GitBotID, nil } -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *MCPUpstreamMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, mcpupstream.FieldDeletedAt) +// ResetGitBotID resets all changes to the "git_bot_id" field. +func (m *GitBotTaskMutation) ResetGitBotID() { + m.git_bot = nil } -// SetName sets the "name" field. -func (m *MCPUpstreamMutation) SetName(s string) { - m.name = &s +// SetTaskID sets the "task_id" field. +func (m *GitBotTaskMutation) SetTaskID(u uuid.UUID) { + m.task = &u } -// Name returns the value of the "name" field in the mutation. -func (m *MCPUpstreamMutation) Name() (r string, exists bool) { - v := m.name +// TaskID returns the value of the "task_id" field in the mutation. +func (m *GitBotTaskMutation) TaskID() (r uuid.UUID, exists bool) { + v := m.task if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// OldTaskID returns the old "task_id" field's value of the GitBotTask entity. +// If the GitBotTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldName(ctx context.Context) (v string, err error) { +func (m *GitBotTaskMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldTaskID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldTaskID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldTaskID: %w", err) } - return oldValue.Name, nil + return oldValue.TaskID, nil } -// ResetName resets all changes to the "name" field. -func (m *MCPUpstreamMutation) ResetName() { - m.name = nil +// ResetTaskID resets all changes to the "task_id" field. +func (m *GitBotTaskMutation) ResetTaskID() { + m.task = nil } -// SetSlug sets the "slug" field. -func (m *MCPUpstreamMutation) SetSlug(s string) { - m.slug = &s +// SetCreatedAt sets the "created_at" field. +func (m *GitBotTaskMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// Slug returns the value of the "slug" field in the mutation. -func (m *MCPUpstreamMutation) Slug() (r string, exists bool) { - v := m.slug +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *GitBotTaskMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldSlug returns the old "slug" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the GitBotTask entity. +// If the GitBotTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldSlug(ctx context.Context) (v string, err error) { +func (m *GitBotTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSlug is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSlug requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSlug: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.Slug, nil + return oldValue.CreatedAt, nil } -// ResetSlug resets all changes to the "slug" field. -func (m *MCPUpstreamMutation) ResetSlug() { - m.slug = nil +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *GitBotTaskMutation) ResetCreatedAt() { + m.created_at = nil } -// SetScope sets the "scope" field. -func (m *MCPUpstreamMutation) SetScope(value mcpupstream.Scope) { - m.scope = &value +// ClearTask clears the "task" edge to the Task entity. +func (m *GitBotTaskMutation) ClearTask() { + m.clearedtask = true + m.clearedFields[gitbottask.FieldTaskID] = struct{}{} } -// Scope returns the value of the "scope" field in the mutation. -func (m *MCPUpstreamMutation) Scope() (r mcpupstream.Scope, exists bool) { - v := m.scope - if v == nil { - return - } - return *v, true +// TaskCleared reports if the "task" edge to the Task entity was cleared. +func (m *GitBotTaskMutation) TaskCleared() bool { + return m.clearedtask } -// OldScope returns the old "scope" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldScope(ctx context.Context) (v mcpupstream.Scope, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldScope is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldScope requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldScope: %w", err) +// TaskIDs returns the "task" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TaskID instead. It exists only for internal usage by the builders. +func (m *GitBotTaskMutation) TaskIDs() (ids []uuid.UUID) { + if id := m.task; id != nil { + ids = append(ids, *id) } - return oldValue.Scope, nil + return } -// ResetScope resets all changes to the "scope" field. -func (m *MCPUpstreamMutation) ResetScope() { - m.scope = nil +// ResetTask resets all changes to the "task" edge. +func (m *GitBotTaskMutation) ResetTask() { + m.task = nil + m.clearedtask = false } -// SetUserID sets the "user_id" field. -func (m *MCPUpstreamMutation) SetUserID(u uuid.UUID) { - m.user = &u +// ClearGitBot clears the "git_bot" edge to the GitBot entity. +func (m *GitBotTaskMutation) ClearGitBot() { + m.clearedgit_bot = true + m.clearedFields[gitbottask.FieldGitBotID] = struct{}{} } -// UserID returns the value of the "user_id" field in the mutation. -func (m *MCPUpstreamMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user - if v == nil { - return - } - return *v, true +// GitBotCleared reports if the "git_bot" edge to the GitBot entity was cleared. +func (m *GitBotTaskMutation) GitBotCleared() bool { + return m.clearedgit_bot } -// OldUserID returns the old "user_id" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldUserID(ctx context.Context) (v *uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) +// GitBotIDs returns the "git_bot" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// GitBotID instead. It exists only for internal usage by the builders. +func (m *GitBotTaskMutation) GitBotIDs() (ids []uuid.UUID) { + if id := m.git_bot; id != nil { + ids = append(ids, *id) } - return oldValue.UserID, nil + return } -// ClearUserID clears the value of the "user_id" field. -func (m *MCPUpstreamMutation) ClearUserID() { - m.user = nil - m.clearedFields[mcpupstream.FieldUserID] = struct{}{} +// ResetGitBot resets all changes to the "git_bot" edge. +func (m *GitBotTaskMutation) ResetGitBot() { + m.git_bot = nil + m.clearedgit_bot = false } -// UserIDCleared returns if the "user_id" field was cleared in this mutation. -func (m *MCPUpstreamMutation) UserIDCleared() bool { - _, ok := m.clearedFields[mcpupstream.FieldUserID] - return ok +// Where appends a list predicates to the GitBotTaskMutation builder. +func (m *GitBotTaskMutation) Where(ps ...predicate.GitBotTask) { + m.predicates = append(m.predicates, ps...) } -// ResetUserID resets all changes to the "user_id" field. -func (m *MCPUpstreamMutation) ResetUserID() { - m.user = nil - delete(m.clearedFields, mcpupstream.FieldUserID) +// WhereP appends storage-level predicates to the GitBotTaskMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *GitBotTaskMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.GitBotTask, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) } -// SetType sets the "type" field. -func (m *MCPUpstreamMutation) SetType(s string) { - m._type = &s +// Op returns the operation name. +func (m *GitBotTaskMutation) Op() Op { + return m.op } -// GetType returns the value of the "type" field in the mutation. -func (m *MCPUpstreamMutation) GetType() (r string, exists bool) { - v := m._type - if v == nil { - return - } - return *v, true +// SetOp allows setting the mutation operation. +func (m *GitBotTaskMutation) SetOp(op Op) { + m.op = op } -// OldType returns the old "type" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldType(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") +// Type returns the node type of this mutation (GitBotTask). +func (m *GitBotTaskMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *GitBotTaskMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.git_bot != nil { + fields = append(fields, gitbottask.FieldGitBotID) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") + if m.task != nil { + fields = append(fields, gitbottask.FieldTaskID) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) + if m.created_at != nil { + fields = append(fields, gitbottask.FieldCreatedAt) } - return oldValue.Type, nil -} - -// ResetType resets all changes to the "type" field. -func (m *MCPUpstreamMutation) ResetType() { - m._type = nil + return fields } -// SetURL sets the "url" field. -func (m *MCPUpstreamMutation) SetURL(s string) { - m.url = &s +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *GitBotTaskMutation) Field(name string) (ent.Value, bool) { + switch name { + case gitbottask.FieldGitBotID: + return m.GitBotID() + case gitbottask.FieldTaskID: + return m.TaskID() + case gitbottask.FieldCreatedAt: + return m.CreatedAt() + } + return nil, false } -// URL returns the value of the "url" field in the mutation. -func (m *MCPUpstreamMutation) URL() (r string, exists bool) { - v := m.url - if v == nil { - return +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *GitBotTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case gitbottask.FieldGitBotID: + return m.OldGitBotID(ctx) + case gitbottask.FieldTaskID: + return m.OldTaskID(ctx) + case gitbottask.FieldCreatedAt: + return m.OldCreatedAt(ctx) } - return *v, true + return nil, fmt.Errorf("unknown GitBotTask field %s", name) } -// OldURL returns the old "url" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldURL(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldURL is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldURL requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldURL: %w", err) +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *GitBotTaskMutation) SetField(name string, value ent.Value) error { + switch name { + case gitbottask.FieldGitBotID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGitBotID(v) + return nil + case gitbottask.FieldTaskID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTaskID(v) + return nil + case gitbottask.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil } - return oldValue.URL, nil + return fmt.Errorf("unknown GitBotTask field %s", name) } -// ResetURL resets all changes to the "url" field. -func (m *MCPUpstreamMutation) ResetURL() { - m.url = nil +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *GitBotTaskMutation) AddedFields() []string { + return nil } -// SetHeaders sets the "headers" field. -func (m *MCPUpstreamMutation) SetHeaders(value map[string]string) { - m.headers = &value +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *GitBotTaskMutation) AddedField(name string) (ent.Value, bool) { + return nil, false } -// Headers returns the value of the "headers" field in the mutation. -func (m *MCPUpstreamMutation) Headers() (r map[string]string, exists bool) { - v := m.headers - if v == nil { - return +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *GitBotTaskMutation) AddField(name string, value ent.Value) error { + switch name { } - return *v, true + return fmt.Errorf("unknown GitBotTask numeric field %s", name) } -// OldHeaders returns the old "headers" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldHeaders(ctx context.Context) (v map[string]string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHeaders is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHeaders requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldHeaders: %w", err) - } - return oldValue.Headers, nil +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *GitBotTaskMutation) ClearedFields() []string { + return nil } -// ClearHeaders clears the value of the "headers" field. -func (m *MCPUpstreamMutation) ClearHeaders() { - m.headers = nil - m.clearedFields[mcpupstream.FieldHeaders] = struct{}{} -} - -// HeadersCleared returns if the "headers" field was cleared in this mutation. -func (m *MCPUpstreamMutation) HeadersCleared() bool { - _, ok := m.clearedFields[mcpupstream.FieldHeaders] +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *GitBotTaskMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] return ok } -// ResetHeaders resets all changes to the "headers" field. -func (m *MCPUpstreamMutation) ResetHeaders() { - m.headers = nil - delete(m.clearedFields, mcpupstream.FieldHeaders) -} - -// SetDescription sets the "description" field. -func (m *MCPUpstreamMutation) SetDescription(s string) { - m.description = &s +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *GitBotTaskMutation) ClearField(name string) error { + return fmt.Errorf("unknown GitBotTask nullable field %s", name) } -// Description returns the value of the "description" field in the mutation. -func (m *MCPUpstreamMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *GitBotTaskMutation) ResetField(name string) error { + switch name { + case gitbottask.FieldGitBotID: + m.ResetGitBotID() + return nil + case gitbottask.FieldTaskID: + m.ResetTaskID() + return nil + case gitbottask.FieldCreatedAt: + m.ResetCreatedAt() + return nil } - return *v, true + return fmt.Errorf("unknown GitBotTask field %s", name) } -// OldDescription returns the old "description" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *GitBotTaskMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.task != nil { + edges = append(edges, gitbottask.EdgeTask) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + if m.git_bot != nil { + edges = append(edges, gitbottask.EdgeGitBot) } - return oldValue.Description, nil + return edges } -// ClearDescription clears the value of the "description" field. -func (m *MCPUpstreamMutation) ClearDescription() { - m.description = nil - m.clearedFields[mcpupstream.FieldDescription] = struct{}{} +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *GitBotTaskMutation) AddedIDs(name string) []ent.Value { + switch name { + case gitbottask.EdgeTask: + if id := m.task; id != nil { + return []ent.Value{*id} + } + case gitbottask.EdgeGitBot: + if id := m.git_bot; id != nil { + return []ent.Value{*id} + } + } + return nil } -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *MCPUpstreamMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[mcpupstream.FieldDescription] - return ok +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *GitBotTaskMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges } -// ResetDescription resets all changes to the "description" field. -func (m *MCPUpstreamMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, mcpupstream.FieldDescription) +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *GitBotTaskMutation) RemovedIDs(name string) []ent.Value { + return nil } -// SetEnabled sets the "enabled" field. -func (m *MCPUpstreamMutation) SetEnabled(b bool) { - m.enabled = &b +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *GitBotTaskMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedtask { + edges = append(edges, gitbottask.EdgeTask) + } + if m.clearedgit_bot { + edges = append(edges, gitbottask.EdgeGitBot) + } + return edges } -// Enabled returns the value of the "enabled" field in the mutation. -func (m *MCPUpstreamMutation) Enabled() (r bool, exists bool) { - v := m.enabled - if v == nil { - return +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *GitBotTaskMutation) EdgeCleared(name string) bool { + switch name { + case gitbottask.EdgeTask: + return m.clearedtask + case gitbottask.EdgeGitBot: + return m.clearedgit_bot } - return *v, true + return false } -// OldEnabled returns the old "enabled" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldEnabled(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEnabled is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEnabled requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEnabled: %w", err) +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *GitBotTaskMutation) ClearEdge(name string) error { + switch name { + case gitbottask.EdgeTask: + m.ClearTask() + return nil + case gitbottask.EdgeGitBot: + m.ClearGitBot() + return nil } - return oldValue.Enabled, nil + return fmt.Errorf("unknown GitBotTask unique edge %s", name) } -// ResetEnabled resets all changes to the "enabled" field. -func (m *MCPUpstreamMutation) ResetEnabled() { - m.enabled = nil +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *GitBotTaskMutation) ResetEdge(name string) error { + switch name { + case gitbottask.EdgeTask: + m.ResetTask() + return nil + case gitbottask.EdgeGitBot: + m.ResetGitBot() + return nil + } + return fmt.Errorf("unknown GitBotTask edge %s", name) } -// SetHealthStatus sets the "health_status" field. -func (m *MCPUpstreamMutation) SetHealthStatus(s string) { - m.health_status = &s +// GitBotUserMutation represents an operation that mutates the GitBotUser nodes in the graph. +type GitBotUserMutation struct { + config + op Op + typ string + id *uuid.UUID + created_at *time.Time + clearedFields map[string]struct{} + git_bot *uuid.UUID + clearedgit_bot bool + user *uuid.UUID + cleareduser bool + done bool + oldValue func(context.Context) (*GitBotUser, error) + predicates []predicate.GitBotUser } -// HealthStatus returns the value of the "health_status" field in the mutation. -func (m *MCPUpstreamMutation) HealthStatus() (r string, exists bool) { - v := m.health_status - if v == nil { - return - } - return *v, true -} +var _ ent.Mutation = (*GitBotUserMutation)(nil) -// OldHealthStatus returns the old "health_status" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldHealthStatus(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHealthStatus is only allowed on UpdateOne operations") +// gitbotuserOption allows management of the mutation configuration using functional options. +type gitbotuserOption func(*GitBotUserMutation) + +// newGitBotUserMutation creates new mutation for the GitBotUser entity. +func newGitBotUserMutation(c config, op Op, opts ...gitbotuserOption) *GitBotUserMutation { + m := &GitBotUserMutation{ + config: c, + op: op, + typ: TypeGitBotUser, + clearedFields: make(map[string]struct{}), } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHealthStatus requires an ID field in the mutation") + for _, opt := range opts { + opt(m) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldHealthStatus: %w", err) + return m +} + +// withGitBotUserID sets the ID field of the mutation. +func withGitBotUserID(id uuid.UUID) gitbotuserOption { + return func(m *GitBotUserMutation) { + var ( + err error + once sync.Once + value *GitBotUser + ) + m.oldValue = func(ctx context.Context) (*GitBotUser, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().GitBotUser.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } - return oldValue.HealthStatus, nil } -// ResetHealthStatus resets all changes to the "health_status" field. -func (m *MCPUpstreamMutation) ResetHealthStatus() { - m.health_status = nil +// withGitBotUser sets the old GitBotUser of the mutation. +func withGitBotUser(node *GitBotUser) gitbotuserOption { + return func(m *GitBotUserMutation) { + m.oldValue = func(context.Context) (*GitBotUser, error) { + return node, nil + } + m.id = &node.ID + } } -// SetSyncStatus sets the "sync_status" field. -func (m *MCPUpstreamMutation) SetSyncStatus(s string) { - m.sync_status = &s +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m GitBotUserMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// SyncStatus returns the value of the "sync_status" field in the mutation. -func (m *MCPUpstreamMutation) SyncStatus() (r string, exists bool) { - v := m.sync_status - if v == nil { - return +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m GitBotUserMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") } - return *v, true + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// OldSyncStatus returns the old "sync_status" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldSyncStatus(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSyncStatus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSyncStatus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSyncStatus: %w", err) +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of GitBotUser entities. +func (m *GitBotUserMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *GitBotUserMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return } - return oldValue.SyncStatus, nil + return *m.id, true } -// ResetSyncStatus resets all changes to the "sync_status" field. -func (m *MCPUpstreamMutation) ResetSyncStatus() { - m.sync_status = nil +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *GitBotUserMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().GitBotUser.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } } -// SetHealthCheckedAt sets the "health_checked_at" field. -func (m *MCPUpstreamMutation) SetHealthCheckedAt(t time.Time) { - m.health_checked_at = &t +// SetGitBotID sets the "git_bot_id" field. +func (m *GitBotUserMutation) SetGitBotID(u uuid.UUID) { + m.git_bot = &u } -// HealthCheckedAt returns the value of the "health_checked_at" field in the mutation. -func (m *MCPUpstreamMutation) HealthCheckedAt() (r time.Time, exists bool) { - v := m.health_checked_at +// GitBotID returns the value of the "git_bot_id" field in the mutation. +func (m *GitBotUserMutation) GitBotID() (r uuid.UUID, exists bool) { + v := m.git_bot if v == nil { return } return *v, true } -// OldHealthCheckedAt returns the old "health_checked_at" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// OldGitBotID returns the old "git_bot_id" field's value of the GitBotUser entity. +// If the GitBotUser object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldHealthCheckedAt(ctx context.Context) (v *time.Time, err error) { +func (m *GitBotUserMutation) OldGitBotID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHealthCheckedAt is only allowed on UpdateOne operations") + return v, errors.New("OldGitBotID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHealthCheckedAt requires an ID field in the mutation") + return v, errors.New("OldGitBotID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldHealthCheckedAt: %w", err) + return v, fmt.Errorf("querying old value for OldGitBotID: %w", err) } - return oldValue.HealthCheckedAt, nil -} - -// ClearHealthCheckedAt clears the value of the "health_checked_at" field. -func (m *MCPUpstreamMutation) ClearHealthCheckedAt() { - m.health_checked_at = nil - m.clearedFields[mcpupstream.FieldHealthCheckedAt] = struct{}{} -} - -// HealthCheckedAtCleared returns if the "health_checked_at" field was cleared in this mutation. -func (m *MCPUpstreamMutation) HealthCheckedAtCleared() bool { - _, ok := m.clearedFields[mcpupstream.FieldHealthCheckedAt] - return ok + return oldValue.GitBotID, nil } -// ResetHealthCheckedAt resets all changes to the "health_checked_at" field. -func (m *MCPUpstreamMutation) ResetHealthCheckedAt() { - m.health_checked_at = nil - delete(m.clearedFields, mcpupstream.FieldHealthCheckedAt) +// ResetGitBotID resets all changes to the "git_bot_id" field. +func (m *GitBotUserMutation) ResetGitBotID() { + m.git_bot = nil } -// SetLastSyncedAt sets the "last_synced_at" field. -func (m *MCPUpstreamMutation) SetLastSyncedAt(t time.Time) { - m.last_synced_at = &t +// SetUserID sets the "user_id" field. +func (m *GitBotUserMutation) SetUserID(u uuid.UUID) { + m.user = &u } -// LastSyncedAt returns the value of the "last_synced_at" field in the mutation. -func (m *MCPUpstreamMutation) LastSyncedAt() (r time.Time, exists bool) { - v := m.last_synced_at +// UserID returns the value of the "user_id" field in the mutation. +func (m *GitBotUserMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user if v == nil { return } return *v, true } -// OldLastSyncedAt returns the old "last_synced_at" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the GitBotUser entity. +// If the GitBotUser object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldLastSyncedAt(ctx context.Context) (v *time.Time, err error) { +func (m *GitBotUserMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastSyncedAt is only allowed on UpdateOne operations") + return v, errors.New("OldUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastSyncedAt requires an ID field in the mutation") + return v, errors.New("OldUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLastSyncedAt: %w", err) + return v, fmt.Errorf("querying old value for OldUserID: %w", err) } - return oldValue.LastSyncedAt, nil -} - -// ClearLastSyncedAt clears the value of the "last_synced_at" field. -func (m *MCPUpstreamMutation) ClearLastSyncedAt() { - m.last_synced_at = nil - m.clearedFields[mcpupstream.FieldLastSyncedAt] = struct{}{} -} - -// LastSyncedAtCleared returns if the "last_synced_at" field was cleared in this mutation. -func (m *MCPUpstreamMutation) LastSyncedAtCleared() bool { - _, ok := m.clearedFields[mcpupstream.FieldLastSyncedAt] - return ok + return oldValue.UserID, nil } -// ResetLastSyncedAt resets all changes to the "last_synced_at" field. -func (m *MCPUpstreamMutation) ResetLastSyncedAt() { - m.last_synced_at = nil - delete(m.clearedFields, mcpupstream.FieldLastSyncedAt) +// ResetUserID resets all changes to the "user_id" field. +func (m *GitBotUserMutation) ResetUserID() { + m.user = nil } // SetCreatedAt sets the "created_at" field. -func (m *MCPUpstreamMutation) SetCreatedAt(t time.Time) { +func (m *GitBotUserMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *MCPUpstreamMutation) CreatedAt() (r time.Time, exists bool) { +func (m *GitBotUserMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -11282,10 +12525,10 @@ func (m *MCPUpstreamMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the GitBotUser entity. +// If the GitBotUser object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *GitBotUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -11300,136 +12543,73 @@ func (m *MCPUpstreamMutation) OldCreatedAt(ctx context.Context) (v time.Time, er } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *MCPUpstreamMutation) ResetCreatedAt() { +func (m *GitBotUserMutation) ResetCreatedAt() { m.created_at = nil } -// SetUpdatedAt sets the "updated_at" field. -func (m *MCPUpstreamMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t +// ClearGitBot clears the "git_bot" edge to the GitBot entity. +func (m *GitBotUserMutation) ClearGitBot() { + m.clearedgit_bot = true + m.clearedFields[gitbotuser.FieldGitBotID] = struct{}{} } -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *MCPUpstreamMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true +// GitBotCleared reports if the "git_bot" edge to the GitBot entity was cleared. +func (m *GitBotUserMutation) GitBotCleared() bool { + return m.clearedgit_bot } -// OldUpdatedAt returns the old "updated_at" field's value of the MCPUpstream entity. -// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUpstreamMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) +// GitBotIDs returns the "git_bot" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// GitBotID instead. It exists only for internal usage by the builders. +func (m *GitBotUserMutation) GitBotIDs() (ids []uuid.UUID) { + if id := m.git_bot; id != nil { + ids = append(ids, *id) } - return oldValue.UpdatedAt, nil + return } -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *MCPUpstreamMutation) ResetUpdatedAt() { - m.updated_at = nil +// ResetGitBot resets all changes to the "git_bot" edge. +func (m *GitBotUserMutation) ResetGitBot() { + m.git_bot = nil + m.clearedgit_bot = false } -// AddToolIDs adds the "tools" edge to the MCPTool entity by ids. -func (m *MCPUpstreamMutation) AddToolIDs(ids ...uuid.UUID) { - if m.tools == nil { - m.tools = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.tools[ids[i]] = struct{}{} - } +// ClearUser clears the "user" edge to the User entity. +func (m *GitBotUserMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[gitbotuser.FieldUserID] = struct{}{} } -// ClearTools clears the "tools" edge to the MCPTool entity. -func (m *MCPUpstreamMutation) ClearTools() { - m.clearedtools = true +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *GitBotUserMutation) UserCleared() bool { + return m.cleareduser } -// ToolsCleared reports if the "tools" edge to the MCPTool entity was cleared. -func (m *MCPUpstreamMutation) ToolsCleared() bool { - return m.clearedtools +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *GitBotUserMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return } -// RemoveToolIDs removes the "tools" edge to the MCPTool entity by IDs. -func (m *MCPUpstreamMutation) RemoveToolIDs(ids ...uuid.UUID) { - if m.removedtools == nil { - m.removedtools = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.tools, ids[i]) - m.removedtools[ids[i]] = struct{}{} - } +// ResetUser resets all changes to the "user" edge. +func (m *GitBotUserMutation) ResetUser() { + m.user = nil + m.cleareduser = false } -// RemovedTools returns the removed IDs of the "tools" edge to the MCPTool entity. -func (m *MCPUpstreamMutation) RemovedToolsIDs() (ids []uuid.UUID) { - for id := range m.removedtools { - ids = append(ids, id) - } - return -} - -// ToolsIDs returns the "tools" edge IDs in the mutation. -func (m *MCPUpstreamMutation) ToolsIDs() (ids []uuid.UUID) { - for id := range m.tools { - ids = append(ids, id) - } - return -} - -// ResetTools resets all changes to the "tools" edge. -func (m *MCPUpstreamMutation) ResetTools() { - m.tools = nil - m.clearedtools = false - m.removedtools = nil -} - -// ClearUser clears the "user" edge to the User entity. -func (m *MCPUpstreamMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[mcpupstream.FieldUserID] = struct{}{} -} - -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *MCPUpstreamMutation) UserCleared() bool { - return m.UserIDCleared() || m.cleareduser -} - -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *MCPUpstreamMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetUser resets all changes to the "user" edge. -func (m *MCPUpstreamMutation) ResetUser() { - m.user = nil - m.cleareduser = false -} - -// Where appends a list predicates to the MCPUpstreamMutation builder. -func (m *MCPUpstreamMutation) Where(ps ...predicate.MCPUpstream) { +// Where appends a list predicates to the GitBotUserMutation builder. +func (m *GitBotUserMutation) Where(ps ...predicate.GitBotUser) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the MCPUpstreamMutation builder. Using this method, +// WhereP appends storage-level predicates to the GitBotUserMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *MCPUpstreamMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.MCPUpstream, len(ps)) +func (m *GitBotUserMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.GitBotUser, len(ps)) for i := range ps { p[i] = ps[i] } @@ -11437,72 +12617,33 @@ func (m *MCPUpstreamMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *MCPUpstreamMutation) Op() Op { +func (m *GitBotUserMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *MCPUpstreamMutation) SetOp(op Op) { +func (m *GitBotUserMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (MCPUpstream). -func (m *MCPUpstreamMutation) Type() string { +// Type returns the node type of this mutation (GitBotUser). +func (m *GitBotUserMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *MCPUpstreamMutation) Fields() []string { - fields := make([]string, 0, 16) - if m.deleted_at != nil { - fields = append(fields, mcpupstream.FieldDeletedAt) - } - if m.name != nil { - fields = append(fields, mcpupstream.FieldName) - } - if m.slug != nil { - fields = append(fields, mcpupstream.FieldSlug) - } - if m.scope != nil { - fields = append(fields, mcpupstream.FieldScope) +func (m *GitBotUserMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.git_bot != nil { + fields = append(fields, gitbotuser.FieldGitBotID) } if m.user != nil { - fields = append(fields, mcpupstream.FieldUserID) - } - if m._type != nil { - fields = append(fields, mcpupstream.FieldType) - } - if m.url != nil { - fields = append(fields, mcpupstream.FieldURL) - } - if m.headers != nil { - fields = append(fields, mcpupstream.FieldHeaders) - } - if m.description != nil { - fields = append(fields, mcpupstream.FieldDescription) - } - if m.enabled != nil { - fields = append(fields, mcpupstream.FieldEnabled) - } - if m.health_status != nil { - fields = append(fields, mcpupstream.FieldHealthStatus) - } - if m.sync_status != nil { - fields = append(fields, mcpupstream.FieldSyncStatus) - } - if m.health_checked_at != nil { - fields = append(fields, mcpupstream.FieldHealthCheckedAt) - } - if m.last_synced_at != nil { - fields = append(fields, mcpupstream.FieldLastSyncedAt) + fields = append(fields, gitbotuser.FieldUserID) } if m.created_at != nil { - fields = append(fields, mcpupstream.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, mcpupstream.FieldUpdatedAt) + fields = append(fields, gitbotuser.FieldCreatedAt) } return fields } @@ -11510,40 +12651,14 @@ func (m *MCPUpstreamMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *MCPUpstreamMutation) Field(name string) (ent.Value, bool) { +func (m *GitBotUserMutation) Field(name string) (ent.Value, bool) { switch name { - case mcpupstream.FieldDeletedAt: - return m.DeletedAt() - case mcpupstream.FieldName: - return m.Name() - case mcpupstream.FieldSlug: - return m.Slug() - case mcpupstream.FieldScope: - return m.Scope() - case mcpupstream.FieldUserID: + case gitbotuser.FieldGitBotID: + return m.GitBotID() + case gitbotuser.FieldUserID: return m.UserID() - case mcpupstream.FieldType: - return m.GetType() - case mcpupstream.FieldURL: - return m.URL() - case mcpupstream.FieldHeaders: - return m.Headers() - case mcpupstream.FieldDescription: - return m.Description() - case mcpupstream.FieldEnabled: - return m.Enabled() - case mcpupstream.FieldHealthStatus: - return m.HealthStatus() - case mcpupstream.FieldSyncStatus: - return m.SyncStatus() - case mcpupstream.FieldHealthCheckedAt: - return m.HealthCheckedAt() - case mcpupstream.FieldLastSyncedAt: - return m.LastSyncedAt() - case mcpupstream.FieldCreatedAt: + case gitbotuser.FieldCreatedAt: return m.CreatedAt() - case mcpupstream.FieldUpdatedAt: - return m.UpdatedAt() } return nil, false } @@ -11551,324 +12666,127 @@ func (m *MCPUpstreamMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *MCPUpstreamMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *GitBotUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case mcpupstream.FieldDeletedAt: - return m.OldDeletedAt(ctx) - case mcpupstream.FieldName: - return m.OldName(ctx) - case mcpupstream.FieldSlug: - return m.OldSlug(ctx) - case mcpupstream.FieldScope: - return m.OldScope(ctx) - case mcpupstream.FieldUserID: + case gitbotuser.FieldGitBotID: + return m.OldGitBotID(ctx) + case gitbotuser.FieldUserID: return m.OldUserID(ctx) - case mcpupstream.FieldType: - return m.OldType(ctx) - case mcpupstream.FieldURL: - return m.OldURL(ctx) - case mcpupstream.FieldHeaders: - return m.OldHeaders(ctx) - case mcpupstream.FieldDescription: - return m.OldDescription(ctx) - case mcpupstream.FieldEnabled: - return m.OldEnabled(ctx) - case mcpupstream.FieldHealthStatus: - return m.OldHealthStatus(ctx) - case mcpupstream.FieldSyncStatus: - return m.OldSyncStatus(ctx) - case mcpupstream.FieldHealthCheckedAt: - return m.OldHealthCheckedAt(ctx) - case mcpupstream.FieldLastSyncedAt: - return m.OldLastSyncedAt(ctx) - case mcpupstream.FieldCreatedAt: + case gitbotuser.FieldCreatedAt: return m.OldCreatedAt(ctx) - case mcpupstream.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown MCPUpstream field %s", name) + return nil, fmt.Errorf("unknown GitBotUser field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *MCPUpstreamMutation) SetField(name string, value ent.Value) error { +func (m *GitBotUserMutation) SetField(name string, value ent.Value) error { switch name { - case mcpupstream.FieldDeletedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDeletedAt(v) - return nil - case mcpupstream.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case mcpupstream.FieldSlug: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSlug(v) - return nil - case mcpupstream.FieldScope: - v, ok := value.(mcpupstream.Scope) + case gitbotuser.FieldGitBotID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetScope(v) + m.SetGitBotID(v) return nil - case mcpupstream.FieldUserID: + case gitbotuser.FieldUserID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUserID(v) return nil - case mcpupstream.FieldType: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case mcpupstream.FieldURL: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetURL(v) - return nil - case mcpupstream.FieldHeaders: - v, ok := value.(map[string]string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHeaders(v) - return nil - case mcpupstream.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case mcpupstream.FieldEnabled: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEnabled(v) - return nil - case mcpupstream.FieldHealthStatus: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHealthStatus(v) - return nil - case mcpupstream.FieldSyncStatus: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSyncStatus(v) - return nil - case mcpupstream.FieldHealthCheckedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHealthCheckedAt(v) - return nil - case mcpupstream.FieldLastSyncedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLastSyncedAt(v) - return nil - case mcpupstream.FieldCreatedAt: + case gitbotuser.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case mcpupstream.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil } - return fmt.Errorf("unknown MCPUpstream field %s", name) + return fmt.Errorf("unknown GitBotUser field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *MCPUpstreamMutation) AddedFields() []string { +func (m *GitBotUserMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *MCPUpstreamMutation) AddedField(name string) (ent.Value, bool) { +func (m *GitBotUserMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *MCPUpstreamMutation) AddField(name string, value ent.Value) error { +func (m *GitBotUserMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown MCPUpstream numeric field %s", name) + return fmt.Errorf("unknown GitBotUser numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *MCPUpstreamMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(mcpupstream.FieldDeletedAt) { - fields = append(fields, mcpupstream.FieldDeletedAt) - } - if m.FieldCleared(mcpupstream.FieldUserID) { - fields = append(fields, mcpupstream.FieldUserID) - } - if m.FieldCleared(mcpupstream.FieldHeaders) { - fields = append(fields, mcpupstream.FieldHeaders) - } - if m.FieldCleared(mcpupstream.FieldDescription) { - fields = append(fields, mcpupstream.FieldDescription) - } - if m.FieldCleared(mcpupstream.FieldHealthCheckedAt) { - fields = append(fields, mcpupstream.FieldHealthCheckedAt) - } - if m.FieldCleared(mcpupstream.FieldLastSyncedAt) { - fields = append(fields, mcpupstream.FieldLastSyncedAt) - } - return fields +func (m *GitBotUserMutation) ClearedFields() []string { + return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *MCPUpstreamMutation) FieldCleared(name string) bool { +func (m *GitBotUserMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *MCPUpstreamMutation) ClearField(name string) error { - switch name { - case mcpupstream.FieldDeletedAt: - m.ClearDeletedAt() - return nil - case mcpupstream.FieldUserID: - m.ClearUserID() - return nil - case mcpupstream.FieldHeaders: - m.ClearHeaders() - return nil - case mcpupstream.FieldDescription: - m.ClearDescription() - return nil - case mcpupstream.FieldHealthCheckedAt: - m.ClearHealthCheckedAt() - return nil - case mcpupstream.FieldLastSyncedAt: - m.ClearLastSyncedAt() - return nil - } - return fmt.Errorf("unknown MCPUpstream nullable field %s", name) +func (m *GitBotUserMutation) ClearField(name string) error { + return fmt.Errorf("unknown GitBotUser nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *MCPUpstreamMutation) ResetField(name string) error { +func (m *GitBotUserMutation) ResetField(name string) error { switch name { - case mcpupstream.FieldDeletedAt: - m.ResetDeletedAt() - return nil - case mcpupstream.FieldName: - m.ResetName() - return nil - case mcpupstream.FieldSlug: - m.ResetSlug() - return nil - case mcpupstream.FieldScope: - m.ResetScope() + case gitbotuser.FieldGitBotID: + m.ResetGitBotID() return nil - case mcpupstream.FieldUserID: + case gitbotuser.FieldUserID: m.ResetUserID() return nil - case mcpupstream.FieldType: - m.ResetType() - return nil - case mcpupstream.FieldURL: - m.ResetURL() - return nil - case mcpupstream.FieldHeaders: - m.ResetHeaders() - return nil - case mcpupstream.FieldDescription: - m.ResetDescription() - return nil - case mcpupstream.FieldEnabled: - m.ResetEnabled() - return nil - case mcpupstream.FieldHealthStatus: - m.ResetHealthStatus() - return nil - case mcpupstream.FieldSyncStatus: - m.ResetSyncStatus() - return nil - case mcpupstream.FieldHealthCheckedAt: - m.ResetHealthCheckedAt() - return nil - case mcpupstream.FieldLastSyncedAt: - m.ResetLastSyncedAt() - return nil - case mcpupstream.FieldCreatedAt: + case gitbotuser.FieldCreatedAt: m.ResetCreatedAt() return nil - case mcpupstream.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil } - return fmt.Errorf("unknown MCPUpstream field %s", name) + return fmt.Errorf("unknown GitBotUser field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *MCPUpstreamMutation) AddedEdges() []string { +func (m *GitBotUserMutation) AddedEdges() []string { edges := make([]string, 0, 2) - if m.tools != nil { - edges = append(edges, mcpupstream.EdgeTools) + if m.git_bot != nil { + edges = append(edges, gitbotuser.EdgeGitBot) } if m.user != nil { - edges = append(edges, mcpupstream.EdgeUser) + edges = append(edges, gitbotuser.EdgeUser) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *MCPUpstreamMutation) AddedIDs(name string) []ent.Value { +func (m *GitBotUserMutation) AddedIDs(name string) []ent.Value { switch name { - case mcpupstream.EdgeTools: - ids := make([]ent.Value, 0, len(m.tools)) - for id := range m.tools { - ids = append(ids, id) + case gitbotuser.EdgeGitBot: + if id := m.git_bot; id != nil { + return []ent.Value{*id} } - return ids - case mcpupstream.EdgeUser: + case gitbotuser.EdgeUser: if id := m.user; id != nil { return []ent.Value{*id} } @@ -11877,47 +12795,36 @@ func (m *MCPUpstreamMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *MCPUpstreamMutation) RemovedEdges() []string { +func (m *GitBotUserMutation) RemovedEdges() []string { edges := make([]string, 0, 2) - if m.removedtools != nil { - edges = append(edges, mcpupstream.EdgeTools) - } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *MCPUpstreamMutation) RemovedIDs(name string) []ent.Value { - switch name { - case mcpupstream.EdgeTools: - ids := make([]ent.Value, 0, len(m.removedtools)) - for id := range m.removedtools { - ids = append(ids, id) - } - return ids - } +func (m *GitBotUserMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *MCPUpstreamMutation) ClearedEdges() []string { +func (m *GitBotUserMutation) ClearedEdges() []string { edges := make([]string, 0, 2) - if m.clearedtools { - edges = append(edges, mcpupstream.EdgeTools) + if m.clearedgit_bot { + edges = append(edges, gitbotuser.EdgeGitBot) } if m.cleareduser { - edges = append(edges, mcpupstream.EdgeUser) + edges = append(edges, gitbotuser.EdgeUser) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *MCPUpstreamMutation) EdgeCleared(name string) bool { +func (m *GitBotUserMutation) EdgeCleared(name string) bool { switch name { - case mcpupstream.EdgeTools: - return m.clearedtools - case mcpupstream.EdgeUser: + case gitbotuser.EdgeGitBot: + return m.clearedgit_bot + case gitbotuser.EdgeUser: return m.cleareduser } return false @@ -11925,79 +12832,102 @@ func (m *MCPUpstreamMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *MCPUpstreamMutation) ClearEdge(name string) error { +func (m *GitBotUserMutation) ClearEdge(name string) error { switch name { - case mcpupstream.EdgeUser: + case gitbotuser.EdgeGitBot: + m.ClearGitBot() + return nil + case gitbotuser.EdgeUser: m.ClearUser() return nil } - return fmt.Errorf("unknown MCPUpstream unique edge %s", name) + return fmt.Errorf("unknown GitBotUser unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *MCPUpstreamMutation) ResetEdge(name string) error { +func (m *GitBotUserMutation) ResetEdge(name string) error { switch name { - case mcpupstream.EdgeTools: - m.ResetTools() + case gitbotuser.EdgeGitBot: + m.ResetGitBot() return nil - case mcpupstream.EdgeUser: + case gitbotuser.EdgeUser: m.ResetUser() return nil } - return fmt.Errorf("unknown MCPUpstream edge %s", name) + return fmt.Errorf("unknown GitBotUser edge %s", name) } -// MCPUserToolSettingMutation represents an operation that mutates the MCPUserToolSetting nodes in the graph. -type MCPUserToolSettingMutation struct { +// GitIdentityMutation represents an operation that mutates the GitIdentity nodes in the graph. +type GitIdentityMutation struct { config - op Op - typ string - id *uuid.UUID - user_id *uuid.UUID - tool_id *uuid.UUID - enabled *bool - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*MCPUserToolSetting, error) - predicates []predicate.MCPUserToolSetting -} - -var _ ent.Mutation = (*MCPUserToolSettingMutation)(nil) - -// mcpusertoolsettingOption allows management of the mutation configuration using functional options. -type mcpusertoolsettingOption func(*MCPUserToolSettingMutation) - -// newMCPUserToolSettingMutation creates new mutation for the MCPUserToolSetting entity. -func newMCPUserToolSettingMutation(c config, op Op, opts ...mcpusertoolsettingOption) *MCPUserToolSettingMutation { - m := &MCPUserToolSettingMutation{ - config: c, - op: op, - typ: TypeMCPUserToolSetting, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withMCPUserToolSettingID sets the ID field of the mutation. -func withMCPUserToolSettingID(id uuid.UUID) mcpusertoolsettingOption { - return func(m *MCPUserToolSettingMutation) { + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + platform *consts.GitPlatform + base_url *string + access_token *string + username *string + email *string + installation_id *int64 + addinstallation_id *int64 + organization_id *string + remark *string + oauth_refresh_token *string + oauth_expires_at *time.Time + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + user *uuid.UUID + cleareduser bool + projects map[uuid.UUID]struct{} + removedprojects map[uuid.UUID]struct{} + clearedprojects bool + project_tasks map[uuid.UUID]struct{} + removedproject_tasks map[uuid.UUID]struct{} + clearedproject_tasks bool + vms map[string]struct{} + removedvms map[string]struct{} + clearedvms bool + done bool + oldValue func(context.Context) (*GitIdentity, error) + predicates []predicate.GitIdentity +} + +var _ ent.Mutation = (*GitIdentityMutation)(nil) + +// gitidentityOption allows management of the mutation configuration using functional options. +type gitidentityOption func(*GitIdentityMutation) + +// newGitIdentityMutation creates new mutation for the GitIdentity entity. +func newGitIdentityMutation(c config, op Op, opts ...gitidentityOption) *GitIdentityMutation { + m := &GitIdentityMutation{ + config: c, + op: op, + typ: TypeGitIdentity, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withGitIdentityID sets the ID field of the mutation. +func withGitIdentityID(id uuid.UUID) gitidentityOption { + return func(m *GitIdentityMutation) { var ( err error once sync.Once - value *MCPUserToolSetting + value *GitIdentity ) - m.oldValue = func(ctx context.Context) (*MCPUserToolSetting, error) { + m.oldValue = func(ctx context.Context) (*GitIdentity, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().MCPUserToolSetting.Get(ctx, id) + value, err = m.Client().GitIdentity.Get(ctx, id) } }) return value, err @@ -12006,10 +12936,10 @@ func withMCPUserToolSettingID(id uuid.UUID) mcpusertoolsettingOption { } } -// withMCPUserToolSetting sets the old MCPUserToolSetting of the mutation. -func withMCPUserToolSetting(node *MCPUserToolSetting) mcpusertoolsettingOption { - return func(m *MCPUserToolSettingMutation) { - m.oldValue = func(context.Context) (*MCPUserToolSetting, error) { +// withGitIdentity sets the old GitIdentity of the mutation. +func withGitIdentity(node *GitIdentity) gitidentityOption { + return func(m *GitIdentityMutation) { + m.oldValue = func(context.Context) (*GitIdentity, error) { return node, nil } m.id = &node.ID @@ -12018,7 +12948,7 @@ func withMCPUserToolSetting(node *MCPUserToolSetting) mcpusertoolsettingOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m MCPUserToolSettingMutation) Client() *Client { +func (m GitIdentityMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -12026,7 +12956,7 @@ func (m MCPUserToolSettingMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m MCPUserToolSettingMutation) Tx() (*Tx, error) { +func (m GitIdentityMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -12036,14 +12966,14 @@ func (m MCPUserToolSettingMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of MCPUserToolSetting entities. -func (m *MCPUserToolSettingMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of GitIdentity entities. +func (m *GitIdentityMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *MCPUserToolSettingMutation) ID() (id uuid.UUID, exists bool) { +func (m *GitIdentityMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -12054,7 +12984,7 @@ func (m *MCPUserToolSettingMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *MCPUserToolSettingMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *GitIdentityMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -12063,2062 +12993,2148 @@ func (m *MCPUserToolSettingMutation) IDs(ctx context.Context) ([]uuid.UUID, erro } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().MCPUserToolSetting.Query().Where(m.predicates...).IDs(ctx) + return m.Client().GitIdentity.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetUserID sets the "user_id" field. -func (m *MCPUserToolSettingMutation) SetUserID(u uuid.UUID) { - m.user_id = &u +// SetDeletedAt sets the "deleted_at" field. +func (m *GitIdentityMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t } -// UserID returns the value of the "user_id" field in the mutation. -func (m *MCPUserToolSettingMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user_id +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *GitIdentityMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at if v == nil { return } return *v, true } -// OldUserID returns the old "user_id" field's value of the MCPUserToolSetting entity. -// If the MCPUserToolSetting object wasn't provided to the builder, the object is fetched from the database. +// OldDeletedAt returns the old "deleted_at" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUserToolSettingMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { +func (m *GitIdentityMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") + return v, errors.New("OldDeletedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) } - return oldValue.UserID, nil + return oldValue.DeletedAt, nil } -// ResetUserID resets all changes to the "user_id" field. -func (m *MCPUserToolSettingMutation) ResetUserID() { - m.user_id = nil +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *GitIdentityMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[gitidentity.FieldDeletedAt] = struct{}{} } -// SetToolID sets the "tool_id" field. -func (m *MCPUserToolSettingMutation) SetToolID(u uuid.UUID) { - m.tool_id = &u +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *GitIdentityMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[gitidentity.FieldDeletedAt] + return ok } -// ToolID returns the value of the "tool_id" field in the mutation. -func (m *MCPUserToolSettingMutation) ToolID() (r uuid.UUID, exists bool) { - v := m.tool_id +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *GitIdentityMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, gitidentity.FieldDeletedAt) +} + +// SetUserID sets the "user_id" field. +func (m *GitIdentityMutation) SetUserID(u uuid.UUID) { + m.user = &u +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *GitIdentityMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user if v == nil { return } return *v, true } -// OldToolID returns the old "tool_id" field's value of the MCPUserToolSetting entity. -// If the MCPUserToolSetting object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUserToolSettingMutation) OldToolID(ctx context.Context) (v uuid.UUID, err error) { +func (m *GitIdentityMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldToolID is only allowed on UpdateOne operations") + return v, errors.New("OldUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldToolID requires an ID field in the mutation") + return v, errors.New("OldUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldToolID: %w", err) + return v, fmt.Errorf("querying old value for OldUserID: %w", err) } - return oldValue.ToolID, nil + return oldValue.UserID, nil } -// ResetToolID resets all changes to the "tool_id" field. -func (m *MCPUserToolSettingMutation) ResetToolID() { - m.tool_id = nil +// ResetUserID resets all changes to the "user_id" field. +func (m *GitIdentityMutation) ResetUserID() { + m.user = nil } -// SetEnabled sets the "enabled" field. -func (m *MCPUserToolSettingMutation) SetEnabled(b bool) { - m.enabled = &b +// SetPlatform sets the "platform" field. +func (m *GitIdentityMutation) SetPlatform(cp consts.GitPlatform) { + m.platform = &cp } -// Enabled returns the value of the "enabled" field in the mutation. -func (m *MCPUserToolSettingMutation) Enabled() (r bool, exists bool) { - v := m.enabled +// Platform returns the value of the "platform" field in the mutation. +func (m *GitIdentityMutation) Platform() (r consts.GitPlatform, exists bool) { + v := m.platform if v == nil { return } return *v, true } -// OldEnabled returns the old "enabled" field's value of the MCPUserToolSetting entity. -// If the MCPUserToolSetting object wasn't provided to the builder, the object is fetched from the database. +// OldPlatform returns the old "platform" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUserToolSettingMutation) OldEnabled(ctx context.Context) (v bool, err error) { +func (m *GitIdentityMutation) OldPlatform(ctx context.Context) (v consts.GitPlatform, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEnabled is only allowed on UpdateOne operations") + return v, errors.New("OldPlatform is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEnabled requires an ID field in the mutation") + return v, errors.New("OldPlatform requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEnabled: %w", err) + return v, fmt.Errorf("querying old value for OldPlatform: %w", err) } - return oldValue.Enabled, nil + return oldValue.Platform, nil } -// ResetEnabled resets all changes to the "enabled" field. -func (m *MCPUserToolSettingMutation) ResetEnabled() { - m.enabled = nil +// ResetPlatform resets all changes to the "platform" field. +func (m *GitIdentityMutation) ResetPlatform() { + m.platform = nil } -// SetCreatedAt sets the "created_at" field. -func (m *MCPUserToolSettingMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// SetBaseURL sets the "base_url" field. +func (m *GitIdentityMutation) SetBaseURL(s string) { + m.base_url = &s } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *MCPUserToolSettingMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// BaseURL returns the value of the "base_url" field in the mutation. +func (m *GitIdentityMutation) BaseURL() (r string, exists bool) { + v := m.base_url if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the MCPUserToolSetting entity. -// If the MCPUserToolSetting object wasn't provided to the builder, the object is fetched from the database. +// OldBaseURL returns the old "base_url" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUserToolSettingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *GitIdentityMutation) OldBaseURL(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldBaseURL is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + return v, errors.New("OldBaseURL requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldBaseURL: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.BaseURL, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *MCPUserToolSettingMutation) ResetCreatedAt() { - m.created_at = nil +// ClearBaseURL clears the value of the "base_url" field. +func (m *GitIdentityMutation) ClearBaseURL() { + m.base_url = nil + m.clearedFields[gitidentity.FieldBaseURL] = struct{}{} } -// SetUpdatedAt sets the "updated_at" field. -func (m *MCPUserToolSettingMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t +// BaseURLCleared returns if the "base_url" field was cleared in this mutation. +func (m *GitIdentityMutation) BaseURLCleared() bool { + _, ok := m.clearedFields[gitidentity.FieldBaseURL] + return ok } -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *MCPUserToolSettingMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at +// ResetBaseURL resets all changes to the "base_url" field. +func (m *GitIdentityMutation) ResetBaseURL() { + m.base_url = nil + delete(m.clearedFields, gitidentity.FieldBaseURL) +} + +// SetAccessToken sets the "access_token" field. +func (m *GitIdentityMutation) SetAccessToken(s string) { + m.access_token = &s +} + +// AccessToken returns the value of the "access_token" field in the mutation. +func (m *GitIdentityMutation) AccessToken() (r string, exists bool) { + v := m.access_token if v == nil { return } return *v, true } -// OldUpdatedAt returns the old "updated_at" field's value of the MCPUserToolSetting entity. -// If the MCPUserToolSetting object wasn't provided to the builder, the object is fetched from the database. +// OldAccessToken returns the old "access_token" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MCPUserToolSettingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { +func (m *GitIdentityMutation) OldAccessToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldAccessToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + return v, errors.New("OldAccessToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldAccessToken: %w", err) } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *MCPUserToolSettingMutation) ResetUpdatedAt() { - m.updated_at = nil + return oldValue.AccessToken, nil } -// Where appends a list predicates to the MCPUserToolSettingMutation builder. -func (m *MCPUserToolSettingMutation) Where(ps ...predicate.MCPUserToolSetting) { - m.predicates = append(m.predicates, ps...) +// ClearAccessToken clears the value of the "access_token" field. +func (m *GitIdentityMutation) ClearAccessToken() { + m.access_token = nil + m.clearedFields[gitidentity.FieldAccessToken] = struct{}{} } -// WhereP appends storage-level predicates to the MCPUserToolSettingMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *MCPUserToolSettingMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.MCPUserToolSetting, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) +// AccessTokenCleared returns if the "access_token" field was cleared in this mutation. +func (m *GitIdentityMutation) AccessTokenCleared() bool { + _, ok := m.clearedFields[gitidentity.FieldAccessToken] + return ok } -// Op returns the operation name. -func (m *MCPUserToolSettingMutation) Op() Op { - return m.op +// ResetAccessToken resets all changes to the "access_token" field. +func (m *GitIdentityMutation) ResetAccessToken() { + m.access_token = nil + delete(m.clearedFields, gitidentity.FieldAccessToken) } -// SetOp allows setting the mutation operation. -func (m *MCPUserToolSettingMutation) SetOp(op Op) { - m.op = op +// SetUsername sets the "username" field. +func (m *GitIdentityMutation) SetUsername(s string) { + m.username = &s } -// Type returns the node type of this mutation (MCPUserToolSetting). -func (m *MCPUserToolSettingMutation) Type() string { - return m.typ +// Username returns the value of the "username" field in the mutation. +func (m *GitIdentityMutation) Username() (r string, exists bool) { + v := m.username + if v == nil { + return + } + return *v, true } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *MCPUserToolSettingMutation) Fields() []string { - fields := make([]string, 0, 5) - if m.user_id != nil { - fields = append(fields, mcpusertoolsetting.FieldUserID) - } - if m.tool_id != nil { - fields = append(fields, mcpusertoolsetting.FieldToolID) - } - if m.enabled != nil { - fields = append(fields, mcpusertoolsetting.FieldEnabled) +// OldUsername returns the old "username" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitIdentityMutation) OldUsername(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUsername is only allowed on UpdateOne operations") } - if m.created_at != nil { - fields = append(fields, mcpusertoolsetting.FieldCreatedAt) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUsername requires an ID field in the mutation") } - if m.updated_at != nil { - fields = append(fields, mcpusertoolsetting.FieldUpdatedAt) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUsername: %w", err) } - return fields + return oldValue.Username, nil } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *MCPUserToolSettingMutation) Field(name string) (ent.Value, bool) { - switch name { - case mcpusertoolsetting.FieldUserID: - return m.UserID() - case mcpusertoolsetting.FieldToolID: - return m.ToolID() - case mcpusertoolsetting.FieldEnabled: - return m.Enabled() - case mcpusertoolsetting.FieldCreatedAt: - return m.CreatedAt() - case mcpusertoolsetting.FieldUpdatedAt: - return m.UpdatedAt() - } - return nil, false +// ClearUsername clears the value of the "username" field. +func (m *GitIdentityMutation) ClearUsername() { + m.username = nil + m.clearedFields[gitidentity.FieldUsername] = struct{}{} } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *MCPUserToolSettingMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case mcpusertoolsetting.FieldUserID: - return m.OldUserID(ctx) - case mcpusertoolsetting.FieldToolID: - return m.OldToolID(ctx) - case mcpusertoolsetting.FieldEnabled: - return m.OldEnabled(ctx) - case mcpusertoolsetting.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case mcpusertoolsetting.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - } - return nil, fmt.Errorf("unknown MCPUserToolSetting field %s", name) +// UsernameCleared returns if the "username" field was cleared in this mutation. +func (m *GitIdentityMutation) UsernameCleared() bool { + _, ok := m.clearedFields[gitidentity.FieldUsername] + return ok } -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *MCPUserToolSettingMutation) SetField(name string, value ent.Value) error { - switch name { - case mcpusertoolsetting.FieldUserID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUserID(v) - return nil - case mcpusertoolsetting.FieldToolID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetToolID(v) - return nil - case mcpusertoolsetting.FieldEnabled: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEnabled(v) - return nil - case mcpusertoolsetting.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case mcpusertoolsetting.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - } - return fmt.Errorf("unknown MCPUserToolSetting field %s", name) +// ResetUsername resets all changes to the "username" field. +func (m *GitIdentityMutation) ResetUsername() { + m.username = nil + delete(m.clearedFields, gitidentity.FieldUsername) } -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *MCPUserToolSettingMutation) AddedFields() []string { - return nil +// SetEmail sets the "email" field. +func (m *GitIdentityMutation) SetEmail(s string) { + m.email = &s } -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *MCPUserToolSettingMutation) AddedField(name string) (ent.Value, bool) { - return nil, false +// Email returns the value of the "email" field in the mutation. +func (m *GitIdentityMutation) Email() (r string, exists bool) { + v := m.email + if v == nil { + return + } + return *v, true } -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *MCPUserToolSettingMutation) AddField(name string, value ent.Value) error { - switch name { +// OldEmail returns the old "email" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitIdentityMutation) OldEmail(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEmail is only allowed on UpdateOne operations") } - return fmt.Errorf("unknown MCPUserToolSetting numeric field %s", name) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEmail requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEmail: %w", err) + } + return oldValue.Email, nil } -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *MCPUserToolSettingMutation) ClearedFields() []string { - return nil +// ClearEmail clears the value of the "email" field. +func (m *GitIdentityMutation) ClearEmail() { + m.email = nil + m.clearedFields[gitidentity.FieldEmail] = struct{}{} } -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *MCPUserToolSettingMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] +// EmailCleared returns if the "email" field was cleared in this mutation. +func (m *GitIdentityMutation) EmailCleared() bool { + _, ok := m.clearedFields[gitidentity.FieldEmail] return ok } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *MCPUserToolSettingMutation) ClearField(name string) error { - return fmt.Errorf("unknown MCPUserToolSetting nullable field %s", name) +// ResetEmail resets all changes to the "email" field. +func (m *GitIdentityMutation) ResetEmail() { + m.email = nil + delete(m.clearedFields, gitidentity.FieldEmail) } -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *MCPUserToolSettingMutation) ResetField(name string) error { - switch name { - case mcpusertoolsetting.FieldUserID: - m.ResetUserID() - return nil - case mcpusertoolsetting.FieldToolID: - m.ResetToolID() - return nil - case mcpusertoolsetting.FieldEnabled: - m.ResetEnabled() - return nil - case mcpusertoolsetting.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case mcpusertoolsetting.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - } - return fmt.Errorf("unknown MCPUserToolSetting field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *MCPUserToolSettingMutation) AddedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *MCPUserToolSettingMutation) AddedIDs(name string) []ent.Value { - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *MCPUserToolSettingMutation) RemovedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *MCPUserToolSettingMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *MCPUserToolSettingMutation) ClearedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *MCPUserToolSettingMutation) EdgeCleared(name string) bool { - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *MCPUserToolSettingMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown MCPUserToolSetting unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *MCPUserToolSettingMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown MCPUserToolSetting edge %s", name) +// SetInstallationID sets the "installation_id" field. +func (m *GitIdentityMutation) SetInstallationID(i int64) { + m.installation_id = &i + m.addinstallation_id = nil } -// ModelMutation represents an operation that mutates the Model nodes in the graph. -type ModelMutation struct { - config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - provider *string - api_key *string - base_url *string - model *string - remark *string - temperature *float64 - addtemperature *float64 - interface_type *string - weight *int - addweight *int - thinking_enabled *bool - support_image *bool - is_hidden *bool - context_limit *int - addcontext_limit *int - output_limit *int - addoutput_limit *int - last_check_at *time.Time - last_check_success *bool - last_check_error *string - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - user *uuid.UUID - cleareduser bool - teams map[uuid.UUID]struct{} - removedteams map[uuid.UUID]struct{} - clearedteams bool - groups map[uuid.UUID]struct{} - removedgroups map[uuid.UUID]struct{} - clearedgroups bool - vms map[string]struct{} - removedvms map[string]struct{} - clearedvms bool - project_tasks map[uuid.UUID]struct{} - removedproject_tasks map[uuid.UUID]struct{} - clearedproject_tasks bool - pricing *uuid.UUID - clearedpricing bool - apikeys map[uuid.UUID]struct{} - removedapikeys map[uuid.UUID]struct{} - clearedapikeys bool - switches_from map[uuid.UUID]struct{} - removedswitches_from map[uuid.UUID]struct{} - clearedswitches_from bool - switches_to map[uuid.UUID]struct{} - removedswitches_to map[uuid.UUID]struct{} - clearedswitches_to bool - team_models map[uuid.UUID]struct{} - removedteam_models map[uuid.UUID]struct{} - clearedteam_models bool - team_group_models map[uuid.UUID]struct{} - removedteam_group_models map[uuid.UUID]struct{} - clearedteam_group_models bool - done bool - oldValue func(context.Context) (*Model, error) - predicates []predicate.Model +// InstallationID returns the value of the "installation_id" field in the mutation. +func (m *GitIdentityMutation) InstallationID() (r int64, exists bool) { + v := m.installation_id + if v == nil { + return + } + return *v, true } -var _ ent.Mutation = (*ModelMutation)(nil) - -// modelOption allows management of the mutation configuration using functional options. -type modelOption func(*ModelMutation) - -// newModelMutation creates new mutation for the Model entity. -func newModelMutation(c config, op Op, opts ...modelOption) *ModelMutation { - m := &ModelMutation{ - config: c, - op: op, - typ: TypeModel, - clearedFields: make(map[string]struct{}), +// OldInstallationID returns the old "installation_id" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitIdentityMutation) OldInstallationID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInstallationID is only allowed on UpdateOne operations") } - for _, opt := range opts { - opt(m) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInstallationID requires an ID field in the mutation") } - return m -} - -// withModelID sets the ID field of the mutation. -func withModelID(id uuid.UUID) modelOption { - return func(m *ModelMutation) { - var ( - err error - once sync.Once - value *Model - ) - m.oldValue = func(ctx context.Context) (*Model, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Model.Get(ctx, id) - } - }) - return value, err - } - m.id = &id + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInstallationID: %w", err) } + return oldValue.InstallationID, nil } -// withModel sets the old Model of the mutation. -func withModel(node *Model) modelOption { - return func(m *ModelMutation) { - m.oldValue = func(context.Context) (*Model, error) { - return node, nil - } - m.id = &node.ID +// AddInstallationID adds i to the "installation_id" field. +func (m *GitIdentityMutation) AddInstallationID(i int64) { + if m.addinstallation_id != nil { + *m.addinstallation_id += i + } else { + m.addinstallation_id = &i } } -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m ModelMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m ModelMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("db: mutation is not running in a transaction") +// AddedInstallationID returns the value that was added to the "installation_id" field in this mutation. +func (m *GitIdentityMutation) AddedInstallationID() (r int64, exists bool) { + v := m.addinstallation_id + if v == nil { + return } - tx := &Tx{config: m.config} - tx.init() - return tx, nil + return *v, true } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Model entities. -func (m *ModelMutation) SetID(id uuid.UUID) { - m.id = &id +// ClearInstallationID clears the value of the "installation_id" field. +func (m *GitIdentityMutation) ClearInstallationID() { + m.installation_id = nil + m.addinstallation_id = nil + m.clearedFields[gitidentity.FieldInstallationID] = struct{}{} } -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *ModelMutation) ID() (id uuid.UUID, exists bool) { - if m.id == nil { - return - } - return *m.id, true +// InstallationIDCleared returns if the "installation_id" field was cleared in this mutation. +func (m *GitIdentityMutation) InstallationIDCleared() bool { + _, ok := m.clearedFields[gitidentity.FieldInstallationID] + return ok } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *ModelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []uuid.UUID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().Model.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } +// ResetInstallationID resets all changes to the "installation_id" field. +func (m *GitIdentityMutation) ResetInstallationID() { + m.installation_id = nil + m.addinstallation_id = nil + delete(m.clearedFields, gitidentity.FieldInstallationID) } -// SetDeletedAt sets the "deleted_at" field. -func (m *ModelMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t +// SetOrganizationID sets the "organization_id" field. +func (m *GitIdentityMutation) SetOrganizationID(s string) { + m.organization_id = &s } -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *ModelMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at +// OrganizationID returns the value of the "organization_id" field in the mutation. +func (m *GitIdentityMutation) OrganizationID() (r string, exists bool) { + v := m.organization_id if v == nil { return } return *v, true } -// OldDeletedAt returns the old "deleted_at" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. +// OldOrganizationID returns the old "organization_id" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { +func (m *GitIdentityMutation) OldOrganizationID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") + return v, errors.New("OldOrganizationID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err) } - return oldValue.DeletedAt, nil + return oldValue.OrganizationID, nil } -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *ModelMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[model.FieldDeletedAt] = struct{}{} +// ClearOrganizationID clears the value of the "organization_id" field. +func (m *GitIdentityMutation) ClearOrganizationID() { + m.organization_id = nil + m.clearedFields[gitidentity.FieldOrganizationID] = struct{}{} } -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *ModelMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[model.FieldDeletedAt] +// OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation. +func (m *GitIdentityMutation) OrganizationIDCleared() bool { + _, ok := m.clearedFields[gitidentity.FieldOrganizationID] return ok } -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *ModelMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, model.FieldDeletedAt) +// ResetOrganizationID resets all changes to the "organization_id" field. +func (m *GitIdentityMutation) ResetOrganizationID() { + m.organization_id = nil + delete(m.clearedFields, gitidentity.FieldOrganizationID) } -// SetUserID sets the "user_id" field. -func (m *ModelMutation) SetUserID(u uuid.UUID) { - m.user = &u +// SetRemark sets the "remark" field. +func (m *GitIdentityMutation) SetRemark(s string) { + m.remark = &s } -// UserID returns the value of the "user_id" field in the mutation. -func (m *ModelMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user +// Remark returns the value of the "remark" field in the mutation. +func (m *GitIdentityMutation) Remark() (r string, exists bool) { + v := m.remark if v == nil { return } return *v, true } -// OldUserID returns the old "user_id" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. +// OldRemark returns the old "remark" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { +func (m *GitIdentityMutation) OldRemark(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") + return v, errors.New("OldRemark is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") + return v, errors.New("OldRemark requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + return v, fmt.Errorf("querying old value for OldRemark: %w", err) } - return oldValue.UserID, nil + return oldValue.Remark, nil } -// ResetUserID resets all changes to the "user_id" field. -func (m *ModelMutation) ResetUserID() { - m.user = nil +// ClearRemark clears the value of the "remark" field. +func (m *GitIdentityMutation) ClearRemark() { + m.remark = nil + m.clearedFields[gitidentity.FieldRemark] = struct{}{} } -// SetProvider sets the "provider" field. -func (m *ModelMutation) SetProvider(s string) { - m.provider = &s +// RemarkCleared returns if the "remark" field was cleared in this mutation. +func (m *GitIdentityMutation) RemarkCleared() bool { + _, ok := m.clearedFields[gitidentity.FieldRemark] + return ok } -// Provider returns the value of the "provider" field in the mutation. -func (m *ModelMutation) Provider() (r string, exists bool) { - v := m.provider +// ResetRemark resets all changes to the "remark" field. +func (m *GitIdentityMutation) ResetRemark() { + m.remark = nil + delete(m.clearedFields, gitidentity.FieldRemark) +} + +// SetOauthRefreshToken sets the "oauth_refresh_token" field. +func (m *GitIdentityMutation) SetOauthRefreshToken(s string) { + m.oauth_refresh_token = &s +} + +// OauthRefreshToken returns the value of the "oauth_refresh_token" field in the mutation. +func (m *GitIdentityMutation) OauthRefreshToken() (r string, exists bool) { + v := m.oauth_refresh_token if v == nil { return } return *v, true } -// OldProvider returns the old "provider" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. +// OldOauthRefreshToken returns the old "oauth_refresh_token" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldProvider(ctx context.Context) (v string, err error) { +func (m *GitIdentityMutation) OldOauthRefreshToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProvider is only allowed on UpdateOne operations") + return v, errors.New("OldOauthRefreshToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProvider requires an ID field in the mutation") + return v, errors.New("OldOauthRefreshToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProvider: %w", err) + return v, fmt.Errorf("querying old value for OldOauthRefreshToken: %w", err) } - return oldValue.Provider, nil + return oldValue.OauthRefreshToken, nil } -// ResetProvider resets all changes to the "provider" field. -func (m *ModelMutation) ResetProvider() { - m.provider = nil +// ClearOauthRefreshToken clears the value of the "oauth_refresh_token" field. +func (m *GitIdentityMutation) ClearOauthRefreshToken() { + m.oauth_refresh_token = nil + m.clearedFields[gitidentity.FieldOauthRefreshToken] = struct{}{} } -// SetAPIKey sets the "api_key" field. -func (m *ModelMutation) SetAPIKey(s string) { - m.api_key = &s +// OauthRefreshTokenCleared returns if the "oauth_refresh_token" field was cleared in this mutation. +func (m *GitIdentityMutation) OauthRefreshTokenCleared() bool { + _, ok := m.clearedFields[gitidentity.FieldOauthRefreshToken] + return ok } -// APIKey returns the value of the "api_key" field in the mutation. -func (m *ModelMutation) APIKey() (r string, exists bool) { - v := m.api_key +// ResetOauthRefreshToken resets all changes to the "oauth_refresh_token" field. +func (m *GitIdentityMutation) ResetOauthRefreshToken() { + m.oauth_refresh_token = nil + delete(m.clearedFields, gitidentity.FieldOauthRefreshToken) +} + +// SetOauthExpiresAt sets the "oauth_expires_at" field. +func (m *GitIdentityMutation) SetOauthExpiresAt(t time.Time) { + m.oauth_expires_at = &t +} + +// OauthExpiresAt returns the value of the "oauth_expires_at" field in the mutation. +func (m *GitIdentityMutation) OauthExpiresAt() (r time.Time, exists bool) { + v := m.oauth_expires_at if v == nil { return } return *v, true } -// OldAPIKey returns the old "api_key" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. +// OldOauthExpiresAt returns the old "oauth_expires_at" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldAPIKey(ctx context.Context) (v string, err error) { +func (m *GitIdentityMutation) OldOauthExpiresAt(ctx context.Context) (v *time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAPIKey is only allowed on UpdateOne operations") + return v, errors.New("OldOauthExpiresAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAPIKey requires an ID field in the mutation") + return v, errors.New("OldOauthExpiresAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAPIKey: %w", err) + return v, fmt.Errorf("querying old value for OldOauthExpiresAt: %w", err) } - return oldValue.APIKey, nil + return oldValue.OauthExpiresAt, nil } -// ResetAPIKey resets all changes to the "api_key" field. -func (m *ModelMutation) ResetAPIKey() { - m.api_key = nil +// ClearOauthExpiresAt clears the value of the "oauth_expires_at" field. +func (m *GitIdentityMutation) ClearOauthExpiresAt() { + m.oauth_expires_at = nil + m.clearedFields[gitidentity.FieldOauthExpiresAt] = struct{}{} } -// SetBaseURL sets the "base_url" field. -func (m *ModelMutation) SetBaseURL(s string) { - m.base_url = &s +// OauthExpiresAtCleared returns if the "oauth_expires_at" field was cleared in this mutation. +func (m *GitIdentityMutation) OauthExpiresAtCleared() bool { + _, ok := m.clearedFields[gitidentity.FieldOauthExpiresAt] + return ok } -// BaseURL returns the value of the "base_url" field in the mutation. -func (m *ModelMutation) BaseURL() (r string, exists bool) { - v := m.base_url +// ResetOauthExpiresAt resets all changes to the "oauth_expires_at" field. +func (m *GitIdentityMutation) ResetOauthExpiresAt() { + m.oauth_expires_at = nil + delete(m.clearedFields, gitidentity.FieldOauthExpiresAt) +} + +// SetCreatedAt sets the "created_at" field. +func (m *GitIdentityMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *GitIdentityMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldBaseURL returns the old "base_url" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldBaseURL(ctx context.Context) (v string, err error) { +func (m *GitIdentityMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBaseURL is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBaseURL requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBaseURL: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.BaseURL, nil + return oldValue.CreatedAt, nil } -// ResetBaseURL resets all changes to the "base_url" field. -func (m *ModelMutation) ResetBaseURL() { - m.base_url = nil +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *GitIdentityMutation) ResetCreatedAt() { + m.created_at = nil } -// SetModel sets the "model" field. -func (m *ModelMutation) SetModel(s string) { - m.model = &s +// SetUpdatedAt sets the "updated_at" field. +func (m *GitIdentityMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t } -// Model returns the value of the "model" field in the mutation. -func (m *ModelMutation) Model() (r string, exists bool) { - v := m.model +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *GitIdentityMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at if v == nil { return } return *v, true } -// OldModel returns the old "model" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. +// OldUpdatedAt returns the old "updated_at" field's value of the GitIdentity entity. +// If the GitIdentity object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldModel(ctx context.Context) (v string, err error) { +func (m *GitIdentityMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModel is only allowed on UpdateOne operations") + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModel requires an ID field in the mutation") + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldModel: %w", err) + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } - return oldValue.Model, nil + return oldValue.UpdatedAt, nil } -// ResetModel resets all changes to the "model" field. -func (m *ModelMutation) ResetModel() { - m.model = nil +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *GitIdentityMutation) ResetUpdatedAt() { + m.updated_at = nil } -// SetRemark sets the "remark" field. -func (m *ModelMutation) SetRemark(s string) { - m.remark = &s +// ClearUser clears the "user" edge to the User entity. +func (m *GitIdentityMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[gitidentity.FieldUserID] = struct{}{} } -// Remark returns the value of the "remark" field in the mutation. -func (m *ModelMutation) Remark() (r string, exists bool) { - v := m.remark - if v == nil { - return - } - return *v, true +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *GitIdentityMutation) UserCleared() bool { + return m.cleareduser } -// OldRemark returns the old "remark" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldRemark(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRemark is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRemark requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRemark: %w", err) +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *GitIdentityMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { + ids = append(ids, *id) } - return oldValue.Remark, nil -} - -// ClearRemark clears the value of the "remark" field. -func (m *ModelMutation) ClearRemark() { - m.remark = nil - m.clearedFields[model.FieldRemark] = struct{}{} + return } -// RemarkCleared returns if the "remark" field was cleared in this mutation. -func (m *ModelMutation) RemarkCleared() bool { - _, ok := m.clearedFields[model.FieldRemark] - return ok +// ResetUser resets all changes to the "user" edge. +func (m *GitIdentityMutation) ResetUser() { + m.user = nil + m.cleareduser = false } -// ResetRemark resets all changes to the "remark" field. -func (m *ModelMutation) ResetRemark() { - m.remark = nil - delete(m.clearedFields, model.FieldRemark) +// AddProjectIDs adds the "projects" edge to the Project entity by ids. +func (m *GitIdentityMutation) AddProjectIDs(ids ...uuid.UUID) { + if m.projects == nil { + m.projects = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.projects[ids[i]] = struct{}{} + } } -// SetTemperature sets the "temperature" field. -func (m *ModelMutation) SetTemperature(f float64) { - m.temperature = &f - m.addtemperature = nil +// ClearProjects clears the "projects" edge to the Project entity. +func (m *GitIdentityMutation) ClearProjects() { + m.clearedprojects = true } -// Temperature returns the value of the "temperature" field in the mutation. -func (m *ModelMutation) Temperature() (r float64, exists bool) { - v := m.temperature - if v == nil { - return - } - return *v, true +// ProjectsCleared reports if the "projects" edge to the Project entity was cleared. +func (m *GitIdentityMutation) ProjectsCleared() bool { + return m.clearedprojects } -// OldTemperature returns the old "temperature" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldTemperature(ctx context.Context) (v float64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTemperature is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTemperature requires an ID field in the mutation") +// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs. +func (m *GitIdentityMutation) RemoveProjectIDs(ids ...uuid.UUID) { + if m.removedprojects == nil { + m.removedprojects = make(map[uuid.UUID]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTemperature: %w", err) + for i := range ids { + delete(m.projects, ids[i]) + m.removedprojects[ids[i]] = struct{}{} } - return oldValue.Temperature, nil } -// AddTemperature adds f to the "temperature" field. -func (m *ModelMutation) AddTemperature(f float64) { - if m.addtemperature != nil { - *m.addtemperature += f - } else { - m.addtemperature = &f +// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity. +func (m *GitIdentityMutation) RemovedProjectsIDs() (ids []uuid.UUID) { + for id := range m.removedprojects { + ids = append(ids, id) } + return } -// AddedTemperature returns the value that was added to the "temperature" field in this mutation. -func (m *ModelMutation) AddedTemperature() (r float64, exists bool) { - v := m.addtemperature - if v == nil { - return +// ProjectsIDs returns the "projects" edge IDs in the mutation. +func (m *GitIdentityMutation) ProjectsIDs() (ids []uuid.UUID) { + for id := range m.projects { + ids = append(ids, id) } - return *v, true + return } -// ClearTemperature clears the value of the "temperature" field. -func (m *ModelMutation) ClearTemperature() { - m.temperature = nil - m.addtemperature = nil - m.clearedFields[model.FieldTemperature] = struct{}{} +// ResetProjects resets all changes to the "projects" edge. +func (m *GitIdentityMutation) ResetProjects() { + m.projects = nil + m.clearedprojects = false + m.removedprojects = nil } -// TemperatureCleared returns if the "temperature" field was cleared in this mutation. -func (m *ModelMutation) TemperatureCleared() bool { - _, ok := m.clearedFields[model.FieldTemperature] - return ok +// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids. +func (m *GitIdentityMutation) AddProjectTaskIDs(ids ...uuid.UUID) { + if m.project_tasks == nil { + m.project_tasks = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.project_tasks[ids[i]] = struct{}{} + } } -// ResetTemperature resets all changes to the "temperature" field. -func (m *ModelMutation) ResetTemperature() { - m.temperature = nil - m.addtemperature = nil - delete(m.clearedFields, model.FieldTemperature) +// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity. +func (m *GitIdentityMutation) ClearProjectTasks() { + m.clearedproject_tasks = true } -// SetInterfaceType sets the "interface_type" field. -func (m *ModelMutation) SetInterfaceType(s string) { - m.interface_type = &s +// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared. +func (m *GitIdentityMutation) ProjectTasksCleared() bool { + return m.clearedproject_tasks } -// InterfaceType returns the value of the "interface_type" field in the mutation. -func (m *ModelMutation) InterfaceType() (r string, exists bool) { - v := m.interface_type - if v == nil { - return +// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs. +func (m *GitIdentityMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) { + if m.removedproject_tasks == nil { + m.removedproject_tasks = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.project_tasks, ids[i]) + m.removedproject_tasks[ids[i]] = struct{}{} } - return *v, true } -// OldInterfaceType returns the old "interface_type" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldInterfaceType(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInterfaceType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInterfaceType requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInterfaceType: %w", err) +// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity. +func (m *GitIdentityMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) { + for id := range m.removedproject_tasks { + ids = append(ids, id) } - return oldValue.InterfaceType, nil + return } -// ClearInterfaceType clears the value of the "interface_type" field. -func (m *ModelMutation) ClearInterfaceType() { - m.interface_type = nil - m.clearedFields[model.FieldInterfaceType] = struct{}{} +// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation. +func (m *GitIdentityMutation) ProjectTasksIDs() (ids []uuid.UUID) { + for id := range m.project_tasks { + ids = append(ids, id) + } + return } -// InterfaceTypeCleared returns if the "interface_type" field was cleared in this mutation. -func (m *ModelMutation) InterfaceTypeCleared() bool { - _, ok := m.clearedFields[model.FieldInterfaceType] - return ok +// ResetProjectTasks resets all changes to the "project_tasks" edge. +func (m *GitIdentityMutation) ResetProjectTasks() { + m.project_tasks = nil + m.clearedproject_tasks = false + m.removedproject_tasks = nil } -// ResetInterfaceType resets all changes to the "interface_type" field. -func (m *ModelMutation) ResetInterfaceType() { - m.interface_type = nil - delete(m.clearedFields, model.FieldInterfaceType) +// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids. +func (m *GitIdentityMutation) AddVMIDs(ids ...string) { + if m.vms == nil { + m.vms = make(map[string]struct{}) + } + for i := range ids { + m.vms[ids[i]] = struct{}{} + } } -// SetWeight sets the "weight" field. -func (m *ModelMutation) SetWeight(i int) { - m.weight = &i - m.addweight = nil +// ClearVms clears the "vms" edge to the VirtualMachine entity. +func (m *GitIdentityMutation) ClearVms() { + m.clearedvms = true } -// Weight returns the value of the "weight" field in the mutation. -func (m *ModelMutation) Weight() (r int, exists bool) { - v := m.weight - if v == nil { - return - } - return *v, true +// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared. +func (m *GitIdentityMutation) VmsCleared() bool { + return m.clearedvms } -// OldWeight returns the old "weight" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldWeight(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWeight is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWeight requires an ID field in the mutation") +// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs. +func (m *GitIdentityMutation) RemoveVMIDs(ids ...string) { + if m.removedvms == nil { + m.removedvms = make(map[string]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldWeight: %w", err) + for i := range ids { + delete(m.vms, ids[i]) + m.removedvms[ids[i]] = struct{}{} } - return oldValue.Weight, nil } -// AddWeight adds i to the "weight" field. -func (m *ModelMutation) AddWeight(i int) { - if m.addweight != nil { - *m.addweight += i - } else { - m.addweight = &i +// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity. +func (m *GitIdentityMutation) RemovedVmsIDs() (ids []string) { + for id := range m.removedvms { + ids = append(ids, id) } + return } -// AddedWeight returns the value that was added to the "weight" field in this mutation. -func (m *ModelMutation) AddedWeight() (r int, exists bool) { - v := m.addweight - if v == nil { - return +// VmsIDs returns the "vms" edge IDs in the mutation. +func (m *GitIdentityMutation) VmsIDs() (ids []string) { + for id := range m.vms { + ids = append(ids, id) } - return *v, true + return } -// ResetWeight resets all changes to the "weight" field. -func (m *ModelMutation) ResetWeight() { - m.weight = nil - m.addweight = nil +// ResetVms resets all changes to the "vms" edge. +func (m *GitIdentityMutation) ResetVms() { + m.vms = nil + m.clearedvms = false + m.removedvms = nil } -// SetThinkingEnabled sets the "thinking_enabled" field. -func (m *ModelMutation) SetThinkingEnabled(b bool) { - m.thinking_enabled = &b +// Where appends a list predicates to the GitIdentityMutation builder. +func (m *GitIdentityMutation) Where(ps ...predicate.GitIdentity) { + m.predicates = append(m.predicates, ps...) } -// ThinkingEnabled returns the value of the "thinking_enabled" field in the mutation. -func (m *ModelMutation) ThinkingEnabled() (r bool, exists bool) { - v := m.thinking_enabled - if v == nil { - return +// WhereP appends storage-level predicates to the GitIdentityMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *GitIdentityMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.GitIdentity, len(ps)) + for i := range ps { + p[i] = ps[i] } - return *v, true + m.Where(p...) } -// OldThinkingEnabled returns the old "thinking_enabled" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldThinkingEnabled(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldThinkingEnabled is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldThinkingEnabled requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldThinkingEnabled: %w", err) - } - return oldValue.ThinkingEnabled, nil +// Op returns the operation name. +func (m *GitIdentityMutation) Op() Op { + return m.op } -// ResetThinkingEnabled resets all changes to the "thinking_enabled" field. -func (m *ModelMutation) ResetThinkingEnabled() { - m.thinking_enabled = nil +// SetOp allows setting the mutation operation. +func (m *GitIdentityMutation) SetOp(op Op) { + m.op = op } -// SetSupportImage sets the "support_image" field. -func (m *ModelMutation) SetSupportImage(b bool) { - m.support_image = &b +// Type returns the node type of this mutation (GitIdentity). +func (m *GitIdentityMutation) Type() string { + return m.typ } -// SupportImage returns the value of the "support_image" field in the mutation. -func (m *ModelMutation) SupportImage() (r bool, exists bool) { - v := m.support_image - if v == nil { - return +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *GitIdentityMutation) Fields() []string { + fields := make([]string, 0, 14) + if m.deleted_at != nil { + fields = append(fields, gitidentity.FieldDeletedAt) } - return *v, true -} - -// OldSupportImage returns the old "support_image" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldSupportImage(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSupportImage is only allowed on UpdateOne operations") + if m.user != nil { + fields = append(fields, gitidentity.FieldUserID) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSupportImage requires an ID field in the mutation") + if m.platform != nil { + fields = append(fields, gitidentity.FieldPlatform) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSupportImage: %w", err) + if m.base_url != nil { + fields = append(fields, gitidentity.FieldBaseURL) } - return oldValue.SupportImage, nil -} - -// ResetSupportImage resets all changes to the "support_image" field. -func (m *ModelMutation) ResetSupportImage() { - m.support_image = nil -} - -// SetIsHidden sets the "is_hidden" field. -func (m *ModelMutation) SetIsHidden(b bool) { - m.is_hidden = &b -} - -// IsHidden returns the value of the "is_hidden" field in the mutation. -func (m *ModelMutation) IsHidden() (r bool, exists bool) { - v := m.is_hidden - if v == nil { - return + if m.access_token != nil { + fields = append(fields, gitidentity.FieldAccessToken) } - return *v, true -} - -// OldIsHidden returns the old "is_hidden" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldIsHidden(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsHidden is only allowed on UpdateOne operations") + if m.username != nil { + fields = append(fields, gitidentity.FieldUsername) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsHidden requires an ID field in the mutation") + if m.email != nil { + fields = append(fields, gitidentity.FieldEmail) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIsHidden: %w", err) + if m.installation_id != nil { + fields = append(fields, gitidentity.FieldInstallationID) } - return oldValue.IsHidden, nil -} - -// ResetIsHidden resets all changes to the "is_hidden" field. -func (m *ModelMutation) ResetIsHidden() { - m.is_hidden = nil -} - -// SetContextLimit sets the "context_limit" field. -func (m *ModelMutation) SetContextLimit(i int) { - m.context_limit = &i - m.addcontext_limit = nil -} - -// ContextLimit returns the value of the "context_limit" field in the mutation. -func (m *ModelMutation) ContextLimit() (r int, exists bool) { - v := m.context_limit - if v == nil { - return + if m.organization_id != nil { + fields = append(fields, gitidentity.FieldOrganizationID) } - return *v, true -} - -// OldContextLimit returns the old "context_limit" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldContextLimit(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldContextLimit is only allowed on UpdateOne operations") + if m.remark != nil { + fields = append(fields, gitidentity.FieldRemark) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldContextLimit requires an ID field in the mutation") + if m.oauth_refresh_token != nil { + fields = append(fields, gitidentity.FieldOauthRefreshToken) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldContextLimit: %w", err) + if m.oauth_expires_at != nil { + fields = append(fields, gitidentity.FieldOauthExpiresAt) } - return oldValue.ContextLimit, nil -} - -// AddContextLimit adds i to the "context_limit" field. -func (m *ModelMutation) AddContextLimit(i int) { - if m.addcontext_limit != nil { - *m.addcontext_limit += i - } else { - m.addcontext_limit = &i + if m.created_at != nil { + fields = append(fields, gitidentity.FieldCreatedAt) } -} - -// AddedContextLimit returns the value that was added to the "context_limit" field in this mutation. -func (m *ModelMutation) AddedContextLimit() (r int, exists bool) { - v := m.addcontext_limit - if v == nil { - return + if m.updated_at != nil { + fields = append(fields, gitidentity.FieldUpdatedAt) } - return *v, true -} - -// ResetContextLimit resets all changes to the "context_limit" field. -func (m *ModelMutation) ResetContextLimit() { - m.context_limit = nil - m.addcontext_limit = nil + return fields } -// SetOutputLimit sets the "output_limit" field. -func (m *ModelMutation) SetOutputLimit(i int) { - m.output_limit = &i - m.addoutput_limit = nil +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *GitIdentityMutation) Field(name string) (ent.Value, bool) { + switch name { + case gitidentity.FieldDeletedAt: + return m.DeletedAt() + case gitidentity.FieldUserID: + return m.UserID() + case gitidentity.FieldPlatform: + return m.Platform() + case gitidentity.FieldBaseURL: + return m.BaseURL() + case gitidentity.FieldAccessToken: + return m.AccessToken() + case gitidentity.FieldUsername: + return m.Username() + case gitidentity.FieldEmail: + return m.Email() + case gitidentity.FieldInstallationID: + return m.InstallationID() + case gitidentity.FieldOrganizationID: + return m.OrganizationID() + case gitidentity.FieldRemark: + return m.Remark() + case gitidentity.FieldOauthRefreshToken: + return m.OauthRefreshToken() + case gitidentity.FieldOauthExpiresAt: + return m.OauthExpiresAt() + case gitidentity.FieldCreatedAt: + return m.CreatedAt() + case gitidentity.FieldUpdatedAt: + return m.UpdatedAt() + } + return nil, false } -// OutputLimit returns the value of the "output_limit" field in the mutation. -func (m *ModelMutation) OutputLimit() (r int, exists bool) { - v := m.output_limit - if v == nil { - return - } - return *v, true -} - -// OldOutputLimit returns the old "output_limit" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldOutputLimit(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOutputLimit is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOutputLimit requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldOutputLimit: %w", err) +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *GitIdentityMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case gitidentity.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case gitidentity.FieldUserID: + return m.OldUserID(ctx) + case gitidentity.FieldPlatform: + return m.OldPlatform(ctx) + case gitidentity.FieldBaseURL: + return m.OldBaseURL(ctx) + case gitidentity.FieldAccessToken: + return m.OldAccessToken(ctx) + case gitidentity.FieldUsername: + return m.OldUsername(ctx) + case gitidentity.FieldEmail: + return m.OldEmail(ctx) + case gitidentity.FieldInstallationID: + return m.OldInstallationID(ctx) + case gitidentity.FieldOrganizationID: + return m.OldOrganizationID(ctx) + case gitidentity.FieldRemark: + return m.OldRemark(ctx) + case gitidentity.FieldOauthRefreshToken: + return m.OldOauthRefreshToken(ctx) + case gitidentity.FieldOauthExpiresAt: + return m.OldOauthExpiresAt(ctx) + case gitidentity.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case gitidentity.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) } - return oldValue.OutputLimit, nil + return nil, fmt.Errorf("unknown GitIdentity field %s", name) } -// AddOutputLimit adds i to the "output_limit" field. -func (m *ModelMutation) AddOutputLimit(i int) { - if m.addoutput_limit != nil { - *m.addoutput_limit += i - } else { - m.addoutput_limit = &i +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *GitIdentityMutation) SetField(name string, value ent.Value) error { + switch name { + case gitidentity.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case gitidentity.FieldUserID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case gitidentity.FieldPlatform: + v, ok := value.(consts.GitPlatform) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPlatform(v) + return nil + case gitidentity.FieldBaseURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBaseURL(v) + return nil + case gitidentity.FieldAccessToken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAccessToken(v) + return nil + case gitidentity.FieldUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsername(v) + return nil + case gitidentity.FieldEmail: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmail(v) + return nil + case gitidentity.FieldInstallationID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInstallationID(v) + return nil + case gitidentity.FieldOrganizationID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOrganizationID(v) + return nil + case gitidentity.FieldRemark: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRemark(v) + return nil + case gitidentity.FieldOauthRefreshToken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOauthRefreshToken(v) + return nil + case gitidentity.FieldOauthExpiresAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOauthExpiresAt(v) + return nil + case gitidentity.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case gitidentity.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil } + return fmt.Errorf("unknown GitIdentity field %s", name) } -// AddedOutputLimit returns the value that was added to the "output_limit" field in this mutation. -func (m *ModelMutation) AddedOutputLimit() (r int, exists bool) { - v := m.addoutput_limit - if v == nil { - return +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *GitIdentityMutation) AddedFields() []string { + var fields []string + if m.addinstallation_id != nil { + fields = append(fields, gitidentity.FieldInstallationID) } - return *v, true -} - -// ResetOutputLimit resets all changes to the "output_limit" field. -func (m *ModelMutation) ResetOutputLimit() { - m.output_limit = nil - m.addoutput_limit = nil + return fields } -// SetLastCheckAt sets the "last_check_at" field. -func (m *ModelMutation) SetLastCheckAt(t time.Time) { - m.last_check_at = &t +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *GitIdentityMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case gitidentity.FieldInstallationID: + return m.AddedInstallationID() + } + return nil, false } -// LastCheckAt returns the value of the "last_check_at" field in the mutation. -func (m *ModelMutation) LastCheckAt() (r time.Time, exists bool) { - v := m.last_check_at - if v == nil { - return +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *GitIdentityMutation) AddField(name string, value ent.Value) error { + switch name { + case gitidentity.FieldInstallationID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddInstallationID(v) + return nil } - return *v, true + return fmt.Errorf("unknown GitIdentity numeric field %s", name) } -// OldLastCheckAt returns the old "last_check_at" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldLastCheckAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastCheckAt is only allowed on UpdateOne operations") +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *GitIdentityMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(gitidentity.FieldDeletedAt) { + fields = append(fields, gitidentity.FieldDeletedAt) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastCheckAt requires an ID field in the mutation") + if m.FieldCleared(gitidentity.FieldBaseURL) { + fields = append(fields, gitidentity.FieldBaseURL) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLastCheckAt: %w", err) + if m.FieldCleared(gitidentity.FieldAccessToken) { + fields = append(fields, gitidentity.FieldAccessToken) } - return oldValue.LastCheckAt, nil -} - -// ClearLastCheckAt clears the value of the "last_check_at" field. -func (m *ModelMutation) ClearLastCheckAt() { - m.last_check_at = nil - m.clearedFields[model.FieldLastCheckAt] = struct{}{} -} - -// LastCheckAtCleared returns if the "last_check_at" field was cleared in this mutation. -func (m *ModelMutation) LastCheckAtCleared() bool { - _, ok := m.clearedFields[model.FieldLastCheckAt] - return ok -} - -// ResetLastCheckAt resets all changes to the "last_check_at" field. -func (m *ModelMutation) ResetLastCheckAt() { - m.last_check_at = nil - delete(m.clearedFields, model.FieldLastCheckAt) -} - -// SetLastCheckSuccess sets the "last_check_success" field. -func (m *ModelMutation) SetLastCheckSuccess(b bool) { - m.last_check_success = &b -} - -// LastCheckSuccess returns the value of the "last_check_success" field in the mutation. -func (m *ModelMutation) LastCheckSuccess() (r bool, exists bool) { - v := m.last_check_success - if v == nil { - return + if m.FieldCleared(gitidentity.FieldUsername) { + fields = append(fields, gitidentity.FieldUsername) } - return *v, true -} - -// OldLastCheckSuccess returns the old "last_check_success" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldLastCheckSuccess(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastCheckSuccess is only allowed on UpdateOne operations") + if m.FieldCleared(gitidentity.FieldEmail) { + fields = append(fields, gitidentity.FieldEmail) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastCheckSuccess requires an ID field in the mutation") + if m.FieldCleared(gitidentity.FieldInstallationID) { + fields = append(fields, gitidentity.FieldInstallationID) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLastCheckSuccess: %w", err) + if m.FieldCleared(gitidentity.FieldOrganizationID) { + fields = append(fields, gitidentity.FieldOrganizationID) } - return oldValue.LastCheckSuccess, nil -} - -// ClearLastCheckSuccess clears the value of the "last_check_success" field. -func (m *ModelMutation) ClearLastCheckSuccess() { - m.last_check_success = nil - m.clearedFields[model.FieldLastCheckSuccess] = struct{}{} + if m.FieldCleared(gitidentity.FieldRemark) { + fields = append(fields, gitidentity.FieldRemark) + } + if m.FieldCleared(gitidentity.FieldOauthRefreshToken) { + fields = append(fields, gitidentity.FieldOauthRefreshToken) + } + if m.FieldCleared(gitidentity.FieldOauthExpiresAt) { + fields = append(fields, gitidentity.FieldOauthExpiresAt) + } + return fields } -// LastCheckSuccessCleared returns if the "last_check_success" field was cleared in this mutation. -func (m *ModelMutation) LastCheckSuccessCleared() bool { - _, ok := m.clearedFields[model.FieldLastCheckSuccess] +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *GitIdentityMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] return ok } -// ResetLastCheckSuccess resets all changes to the "last_check_success" field. -func (m *ModelMutation) ResetLastCheckSuccess() { - m.last_check_success = nil - delete(m.clearedFields, model.FieldLastCheckSuccess) -} - -// SetLastCheckError sets the "last_check_error" field. -func (m *ModelMutation) SetLastCheckError(s string) { - m.last_check_error = &s +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *GitIdentityMutation) ClearField(name string) error { + switch name { + case gitidentity.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case gitidentity.FieldBaseURL: + m.ClearBaseURL() + return nil + case gitidentity.FieldAccessToken: + m.ClearAccessToken() + return nil + case gitidentity.FieldUsername: + m.ClearUsername() + return nil + case gitidentity.FieldEmail: + m.ClearEmail() + return nil + case gitidentity.FieldInstallationID: + m.ClearInstallationID() + return nil + case gitidentity.FieldOrganizationID: + m.ClearOrganizationID() + return nil + case gitidentity.FieldRemark: + m.ClearRemark() + return nil + case gitidentity.FieldOauthRefreshToken: + m.ClearOauthRefreshToken() + return nil + case gitidentity.FieldOauthExpiresAt: + m.ClearOauthExpiresAt() + return nil + } + return fmt.Errorf("unknown GitIdentity nullable field %s", name) } -// LastCheckError returns the value of the "last_check_error" field in the mutation. -func (m *ModelMutation) LastCheckError() (r string, exists bool) { - v := m.last_check_error - if v == nil { - return +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *GitIdentityMutation) ResetField(name string) error { + switch name { + case gitidentity.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case gitidentity.FieldUserID: + m.ResetUserID() + return nil + case gitidentity.FieldPlatform: + m.ResetPlatform() + return nil + case gitidentity.FieldBaseURL: + m.ResetBaseURL() + return nil + case gitidentity.FieldAccessToken: + m.ResetAccessToken() + return nil + case gitidentity.FieldUsername: + m.ResetUsername() + return nil + case gitidentity.FieldEmail: + m.ResetEmail() + return nil + case gitidentity.FieldInstallationID: + m.ResetInstallationID() + return nil + case gitidentity.FieldOrganizationID: + m.ResetOrganizationID() + return nil + case gitidentity.FieldRemark: + m.ResetRemark() + return nil + case gitidentity.FieldOauthRefreshToken: + m.ResetOauthRefreshToken() + return nil + case gitidentity.FieldOauthExpiresAt: + m.ResetOauthExpiresAt() + return nil + case gitidentity.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case gitidentity.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil } - return *v, true + return fmt.Errorf("unknown GitIdentity field %s", name) } -// OldLastCheckError returns the old "last_check_error" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldLastCheckError(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastCheckError is only allowed on UpdateOne operations") +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *GitIdentityMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.user != nil { + edges = append(edges, gitidentity.EdgeUser) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastCheckError requires an ID field in the mutation") + if m.projects != nil { + edges = append(edges, gitidentity.EdgeProjects) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLastCheckError: %w", err) + if m.project_tasks != nil { + edges = append(edges, gitidentity.EdgeProjectTasks) } - return oldValue.LastCheckError, nil -} - -// ClearLastCheckError clears the value of the "last_check_error" field. -func (m *ModelMutation) ClearLastCheckError() { - m.last_check_error = nil - m.clearedFields[model.FieldLastCheckError] = struct{}{} -} - -// LastCheckErrorCleared returns if the "last_check_error" field was cleared in this mutation. -func (m *ModelMutation) LastCheckErrorCleared() bool { - _, ok := m.clearedFields[model.FieldLastCheckError] - return ok -} - -// ResetLastCheckError resets all changes to the "last_check_error" field. -func (m *ModelMutation) ResetLastCheckError() { - m.last_check_error = nil - delete(m.clearedFields, model.FieldLastCheckError) -} - -// SetCreatedAt sets the "created_at" field. -func (m *ModelMutation) SetCreatedAt(t time.Time) { - m.created_at = &t + if m.vms != nil { + edges = append(edges, gitidentity.EdgeVms) + } + return edges } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ModelMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *GitIdentityMutation) AddedIDs(name string) []ent.Value { + switch name { + case gitidentity.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + case gitidentity.EdgeProjects: + ids := make([]ent.Value, 0, len(m.projects)) + for id := range m.projects { + ids = append(ids, id) + } + return ids + case gitidentity.EdgeProjectTasks: + ids := make([]ent.Value, 0, len(m.project_tasks)) + for id := range m.project_tasks { + ids = append(ids, id) + } + return ids + case gitidentity.EdgeVms: + ids := make([]ent.Value, 0, len(m.vms)) + for id := range m.vms { + ids = append(ids, id) + } + return ids } - return *v, true + return nil } -// OldCreatedAt returns the old "created_at" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *GitIdentityMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedprojects != nil { + edges = append(edges, gitidentity.EdgeProjects) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + if m.removedproject_tasks != nil { + edges = append(edges, gitidentity.EdgeProjectTasks) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + if m.removedvms != nil { + edges = append(edges, gitidentity.EdgeVms) } - return oldValue.CreatedAt, nil + return edges } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *ModelMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *ModelMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *ModelMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *GitIdentityMutation) RemovedIDs(name string) []ent.Value { + switch name { + case gitidentity.EdgeProjects: + ids := make([]ent.Value, 0, len(m.removedprojects)) + for id := range m.removedprojects { + ids = append(ids, id) + } + return ids + case gitidentity.EdgeProjectTasks: + ids := make([]ent.Value, 0, len(m.removedproject_tasks)) + for id := range m.removedproject_tasks { + ids = append(ids, id) + } + return ids + case gitidentity.EdgeVms: + ids := make([]ent.Value, 0, len(m.removedvms)) + for id := range m.removedvms { + ids = append(ids, id) + } + return ids } - return *v, true + return nil } -// OldUpdatedAt returns the old "updated_at" field's value of the Model entity. -// If the Model object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *GitIdentityMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.cleareduser { + edges = append(edges, gitidentity.EdgeUser) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + if m.clearedprojects { + edges = append(edges, gitidentity.EdgeProjects) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + if m.clearedproject_tasks { + edges = append(edges, gitidentity.EdgeProjectTasks) } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *ModelMutation) ResetUpdatedAt() { - m.updated_at = nil + if m.clearedvms { + edges = append(edges, gitidentity.EdgeVms) + } + return edges } -// ClearUser clears the "user" edge to the User entity. -func (m *ModelMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[model.FieldUserID] = struct{}{} +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *GitIdentityMutation) EdgeCleared(name string) bool { + switch name { + case gitidentity.EdgeUser: + return m.cleareduser + case gitidentity.EdgeProjects: + return m.clearedprojects + case gitidentity.EdgeProjectTasks: + return m.clearedproject_tasks + case gitidentity.EdgeVms: + return m.clearedvms + } + return false } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *ModelMutation) UserCleared() bool { - return m.cleareduser +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *GitIdentityMutation) ClearEdge(name string) error { + switch name { + case gitidentity.EdgeUser: + m.ClearUser() + return nil + } + return fmt.Errorf("unknown GitIdentity unique edge %s", name) } -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *ModelMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { - ids = append(ids, *id) +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *GitIdentityMutation) ResetEdge(name string) error { + switch name { + case gitidentity.EdgeUser: + m.ResetUser() + return nil + case gitidentity.EdgeProjects: + m.ResetProjects() + return nil + case gitidentity.EdgeProjectTasks: + m.ResetProjectTasks() + return nil + case gitidentity.EdgeVms: + m.ResetVms() + return nil } - return + return fmt.Errorf("unknown GitIdentity edge %s", name) } -// ResetUser resets all changes to the "user" edge. -func (m *ModelMutation) ResetUser() { - m.user = nil - m.cleareduser = false +// GitTaskMutation represents an operation that mutates the GitTask nodes in the graph. +type GitTaskMutation struct { + config + op Op + typ string + id *uuid.UUID + repo_id *uuid.UUID + subject_type *string + subject_id *string + subject_number *int + addsubject_number *int + subject_url *string + subject_title *string + prompt_id *string + show_url *string + github_installation_id *int64 + addgithub_installation_id *int64 + created_at *time.Time + clearedFields map[string]struct{} + task *uuid.UUID + clearedtask bool + done bool + oldValue func(context.Context) (*GitTask, error) + predicates []predicate.GitTask } -// AddTeamIDs adds the "teams" edge to the Team entity by ids. -func (m *ModelMutation) AddTeamIDs(ids ...uuid.UUID) { - if m.teams == nil { - m.teams = make(map[uuid.UUID]struct{}) +var _ ent.Mutation = (*GitTaskMutation)(nil) + +// gittaskOption allows management of the mutation configuration using functional options. +type gittaskOption func(*GitTaskMutation) + +// newGitTaskMutation creates new mutation for the GitTask entity. +func newGitTaskMutation(c config, op Op, opts ...gittaskOption) *GitTaskMutation { + m := &GitTaskMutation{ + config: c, + op: op, + typ: TypeGitTask, + clearedFields: make(map[string]struct{}), } - for i := range ids { - m.teams[ids[i]] = struct{}{} + for _, opt := range opts { + opt(m) } + return m } -// ClearTeams clears the "teams" edge to the Team entity. -func (m *ModelMutation) ClearTeams() { - m.clearedteams = true -} - -// TeamsCleared reports if the "teams" edge to the Team entity was cleared. -func (m *ModelMutation) TeamsCleared() bool { - return m.clearedteams +// withGitTaskID sets the ID field of the mutation. +func withGitTaskID(id uuid.UUID) gittaskOption { + return func(m *GitTaskMutation) { + var ( + err error + once sync.Once + value *GitTask + ) + m.oldValue = func(ctx context.Context) (*GitTask, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().GitTask.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } } -// RemoveTeamIDs removes the "teams" edge to the Team entity by IDs. -func (m *ModelMutation) RemoveTeamIDs(ids ...uuid.UUID) { - if m.removedteams == nil { - m.removedteams = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.teams, ids[i]) - m.removedteams[ids[i]] = struct{}{} +// withGitTask sets the old GitTask of the mutation. +func withGitTask(node *GitTask) gittaskOption { + return func(m *GitTaskMutation) { + m.oldValue = func(context.Context) (*GitTask, error) { + return node, nil + } + m.id = &node.ID } } -// RemovedTeams returns the removed IDs of the "teams" edge to the Team entity. -func (m *ModelMutation) RemovedTeamsIDs() (ids []uuid.UUID) { - for id := range m.removedteams { - ids = append(ids, id) - } - return +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m GitTaskMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// TeamsIDs returns the "teams" edge IDs in the mutation. -func (m *ModelMutation) TeamsIDs() (ids []uuid.UUID) { - for id := range m.teams { - ids = append(ids, id) +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m GitTaskMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") } - return + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// ResetTeams resets all changes to the "teams" edge. -func (m *ModelMutation) ResetTeams() { - m.teams = nil - m.clearedteams = false - m.removedteams = nil +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of GitTask entities. +func (m *GitTaskMutation) SetID(id uuid.UUID) { + m.id = &id } -// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids. -func (m *ModelMutation) AddGroupIDs(ids ...uuid.UUID) { - if m.groups == nil { - m.groups = make(map[uuid.UUID]struct{}) +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *GitTaskMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return } - for i := range ids { - m.groups[ids[i]] = struct{}{} + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *GitTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().GitTask.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// ClearGroups clears the "groups" edge to the TeamGroup entity. -func (m *ModelMutation) ClearGroups() { - m.clearedgroups = true +// SetTaskID sets the "task_id" field. +func (m *GitTaskMutation) SetTaskID(u uuid.UUID) { + m.task = &u } -// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared. -func (m *ModelMutation) GroupsCleared() bool { - return m.clearedgroups +// TaskID returns the value of the "task_id" field in the mutation. +func (m *GitTaskMutation) TaskID() (r uuid.UUID, exists bool) { + v := m.task + if v == nil { + return + } + return *v, true } -// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs. -func (m *ModelMutation) RemoveGroupIDs(ids ...uuid.UUID) { - if m.removedgroups == nil { - m.removedgroups = make(map[uuid.UUID]struct{}) +// OldTaskID returns the old "task_id" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTaskID is only allowed on UpdateOne operations") } - for i := range ids { - delete(m.groups, ids[i]) - m.removedgroups[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTaskID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTaskID: %w", err) } + return oldValue.TaskID, nil } -// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity. -func (m *ModelMutation) RemovedGroupsIDs() (ids []uuid.UUID) { - for id := range m.removedgroups { - ids = append(ids, id) - } - return +// ResetTaskID resets all changes to the "task_id" field. +func (m *GitTaskMutation) ResetTaskID() { + m.task = nil } -// GroupsIDs returns the "groups" edge IDs in the mutation. -func (m *ModelMutation) GroupsIDs() (ids []uuid.UUID) { - for id := range m.groups { - ids = append(ids, id) - } - return +// SetRepoID sets the "repo_id" field. +func (m *GitTaskMutation) SetRepoID(u uuid.UUID) { + m.repo_id = &u } -// ResetGroups resets all changes to the "groups" edge. -func (m *ModelMutation) ResetGroups() { - m.groups = nil - m.clearedgroups = false - m.removedgroups = nil +// RepoID returns the value of the "repo_id" field in the mutation. +func (m *GitTaskMutation) RepoID() (r uuid.UUID, exists bool) { + v := m.repo_id + if v == nil { + return + } + return *v, true } -// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids. -func (m *ModelMutation) AddVMIDs(ids ...string) { - if m.vms == nil { - m.vms = make(map[string]struct{}) +// OldRepoID returns the old "repo_id" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldRepoID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRepoID is only allowed on UpdateOne operations") } - for i := range ids { - m.vms[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRepoID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRepoID: %w", err) } + return oldValue.RepoID, nil } -// ClearVms clears the "vms" edge to the VirtualMachine entity. -func (m *ModelMutation) ClearVms() { - m.clearedvms = true +// ClearRepoID clears the value of the "repo_id" field. +func (m *GitTaskMutation) ClearRepoID() { + m.repo_id = nil + m.clearedFields[gittask.FieldRepoID] = struct{}{} } -// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared. -func (m *ModelMutation) VmsCleared() bool { - return m.clearedvms +// RepoIDCleared returns if the "repo_id" field was cleared in this mutation. +func (m *GitTaskMutation) RepoIDCleared() bool { + _, ok := m.clearedFields[gittask.FieldRepoID] + return ok } -// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs. -func (m *ModelMutation) RemoveVMIDs(ids ...string) { - if m.removedvms == nil { - m.removedvms = make(map[string]struct{}) - } - for i := range ids { - delete(m.vms, ids[i]) - m.removedvms[ids[i]] = struct{}{} - } +// ResetRepoID resets all changes to the "repo_id" field. +func (m *GitTaskMutation) ResetRepoID() { + m.repo_id = nil + delete(m.clearedFields, gittask.FieldRepoID) } -// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity. -func (m *ModelMutation) RemovedVmsIDs() (ids []string) { - for id := range m.removedvms { - ids = append(ids, id) - } - return +// SetSubjectType sets the "subject_type" field. +func (m *GitTaskMutation) SetSubjectType(s string) { + m.subject_type = &s } -// VmsIDs returns the "vms" edge IDs in the mutation. -func (m *ModelMutation) VmsIDs() (ids []string) { - for id := range m.vms { - ids = append(ids, id) +// SubjectType returns the value of the "subject_type" field in the mutation. +func (m *GitTaskMutation) SubjectType() (r string, exists bool) { + v := m.subject_type + if v == nil { + return } - return -} - -// ResetVms resets all changes to the "vms" edge. -func (m *ModelMutation) ResetVms() { - m.vms = nil - m.clearedvms = false - m.removedvms = nil + return *v, true } -// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids. -func (m *ModelMutation) AddProjectTaskIDs(ids ...uuid.UUID) { - if m.project_tasks == nil { - m.project_tasks = make(map[uuid.UUID]struct{}) +// OldSubjectType returns the old "subject_type" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldSubjectType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubjectType is only allowed on UpdateOne operations") } - for i := range ids { - m.project_tasks[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubjectType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubjectType: %w", err) } + return oldValue.SubjectType, nil } -// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity. -func (m *ModelMutation) ClearProjectTasks() { - m.clearedproject_tasks = true +// ResetSubjectType resets all changes to the "subject_type" field. +func (m *GitTaskMutation) ResetSubjectType() { + m.subject_type = nil } -// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared. -func (m *ModelMutation) ProjectTasksCleared() bool { - return m.clearedproject_tasks +// SetSubjectID sets the "subject_id" field. +func (m *GitTaskMutation) SetSubjectID(s string) { + m.subject_id = &s } -// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs. -func (m *ModelMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) { - if m.removedproject_tasks == nil { - m.removedproject_tasks = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.project_tasks, ids[i]) - m.removedproject_tasks[ids[i]] = struct{}{} +// SubjectID returns the value of the "subject_id" field in the mutation. +func (m *GitTaskMutation) SubjectID() (r string, exists bool) { + v := m.subject_id + if v == nil { + return } + return *v, true } -// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity. -func (m *ModelMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) { - for id := range m.removedproject_tasks { - ids = append(ids, id) +// OldSubjectID returns the old "subject_id" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldSubjectID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubjectID is only allowed on UpdateOne operations") } - return -} - -// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation. -func (m *ModelMutation) ProjectTasksIDs() (ids []uuid.UUID) { - for id := range m.project_tasks { - ids = append(ids, id) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubjectID requires an ID field in the mutation") } - return + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubjectID: %w", err) + } + return oldValue.SubjectID, nil } -// ResetProjectTasks resets all changes to the "project_tasks" edge. -func (m *ModelMutation) ResetProjectTasks() { - m.project_tasks = nil - m.clearedproject_tasks = false - m.removedproject_tasks = nil +// ClearSubjectID clears the value of the "subject_id" field. +func (m *GitTaskMutation) ClearSubjectID() { + m.subject_id = nil + m.clearedFields[gittask.FieldSubjectID] = struct{}{} } -// SetPricingID sets the "pricing" edge to the ModelPricing entity by id. -func (m *ModelMutation) SetPricingID(id uuid.UUID) { - m.pricing = &id +// SubjectIDCleared returns if the "subject_id" field was cleared in this mutation. +func (m *GitTaskMutation) SubjectIDCleared() bool { + _, ok := m.clearedFields[gittask.FieldSubjectID] + return ok } -// ClearPricing clears the "pricing" edge to the ModelPricing entity. -func (m *ModelMutation) ClearPricing() { - m.clearedpricing = true +// ResetSubjectID resets all changes to the "subject_id" field. +func (m *GitTaskMutation) ResetSubjectID() { + m.subject_id = nil + delete(m.clearedFields, gittask.FieldSubjectID) } -// PricingCleared reports if the "pricing" edge to the ModelPricing entity was cleared. -func (m *ModelMutation) PricingCleared() bool { - return m.clearedpricing +// SetSubjectNumber sets the "subject_number" field. +func (m *GitTaskMutation) SetSubjectNumber(i int) { + m.subject_number = &i + m.addsubject_number = nil } -// PricingID returns the "pricing" edge ID in the mutation. -func (m *ModelMutation) PricingID() (id uuid.UUID, exists bool) { - if m.pricing != nil { - return *m.pricing, true +// SubjectNumber returns the value of the "subject_number" field in the mutation. +func (m *GitTaskMutation) SubjectNumber() (r int, exists bool) { + v := m.subject_number + if v == nil { + return } - return + return *v, true } -// PricingIDs returns the "pricing" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// PricingID instead. It exists only for internal usage by the builders. -func (m *ModelMutation) PricingIDs() (ids []uuid.UUID) { - if id := m.pricing; id != nil { - ids = append(ids, *id) +// OldSubjectNumber returns the old "subject_number" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldSubjectNumber(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubjectNumber is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubjectNumber requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubjectNumber: %w", err) + } + return oldValue.SubjectNumber, nil } -// ResetPricing resets all changes to the "pricing" edge. -func (m *ModelMutation) ResetPricing() { - m.pricing = nil - m.clearedpricing = false +// AddSubjectNumber adds i to the "subject_number" field. +func (m *GitTaskMutation) AddSubjectNumber(i int) { + if m.addsubject_number != nil { + *m.addsubject_number += i + } else { + m.addsubject_number = &i + } } -// AddApikeyIDs adds the "apikeys" edge to the ModelApiKey entity by ids. -func (m *ModelMutation) AddApikeyIDs(ids ...uuid.UUID) { - if m.apikeys == nil { - m.apikeys = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.apikeys[ids[i]] = struct{}{} +// AddedSubjectNumber returns the value that was added to the "subject_number" field in this mutation. +func (m *GitTaskMutation) AddedSubjectNumber() (r int, exists bool) { + v := m.addsubject_number + if v == nil { + return } + return *v, true } -// ClearApikeys clears the "apikeys" edge to the ModelApiKey entity. -func (m *ModelMutation) ClearApikeys() { - m.clearedapikeys = true +// ClearSubjectNumber clears the value of the "subject_number" field. +func (m *GitTaskMutation) ClearSubjectNumber() { + m.subject_number = nil + m.addsubject_number = nil + m.clearedFields[gittask.FieldSubjectNumber] = struct{}{} } -// ApikeysCleared reports if the "apikeys" edge to the ModelApiKey entity was cleared. -func (m *ModelMutation) ApikeysCleared() bool { - return m.clearedapikeys +// SubjectNumberCleared returns if the "subject_number" field was cleared in this mutation. +func (m *GitTaskMutation) SubjectNumberCleared() bool { + _, ok := m.clearedFields[gittask.FieldSubjectNumber] + return ok } -// RemoveApikeyIDs removes the "apikeys" edge to the ModelApiKey entity by IDs. -func (m *ModelMutation) RemoveApikeyIDs(ids ...uuid.UUID) { - if m.removedapikeys == nil { - m.removedapikeys = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.apikeys, ids[i]) - m.removedapikeys[ids[i]] = struct{}{} - } +// ResetSubjectNumber resets all changes to the "subject_number" field. +func (m *GitTaskMutation) ResetSubjectNumber() { + m.subject_number = nil + m.addsubject_number = nil + delete(m.clearedFields, gittask.FieldSubjectNumber) } -// RemovedApikeys returns the removed IDs of the "apikeys" edge to the ModelApiKey entity. -func (m *ModelMutation) RemovedApikeysIDs() (ids []uuid.UUID) { - for id := range m.removedapikeys { - ids = append(ids, id) +// SetSubjectURL sets the "subject_url" field. +func (m *GitTaskMutation) SetSubjectURL(s string) { + m.subject_url = &s +} + +// SubjectURL returns the value of the "subject_url" field in the mutation. +func (m *GitTaskMutation) SubjectURL() (r string, exists bool) { + v := m.subject_url + if v == nil { + return } - return + return *v, true } -// ApikeysIDs returns the "apikeys" edge IDs in the mutation. -func (m *ModelMutation) ApikeysIDs() (ids []uuid.UUID) { - for id := range m.apikeys { - ids = append(ids, id) +// OldSubjectURL returns the old "subject_url" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldSubjectURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubjectURL is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubjectURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubjectURL: %w", err) + } + return oldValue.SubjectURL, nil } -// ResetApikeys resets all changes to the "apikeys" edge. -func (m *ModelMutation) ResetApikeys() { - m.apikeys = nil - m.clearedapikeys = false - m.removedapikeys = nil +// ClearSubjectURL clears the value of the "subject_url" field. +func (m *GitTaskMutation) ClearSubjectURL() { + m.subject_url = nil + m.clearedFields[gittask.FieldSubjectURL] = struct{}{} } -// AddSwitchesFromIDs adds the "switches_from" edge to the TaskModelSwitch entity by ids. -func (m *ModelMutation) AddSwitchesFromIDs(ids ...uuid.UUID) { - if m.switches_from == nil { - m.switches_from = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.switches_from[ids[i]] = struct{}{} - } +// SubjectURLCleared returns if the "subject_url" field was cleared in this mutation. +func (m *GitTaskMutation) SubjectURLCleared() bool { + _, ok := m.clearedFields[gittask.FieldSubjectURL] + return ok } -// ClearSwitchesFrom clears the "switches_from" edge to the TaskModelSwitch entity. -func (m *ModelMutation) ClearSwitchesFrom() { - m.clearedswitches_from = true +// ResetSubjectURL resets all changes to the "subject_url" field. +func (m *GitTaskMutation) ResetSubjectURL() { + m.subject_url = nil + delete(m.clearedFields, gittask.FieldSubjectURL) } -// SwitchesFromCleared reports if the "switches_from" edge to the TaskModelSwitch entity was cleared. -func (m *ModelMutation) SwitchesFromCleared() bool { - return m.clearedswitches_from +// SetSubjectTitle sets the "subject_title" field. +func (m *GitTaskMutation) SetSubjectTitle(s string) { + m.subject_title = &s } -// RemoveSwitchesFromIDs removes the "switches_from" edge to the TaskModelSwitch entity by IDs. -func (m *ModelMutation) RemoveSwitchesFromIDs(ids ...uuid.UUID) { - if m.removedswitches_from == nil { - m.removedswitches_from = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.switches_from, ids[i]) - m.removedswitches_from[ids[i]] = struct{}{} +// SubjectTitle returns the value of the "subject_title" field in the mutation. +func (m *GitTaskMutation) SubjectTitle() (r string, exists bool) { + v := m.subject_title + if v == nil { + return } + return *v, true } -// RemovedSwitchesFrom returns the removed IDs of the "switches_from" edge to the TaskModelSwitch entity. -func (m *ModelMutation) RemovedSwitchesFromIDs() (ids []uuid.UUID) { - for id := range m.removedswitches_from { - ids = append(ids, id) +// OldSubjectTitle returns the old "subject_title" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldSubjectTitle(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubjectTitle is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubjectTitle requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubjectTitle: %w", err) + } + return oldValue.SubjectTitle, nil } -// SwitchesFromIDs returns the "switches_from" edge IDs in the mutation. -func (m *ModelMutation) SwitchesFromIDs() (ids []uuid.UUID) { - for id := range m.switches_from { - ids = append(ids, id) - } - return +// ClearSubjectTitle clears the value of the "subject_title" field. +func (m *GitTaskMutation) ClearSubjectTitle() { + m.subject_title = nil + m.clearedFields[gittask.FieldSubjectTitle] = struct{}{} } -// ResetSwitchesFrom resets all changes to the "switches_from" edge. -func (m *ModelMutation) ResetSwitchesFrom() { - m.switches_from = nil - m.clearedswitches_from = false - m.removedswitches_from = nil +// SubjectTitleCleared returns if the "subject_title" field was cleared in this mutation. +func (m *GitTaskMutation) SubjectTitleCleared() bool { + _, ok := m.clearedFields[gittask.FieldSubjectTitle] + return ok } -// AddSwitchesToIDs adds the "switches_to" edge to the TaskModelSwitch entity by ids. -func (m *ModelMutation) AddSwitchesToIDs(ids ...uuid.UUID) { - if m.switches_to == nil { - m.switches_to = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.switches_to[ids[i]] = struct{}{} - } +// ResetSubjectTitle resets all changes to the "subject_title" field. +func (m *GitTaskMutation) ResetSubjectTitle() { + m.subject_title = nil + delete(m.clearedFields, gittask.FieldSubjectTitle) } -// ClearSwitchesTo clears the "switches_to" edge to the TaskModelSwitch entity. -func (m *ModelMutation) ClearSwitchesTo() { - m.clearedswitches_to = true +// SetPromptID sets the "prompt_id" field. +func (m *GitTaskMutation) SetPromptID(s string) { + m.prompt_id = &s } -// SwitchesToCleared reports if the "switches_to" edge to the TaskModelSwitch entity was cleared. -func (m *ModelMutation) SwitchesToCleared() bool { - return m.clearedswitches_to +// PromptID returns the value of the "prompt_id" field in the mutation. +func (m *GitTaskMutation) PromptID() (r string, exists bool) { + v := m.prompt_id + if v == nil { + return + } + return *v, true } -// RemoveSwitchesToIDs removes the "switches_to" edge to the TaskModelSwitch entity by IDs. -func (m *ModelMutation) RemoveSwitchesToIDs(ids ...uuid.UUID) { - if m.removedswitches_to == nil { - m.removedswitches_to = make(map[uuid.UUID]struct{}) +// OldPromptID returns the old "prompt_id" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldPromptID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPromptID is only allowed on UpdateOne operations") } - for i := range ids { - delete(m.switches_to, ids[i]) - m.removedswitches_to[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPromptID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPromptID: %w", err) } + return oldValue.PromptID, nil } -// RemovedSwitchesTo returns the removed IDs of the "switches_to" edge to the TaskModelSwitch entity. -func (m *ModelMutation) RemovedSwitchesToIDs() (ids []uuid.UUID) { - for id := range m.removedswitches_to { - ids = append(ids, id) - } - return +// ClearPromptID clears the value of the "prompt_id" field. +func (m *GitTaskMutation) ClearPromptID() { + m.prompt_id = nil + m.clearedFields[gittask.FieldPromptID] = struct{}{} } -// SwitchesToIDs returns the "switches_to" edge IDs in the mutation. -func (m *ModelMutation) SwitchesToIDs() (ids []uuid.UUID) { - for id := range m.switches_to { - ids = append(ids, id) - } - return +// PromptIDCleared returns if the "prompt_id" field was cleared in this mutation. +func (m *GitTaskMutation) PromptIDCleared() bool { + _, ok := m.clearedFields[gittask.FieldPromptID] + return ok } -// ResetSwitchesTo resets all changes to the "switches_to" edge. -func (m *ModelMutation) ResetSwitchesTo() { - m.switches_to = nil - m.clearedswitches_to = false - m.removedswitches_to = nil +// ResetPromptID resets all changes to the "prompt_id" field. +func (m *GitTaskMutation) ResetPromptID() { + m.prompt_id = nil + delete(m.clearedFields, gittask.FieldPromptID) } -// AddTeamModelIDs adds the "team_models" edge to the TeamModel entity by ids. -func (m *ModelMutation) AddTeamModelIDs(ids ...uuid.UUID) { - if m.team_models == nil { - m.team_models = make(map[uuid.UUID]struct{}) +// SetShowURL sets the "show_url" field. +func (m *GitTaskMutation) SetShowURL(s string) { + m.show_url = &s +} + +// ShowURL returns the value of the "show_url" field in the mutation. +func (m *GitTaskMutation) ShowURL() (r string, exists bool) { + v := m.show_url + if v == nil { + return } - for i := range ids { - m.team_models[ids[i]] = struct{}{} + return *v, true +} + +// OldShowURL returns the old "show_url" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldShowURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldShowURL is only allowed on UpdateOne operations") } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldShowURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldShowURL: %w", err) + } + return oldValue.ShowURL, nil } -// ClearTeamModels clears the "team_models" edge to the TeamModel entity. -func (m *ModelMutation) ClearTeamModels() { - m.clearedteam_models = true +// ClearShowURL clears the value of the "show_url" field. +func (m *GitTaskMutation) ClearShowURL() { + m.show_url = nil + m.clearedFields[gittask.FieldShowURL] = struct{}{} } -// TeamModelsCleared reports if the "team_models" edge to the TeamModel entity was cleared. -func (m *ModelMutation) TeamModelsCleared() bool { - return m.clearedteam_models +// ShowURLCleared returns if the "show_url" field was cleared in this mutation. +func (m *GitTaskMutation) ShowURLCleared() bool { + _, ok := m.clearedFields[gittask.FieldShowURL] + return ok } -// RemoveTeamModelIDs removes the "team_models" edge to the TeamModel entity by IDs. -func (m *ModelMutation) RemoveTeamModelIDs(ids ...uuid.UUID) { - if m.removedteam_models == nil { - m.removedteam_models = make(map[uuid.UUID]struct{}) +// ResetShowURL resets all changes to the "show_url" field. +func (m *GitTaskMutation) ResetShowURL() { + m.show_url = nil + delete(m.clearedFields, gittask.FieldShowURL) +} + +// SetGithubInstallationID sets the "github_installation_id" field. +func (m *GitTaskMutation) SetGithubInstallationID(i int64) { + m.github_installation_id = &i + m.addgithub_installation_id = nil +} + +// GithubInstallationID returns the value of the "github_installation_id" field in the mutation. +func (m *GitTaskMutation) GithubInstallationID() (r int64, exists bool) { + v := m.github_installation_id + if v == nil { + return } - for i := range ids { - delete(m.team_models, ids[i]) - m.removedteam_models[ids[i]] = struct{}{} + return *v, true +} + +// OldGithubInstallationID returns the old "github_installation_id" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldGithubInstallationID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGithubInstallationID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGithubInstallationID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGithubInstallationID: %w", err) } + return oldValue.GithubInstallationID, nil } -// RemovedTeamModels returns the removed IDs of the "team_models" edge to the TeamModel entity. -func (m *ModelMutation) RemovedTeamModelsIDs() (ids []uuid.UUID) { - for id := range m.removedteam_models { - ids = append(ids, id) +// AddGithubInstallationID adds i to the "github_installation_id" field. +func (m *GitTaskMutation) AddGithubInstallationID(i int64) { + if m.addgithub_installation_id != nil { + *m.addgithub_installation_id += i + } else { + m.addgithub_installation_id = &i } - return } -// TeamModelsIDs returns the "team_models" edge IDs in the mutation. -func (m *ModelMutation) TeamModelsIDs() (ids []uuid.UUID) { - for id := range m.team_models { - ids = append(ids, id) +// AddedGithubInstallationID returns the value that was added to the "github_installation_id" field in this mutation. +func (m *GitTaskMutation) AddedGithubInstallationID() (r int64, exists bool) { + v := m.addgithub_installation_id + if v == nil { + return } - return + return *v, true } -// ResetTeamModels resets all changes to the "team_models" edge. -func (m *ModelMutation) ResetTeamModels() { - m.team_models = nil - m.clearedteam_models = false - m.removedteam_models = nil +// ClearGithubInstallationID clears the value of the "github_installation_id" field. +func (m *GitTaskMutation) ClearGithubInstallationID() { + m.github_installation_id = nil + m.addgithub_installation_id = nil + m.clearedFields[gittask.FieldGithubInstallationID] = struct{}{} } -// AddTeamGroupModelIDs adds the "team_group_models" edge to the TeamGroupModel entity by ids. -func (m *ModelMutation) AddTeamGroupModelIDs(ids ...uuid.UUID) { - if m.team_group_models == nil { - m.team_group_models = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.team_group_models[ids[i]] = struct{}{} - } +// GithubInstallationIDCleared returns if the "github_installation_id" field was cleared in this mutation. +func (m *GitTaskMutation) GithubInstallationIDCleared() bool { + _, ok := m.clearedFields[gittask.FieldGithubInstallationID] + return ok } -// ClearTeamGroupModels clears the "team_group_models" edge to the TeamGroupModel entity. -func (m *ModelMutation) ClearTeamGroupModels() { - m.clearedteam_group_models = true +// ResetGithubInstallationID resets all changes to the "github_installation_id" field. +func (m *GitTaskMutation) ResetGithubInstallationID() { + m.github_installation_id = nil + m.addgithub_installation_id = nil + delete(m.clearedFields, gittask.FieldGithubInstallationID) } -// TeamGroupModelsCleared reports if the "team_group_models" edge to the TeamGroupModel entity was cleared. -func (m *ModelMutation) TeamGroupModelsCleared() bool { - return m.clearedteam_group_models +// SetCreatedAt sets the "created_at" field. +func (m *GitTaskMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// RemoveTeamGroupModelIDs removes the "team_group_models" edge to the TeamGroupModel entity by IDs. -func (m *ModelMutation) RemoveTeamGroupModelIDs(ids ...uuid.UUID) { - if m.removedteam_group_models == nil { - m.removedteam_group_models = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.team_group_models, ids[i]) - m.removedteam_group_models[ids[i]] = struct{}{} +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *GitTaskMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return } + return *v, true } -// RemovedTeamGroupModels returns the removed IDs of the "team_group_models" edge to the TeamGroupModel entity. -func (m *ModelMutation) RemovedTeamGroupModelsIDs() (ids []uuid.UUID) { - for id := range m.removedteam_group_models { - ids = append(ids, id) +// OldCreatedAt returns the old "created_at" field's value of the GitTask entity. +// If the GitTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *GitTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil } -// TeamGroupModelsIDs returns the "team_group_models" edge IDs in the mutation. -func (m *ModelMutation) TeamGroupModelsIDs() (ids []uuid.UUID) { - for id := range m.team_group_models { - ids = append(ids, id) +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *GitTaskMutation) ResetCreatedAt() { + m.created_at = nil +} + +// ClearTask clears the "task" edge to the Task entity. +func (m *GitTaskMutation) ClearTask() { + m.clearedtask = true + m.clearedFields[gittask.FieldTaskID] = struct{}{} +} + +// TaskCleared reports if the "task" edge to the Task entity was cleared. +func (m *GitTaskMutation) TaskCleared() bool { + return m.clearedtask +} + +// TaskIDs returns the "task" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TaskID instead. It exists only for internal usage by the builders. +func (m *GitTaskMutation) TaskIDs() (ids []uuid.UUID) { + if id := m.task; id != nil { + ids = append(ids, *id) } return } -// ResetTeamGroupModels resets all changes to the "team_group_models" edge. -func (m *ModelMutation) ResetTeamGroupModels() { - m.team_group_models = nil - m.clearedteam_group_models = false - m.removedteam_group_models = nil +// ResetTask resets all changes to the "task" edge. +func (m *GitTaskMutation) ResetTask() { + m.task = nil + m.clearedtask = false } -// Where appends a list predicates to the ModelMutation builder. -func (m *ModelMutation) Where(ps ...predicate.Model) { +// Where appends a list predicates to the GitTaskMutation builder. +func (m *GitTaskMutation) Where(ps ...predicate.GitTask) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ModelMutation builder. Using this method, +// WhereP appends storage-level predicates to the GitTaskMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ModelMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Model, len(ps)) +func (m *GitTaskMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.GitTask, len(ps)) for i := range ps { p[i] = ps[i] } @@ -14126,84 +15142,57 @@ func (m *ModelMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ModelMutation) Op() Op { +func (m *GitTaskMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ModelMutation) SetOp(op Op) { +func (m *GitTaskMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Model). -func (m *ModelMutation) Type() string { +// Type returns the node type of this mutation (GitTask). +func (m *GitTaskMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ModelMutation) Fields() []string { - fields := make([]string, 0, 20) - if m.deleted_at != nil { - fields = append(fields, model.FieldDeletedAt) - } - if m.user != nil { - fields = append(fields, model.FieldUserID) - } - if m.provider != nil { - fields = append(fields, model.FieldProvider) - } - if m.api_key != nil { - fields = append(fields, model.FieldAPIKey) - } - if m.base_url != nil { - fields = append(fields, model.FieldBaseURL) - } - if m.model != nil { - fields = append(fields, model.FieldModel) - } - if m.remark != nil { - fields = append(fields, model.FieldRemark) - } - if m.temperature != nil { - fields = append(fields, model.FieldTemperature) - } - if m.interface_type != nil { - fields = append(fields, model.FieldInterfaceType) +func (m *GitTaskMutation) Fields() []string { + fields := make([]string, 0, 11) + if m.task != nil { + fields = append(fields, gittask.FieldTaskID) } - if m.weight != nil { - fields = append(fields, model.FieldWeight) + if m.repo_id != nil { + fields = append(fields, gittask.FieldRepoID) } - if m.thinking_enabled != nil { - fields = append(fields, model.FieldThinkingEnabled) + if m.subject_type != nil { + fields = append(fields, gittask.FieldSubjectType) } - if m.support_image != nil { - fields = append(fields, model.FieldSupportImage) + if m.subject_id != nil { + fields = append(fields, gittask.FieldSubjectID) } - if m.is_hidden != nil { - fields = append(fields, model.FieldIsHidden) + if m.subject_number != nil { + fields = append(fields, gittask.FieldSubjectNumber) } - if m.context_limit != nil { - fields = append(fields, model.FieldContextLimit) + if m.subject_url != nil { + fields = append(fields, gittask.FieldSubjectURL) } - if m.output_limit != nil { - fields = append(fields, model.FieldOutputLimit) + if m.subject_title != nil { + fields = append(fields, gittask.FieldSubjectTitle) } - if m.last_check_at != nil { - fields = append(fields, model.FieldLastCheckAt) + if m.prompt_id != nil { + fields = append(fields, gittask.FieldPromptID) } - if m.last_check_success != nil { - fields = append(fields, model.FieldLastCheckSuccess) + if m.show_url != nil { + fields = append(fields, gittask.FieldShowURL) } - if m.last_check_error != nil { - fields = append(fields, model.FieldLastCheckError) + if m.github_installation_id != nil { + fields = append(fields, gittask.FieldGithubInstallationID) } if m.created_at != nil { - fields = append(fields, model.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, model.FieldUpdatedAt) + fields = append(fields, gittask.FieldCreatedAt) } return fields } @@ -14211,48 +15200,30 @@ func (m *ModelMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ModelMutation) Field(name string) (ent.Value, bool) { +func (m *GitTaskMutation) Field(name string) (ent.Value, bool) { switch name { - case model.FieldDeletedAt: - return m.DeletedAt() - case model.FieldUserID: - return m.UserID() - case model.FieldProvider: - return m.Provider() - case model.FieldAPIKey: - return m.APIKey() - case model.FieldBaseURL: - return m.BaseURL() - case model.FieldModel: - return m.Model() - case model.FieldRemark: - return m.Remark() - case model.FieldTemperature: - return m.Temperature() - case model.FieldInterfaceType: - return m.InterfaceType() - case model.FieldWeight: - return m.Weight() - case model.FieldThinkingEnabled: - return m.ThinkingEnabled() - case model.FieldSupportImage: - return m.SupportImage() - case model.FieldIsHidden: - return m.IsHidden() - case model.FieldContextLimit: - return m.ContextLimit() - case model.FieldOutputLimit: - return m.OutputLimit() - case model.FieldLastCheckAt: - return m.LastCheckAt() - case model.FieldLastCheckSuccess: - return m.LastCheckSuccess() - case model.FieldLastCheckError: - return m.LastCheckError() - case model.FieldCreatedAt: + case gittask.FieldTaskID: + return m.TaskID() + case gittask.FieldRepoID: + return m.RepoID() + case gittask.FieldSubjectType: + return m.SubjectType() + case gittask.FieldSubjectID: + return m.SubjectID() + case gittask.FieldSubjectNumber: + return m.SubjectNumber() + case gittask.FieldSubjectURL: + return m.SubjectURL() + case gittask.FieldSubjectTitle: + return m.SubjectTitle() + case gittask.FieldPromptID: + return m.PromptID() + case gittask.FieldShowURL: + return m.ShowURL() + case gittask.FieldGithubInstallationID: + return m.GithubInstallationID() + case gittask.FieldCreatedAt: return m.CreatedAt() - case model.FieldUpdatedAt: - return m.UpdatedAt() } return nil, false } @@ -14260,216 +15231,129 @@ func (m *ModelMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ModelMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *GitTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case model.FieldDeletedAt: - return m.OldDeletedAt(ctx) - case model.FieldUserID: - return m.OldUserID(ctx) - case model.FieldProvider: - return m.OldProvider(ctx) - case model.FieldAPIKey: - return m.OldAPIKey(ctx) - case model.FieldBaseURL: - return m.OldBaseURL(ctx) - case model.FieldModel: - return m.OldModel(ctx) - case model.FieldRemark: - return m.OldRemark(ctx) - case model.FieldTemperature: - return m.OldTemperature(ctx) - case model.FieldInterfaceType: - return m.OldInterfaceType(ctx) - case model.FieldWeight: - return m.OldWeight(ctx) - case model.FieldThinkingEnabled: - return m.OldThinkingEnabled(ctx) - case model.FieldSupportImage: - return m.OldSupportImage(ctx) - case model.FieldIsHidden: - return m.OldIsHidden(ctx) - case model.FieldContextLimit: - return m.OldContextLimit(ctx) - case model.FieldOutputLimit: - return m.OldOutputLimit(ctx) - case model.FieldLastCheckAt: - return m.OldLastCheckAt(ctx) - case model.FieldLastCheckSuccess: - return m.OldLastCheckSuccess(ctx) - case model.FieldLastCheckError: - return m.OldLastCheckError(ctx) - case model.FieldCreatedAt: + case gittask.FieldTaskID: + return m.OldTaskID(ctx) + case gittask.FieldRepoID: + return m.OldRepoID(ctx) + case gittask.FieldSubjectType: + return m.OldSubjectType(ctx) + case gittask.FieldSubjectID: + return m.OldSubjectID(ctx) + case gittask.FieldSubjectNumber: + return m.OldSubjectNumber(ctx) + case gittask.FieldSubjectURL: + return m.OldSubjectURL(ctx) + case gittask.FieldSubjectTitle: + return m.OldSubjectTitle(ctx) + case gittask.FieldPromptID: + return m.OldPromptID(ctx) + case gittask.FieldShowURL: + return m.OldShowURL(ctx) + case gittask.FieldGithubInstallationID: + return m.OldGithubInstallationID(ctx) + case gittask.FieldCreatedAt: return m.OldCreatedAt(ctx) - case model.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown Model field %s", name) + return nil, fmt.Errorf("unknown GitTask field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ModelMutation) SetField(name string, value ent.Value) error { +func (m *GitTaskMutation) SetField(name string, value ent.Value) error { switch name { - case model.FieldDeletedAt: - v, ok := value.(time.Time) + case gittask.FieldTaskID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDeletedAt(v) + m.SetTaskID(v) return nil - case model.FieldUserID: + case gittask.FieldRepoID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) + m.SetRepoID(v) return nil - case model.FieldProvider: + case gittask.FieldSubjectType: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetProvider(v) + m.SetSubjectType(v) return nil - case model.FieldAPIKey: + case gittask.FieldSubjectID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetAPIKey(v) + m.SetSubjectID(v) return nil - case model.FieldBaseURL: - v, ok := value.(string) + case gittask.FieldSubjectNumber: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetBaseURL(v) + m.SetSubjectNumber(v) return nil - case model.FieldModel: + case gittask.FieldSubjectURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModel(v) + m.SetSubjectURL(v) return nil - case model.FieldRemark: + case gittask.FieldSubjectTitle: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRemark(v) - return nil - case model.FieldTemperature: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTemperature(v) + m.SetSubjectTitle(v) return nil - case model.FieldInterfaceType: + case gittask.FieldPromptID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInterfaceType(v) - return nil - case model.FieldWeight: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetWeight(v) - return nil - case model.FieldThinkingEnabled: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetThinkingEnabled(v) - return nil - case model.FieldSupportImage: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSupportImage(v) - return nil - case model.FieldIsHidden: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIsHidden(v) - return nil - case model.FieldContextLimit: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetContextLimit(v) - return nil - case model.FieldOutputLimit: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetOutputLimit(v) - return nil - case model.FieldLastCheckAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLastCheckAt(v) - return nil - case model.FieldLastCheckSuccess: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLastCheckSuccess(v) + m.SetPromptID(v) return nil - case model.FieldLastCheckError: + case gittask.FieldShowURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetLastCheckError(v) + m.SetShowURL(v) return nil - case model.FieldCreatedAt: - v, ok := value.(time.Time) + case gittask.FieldGithubInstallationID: + v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreatedAt(v) + m.SetGithubInstallationID(v) return nil - case model.FieldUpdatedAt: + case gittask.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUpdatedAt(v) + m.SetCreatedAt(v) return nil } - return fmt.Errorf("unknown Model field %s", name) + return fmt.Errorf("unknown GitTask field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ModelMutation) AddedFields() []string { +func (m *GitTaskMutation) AddedFields() []string { var fields []string - if m.addtemperature != nil { - fields = append(fields, model.FieldTemperature) - } - if m.addweight != nil { - fields = append(fields, model.FieldWeight) - } - if m.addcontext_limit != nil { - fields = append(fields, model.FieldContextLimit) + if m.addsubject_number != nil { + fields = append(fields, gittask.FieldSubjectNumber) } - if m.addoutput_limit != nil { - fields = append(fields, model.FieldOutputLimit) + if m.addgithub_installation_id != nil { + fields = append(fields, gittask.FieldGithubInstallationID) } return fields } @@ -14477,16 +15361,12 @@ func (m *ModelMutation) AddedFields() []string { // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ModelMutation) AddedField(name string) (ent.Value, bool) { +func (m *GitTaskMutation) AddedField(name string) (ent.Value, bool) { switch name { - case model.FieldTemperature: - return m.AddedTemperature() - case model.FieldWeight: - return m.AddedWeight() - case model.FieldContextLimit: - return m.AddedContextLimit() - case model.FieldOutputLimit: - return m.AddedOutputLimit() + case gittask.FieldSubjectNumber: + return m.AddedSubjectNumber() + case gittask.FieldGithubInstallationID: + return m.AddedGithubInstallationID() } return nil, false } @@ -14494,901 +15374,8419 @@ func (m *ModelMutation) AddedField(name string) (ent.Value, bool) { // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ModelMutation) AddField(name string, value ent.Value) error { +func (m *GitTaskMutation) AddField(name string, value ent.Value) error { switch name { - case model.FieldTemperature: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddTemperature(v) - return nil - case model.FieldWeight: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddWeight(v) - return nil - case model.FieldContextLimit: + case gittask.FieldSubjectNumber: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddContextLimit(v) + m.AddSubjectNumber(v) return nil - case model.FieldOutputLimit: - v, ok := value.(int) + case gittask.FieldGithubInstallationID: + v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddOutputLimit(v) + m.AddGithubInstallationID(v) return nil } - return fmt.Errorf("unknown Model numeric field %s", name) + return fmt.Errorf("unknown GitTask numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ModelMutation) ClearedFields() []string { +func (m *GitTaskMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(model.FieldDeletedAt) { - fields = append(fields, model.FieldDeletedAt) + if m.FieldCleared(gittask.FieldRepoID) { + fields = append(fields, gittask.FieldRepoID) } - if m.FieldCleared(model.FieldRemark) { - fields = append(fields, model.FieldRemark) + if m.FieldCleared(gittask.FieldSubjectID) { + fields = append(fields, gittask.FieldSubjectID) } - if m.FieldCleared(model.FieldTemperature) { - fields = append(fields, model.FieldTemperature) + if m.FieldCleared(gittask.FieldSubjectNumber) { + fields = append(fields, gittask.FieldSubjectNumber) } - if m.FieldCleared(model.FieldInterfaceType) { - fields = append(fields, model.FieldInterfaceType) + if m.FieldCleared(gittask.FieldSubjectURL) { + fields = append(fields, gittask.FieldSubjectURL) } - if m.FieldCleared(model.FieldLastCheckAt) { - fields = append(fields, model.FieldLastCheckAt) + if m.FieldCleared(gittask.FieldSubjectTitle) { + fields = append(fields, gittask.FieldSubjectTitle) } - if m.FieldCleared(model.FieldLastCheckSuccess) { - fields = append(fields, model.FieldLastCheckSuccess) + if m.FieldCleared(gittask.FieldPromptID) { + fields = append(fields, gittask.FieldPromptID) } - if m.FieldCleared(model.FieldLastCheckError) { - fields = append(fields, model.FieldLastCheckError) + if m.FieldCleared(gittask.FieldShowURL) { + fields = append(fields, gittask.FieldShowURL) + } + if m.FieldCleared(gittask.FieldGithubInstallationID) { + fields = append(fields, gittask.FieldGithubInstallationID) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ModelMutation) FieldCleared(name string) bool { +func (m *GitTaskMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ModelMutation) ClearField(name string) error { +func (m *GitTaskMutation) ClearField(name string) error { switch name { - case model.FieldDeletedAt: - m.ClearDeletedAt() + case gittask.FieldRepoID: + m.ClearRepoID() return nil - case model.FieldRemark: - m.ClearRemark() + case gittask.FieldSubjectID: + m.ClearSubjectID() return nil - case model.FieldTemperature: - m.ClearTemperature() + case gittask.FieldSubjectNumber: + m.ClearSubjectNumber() return nil - case model.FieldInterfaceType: - m.ClearInterfaceType() + case gittask.FieldSubjectURL: + m.ClearSubjectURL() return nil - case model.FieldLastCheckAt: - m.ClearLastCheckAt() + case gittask.FieldSubjectTitle: + m.ClearSubjectTitle() return nil - case model.FieldLastCheckSuccess: - m.ClearLastCheckSuccess() + case gittask.FieldPromptID: + m.ClearPromptID() return nil - case model.FieldLastCheckError: - m.ClearLastCheckError() + case gittask.FieldShowURL: + m.ClearShowURL() + return nil + case gittask.FieldGithubInstallationID: + m.ClearGithubInstallationID() return nil } - return fmt.Errorf("unknown Model nullable field %s", name) + return fmt.Errorf("unknown GitTask nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ModelMutation) ResetField(name string) error { +func (m *GitTaskMutation) ResetField(name string) error { switch name { - case model.FieldDeletedAt: - m.ResetDeletedAt() - return nil - case model.FieldUserID: - m.ResetUserID() - return nil - case model.FieldProvider: - m.ResetProvider() - return nil - case model.FieldAPIKey: - m.ResetAPIKey() - return nil - case model.FieldBaseURL: - m.ResetBaseURL() - return nil - case model.FieldModel: - m.ResetModel() + case gittask.FieldTaskID: + m.ResetTaskID() return nil - case model.FieldRemark: - m.ResetRemark() + case gittask.FieldRepoID: + m.ResetRepoID() return nil - case model.FieldTemperature: - m.ResetTemperature() + case gittask.FieldSubjectType: + m.ResetSubjectType() return nil - case model.FieldInterfaceType: - m.ResetInterfaceType() + case gittask.FieldSubjectID: + m.ResetSubjectID() return nil - case model.FieldWeight: - m.ResetWeight() + case gittask.FieldSubjectNumber: + m.ResetSubjectNumber() return nil - case model.FieldThinkingEnabled: - m.ResetThinkingEnabled() + case gittask.FieldSubjectURL: + m.ResetSubjectURL() return nil - case model.FieldSupportImage: - m.ResetSupportImage() + case gittask.FieldSubjectTitle: + m.ResetSubjectTitle() return nil - case model.FieldIsHidden: - m.ResetIsHidden() + case gittask.FieldPromptID: + m.ResetPromptID() return nil - case model.FieldContextLimit: - m.ResetContextLimit() + case gittask.FieldShowURL: + m.ResetShowURL() return nil - case model.FieldOutputLimit: - m.ResetOutputLimit() + case gittask.FieldGithubInstallationID: + m.ResetGithubInstallationID() return nil - case model.FieldLastCheckAt: - m.ResetLastCheckAt() + case gittask.FieldCreatedAt: + m.ResetCreatedAt() return nil - case model.FieldLastCheckSuccess: - m.ResetLastCheckSuccess() - return nil - case model.FieldLastCheckError: - m.ResetLastCheckError() - return nil - case model.FieldCreatedAt: - m.ResetCreatedAt() + } + return fmt.Errorf("unknown GitTask field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *GitTaskMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.task != nil { + edges = append(edges, gittask.EdgeTask) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *GitTaskMutation) AddedIDs(name string) []ent.Value { + switch name { + case gittask.EdgeTask: + if id := m.task; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *GitTaskMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *GitTaskMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *GitTaskMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedtask { + edges = append(edges, gittask.EdgeTask) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *GitTaskMutation) EdgeCleared(name string) bool { + switch name { + case gittask.EdgeTask: + return m.clearedtask + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *GitTaskMutation) ClearEdge(name string) error { + switch name { + case gittask.EdgeTask: + m.ClearTask() return nil - case model.FieldUpdatedAt: - m.ResetUpdatedAt() + } + return fmt.Errorf("unknown GitTask unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *GitTaskMutation) ResetEdge(name string) error { + switch name { + case gittask.EdgeTask: + m.ResetTask() return nil } - return fmt.Errorf("unknown Model field %s", name) + return fmt.Errorf("unknown GitTask edge %s", name) +} + +// HostMutation represents an operation that mutates the Host nodes in the graph. +type HostMutation struct { + config + op Op + typ string + id *string + deleted_at *time.Time + hostname *string + arch *string + cores *int + addcores *int + weight *int + addweight *int + memory *int64 + addmemory *int64 + disk *int64 + adddisk *int64 + os *string + external_ip *string + internal_ip *string + version *string + machine_id *string + remark *string + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + vms map[string]struct{} + removedvms map[string]struct{} + clearedvms bool + user *uuid.UUID + cleareduser bool + groups map[uuid.UUID]struct{} + removedgroups map[uuid.UUID]struct{} + clearedgroups bool + git_bots map[uuid.UUID]struct{} + removedgit_bots map[uuid.UUID]struct{} + clearedgit_bots bool + team_group_hosts map[uuid.UUID]struct{} + removedteam_group_hosts map[uuid.UUID]struct{} + clearedteam_group_hosts bool + done bool + oldValue func(context.Context) (*Host, error) + predicates []predicate.Host +} + +var _ ent.Mutation = (*HostMutation)(nil) + +// hostOption allows management of the mutation configuration using functional options. +type hostOption func(*HostMutation) + +// newHostMutation creates new mutation for the Host entity. +func newHostMutation(c config, op Op, opts ...hostOption) *HostMutation { + m := &HostMutation{ + config: c, + op: op, + typ: TypeHost, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withHostID sets the ID field of the mutation. +func withHostID(id string) hostOption { + return func(m *HostMutation) { + var ( + err error + once sync.Once + value *Host + ) + m.oldValue = func(ctx context.Context) (*Host, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Host.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withHost sets the old Host of the mutation. +func withHost(node *Host) hostOption { + return func(m *HostMutation) { + m.oldValue = func(context.Context) (*Host, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m HostMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m HostMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Host entities. +func (m *HostMutation) SetID(id string) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *HostMutation) ID() (id string, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *HostMutation) IDs(ctx context.Context) ([]string, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []string{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Host.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *HostMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *HostMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *HostMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[host.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *HostMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[host.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *HostMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, host.FieldDeletedAt) +} + +// SetUserID sets the "user_id" field. +func (m *HostMutation) SetUserID(u uuid.UUID) { + m.user = &u +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *HostMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *HostMutation) ResetUserID() { + m.user = nil +} + +// SetHostname sets the "hostname" field. +func (m *HostMutation) SetHostname(s string) { + m.hostname = &s +} + +// Hostname returns the value of the "hostname" field in the mutation. +func (m *HostMutation) Hostname() (r string, exists bool) { + v := m.hostname + if v == nil { + return + } + return *v, true +} + +// OldHostname returns the old "hostname" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldHostname(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHostname is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHostname requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHostname: %w", err) + } + return oldValue.Hostname, nil +} + +// ClearHostname clears the value of the "hostname" field. +func (m *HostMutation) ClearHostname() { + m.hostname = nil + m.clearedFields[host.FieldHostname] = struct{}{} +} + +// HostnameCleared returns if the "hostname" field was cleared in this mutation. +func (m *HostMutation) HostnameCleared() bool { + _, ok := m.clearedFields[host.FieldHostname] + return ok +} + +// ResetHostname resets all changes to the "hostname" field. +func (m *HostMutation) ResetHostname() { + m.hostname = nil + delete(m.clearedFields, host.FieldHostname) +} + +// SetArch sets the "arch" field. +func (m *HostMutation) SetArch(s string) { + m.arch = &s +} + +// Arch returns the value of the "arch" field in the mutation. +func (m *HostMutation) Arch() (r string, exists bool) { + v := m.arch + if v == nil { + return + } + return *v, true +} + +// OldArch returns the old "arch" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldArch(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArch is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArch requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArch: %w", err) + } + return oldValue.Arch, nil +} + +// ClearArch clears the value of the "arch" field. +func (m *HostMutation) ClearArch() { + m.arch = nil + m.clearedFields[host.FieldArch] = struct{}{} +} + +// ArchCleared returns if the "arch" field was cleared in this mutation. +func (m *HostMutation) ArchCleared() bool { + _, ok := m.clearedFields[host.FieldArch] + return ok +} + +// ResetArch resets all changes to the "arch" field. +func (m *HostMutation) ResetArch() { + m.arch = nil + delete(m.clearedFields, host.FieldArch) +} + +// SetCores sets the "cores" field. +func (m *HostMutation) SetCores(i int) { + m.cores = &i + m.addcores = nil +} + +// Cores returns the value of the "cores" field in the mutation. +func (m *HostMutation) Cores() (r int, exists bool) { + v := m.cores + if v == nil { + return + } + return *v, true +} + +// OldCores returns the old "cores" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldCores(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCores is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCores requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCores: %w", err) + } + return oldValue.Cores, nil +} + +// AddCores adds i to the "cores" field. +func (m *HostMutation) AddCores(i int) { + if m.addcores != nil { + *m.addcores += i + } else { + m.addcores = &i + } +} + +// AddedCores returns the value that was added to the "cores" field in this mutation. +func (m *HostMutation) AddedCores() (r int, exists bool) { + v := m.addcores + if v == nil { + return + } + return *v, true +} + +// ClearCores clears the value of the "cores" field. +func (m *HostMutation) ClearCores() { + m.cores = nil + m.addcores = nil + m.clearedFields[host.FieldCores] = struct{}{} +} + +// CoresCleared returns if the "cores" field was cleared in this mutation. +func (m *HostMutation) CoresCleared() bool { + _, ok := m.clearedFields[host.FieldCores] + return ok +} + +// ResetCores resets all changes to the "cores" field. +func (m *HostMutation) ResetCores() { + m.cores = nil + m.addcores = nil + delete(m.clearedFields, host.FieldCores) +} + +// SetWeight sets the "weight" field. +func (m *HostMutation) SetWeight(i int) { + m.weight = &i + m.addweight = nil +} + +// Weight returns the value of the "weight" field in the mutation. +func (m *HostMutation) Weight() (r int, exists bool) { + v := m.weight + if v == nil { + return + } + return *v, true +} + +// OldWeight returns the old "weight" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldWeight(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWeight is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWeight requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWeight: %w", err) + } + return oldValue.Weight, nil +} + +// AddWeight adds i to the "weight" field. +func (m *HostMutation) AddWeight(i int) { + if m.addweight != nil { + *m.addweight += i + } else { + m.addweight = &i + } +} + +// AddedWeight returns the value that was added to the "weight" field in this mutation. +func (m *HostMutation) AddedWeight() (r int, exists bool) { + v := m.addweight + if v == nil { + return + } + return *v, true +} + +// ResetWeight resets all changes to the "weight" field. +func (m *HostMutation) ResetWeight() { + m.weight = nil + m.addweight = nil +} + +// SetMemory sets the "memory" field. +func (m *HostMutation) SetMemory(i int64) { + m.memory = &i + m.addmemory = nil +} + +// Memory returns the value of the "memory" field in the mutation. +func (m *HostMutation) Memory() (r int64, exists bool) { + v := m.memory + if v == nil { + return + } + return *v, true +} + +// OldMemory returns the old "memory" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldMemory(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMemory is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMemory requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMemory: %w", err) + } + return oldValue.Memory, nil +} + +// AddMemory adds i to the "memory" field. +func (m *HostMutation) AddMemory(i int64) { + if m.addmemory != nil { + *m.addmemory += i + } else { + m.addmemory = &i + } +} + +// AddedMemory returns the value that was added to the "memory" field in this mutation. +func (m *HostMutation) AddedMemory() (r int64, exists bool) { + v := m.addmemory + if v == nil { + return + } + return *v, true +} + +// ClearMemory clears the value of the "memory" field. +func (m *HostMutation) ClearMemory() { + m.memory = nil + m.addmemory = nil + m.clearedFields[host.FieldMemory] = struct{}{} +} + +// MemoryCleared returns if the "memory" field was cleared in this mutation. +func (m *HostMutation) MemoryCleared() bool { + _, ok := m.clearedFields[host.FieldMemory] + return ok +} + +// ResetMemory resets all changes to the "memory" field. +func (m *HostMutation) ResetMemory() { + m.memory = nil + m.addmemory = nil + delete(m.clearedFields, host.FieldMemory) +} + +// SetDisk sets the "disk" field. +func (m *HostMutation) SetDisk(i int64) { + m.disk = &i + m.adddisk = nil +} + +// Disk returns the value of the "disk" field in the mutation. +func (m *HostMutation) Disk() (r int64, exists bool) { + v := m.disk + if v == nil { + return + } + return *v, true +} + +// OldDisk returns the old "disk" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldDisk(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDisk is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDisk requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDisk: %w", err) + } + return oldValue.Disk, nil +} + +// AddDisk adds i to the "disk" field. +func (m *HostMutation) AddDisk(i int64) { + if m.adddisk != nil { + *m.adddisk += i + } else { + m.adddisk = &i + } +} + +// AddedDisk returns the value that was added to the "disk" field in this mutation. +func (m *HostMutation) AddedDisk() (r int64, exists bool) { + v := m.adddisk + if v == nil { + return + } + return *v, true +} + +// ClearDisk clears the value of the "disk" field. +func (m *HostMutation) ClearDisk() { + m.disk = nil + m.adddisk = nil + m.clearedFields[host.FieldDisk] = struct{}{} +} + +// DiskCleared returns if the "disk" field was cleared in this mutation. +func (m *HostMutation) DiskCleared() bool { + _, ok := m.clearedFields[host.FieldDisk] + return ok +} + +// ResetDisk resets all changes to the "disk" field. +func (m *HostMutation) ResetDisk() { + m.disk = nil + m.adddisk = nil + delete(m.clearedFields, host.FieldDisk) +} + +// SetOs sets the "os" field. +func (m *HostMutation) SetOs(s string) { + m.os = &s +} + +// Os returns the value of the "os" field in the mutation. +func (m *HostMutation) Os() (r string, exists bool) { + v := m.os + if v == nil { + return + } + return *v, true +} + +// OldOs returns the old "os" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldOs(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOs is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOs requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOs: %w", err) + } + return oldValue.Os, nil +} + +// ClearOs clears the value of the "os" field. +func (m *HostMutation) ClearOs() { + m.os = nil + m.clearedFields[host.FieldOs] = struct{}{} +} + +// OsCleared returns if the "os" field was cleared in this mutation. +func (m *HostMutation) OsCleared() bool { + _, ok := m.clearedFields[host.FieldOs] + return ok +} + +// ResetOs resets all changes to the "os" field. +func (m *HostMutation) ResetOs() { + m.os = nil + delete(m.clearedFields, host.FieldOs) +} + +// SetExternalIP sets the "external_ip" field. +func (m *HostMutation) SetExternalIP(s string) { + m.external_ip = &s +} + +// ExternalIP returns the value of the "external_ip" field in the mutation. +func (m *HostMutation) ExternalIP() (r string, exists bool) { + v := m.external_ip + if v == nil { + return + } + return *v, true +} + +// OldExternalIP returns the old "external_ip" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldExternalIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExternalIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExternalIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExternalIP: %w", err) + } + return oldValue.ExternalIP, nil +} + +// ClearExternalIP clears the value of the "external_ip" field. +func (m *HostMutation) ClearExternalIP() { + m.external_ip = nil + m.clearedFields[host.FieldExternalIP] = struct{}{} +} + +// ExternalIPCleared returns if the "external_ip" field was cleared in this mutation. +func (m *HostMutation) ExternalIPCleared() bool { + _, ok := m.clearedFields[host.FieldExternalIP] + return ok +} + +// ResetExternalIP resets all changes to the "external_ip" field. +func (m *HostMutation) ResetExternalIP() { + m.external_ip = nil + delete(m.clearedFields, host.FieldExternalIP) +} + +// SetInternalIP sets the "internal_ip" field. +func (m *HostMutation) SetInternalIP(s string) { + m.internal_ip = &s +} + +// InternalIP returns the value of the "internal_ip" field in the mutation. +func (m *HostMutation) InternalIP() (r string, exists bool) { + v := m.internal_ip + if v == nil { + return + } + return *v, true +} + +// OldInternalIP returns the old "internal_ip" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldInternalIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInternalIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInternalIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInternalIP: %w", err) + } + return oldValue.InternalIP, nil +} + +// ClearInternalIP clears the value of the "internal_ip" field. +func (m *HostMutation) ClearInternalIP() { + m.internal_ip = nil + m.clearedFields[host.FieldInternalIP] = struct{}{} +} + +// InternalIPCleared returns if the "internal_ip" field was cleared in this mutation. +func (m *HostMutation) InternalIPCleared() bool { + _, ok := m.clearedFields[host.FieldInternalIP] + return ok +} + +// ResetInternalIP resets all changes to the "internal_ip" field. +func (m *HostMutation) ResetInternalIP() { + m.internal_ip = nil + delete(m.clearedFields, host.FieldInternalIP) +} + +// SetVersion sets the "version" field. +func (m *HostMutation) SetVersion(s string) { + m.version = &s +} + +// Version returns the value of the "version" field in the mutation. +func (m *HostMutation) Version() (r string, exists bool) { + v := m.version + if v == nil { + return + } + return *v, true +} + +// OldVersion returns the old "version" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersion: %w", err) + } + return oldValue.Version, nil +} + +// ClearVersion clears the value of the "version" field. +func (m *HostMutation) ClearVersion() { + m.version = nil + m.clearedFields[host.FieldVersion] = struct{}{} +} + +// VersionCleared returns if the "version" field was cleared in this mutation. +func (m *HostMutation) VersionCleared() bool { + _, ok := m.clearedFields[host.FieldVersion] + return ok +} + +// ResetVersion resets all changes to the "version" field. +func (m *HostMutation) ResetVersion() { + m.version = nil + delete(m.clearedFields, host.FieldVersion) +} + +// SetMachineID sets the "machine_id" field. +func (m *HostMutation) SetMachineID(s string) { + m.machine_id = &s +} + +// MachineID returns the value of the "machine_id" field in the mutation. +func (m *HostMutation) MachineID() (r string, exists bool) { + v := m.machine_id + if v == nil { + return + } + return *v, true +} + +// OldMachineID returns the old "machine_id" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldMachineID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMachineID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMachineID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMachineID: %w", err) + } + return oldValue.MachineID, nil +} + +// ClearMachineID clears the value of the "machine_id" field. +func (m *HostMutation) ClearMachineID() { + m.machine_id = nil + m.clearedFields[host.FieldMachineID] = struct{}{} +} + +// MachineIDCleared returns if the "machine_id" field was cleared in this mutation. +func (m *HostMutation) MachineIDCleared() bool { + _, ok := m.clearedFields[host.FieldMachineID] + return ok +} + +// ResetMachineID resets all changes to the "machine_id" field. +func (m *HostMutation) ResetMachineID() { + m.machine_id = nil + delete(m.clearedFields, host.FieldMachineID) +} + +// SetRemark sets the "remark" field. +func (m *HostMutation) SetRemark(s string) { + m.remark = &s +} + +// Remark returns the value of the "remark" field in the mutation. +func (m *HostMutation) Remark() (r string, exists bool) { + v := m.remark + if v == nil { + return + } + return *v, true +} + +// OldRemark returns the old "remark" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldRemark(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRemark is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRemark requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRemark: %w", err) + } + return oldValue.Remark, nil +} + +// ClearRemark clears the value of the "remark" field. +func (m *HostMutation) ClearRemark() { + m.remark = nil + m.clearedFields[host.FieldRemark] = struct{}{} +} + +// RemarkCleared returns if the "remark" field was cleared in this mutation. +func (m *HostMutation) RemarkCleared() bool { + _, ok := m.clearedFields[host.FieldRemark] + return ok +} + +// ResetRemark resets all changes to the "remark" field. +func (m *HostMutation) ResetRemark() { + m.remark = nil + delete(m.clearedFields, host.FieldRemark) +} + +// SetCreatedAt sets the "created_at" field. +func (m *HostMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *HostMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *HostMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *HostMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *HostMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Host entity. +// If the Host object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *HostMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids. +func (m *HostMutation) AddVMIDs(ids ...string) { + if m.vms == nil { + m.vms = make(map[string]struct{}) + } + for i := range ids { + m.vms[ids[i]] = struct{}{} + } +} + +// ClearVms clears the "vms" edge to the VirtualMachine entity. +func (m *HostMutation) ClearVms() { + m.clearedvms = true +} + +// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared. +func (m *HostMutation) VmsCleared() bool { + return m.clearedvms +} + +// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs. +func (m *HostMutation) RemoveVMIDs(ids ...string) { + if m.removedvms == nil { + m.removedvms = make(map[string]struct{}) + } + for i := range ids { + delete(m.vms, ids[i]) + m.removedvms[ids[i]] = struct{}{} + } +} + +// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity. +func (m *HostMutation) RemovedVmsIDs() (ids []string) { + for id := range m.removedvms { + ids = append(ids, id) + } + return +} + +// VmsIDs returns the "vms" edge IDs in the mutation. +func (m *HostMutation) VmsIDs() (ids []string) { + for id := range m.vms { + ids = append(ids, id) + } + return +} + +// ResetVms resets all changes to the "vms" edge. +func (m *HostMutation) ResetVms() { + m.vms = nil + m.clearedvms = false + m.removedvms = nil +} + +// ClearUser clears the "user" edge to the User entity. +func (m *HostMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[host.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *HostMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *HostMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *HostMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids. +func (m *HostMutation) AddGroupIDs(ids ...uuid.UUID) { + if m.groups == nil { + m.groups = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.groups[ids[i]] = struct{}{} + } +} + +// ClearGroups clears the "groups" edge to the TeamGroup entity. +func (m *HostMutation) ClearGroups() { + m.clearedgroups = true +} + +// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared. +func (m *HostMutation) GroupsCleared() bool { + return m.clearedgroups +} + +// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs. +func (m *HostMutation) RemoveGroupIDs(ids ...uuid.UUID) { + if m.removedgroups == nil { + m.removedgroups = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.groups, ids[i]) + m.removedgroups[ids[i]] = struct{}{} + } +} + +// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity. +func (m *HostMutation) RemovedGroupsIDs() (ids []uuid.UUID) { + for id := range m.removedgroups { + ids = append(ids, id) + } + return +} + +// GroupsIDs returns the "groups" edge IDs in the mutation. +func (m *HostMutation) GroupsIDs() (ids []uuid.UUID) { + for id := range m.groups { + ids = append(ids, id) + } + return +} + +// ResetGroups resets all changes to the "groups" edge. +func (m *HostMutation) ResetGroups() { + m.groups = nil + m.clearedgroups = false + m.removedgroups = nil +} + +// AddGitBotIDs adds the "git_bots" edge to the GitBot entity by ids. +func (m *HostMutation) AddGitBotIDs(ids ...uuid.UUID) { + if m.git_bots == nil { + m.git_bots = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.git_bots[ids[i]] = struct{}{} + } +} + +// ClearGitBots clears the "git_bots" edge to the GitBot entity. +func (m *HostMutation) ClearGitBots() { + m.clearedgit_bots = true +} + +// GitBotsCleared reports if the "git_bots" edge to the GitBot entity was cleared. +func (m *HostMutation) GitBotsCleared() bool { + return m.clearedgit_bots +} + +// RemoveGitBotIDs removes the "git_bots" edge to the GitBot entity by IDs. +func (m *HostMutation) RemoveGitBotIDs(ids ...uuid.UUID) { + if m.removedgit_bots == nil { + m.removedgit_bots = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.git_bots, ids[i]) + m.removedgit_bots[ids[i]] = struct{}{} + } +} + +// RemovedGitBots returns the removed IDs of the "git_bots" edge to the GitBot entity. +func (m *HostMutation) RemovedGitBotsIDs() (ids []uuid.UUID) { + for id := range m.removedgit_bots { + ids = append(ids, id) + } + return +} + +// GitBotsIDs returns the "git_bots" edge IDs in the mutation. +func (m *HostMutation) GitBotsIDs() (ids []uuid.UUID) { + for id := range m.git_bots { + ids = append(ids, id) + } + return +} + +// ResetGitBots resets all changes to the "git_bots" edge. +func (m *HostMutation) ResetGitBots() { + m.git_bots = nil + m.clearedgit_bots = false + m.removedgit_bots = nil +} + +// AddTeamGroupHostIDs adds the "team_group_hosts" edge to the TeamGroupHost entity by ids. +func (m *HostMutation) AddTeamGroupHostIDs(ids ...uuid.UUID) { + if m.team_group_hosts == nil { + m.team_group_hosts = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.team_group_hosts[ids[i]] = struct{}{} + } +} + +// ClearTeamGroupHosts clears the "team_group_hosts" edge to the TeamGroupHost entity. +func (m *HostMutation) ClearTeamGroupHosts() { + m.clearedteam_group_hosts = true +} + +// TeamGroupHostsCleared reports if the "team_group_hosts" edge to the TeamGroupHost entity was cleared. +func (m *HostMutation) TeamGroupHostsCleared() bool { + return m.clearedteam_group_hosts +} + +// RemoveTeamGroupHostIDs removes the "team_group_hosts" edge to the TeamGroupHost entity by IDs. +func (m *HostMutation) RemoveTeamGroupHostIDs(ids ...uuid.UUID) { + if m.removedteam_group_hosts == nil { + m.removedteam_group_hosts = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.team_group_hosts, ids[i]) + m.removedteam_group_hosts[ids[i]] = struct{}{} + } +} + +// RemovedTeamGroupHosts returns the removed IDs of the "team_group_hosts" edge to the TeamGroupHost entity. +func (m *HostMutation) RemovedTeamGroupHostsIDs() (ids []uuid.UUID) { + for id := range m.removedteam_group_hosts { + ids = append(ids, id) + } + return +} + +// TeamGroupHostsIDs returns the "team_group_hosts" edge IDs in the mutation. +func (m *HostMutation) TeamGroupHostsIDs() (ids []uuid.UUID) { + for id := range m.team_group_hosts { + ids = append(ids, id) + } + return +} + +// ResetTeamGroupHosts resets all changes to the "team_group_hosts" edge. +func (m *HostMutation) ResetTeamGroupHosts() { + m.team_group_hosts = nil + m.clearedteam_group_hosts = false + m.removedteam_group_hosts = nil +} + +// Where appends a list predicates to the HostMutation builder. +func (m *HostMutation) Where(ps ...predicate.Host) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the HostMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *HostMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Host, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *HostMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *HostMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Host). +func (m *HostMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *HostMutation) Fields() []string { + fields := make([]string, 0, 16) + if m.deleted_at != nil { + fields = append(fields, host.FieldDeletedAt) + } + if m.user != nil { + fields = append(fields, host.FieldUserID) + } + if m.hostname != nil { + fields = append(fields, host.FieldHostname) + } + if m.arch != nil { + fields = append(fields, host.FieldArch) + } + if m.cores != nil { + fields = append(fields, host.FieldCores) + } + if m.weight != nil { + fields = append(fields, host.FieldWeight) + } + if m.memory != nil { + fields = append(fields, host.FieldMemory) + } + if m.disk != nil { + fields = append(fields, host.FieldDisk) + } + if m.os != nil { + fields = append(fields, host.FieldOs) + } + if m.external_ip != nil { + fields = append(fields, host.FieldExternalIP) + } + if m.internal_ip != nil { + fields = append(fields, host.FieldInternalIP) + } + if m.version != nil { + fields = append(fields, host.FieldVersion) + } + if m.machine_id != nil { + fields = append(fields, host.FieldMachineID) + } + if m.remark != nil { + fields = append(fields, host.FieldRemark) + } + if m.created_at != nil { + fields = append(fields, host.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, host.FieldUpdatedAt) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *HostMutation) Field(name string) (ent.Value, bool) { + switch name { + case host.FieldDeletedAt: + return m.DeletedAt() + case host.FieldUserID: + return m.UserID() + case host.FieldHostname: + return m.Hostname() + case host.FieldArch: + return m.Arch() + case host.FieldCores: + return m.Cores() + case host.FieldWeight: + return m.Weight() + case host.FieldMemory: + return m.Memory() + case host.FieldDisk: + return m.Disk() + case host.FieldOs: + return m.Os() + case host.FieldExternalIP: + return m.ExternalIP() + case host.FieldInternalIP: + return m.InternalIP() + case host.FieldVersion: + return m.Version() + case host.FieldMachineID: + return m.MachineID() + case host.FieldRemark: + return m.Remark() + case host.FieldCreatedAt: + return m.CreatedAt() + case host.FieldUpdatedAt: + return m.UpdatedAt() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *HostMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case host.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case host.FieldUserID: + return m.OldUserID(ctx) + case host.FieldHostname: + return m.OldHostname(ctx) + case host.FieldArch: + return m.OldArch(ctx) + case host.FieldCores: + return m.OldCores(ctx) + case host.FieldWeight: + return m.OldWeight(ctx) + case host.FieldMemory: + return m.OldMemory(ctx) + case host.FieldDisk: + return m.OldDisk(ctx) + case host.FieldOs: + return m.OldOs(ctx) + case host.FieldExternalIP: + return m.OldExternalIP(ctx) + case host.FieldInternalIP: + return m.OldInternalIP(ctx) + case host.FieldVersion: + return m.OldVersion(ctx) + case host.FieldMachineID: + return m.OldMachineID(ctx) + case host.FieldRemark: + return m.OldRemark(ctx) + case host.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case host.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + } + return nil, fmt.Errorf("unknown Host field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *HostMutation) SetField(name string, value ent.Value) error { + switch name { + case host.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case host.FieldUserID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case host.FieldHostname: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHostname(v) + return nil + case host.FieldArch: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArch(v) + return nil + case host.FieldCores: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCores(v) + return nil + case host.FieldWeight: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWeight(v) + return nil + case host.FieldMemory: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMemory(v) + return nil + case host.FieldDisk: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDisk(v) + return nil + case host.FieldOs: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOs(v) + return nil + case host.FieldExternalIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExternalIP(v) + return nil + case host.FieldInternalIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInternalIP(v) + return nil + case host.FieldVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersion(v) + return nil + case host.FieldMachineID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMachineID(v) + return nil + case host.FieldRemark: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRemark(v) + return nil + case host.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case host.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + } + return fmt.Errorf("unknown Host field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *HostMutation) AddedFields() []string { + var fields []string + if m.addcores != nil { + fields = append(fields, host.FieldCores) + } + if m.addweight != nil { + fields = append(fields, host.FieldWeight) + } + if m.addmemory != nil { + fields = append(fields, host.FieldMemory) + } + if m.adddisk != nil { + fields = append(fields, host.FieldDisk) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *HostMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case host.FieldCores: + return m.AddedCores() + case host.FieldWeight: + return m.AddedWeight() + case host.FieldMemory: + return m.AddedMemory() + case host.FieldDisk: + return m.AddedDisk() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *HostMutation) AddField(name string, value ent.Value) error { + switch name { + case host.FieldCores: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCores(v) + return nil + case host.FieldWeight: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddWeight(v) + return nil + case host.FieldMemory: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMemory(v) + return nil + case host.FieldDisk: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDisk(v) + return nil + } + return fmt.Errorf("unknown Host numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *HostMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(host.FieldDeletedAt) { + fields = append(fields, host.FieldDeletedAt) + } + if m.FieldCleared(host.FieldHostname) { + fields = append(fields, host.FieldHostname) + } + if m.FieldCleared(host.FieldArch) { + fields = append(fields, host.FieldArch) + } + if m.FieldCleared(host.FieldCores) { + fields = append(fields, host.FieldCores) + } + if m.FieldCleared(host.FieldMemory) { + fields = append(fields, host.FieldMemory) + } + if m.FieldCleared(host.FieldDisk) { + fields = append(fields, host.FieldDisk) + } + if m.FieldCleared(host.FieldOs) { + fields = append(fields, host.FieldOs) + } + if m.FieldCleared(host.FieldExternalIP) { + fields = append(fields, host.FieldExternalIP) + } + if m.FieldCleared(host.FieldInternalIP) { + fields = append(fields, host.FieldInternalIP) + } + if m.FieldCleared(host.FieldVersion) { + fields = append(fields, host.FieldVersion) + } + if m.FieldCleared(host.FieldMachineID) { + fields = append(fields, host.FieldMachineID) + } + if m.FieldCleared(host.FieldRemark) { + fields = append(fields, host.FieldRemark) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *HostMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *HostMutation) ClearField(name string) error { + switch name { + case host.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case host.FieldHostname: + m.ClearHostname() + return nil + case host.FieldArch: + m.ClearArch() + return nil + case host.FieldCores: + m.ClearCores() + return nil + case host.FieldMemory: + m.ClearMemory() + return nil + case host.FieldDisk: + m.ClearDisk() + return nil + case host.FieldOs: + m.ClearOs() + return nil + case host.FieldExternalIP: + m.ClearExternalIP() + return nil + case host.FieldInternalIP: + m.ClearInternalIP() + return nil + case host.FieldVersion: + m.ClearVersion() + return nil + case host.FieldMachineID: + m.ClearMachineID() + return nil + case host.FieldRemark: + m.ClearRemark() + return nil + } + return fmt.Errorf("unknown Host nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *HostMutation) ResetField(name string) error { + switch name { + case host.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case host.FieldUserID: + m.ResetUserID() + return nil + case host.FieldHostname: + m.ResetHostname() + return nil + case host.FieldArch: + m.ResetArch() + return nil + case host.FieldCores: + m.ResetCores() + return nil + case host.FieldWeight: + m.ResetWeight() + return nil + case host.FieldMemory: + m.ResetMemory() + return nil + case host.FieldDisk: + m.ResetDisk() + return nil + case host.FieldOs: + m.ResetOs() + return nil + case host.FieldExternalIP: + m.ResetExternalIP() + return nil + case host.FieldInternalIP: + m.ResetInternalIP() + return nil + case host.FieldVersion: + m.ResetVersion() + return nil + case host.FieldMachineID: + m.ResetMachineID() + return nil + case host.FieldRemark: + m.ResetRemark() + return nil + case host.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case host.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + } + return fmt.Errorf("unknown Host field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *HostMutation) AddedEdges() []string { + edges := make([]string, 0, 5) + if m.vms != nil { + edges = append(edges, host.EdgeVms) + } + if m.user != nil { + edges = append(edges, host.EdgeUser) + } + if m.groups != nil { + edges = append(edges, host.EdgeGroups) + } + if m.git_bots != nil { + edges = append(edges, host.EdgeGitBots) + } + if m.team_group_hosts != nil { + edges = append(edges, host.EdgeTeamGroupHosts) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *HostMutation) AddedIDs(name string) []ent.Value { + switch name { + case host.EdgeVms: + ids := make([]ent.Value, 0, len(m.vms)) + for id := range m.vms { + ids = append(ids, id) + } + return ids + case host.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + case host.EdgeGroups: + ids := make([]ent.Value, 0, len(m.groups)) + for id := range m.groups { + ids = append(ids, id) + } + return ids + case host.EdgeGitBots: + ids := make([]ent.Value, 0, len(m.git_bots)) + for id := range m.git_bots { + ids = append(ids, id) + } + return ids + case host.EdgeTeamGroupHosts: + ids := make([]ent.Value, 0, len(m.team_group_hosts)) + for id := range m.team_group_hosts { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *HostMutation) RemovedEdges() []string { + edges := make([]string, 0, 5) + if m.removedvms != nil { + edges = append(edges, host.EdgeVms) + } + if m.removedgroups != nil { + edges = append(edges, host.EdgeGroups) + } + if m.removedgit_bots != nil { + edges = append(edges, host.EdgeGitBots) + } + if m.removedteam_group_hosts != nil { + edges = append(edges, host.EdgeTeamGroupHosts) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *HostMutation) RemovedIDs(name string) []ent.Value { + switch name { + case host.EdgeVms: + ids := make([]ent.Value, 0, len(m.removedvms)) + for id := range m.removedvms { + ids = append(ids, id) + } + return ids + case host.EdgeGroups: + ids := make([]ent.Value, 0, len(m.removedgroups)) + for id := range m.removedgroups { + ids = append(ids, id) + } + return ids + case host.EdgeGitBots: + ids := make([]ent.Value, 0, len(m.removedgit_bots)) + for id := range m.removedgit_bots { + ids = append(ids, id) + } + return ids + case host.EdgeTeamGroupHosts: + ids := make([]ent.Value, 0, len(m.removedteam_group_hosts)) + for id := range m.removedteam_group_hosts { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *HostMutation) ClearedEdges() []string { + edges := make([]string, 0, 5) + if m.clearedvms { + edges = append(edges, host.EdgeVms) + } + if m.cleareduser { + edges = append(edges, host.EdgeUser) + } + if m.clearedgroups { + edges = append(edges, host.EdgeGroups) + } + if m.clearedgit_bots { + edges = append(edges, host.EdgeGitBots) + } + if m.clearedteam_group_hosts { + edges = append(edges, host.EdgeTeamGroupHosts) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *HostMutation) EdgeCleared(name string) bool { + switch name { + case host.EdgeVms: + return m.clearedvms + case host.EdgeUser: + return m.cleareduser + case host.EdgeGroups: + return m.clearedgroups + case host.EdgeGitBots: + return m.clearedgit_bots + case host.EdgeTeamGroupHosts: + return m.clearedteam_group_hosts + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *HostMutation) ClearEdge(name string) error { + switch name { + case host.EdgeUser: + m.ClearUser() + return nil + } + return fmt.Errorf("unknown Host unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *HostMutation) ResetEdge(name string) error { + switch name { + case host.EdgeVms: + m.ResetVms() + return nil + case host.EdgeUser: + m.ResetUser() + return nil + case host.EdgeGroups: + m.ResetGroups() + return nil + case host.EdgeGitBots: + m.ResetGitBots() + return nil + case host.EdgeTeamGroupHosts: + m.ResetTeamGroupHosts() + return nil + } + return fmt.Errorf("unknown Host edge %s", name) +} + +// ImageMutation represents an operation that mutates the Image nodes in the graph. +type ImageMutation struct { + config + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + name *string + remark *string + extension_package_id *string + extension_image_id *string + extension_version *string + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + user *uuid.UUID + cleareduser bool + teams map[uuid.UUID]struct{} + removedteams map[uuid.UUID]struct{} + clearedteams bool + groups map[uuid.UUID]struct{} + removedgroups map[uuid.UUID]struct{} + clearedgroups bool + project_tasks map[uuid.UUID]struct{} + removedproject_tasks map[uuid.UUID]struct{} + clearedproject_tasks bool + projects map[uuid.UUID]struct{} + removedprojects map[uuid.UUID]struct{} + clearedprojects bool + extension_archives map[uuid.UUID]struct{} + removedextension_archives map[uuid.UUID]struct{} + clearedextension_archives bool + team_images map[uuid.UUID]struct{} + removedteam_images map[uuid.UUID]struct{} + clearedteam_images bool + team_group_images map[uuid.UUID]struct{} + removedteam_group_images map[uuid.UUID]struct{} + clearedteam_group_images bool + done bool + oldValue func(context.Context) (*Image, error) + predicates []predicate.Image +} + +var _ ent.Mutation = (*ImageMutation)(nil) + +// imageOption allows management of the mutation configuration using functional options. +type imageOption func(*ImageMutation) + +// newImageMutation creates new mutation for the Image entity. +func newImageMutation(c config, op Op, opts ...imageOption) *ImageMutation { + m := &ImageMutation{ + config: c, + op: op, + typ: TypeImage, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withImageID sets the ID field of the mutation. +func withImageID(id uuid.UUID) imageOption { + return func(m *ImageMutation) { + var ( + err error + once sync.Once + value *Image + ) + m.oldValue = func(ctx context.Context) (*Image, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Image.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withImage sets the old Image of the mutation. +func withImage(node *Image) imageOption { + return func(m *ImageMutation) { + m.oldValue = func(context.Context) (*Image, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ImageMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ImageMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Image entities. +func (m *ImageMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ImageMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ImageMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Image.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *ImageMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *ImageMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Image entity. +// If the Image object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ImageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *ImageMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[image.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *ImageMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[image.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *ImageMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, image.FieldDeletedAt) +} + +// SetUserID sets the "user_id" field. +func (m *ImageMutation) SetUserID(u uuid.UUID) { + m.user = &u +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *ImageMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the Image entity. +// If the Image object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ImageMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *ImageMutation) ResetUserID() { + m.user = nil +} + +// SetName sets the "name" field. +func (m *ImageMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ImageMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Image entity. +// If the Image object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ImageMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *ImageMutation) ResetName() { + m.name = nil +} + +// SetRemark sets the "remark" field. +func (m *ImageMutation) SetRemark(s string) { + m.remark = &s +} + +// Remark returns the value of the "remark" field in the mutation. +func (m *ImageMutation) Remark() (r string, exists bool) { + v := m.remark + if v == nil { + return + } + return *v, true +} + +// OldRemark returns the old "remark" field's value of the Image entity. +// If the Image object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ImageMutation) OldRemark(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRemark is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRemark requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRemark: %w", err) + } + return oldValue.Remark, nil +} + +// ClearRemark clears the value of the "remark" field. +func (m *ImageMutation) ClearRemark() { + m.remark = nil + m.clearedFields[image.FieldRemark] = struct{}{} +} + +// RemarkCleared returns if the "remark" field was cleared in this mutation. +func (m *ImageMutation) RemarkCleared() bool { + _, ok := m.clearedFields[image.FieldRemark] + return ok +} + +// ResetRemark resets all changes to the "remark" field. +func (m *ImageMutation) ResetRemark() { + m.remark = nil + delete(m.clearedFields, image.FieldRemark) +} + +// SetExtensionPackageID sets the "extension_package_id" field. +func (m *ImageMutation) SetExtensionPackageID(s string) { + m.extension_package_id = &s +} + +// ExtensionPackageID returns the value of the "extension_package_id" field in the mutation. +func (m *ImageMutation) ExtensionPackageID() (r string, exists bool) { + v := m.extension_package_id + if v == nil { + return + } + return *v, true +} + +// OldExtensionPackageID returns the old "extension_package_id" field's value of the Image entity. +// If the Image object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ImageMutation) OldExtensionPackageID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExtensionPackageID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExtensionPackageID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExtensionPackageID: %w", err) + } + return oldValue.ExtensionPackageID, nil +} + +// ClearExtensionPackageID clears the value of the "extension_package_id" field. +func (m *ImageMutation) ClearExtensionPackageID() { + m.extension_package_id = nil + m.clearedFields[image.FieldExtensionPackageID] = struct{}{} +} + +// ExtensionPackageIDCleared returns if the "extension_package_id" field was cleared in this mutation. +func (m *ImageMutation) ExtensionPackageIDCleared() bool { + _, ok := m.clearedFields[image.FieldExtensionPackageID] + return ok +} + +// ResetExtensionPackageID resets all changes to the "extension_package_id" field. +func (m *ImageMutation) ResetExtensionPackageID() { + m.extension_package_id = nil + delete(m.clearedFields, image.FieldExtensionPackageID) +} + +// SetExtensionImageID sets the "extension_image_id" field. +func (m *ImageMutation) SetExtensionImageID(s string) { + m.extension_image_id = &s +} + +// ExtensionImageID returns the value of the "extension_image_id" field in the mutation. +func (m *ImageMutation) ExtensionImageID() (r string, exists bool) { + v := m.extension_image_id + if v == nil { + return + } + return *v, true +} + +// OldExtensionImageID returns the old "extension_image_id" field's value of the Image entity. +// If the Image object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ImageMutation) OldExtensionImageID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExtensionImageID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExtensionImageID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExtensionImageID: %w", err) + } + return oldValue.ExtensionImageID, nil +} + +// ClearExtensionImageID clears the value of the "extension_image_id" field. +func (m *ImageMutation) ClearExtensionImageID() { + m.extension_image_id = nil + m.clearedFields[image.FieldExtensionImageID] = struct{}{} +} + +// ExtensionImageIDCleared returns if the "extension_image_id" field was cleared in this mutation. +func (m *ImageMutation) ExtensionImageIDCleared() bool { + _, ok := m.clearedFields[image.FieldExtensionImageID] + return ok +} + +// ResetExtensionImageID resets all changes to the "extension_image_id" field. +func (m *ImageMutation) ResetExtensionImageID() { + m.extension_image_id = nil + delete(m.clearedFields, image.FieldExtensionImageID) +} + +// SetExtensionVersion sets the "extension_version" field. +func (m *ImageMutation) SetExtensionVersion(s string) { + m.extension_version = &s +} + +// ExtensionVersion returns the value of the "extension_version" field in the mutation. +func (m *ImageMutation) ExtensionVersion() (r string, exists bool) { + v := m.extension_version + if v == nil { + return + } + return *v, true +} + +// OldExtensionVersion returns the old "extension_version" field's value of the Image entity. +// If the Image object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ImageMutation) OldExtensionVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExtensionVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExtensionVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExtensionVersion: %w", err) + } + return oldValue.ExtensionVersion, nil +} + +// ClearExtensionVersion clears the value of the "extension_version" field. +func (m *ImageMutation) ClearExtensionVersion() { + m.extension_version = nil + m.clearedFields[image.FieldExtensionVersion] = struct{}{} +} + +// ExtensionVersionCleared returns if the "extension_version" field was cleared in this mutation. +func (m *ImageMutation) ExtensionVersionCleared() bool { + _, ok := m.clearedFields[image.FieldExtensionVersion] + return ok +} + +// ResetExtensionVersion resets all changes to the "extension_version" field. +func (m *ImageMutation) ResetExtensionVersion() { + m.extension_version = nil + delete(m.clearedFields, image.FieldExtensionVersion) +} + +// SetCreatedAt sets the "created_at" field. +func (m *ImageMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ImageMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Image entity. +// If the Image object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ImageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ImageMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *ImageMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ImageMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Image entity. +// If the Image object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ImageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ImageMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// ClearUser clears the "user" edge to the User entity. +func (m *ImageMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[image.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *ImageMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *ImageMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *ImageMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// AddTeamIDs adds the "teams" edge to the Team entity by ids. +func (m *ImageMutation) AddTeamIDs(ids ...uuid.UUID) { + if m.teams == nil { + m.teams = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.teams[ids[i]] = struct{}{} + } +} + +// ClearTeams clears the "teams" edge to the Team entity. +func (m *ImageMutation) ClearTeams() { + m.clearedteams = true +} + +// TeamsCleared reports if the "teams" edge to the Team entity was cleared. +func (m *ImageMutation) TeamsCleared() bool { + return m.clearedteams +} + +// RemoveTeamIDs removes the "teams" edge to the Team entity by IDs. +func (m *ImageMutation) RemoveTeamIDs(ids ...uuid.UUID) { + if m.removedteams == nil { + m.removedteams = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.teams, ids[i]) + m.removedteams[ids[i]] = struct{}{} + } +} + +// RemovedTeams returns the removed IDs of the "teams" edge to the Team entity. +func (m *ImageMutation) RemovedTeamsIDs() (ids []uuid.UUID) { + for id := range m.removedteams { + ids = append(ids, id) + } + return +} + +// TeamsIDs returns the "teams" edge IDs in the mutation. +func (m *ImageMutation) TeamsIDs() (ids []uuid.UUID) { + for id := range m.teams { + ids = append(ids, id) + } + return +} + +// ResetTeams resets all changes to the "teams" edge. +func (m *ImageMutation) ResetTeams() { + m.teams = nil + m.clearedteams = false + m.removedteams = nil +} + +// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids. +func (m *ImageMutation) AddGroupIDs(ids ...uuid.UUID) { + if m.groups == nil { + m.groups = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.groups[ids[i]] = struct{}{} + } +} + +// ClearGroups clears the "groups" edge to the TeamGroup entity. +func (m *ImageMutation) ClearGroups() { + m.clearedgroups = true +} + +// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared. +func (m *ImageMutation) GroupsCleared() bool { + return m.clearedgroups +} + +// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs. +func (m *ImageMutation) RemoveGroupIDs(ids ...uuid.UUID) { + if m.removedgroups == nil { + m.removedgroups = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.groups, ids[i]) + m.removedgroups[ids[i]] = struct{}{} + } +} + +// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity. +func (m *ImageMutation) RemovedGroupsIDs() (ids []uuid.UUID) { + for id := range m.removedgroups { + ids = append(ids, id) + } + return +} + +// GroupsIDs returns the "groups" edge IDs in the mutation. +func (m *ImageMutation) GroupsIDs() (ids []uuid.UUID) { + for id := range m.groups { + ids = append(ids, id) + } + return +} + +// ResetGroups resets all changes to the "groups" edge. +func (m *ImageMutation) ResetGroups() { + m.groups = nil + m.clearedgroups = false + m.removedgroups = nil +} + +// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids. +func (m *ImageMutation) AddProjectTaskIDs(ids ...uuid.UUID) { + if m.project_tasks == nil { + m.project_tasks = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.project_tasks[ids[i]] = struct{}{} + } +} + +// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity. +func (m *ImageMutation) ClearProjectTasks() { + m.clearedproject_tasks = true +} + +// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared. +func (m *ImageMutation) ProjectTasksCleared() bool { + return m.clearedproject_tasks +} + +// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs. +func (m *ImageMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) { + if m.removedproject_tasks == nil { + m.removedproject_tasks = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.project_tasks, ids[i]) + m.removedproject_tasks[ids[i]] = struct{}{} + } +} + +// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity. +func (m *ImageMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) { + for id := range m.removedproject_tasks { + ids = append(ids, id) + } + return +} + +// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation. +func (m *ImageMutation) ProjectTasksIDs() (ids []uuid.UUID) { + for id := range m.project_tasks { + ids = append(ids, id) + } + return +} + +// ResetProjectTasks resets all changes to the "project_tasks" edge. +func (m *ImageMutation) ResetProjectTasks() { + m.project_tasks = nil + m.clearedproject_tasks = false + m.removedproject_tasks = nil +} + +// AddProjectIDs adds the "projects" edge to the Project entity by ids. +func (m *ImageMutation) AddProjectIDs(ids ...uuid.UUID) { + if m.projects == nil { + m.projects = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.projects[ids[i]] = struct{}{} + } +} + +// ClearProjects clears the "projects" edge to the Project entity. +func (m *ImageMutation) ClearProjects() { + m.clearedprojects = true +} + +// ProjectsCleared reports if the "projects" edge to the Project entity was cleared. +func (m *ImageMutation) ProjectsCleared() bool { + return m.clearedprojects +} + +// RemoveProjectIDs removes the "projects" edge to the Project entity by IDs. +func (m *ImageMutation) RemoveProjectIDs(ids ...uuid.UUID) { + if m.removedprojects == nil { + m.removedprojects = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.projects, ids[i]) + m.removedprojects[ids[i]] = struct{}{} + } +} + +// RemovedProjects returns the removed IDs of the "projects" edge to the Project entity. +func (m *ImageMutation) RemovedProjectsIDs() (ids []uuid.UUID) { + for id := range m.removedprojects { + ids = append(ids, id) + } + return +} + +// ProjectsIDs returns the "projects" edge IDs in the mutation. +func (m *ImageMutation) ProjectsIDs() (ids []uuid.UUID) { + for id := range m.projects { + ids = append(ids, id) + } + return +} + +// ResetProjects resets all changes to the "projects" edge. +func (m *ImageMutation) ResetProjects() { + m.projects = nil + m.clearedprojects = false + m.removedprojects = nil +} + +// AddExtensionArchiveIDs adds the "extension_archives" edge to the TeamExtensionImageArchive entity by ids. +func (m *ImageMutation) AddExtensionArchiveIDs(ids ...uuid.UUID) { + if m.extension_archives == nil { + m.extension_archives = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.extension_archives[ids[i]] = struct{}{} + } +} + +// ClearExtensionArchives clears the "extension_archives" edge to the TeamExtensionImageArchive entity. +func (m *ImageMutation) ClearExtensionArchives() { + m.clearedextension_archives = true +} + +// ExtensionArchivesCleared reports if the "extension_archives" edge to the TeamExtensionImageArchive entity was cleared. +func (m *ImageMutation) ExtensionArchivesCleared() bool { + return m.clearedextension_archives +} + +// RemoveExtensionArchiveIDs removes the "extension_archives" edge to the TeamExtensionImageArchive entity by IDs. +func (m *ImageMutation) RemoveExtensionArchiveIDs(ids ...uuid.UUID) { + if m.removedextension_archives == nil { + m.removedextension_archives = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.extension_archives, ids[i]) + m.removedextension_archives[ids[i]] = struct{}{} + } +} + +// RemovedExtensionArchives returns the removed IDs of the "extension_archives" edge to the TeamExtensionImageArchive entity. +func (m *ImageMutation) RemovedExtensionArchivesIDs() (ids []uuid.UUID) { + for id := range m.removedextension_archives { + ids = append(ids, id) + } + return +} + +// ExtensionArchivesIDs returns the "extension_archives" edge IDs in the mutation. +func (m *ImageMutation) ExtensionArchivesIDs() (ids []uuid.UUID) { + for id := range m.extension_archives { + ids = append(ids, id) + } + return +} + +// ResetExtensionArchives resets all changes to the "extension_archives" edge. +func (m *ImageMutation) ResetExtensionArchives() { + m.extension_archives = nil + m.clearedextension_archives = false + m.removedextension_archives = nil +} + +// AddTeamImageIDs adds the "team_images" edge to the TeamImage entity by ids. +func (m *ImageMutation) AddTeamImageIDs(ids ...uuid.UUID) { + if m.team_images == nil { + m.team_images = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.team_images[ids[i]] = struct{}{} + } +} + +// ClearTeamImages clears the "team_images" edge to the TeamImage entity. +func (m *ImageMutation) ClearTeamImages() { + m.clearedteam_images = true +} + +// TeamImagesCleared reports if the "team_images" edge to the TeamImage entity was cleared. +func (m *ImageMutation) TeamImagesCleared() bool { + return m.clearedteam_images +} + +// RemoveTeamImageIDs removes the "team_images" edge to the TeamImage entity by IDs. +func (m *ImageMutation) RemoveTeamImageIDs(ids ...uuid.UUID) { + if m.removedteam_images == nil { + m.removedteam_images = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.team_images, ids[i]) + m.removedteam_images[ids[i]] = struct{}{} + } +} + +// RemovedTeamImages returns the removed IDs of the "team_images" edge to the TeamImage entity. +func (m *ImageMutation) RemovedTeamImagesIDs() (ids []uuid.UUID) { + for id := range m.removedteam_images { + ids = append(ids, id) + } + return +} + +// TeamImagesIDs returns the "team_images" edge IDs in the mutation. +func (m *ImageMutation) TeamImagesIDs() (ids []uuid.UUID) { + for id := range m.team_images { + ids = append(ids, id) + } + return +} + +// ResetTeamImages resets all changes to the "team_images" edge. +func (m *ImageMutation) ResetTeamImages() { + m.team_images = nil + m.clearedteam_images = false + m.removedteam_images = nil +} + +// AddTeamGroupImageIDs adds the "team_group_images" edge to the TeamGroupImage entity by ids. +func (m *ImageMutation) AddTeamGroupImageIDs(ids ...uuid.UUID) { + if m.team_group_images == nil { + m.team_group_images = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.team_group_images[ids[i]] = struct{}{} + } +} + +// ClearTeamGroupImages clears the "team_group_images" edge to the TeamGroupImage entity. +func (m *ImageMutation) ClearTeamGroupImages() { + m.clearedteam_group_images = true +} + +// TeamGroupImagesCleared reports if the "team_group_images" edge to the TeamGroupImage entity was cleared. +func (m *ImageMutation) TeamGroupImagesCleared() bool { + return m.clearedteam_group_images +} + +// RemoveTeamGroupImageIDs removes the "team_group_images" edge to the TeamGroupImage entity by IDs. +func (m *ImageMutation) RemoveTeamGroupImageIDs(ids ...uuid.UUID) { + if m.removedteam_group_images == nil { + m.removedteam_group_images = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.team_group_images, ids[i]) + m.removedteam_group_images[ids[i]] = struct{}{} + } +} + +// RemovedTeamGroupImages returns the removed IDs of the "team_group_images" edge to the TeamGroupImage entity. +func (m *ImageMutation) RemovedTeamGroupImagesIDs() (ids []uuid.UUID) { + for id := range m.removedteam_group_images { + ids = append(ids, id) + } + return +} + +// TeamGroupImagesIDs returns the "team_group_images" edge IDs in the mutation. +func (m *ImageMutation) TeamGroupImagesIDs() (ids []uuid.UUID) { + for id := range m.team_group_images { + ids = append(ids, id) + } + return +} + +// ResetTeamGroupImages resets all changes to the "team_group_images" edge. +func (m *ImageMutation) ResetTeamGroupImages() { + m.team_group_images = nil + m.clearedteam_group_images = false + m.removedteam_group_images = nil +} + +// Where appends a list predicates to the ImageMutation builder. +func (m *ImageMutation) Where(ps ...predicate.Image) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ImageMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ImageMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Image, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ImageMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ImageMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Image). +func (m *ImageMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ImageMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.deleted_at != nil { + fields = append(fields, image.FieldDeletedAt) + } + if m.user != nil { + fields = append(fields, image.FieldUserID) + } + if m.name != nil { + fields = append(fields, image.FieldName) + } + if m.remark != nil { + fields = append(fields, image.FieldRemark) + } + if m.extension_package_id != nil { + fields = append(fields, image.FieldExtensionPackageID) + } + if m.extension_image_id != nil { + fields = append(fields, image.FieldExtensionImageID) + } + if m.extension_version != nil { + fields = append(fields, image.FieldExtensionVersion) + } + if m.created_at != nil { + fields = append(fields, image.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, image.FieldUpdatedAt) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ImageMutation) Field(name string) (ent.Value, bool) { + switch name { + case image.FieldDeletedAt: + return m.DeletedAt() + case image.FieldUserID: + return m.UserID() + case image.FieldName: + return m.Name() + case image.FieldRemark: + return m.Remark() + case image.FieldExtensionPackageID: + return m.ExtensionPackageID() + case image.FieldExtensionImageID: + return m.ExtensionImageID() + case image.FieldExtensionVersion: + return m.ExtensionVersion() + case image.FieldCreatedAt: + return m.CreatedAt() + case image.FieldUpdatedAt: + return m.UpdatedAt() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ImageMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case image.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case image.FieldUserID: + return m.OldUserID(ctx) + case image.FieldName: + return m.OldName(ctx) + case image.FieldRemark: + return m.OldRemark(ctx) + case image.FieldExtensionPackageID: + return m.OldExtensionPackageID(ctx) + case image.FieldExtensionImageID: + return m.OldExtensionImageID(ctx) + case image.FieldExtensionVersion: + return m.OldExtensionVersion(ctx) + case image.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case image.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + } + return nil, fmt.Errorf("unknown Image field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ImageMutation) SetField(name string, value ent.Value) error { + switch name { + case image.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case image.FieldUserID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case image.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case image.FieldRemark: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRemark(v) + return nil + case image.FieldExtensionPackageID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExtensionPackageID(v) + return nil + case image.FieldExtensionImageID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExtensionImageID(v) + return nil + case image.FieldExtensionVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExtensionVersion(v) + return nil + case image.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case image.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + } + return fmt.Errorf("unknown Image field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ImageMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ImageMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ImageMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Image numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ImageMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(image.FieldDeletedAt) { + fields = append(fields, image.FieldDeletedAt) + } + if m.FieldCleared(image.FieldRemark) { + fields = append(fields, image.FieldRemark) + } + if m.FieldCleared(image.FieldExtensionPackageID) { + fields = append(fields, image.FieldExtensionPackageID) + } + if m.FieldCleared(image.FieldExtensionImageID) { + fields = append(fields, image.FieldExtensionImageID) + } + if m.FieldCleared(image.FieldExtensionVersion) { + fields = append(fields, image.FieldExtensionVersion) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ImageMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ImageMutation) ClearField(name string) error { + switch name { + case image.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case image.FieldRemark: + m.ClearRemark() + return nil + case image.FieldExtensionPackageID: + m.ClearExtensionPackageID() + return nil + case image.FieldExtensionImageID: + m.ClearExtensionImageID() + return nil + case image.FieldExtensionVersion: + m.ClearExtensionVersion() + return nil + } + return fmt.Errorf("unknown Image nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ImageMutation) ResetField(name string) error { + switch name { + case image.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case image.FieldUserID: + m.ResetUserID() + return nil + case image.FieldName: + m.ResetName() + return nil + case image.FieldRemark: + m.ResetRemark() + return nil + case image.FieldExtensionPackageID: + m.ResetExtensionPackageID() + return nil + case image.FieldExtensionImageID: + m.ResetExtensionImageID() + return nil + case image.FieldExtensionVersion: + m.ResetExtensionVersion() + return nil + case image.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case image.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + } + return fmt.Errorf("unknown Image field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ImageMutation) AddedEdges() []string { + edges := make([]string, 0, 8) + if m.user != nil { + edges = append(edges, image.EdgeUser) + } + if m.teams != nil { + edges = append(edges, image.EdgeTeams) + } + if m.groups != nil { + edges = append(edges, image.EdgeGroups) + } + if m.project_tasks != nil { + edges = append(edges, image.EdgeProjectTasks) + } + if m.projects != nil { + edges = append(edges, image.EdgeProjects) + } + if m.extension_archives != nil { + edges = append(edges, image.EdgeExtensionArchives) + } + if m.team_images != nil { + edges = append(edges, image.EdgeTeamImages) + } + if m.team_group_images != nil { + edges = append(edges, image.EdgeTeamGroupImages) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ImageMutation) AddedIDs(name string) []ent.Value { + switch name { + case image.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + case image.EdgeTeams: + ids := make([]ent.Value, 0, len(m.teams)) + for id := range m.teams { + ids = append(ids, id) + } + return ids + case image.EdgeGroups: + ids := make([]ent.Value, 0, len(m.groups)) + for id := range m.groups { + ids = append(ids, id) + } + return ids + case image.EdgeProjectTasks: + ids := make([]ent.Value, 0, len(m.project_tasks)) + for id := range m.project_tasks { + ids = append(ids, id) + } + return ids + case image.EdgeProjects: + ids := make([]ent.Value, 0, len(m.projects)) + for id := range m.projects { + ids = append(ids, id) + } + return ids + case image.EdgeExtensionArchives: + ids := make([]ent.Value, 0, len(m.extension_archives)) + for id := range m.extension_archives { + ids = append(ids, id) + } + return ids + case image.EdgeTeamImages: + ids := make([]ent.Value, 0, len(m.team_images)) + for id := range m.team_images { + ids = append(ids, id) + } + return ids + case image.EdgeTeamGroupImages: + ids := make([]ent.Value, 0, len(m.team_group_images)) + for id := range m.team_group_images { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ImageMutation) RemovedEdges() []string { + edges := make([]string, 0, 8) + if m.removedteams != nil { + edges = append(edges, image.EdgeTeams) + } + if m.removedgroups != nil { + edges = append(edges, image.EdgeGroups) + } + if m.removedproject_tasks != nil { + edges = append(edges, image.EdgeProjectTasks) + } + if m.removedprojects != nil { + edges = append(edges, image.EdgeProjects) + } + if m.removedextension_archives != nil { + edges = append(edges, image.EdgeExtensionArchives) + } + if m.removedteam_images != nil { + edges = append(edges, image.EdgeTeamImages) + } + if m.removedteam_group_images != nil { + edges = append(edges, image.EdgeTeamGroupImages) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ImageMutation) RemovedIDs(name string) []ent.Value { + switch name { + case image.EdgeTeams: + ids := make([]ent.Value, 0, len(m.removedteams)) + for id := range m.removedteams { + ids = append(ids, id) + } + return ids + case image.EdgeGroups: + ids := make([]ent.Value, 0, len(m.removedgroups)) + for id := range m.removedgroups { + ids = append(ids, id) + } + return ids + case image.EdgeProjectTasks: + ids := make([]ent.Value, 0, len(m.removedproject_tasks)) + for id := range m.removedproject_tasks { + ids = append(ids, id) + } + return ids + case image.EdgeProjects: + ids := make([]ent.Value, 0, len(m.removedprojects)) + for id := range m.removedprojects { + ids = append(ids, id) + } + return ids + case image.EdgeExtensionArchives: + ids := make([]ent.Value, 0, len(m.removedextension_archives)) + for id := range m.removedextension_archives { + ids = append(ids, id) + } + return ids + case image.EdgeTeamImages: + ids := make([]ent.Value, 0, len(m.removedteam_images)) + for id := range m.removedteam_images { + ids = append(ids, id) + } + return ids + case image.EdgeTeamGroupImages: + ids := make([]ent.Value, 0, len(m.removedteam_group_images)) + for id := range m.removedteam_group_images { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ImageMutation) ClearedEdges() []string { + edges := make([]string, 0, 8) + if m.cleareduser { + edges = append(edges, image.EdgeUser) + } + if m.clearedteams { + edges = append(edges, image.EdgeTeams) + } + if m.clearedgroups { + edges = append(edges, image.EdgeGroups) + } + if m.clearedproject_tasks { + edges = append(edges, image.EdgeProjectTasks) + } + if m.clearedprojects { + edges = append(edges, image.EdgeProjects) + } + if m.clearedextension_archives { + edges = append(edges, image.EdgeExtensionArchives) + } + if m.clearedteam_images { + edges = append(edges, image.EdgeTeamImages) + } + if m.clearedteam_group_images { + edges = append(edges, image.EdgeTeamGroupImages) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ImageMutation) EdgeCleared(name string) bool { + switch name { + case image.EdgeUser: + return m.cleareduser + case image.EdgeTeams: + return m.clearedteams + case image.EdgeGroups: + return m.clearedgroups + case image.EdgeProjectTasks: + return m.clearedproject_tasks + case image.EdgeProjects: + return m.clearedprojects + case image.EdgeExtensionArchives: + return m.clearedextension_archives + case image.EdgeTeamImages: + return m.clearedteam_images + case image.EdgeTeamGroupImages: + return m.clearedteam_group_images + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ImageMutation) ClearEdge(name string) error { + switch name { + case image.EdgeUser: + m.ClearUser() + return nil + } + return fmt.Errorf("unknown Image unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ImageMutation) ResetEdge(name string) error { + switch name { + case image.EdgeUser: + m.ResetUser() + return nil + case image.EdgeTeams: + m.ResetTeams() + return nil + case image.EdgeGroups: + m.ResetGroups() + return nil + case image.EdgeProjectTasks: + m.ResetProjectTasks() + return nil + case image.EdgeProjects: + m.ResetProjects() + return nil + case image.EdgeExtensionArchives: + m.ResetExtensionArchives() + return nil + case image.EdgeTeamImages: + m.ResetTeamImages() + return nil + case image.EdgeTeamGroupImages: + m.ResetTeamGroupImages() + return nil + } + return fmt.Errorf("unknown Image edge %s", name) +} + +// MCPToolMutation represents an operation that mutates the MCPTool nodes in the graph. +type MCPToolMutation struct { + config + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + name *string + namespaced_name *string + scope *mcptool.Scope + user_id *uuid.UUID + description *string + input_schema *map[string]interface{} + price *int64 + addprice *int64 + enabled *bool + version_hash *string + synced_at *time.Time + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + upstream *uuid.UUID + clearedupstream bool + done bool + oldValue func(context.Context) (*MCPTool, error) + predicates []predicate.MCPTool +} + +var _ ent.Mutation = (*MCPToolMutation)(nil) + +// mcptoolOption allows management of the mutation configuration using functional options. +type mcptoolOption func(*MCPToolMutation) + +// newMCPToolMutation creates new mutation for the MCPTool entity. +func newMCPToolMutation(c config, op Op, opts ...mcptoolOption) *MCPToolMutation { + m := &MCPToolMutation{ + config: c, + op: op, + typ: TypeMCPTool, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withMCPToolID sets the ID field of the mutation. +func withMCPToolID(id uuid.UUID) mcptoolOption { + return func(m *MCPToolMutation) { + var ( + err error + once sync.Once + value *MCPTool + ) + m.oldValue = func(ctx context.Context) (*MCPTool, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().MCPTool.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withMCPTool sets the old MCPTool of the mutation. +func withMCPTool(node *MCPTool) mcptoolOption { + return func(m *MCPToolMutation) { + m.oldValue = func(context.Context) (*MCPTool, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m MCPToolMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m MCPToolMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of MCPTool entities. +func (m *MCPToolMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *MCPToolMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *MCPToolMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().MCPTool.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *MCPToolMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *MCPToolMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *MCPToolMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[mcptool.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *MCPToolMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[mcptool.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *MCPToolMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, mcptool.FieldDeletedAt) +} + +// SetUpstreamID sets the "upstream_id" field. +func (m *MCPToolMutation) SetUpstreamID(u uuid.UUID) { + m.upstream = &u +} + +// UpstreamID returns the value of the "upstream_id" field in the mutation. +func (m *MCPToolMutation) UpstreamID() (r uuid.UUID, exists bool) { + v := m.upstream + if v == nil { + return + } + return *v, true +} + +// OldUpstreamID returns the old "upstream_id" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldUpstreamID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpstreamID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpstreamID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpstreamID: %w", err) + } + return oldValue.UpstreamID, nil +} + +// ResetUpstreamID resets all changes to the "upstream_id" field. +func (m *MCPToolMutation) ResetUpstreamID() { + m.upstream = nil +} + +// SetName sets the "name" field. +func (m *MCPToolMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *MCPToolMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *MCPToolMutation) ResetName() { + m.name = nil +} + +// SetNamespacedName sets the "namespaced_name" field. +func (m *MCPToolMutation) SetNamespacedName(s string) { + m.namespaced_name = &s +} + +// NamespacedName returns the value of the "namespaced_name" field in the mutation. +func (m *MCPToolMutation) NamespacedName() (r string, exists bool) { + v := m.namespaced_name + if v == nil { + return + } + return *v, true +} + +// OldNamespacedName returns the old "namespaced_name" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldNamespacedName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNamespacedName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNamespacedName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNamespacedName: %w", err) + } + return oldValue.NamespacedName, nil +} + +// ResetNamespacedName resets all changes to the "namespaced_name" field. +func (m *MCPToolMutation) ResetNamespacedName() { + m.namespaced_name = nil +} + +// SetScope sets the "scope" field. +func (m *MCPToolMutation) SetScope(value mcptool.Scope) { + m.scope = &value +} + +// Scope returns the value of the "scope" field in the mutation. +func (m *MCPToolMutation) Scope() (r mcptool.Scope, exists bool) { + v := m.scope + if v == nil { + return + } + return *v, true +} + +// OldScope returns the old "scope" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldScope(ctx context.Context) (v mcptool.Scope, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldScope is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldScope requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldScope: %w", err) + } + return oldValue.Scope, nil +} + +// ResetScope resets all changes to the "scope" field. +func (m *MCPToolMutation) ResetScope() { + m.scope = nil +} + +// SetUserID sets the "user_id" field. +func (m *MCPToolMutation) SetUserID(u uuid.UUID) { + m.user_id = &u +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *MCPToolMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user_id + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldUserID(ctx context.Context) (v *uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ClearUserID clears the value of the "user_id" field. +func (m *MCPToolMutation) ClearUserID() { + m.user_id = nil + m.clearedFields[mcptool.FieldUserID] = struct{}{} +} + +// UserIDCleared returns if the "user_id" field was cleared in this mutation. +func (m *MCPToolMutation) UserIDCleared() bool { + _, ok := m.clearedFields[mcptool.FieldUserID] + return ok +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *MCPToolMutation) ResetUserID() { + m.user_id = nil + delete(m.clearedFields, mcptool.FieldUserID) +} + +// SetDescription sets the "description" field. +func (m *MCPToolMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *MCPToolMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *MCPToolMutation) ClearDescription() { + m.description = nil + m.clearedFields[mcptool.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *MCPToolMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[mcptool.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *MCPToolMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, mcptool.FieldDescription) +} + +// SetInputSchema sets the "input_schema" field. +func (m *MCPToolMutation) SetInputSchema(value map[string]interface{}) { + m.input_schema = &value +} + +// InputSchema returns the value of the "input_schema" field in the mutation. +func (m *MCPToolMutation) InputSchema() (r map[string]interface{}, exists bool) { + v := m.input_schema + if v == nil { + return + } + return *v, true +} + +// OldInputSchema returns the old "input_schema" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldInputSchema(ctx context.Context) (v map[string]interface{}, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInputSchema is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInputSchema requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInputSchema: %w", err) + } + return oldValue.InputSchema, nil +} + +// ClearInputSchema clears the value of the "input_schema" field. +func (m *MCPToolMutation) ClearInputSchema() { + m.input_schema = nil + m.clearedFields[mcptool.FieldInputSchema] = struct{}{} +} + +// InputSchemaCleared returns if the "input_schema" field was cleared in this mutation. +func (m *MCPToolMutation) InputSchemaCleared() bool { + _, ok := m.clearedFields[mcptool.FieldInputSchema] + return ok +} + +// ResetInputSchema resets all changes to the "input_schema" field. +func (m *MCPToolMutation) ResetInputSchema() { + m.input_schema = nil + delete(m.clearedFields, mcptool.FieldInputSchema) +} + +// SetPrice sets the "price" field. +func (m *MCPToolMutation) SetPrice(i int64) { + m.price = &i + m.addprice = nil +} + +// Price returns the value of the "price" field in the mutation. +func (m *MCPToolMutation) Price() (r int64, exists bool) { + v := m.price + if v == nil { + return + } + return *v, true +} + +// OldPrice returns the old "price" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldPrice(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPrice is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPrice requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPrice: %w", err) + } + return oldValue.Price, nil +} + +// AddPrice adds i to the "price" field. +func (m *MCPToolMutation) AddPrice(i int64) { + if m.addprice != nil { + *m.addprice += i + } else { + m.addprice = &i + } +} + +// AddedPrice returns the value that was added to the "price" field in this mutation. +func (m *MCPToolMutation) AddedPrice() (r int64, exists bool) { + v := m.addprice + if v == nil { + return + } + return *v, true +} + +// ResetPrice resets all changes to the "price" field. +func (m *MCPToolMutation) ResetPrice() { + m.price = nil + m.addprice = nil +} + +// SetEnabled sets the "enabled" field. +func (m *MCPToolMutation) SetEnabled(b bool) { + m.enabled = &b +} + +// Enabled returns the value of the "enabled" field in the mutation. +func (m *MCPToolMutation) Enabled() (r bool, exists bool) { + v := m.enabled + if v == nil { + return + } + return *v, true +} + +// OldEnabled returns the old "enabled" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEnabled: %w", err) + } + return oldValue.Enabled, nil +} + +// ResetEnabled resets all changes to the "enabled" field. +func (m *MCPToolMutation) ResetEnabled() { + m.enabled = nil +} + +// SetVersionHash sets the "version_hash" field. +func (m *MCPToolMutation) SetVersionHash(s string) { + m.version_hash = &s +} + +// VersionHash returns the value of the "version_hash" field in the mutation. +func (m *MCPToolMutation) VersionHash() (r string, exists bool) { + v := m.version_hash + if v == nil { + return + } + return *v, true +} + +// OldVersionHash returns the old "version_hash" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldVersionHash(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersionHash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersionHash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersionHash: %w", err) + } + return oldValue.VersionHash, nil +} + +// ClearVersionHash clears the value of the "version_hash" field. +func (m *MCPToolMutation) ClearVersionHash() { + m.version_hash = nil + m.clearedFields[mcptool.FieldVersionHash] = struct{}{} +} + +// VersionHashCleared returns if the "version_hash" field was cleared in this mutation. +func (m *MCPToolMutation) VersionHashCleared() bool { + _, ok := m.clearedFields[mcptool.FieldVersionHash] + return ok +} + +// ResetVersionHash resets all changes to the "version_hash" field. +func (m *MCPToolMutation) ResetVersionHash() { + m.version_hash = nil + delete(m.clearedFields, mcptool.FieldVersionHash) +} + +// SetSyncedAt sets the "synced_at" field. +func (m *MCPToolMutation) SetSyncedAt(t time.Time) { + m.synced_at = &t +} + +// SyncedAt returns the value of the "synced_at" field in the mutation. +func (m *MCPToolMutation) SyncedAt() (r time.Time, exists bool) { + v := m.synced_at + if v == nil { + return + } + return *v, true +} + +// OldSyncedAt returns the old "synced_at" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldSyncedAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSyncedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSyncedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSyncedAt: %w", err) + } + return oldValue.SyncedAt, nil +} + +// ClearSyncedAt clears the value of the "synced_at" field. +func (m *MCPToolMutation) ClearSyncedAt() { + m.synced_at = nil + m.clearedFields[mcptool.FieldSyncedAt] = struct{}{} +} + +// SyncedAtCleared returns if the "synced_at" field was cleared in this mutation. +func (m *MCPToolMutation) SyncedAtCleared() bool { + _, ok := m.clearedFields[mcptool.FieldSyncedAt] + return ok +} + +// ResetSyncedAt resets all changes to the "synced_at" field. +func (m *MCPToolMutation) ResetSyncedAt() { + m.synced_at = nil + delete(m.clearedFields, mcptool.FieldSyncedAt) +} + +// SetCreatedAt sets the "created_at" field. +func (m *MCPToolMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *MCPToolMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *MCPToolMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *MCPToolMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *MCPToolMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the MCPTool entity. +// If the MCPTool object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPToolMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *MCPToolMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// ClearUpstream clears the "upstream" edge to the MCPUpstream entity. +func (m *MCPToolMutation) ClearUpstream() { + m.clearedupstream = true + m.clearedFields[mcptool.FieldUpstreamID] = struct{}{} +} + +// UpstreamCleared reports if the "upstream" edge to the MCPUpstream entity was cleared. +func (m *MCPToolMutation) UpstreamCleared() bool { + return m.clearedupstream +} + +// UpstreamIDs returns the "upstream" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UpstreamID instead. It exists only for internal usage by the builders. +func (m *MCPToolMutation) UpstreamIDs() (ids []uuid.UUID) { + if id := m.upstream; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUpstream resets all changes to the "upstream" edge. +func (m *MCPToolMutation) ResetUpstream() { + m.upstream = nil + m.clearedupstream = false +} + +// Where appends a list predicates to the MCPToolMutation builder. +func (m *MCPToolMutation) Where(ps ...predicate.MCPTool) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the MCPToolMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *MCPToolMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.MCPTool, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *MCPToolMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *MCPToolMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (MCPTool). +func (m *MCPToolMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *MCPToolMutation) Fields() []string { + fields := make([]string, 0, 14) + if m.deleted_at != nil { + fields = append(fields, mcptool.FieldDeletedAt) + } + if m.upstream != nil { + fields = append(fields, mcptool.FieldUpstreamID) + } + if m.name != nil { + fields = append(fields, mcptool.FieldName) + } + if m.namespaced_name != nil { + fields = append(fields, mcptool.FieldNamespacedName) + } + if m.scope != nil { + fields = append(fields, mcptool.FieldScope) + } + if m.user_id != nil { + fields = append(fields, mcptool.FieldUserID) + } + if m.description != nil { + fields = append(fields, mcptool.FieldDescription) + } + if m.input_schema != nil { + fields = append(fields, mcptool.FieldInputSchema) + } + if m.price != nil { + fields = append(fields, mcptool.FieldPrice) + } + if m.enabled != nil { + fields = append(fields, mcptool.FieldEnabled) + } + if m.version_hash != nil { + fields = append(fields, mcptool.FieldVersionHash) + } + if m.synced_at != nil { + fields = append(fields, mcptool.FieldSyncedAt) + } + if m.created_at != nil { + fields = append(fields, mcptool.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, mcptool.FieldUpdatedAt) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *MCPToolMutation) Field(name string) (ent.Value, bool) { + switch name { + case mcptool.FieldDeletedAt: + return m.DeletedAt() + case mcptool.FieldUpstreamID: + return m.UpstreamID() + case mcptool.FieldName: + return m.Name() + case mcptool.FieldNamespacedName: + return m.NamespacedName() + case mcptool.FieldScope: + return m.Scope() + case mcptool.FieldUserID: + return m.UserID() + case mcptool.FieldDescription: + return m.Description() + case mcptool.FieldInputSchema: + return m.InputSchema() + case mcptool.FieldPrice: + return m.Price() + case mcptool.FieldEnabled: + return m.Enabled() + case mcptool.FieldVersionHash: + return m.VersionHash() + case mcptool.FieldSyncedAt: + return m.SyncedAt() + case mcptool.FieldCreatedAt: + return m.CreatedAt() + case mcptool.FieldUpdatedAt: + return m.UpdatedAt() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *MCPToolMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case mcptool.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case mcptool.FieldUpstreamID: + return m.OldUpstreamID(ctx) + case mcptool.FieldName: + return m.OldName(ctx) + case mcptool.FieldNamespacedName: + return m.OldNamespacedName(ctx) + case mcptool.FieldScope: + return m.OldScope(ctx) + case mcptool.FieldUserID: + return m.OldUserID(ctx) + case mcptool.FieldDescription: + return m.OldDescription(ctx) + case mcptool.FieldInputSchema: + return m.OldInputSchema(ctx) + case mcptool.FieldPrice: + return m.OldPrice(ctx) + case mcptool.FieldEnabled: + return m.OldEnabled(ctx) + case mcptool.FieldVersionHash: + return m.OldVersionHash(ctx) + case mcptool.FieldSyncedAt: + return m.OldSyncedAt(ctx) + case mcptool.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case mcptool.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + } + return nil, fmt.Errorf("unknown MCPTool field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MCPToolMutation) SetField(name string, value ent.Value) error { + switch name { + case mcptool.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case mcptool.FieldUpstreamID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpstreamID(v) + return nil + case mcptool.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case mcptool.FieldNamespacedName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNamespacedName(v) + return nil + case mcptool.FieldScope: + v, ok := value.(mcptool.Scope) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScope(v) + return nil + case mcptool.FieldUserID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case mcptool.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case mcptool.FieldInputSchema: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInputSchema(v) + return nil + case mcptool.FieldPrice: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPrice(v) + return nil + case mcptool.FieldEnabled: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEnabled(v) + return nil + case mcptool.FieldVersionHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersionHash(v) + return nil + case mcptool.FieldSyncedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSyncedAt(v) + return nil + case mcptool.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case mcptool.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + } + return fmt.Errorf("unknown MCPTool field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *MCPToolMutation) AddedFields() []string { + var fields []string + if m.addprice != nil { + fields = append(fields, mcptool.FieldPrice) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *MCPToolMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case mcptool.FieldPrice: + return m.AddedPrice() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MCPToolMutation) AddField(name string, value ent.Value) error { + switch name { + case mcptool.FieldPrice: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPrice(v) + return nil + } + return fmt.Errorf("unknown MCPTool numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *MCPToolMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(mcptool.FieldDeletedAt) { + fields = append(fields, mcptool.FieldDeletedAt) + } + if m.FieldCleared(mcptool.FieldUserID) { + fields = append(fields, mcptool.FieldUserID) + } + if m.FieldCleared(mcptool.FieldDescription) { + fields = append(fields, mcptool.FieldDescription) + } + if m.FieldCleared(mcptool.FieldInputSchema) { + fields = append(fields, mcptool.FieldInputSchema) + } + if m.FieldCleared(mcptool.FieldVersionHash) { + fields = append(fields, mcptool.FieldVersionHash) + } + if m.FieldCleared(mcptool.FieldSyncedAt) { + fields = append(fields, mcptool.FieldSyncedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *MCPToolMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *MCPToolMutation) ClearField(name string) error { + switch name { + case mcptool.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case mcptool.FieldUserID: + m.ClearUserID() + return nil + case mcptool.FieldDescription: + m.ClearDescription() + return nil + case mcptool.FieldInputSchema: + m.ClearInputSchema() + return nil + case mcptool.FieldVersionHash: + m.ClearVersionHash() + return nil + case mcptool.FieldSyncedAt: + m.ClearSyncedAt() + return nil + } + return fmt.Errorf("unknown MCPTool nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *MCPToolMutation) ResetField(name string) error { + switch name { + case mcptool.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case mcptool.FieldUpstreamID: + m.ResetUpstreamID() + return nil + case mcptool.FieldName: + m.ResetName() + return nil + case mcptool.FieldNamespacedName: + m.ResetNamespacedName() + return nil + case mcptool.FieldScope: + m.ResetScope() + return nil + case mcptool.FieldUserID: + m.ResetUserID() + return nil + case mcptool.FieldDescription: + m.ResetDescription() + return nil + case mcptool.FieldInputSchema: + m.ResetInputSchema() + return nil + case mcptool.FieldPrice: + m.ResetPrice() + return nil + case mcptool.FieldEnabled: + m.ResetEnabled() + return nil + case mcptool.FieldVersionHash: + m.ResetVersionHash() + return nil + case mcptool.FieldSyncedAt: + m.ResetSyncedAt() + return nil + case mcptool.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case mcptool.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + } + return fmt.Errorf("unknown MCPTool field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *MCPToolMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.upstream != nil { + edges = append(edges, mcptool.EdgeUpstream) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *MCPToolMutation) AddedIDs(name string) []ent.Value { + switch name { + case mcptool.EdgeUpstream: + if id := m.upstream; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *MCPToolMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *MCPToolMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *MCPToolMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedupstream { + edges = append(edges, mcptool.EdgeUpstream) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *MCPToolMutation) EdgeCleared(name string) bool { + switch name { + case mcptool.EdgeUpstream: + return m.clearedupstream + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *MCPToolMutation) ClearEdge(name string) error { + switch name { + case mcptool.EdgeUpstream: + m.ClearUpstream() + return nil + } + return fmt.Errorf("unknown MCPTool unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *MCPToolMutation) ResetEdge(name string) error { + switch name { + case mcptool.EdgeUpstream: + m.ResetUpstream() + return nil + } + return fmt.Errorf("unknown MCPTool edge %s", name) +} + +// MCPUpstreamMutation represents an operation that mutates the MCPUpstream nodes in the graph. +type MCPUpstreamMutation struct { + config + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + name *string + slug *string + scope *mcpupstream.Scope + _type *string + url *string + headers *map[string]string + description *string + enabled *bool + health_status *string + sync_status *string + health_checked_at *time.Time + last_synced_at *time.Time + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + tools map[uuid.UUID]struct{} + removedtools map[uuid.UUID]struct{} + clearedtools bool + user *uuid.UUID + cleareduser bool + done bool + oldValue func(context.Context) (*MCPUpstream, error) + predicates []predicate.MCPUpstream +} + +var _ ent.Mutation = (*MCPUpstreamMutation)(nil) + +// mcpupstreamOption allows management of the mutation configuration using functional options. +type mcpupstreamOption func(*MCPUpstreamMutation) + +// newMCPUpstreamMutation creates new mutation for the MCPUpstream entity. +func newMCPUpstreamMutation(c config, op Op, opts ...mcpupstreamOption) *MCPUpstreamMutation { + m := &MCPUpstreamMutation{ + config: c, + op: op, + typ: TypeMCPUpstream, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withMCPUpstreamID sets the ID field of the mutation. +func withMCPUpstreamID(id uuid.UUID) mcpupstreamOption { + return func(m *MCPUpstreamMutation) { + var ( + err error + once sync.Once + value *MCPUpstream + ) + m.oldValue = func(ctx context.Context) (*MCPUpstream, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().MCPUpstream.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withMCPUpstream sets the old MCPUpstream of the mutation. +func withMCPUpstream(node *MCPUpstream) mcpupstreamOption { + return func(m *MCPUpstreamMutation) { + m.oldValue = func(context.Context) (*MCPUpstream, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m MCPUpstreamMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m MCPUpstreamMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of MCPUpstream entities. +func (m *MCPUpstreamMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *MCPUpstreamMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *MCPUpstreamMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().MCPUpstream.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *MCPUpstreamMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *MCPUpstreamMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *MCPUpstreamMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[mcpupstream.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *MCPUpstreamMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[mcpupstream.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *MCPUpstreamMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, mcpupstream.FieldDeletedAt) +} + +// SetName sets the "name" field. +func (m *MCPUpstreamMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *MCPUpstreamMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *MCPUpstreamMutation) ResetName() { + m.name = nil +} + +// SetSlug sets the "slug" field. +func (m *MCPUpstreamMutation) SetSlug(s string) { + m.slug = &s +} + +// Slug returns the value of the "slug" field in the mutation. +func (m *MCPUpstreamMutation) Slug() (r string, exists bool) { + v := m.slug + if v == nil { + return + } + return *v, true +} + +// OldSlug returns the old "slug" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldSlug(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSlug is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSlug requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSlug: %w", err) + } + return oldValue.Slug, nil +} + +// ResetSlug resets all changes to the "slug" field. +func (m *MCPUpstreamMutation) ResetSlug() { + m.slug = nil +} + +// SetScope sets the "scope" field. +func (m *MCPUpstreamMutation) SetScope(value mcpupstream.Scope) { + m.scope = &value +} + +// Scope returns the value of the "scope" field in the mutation. +func (m *MCPUpstreamMutation) Scope() (r mcpupstream.Scope, exists bool) { + v := m.scope + if v == nil { + return + } + return *v, true +} + +// OldScope returns the old "scope" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldScope(ctx context.Context) (v mcpupstream.Scope, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldScope is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldScope requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldScope: %w", err) + } + return oldValue.Scope, nil +} + +// ResetScope resets all changes to the "scope" field. +func (m *MCPUpstreamMutation) ResetScope() { + m.scope = nil +} + +// SetUserID sets the "user_id" field. +func (m *MCPUpstreamMutation) SetUserID(u uuid.UUID) { + m.user = &u +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *MCPUpstreamMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldUserID(ctx context.Context) (v *uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ClearUserID clears the value of the "user_id" field. +func (m *MCPUpstreamMutation) ClearUserID() { + m.user = nil + m.clearedFields[mcpupstream.FieldUserID] = struct{}{} +} + +// UserIDCleared returns if the "user_id" field was cleared in this mutation. +func (m *MCPUpstreamMutation) UserIDCleared() bool { + _, ok := m.clearedFields[mcpupstream.FieldUserID] + return ok +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *MCPUpstreamMutation) ResetUserID() { + m.user = nil + delete(m.clearedFields, mcpupstream.FieldUserID) +} + +// SetType sets the "type" field. +func (m *MCPUpstreamMutation) SetType(s string) { + m._type = &s +} + +// GetType returns the value of the "type" field in the mutation. +func (m *MCPUpstreamMutation) GetType() (r string, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *MCPUpstreamMutation) ResetType() { + m._type = nil +} + +// SetURL sets the "url" field. +func (m *MCPUpstreamMutation) SetURL(s string) { + m.url = &s +} + +// URL returns the value of the "url" field in the mutation. +func (m *MCPUpstreamMutation) URL() (r string, exists bool) { + v := m.url + if v == nil { + return + } + return *v, true +} + +// OldURL returns the old "url" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldURL: %w", err) + } + return oldValue.URL, nil +} + +// ResetURL resets all changes to the "url" field. +func (m *MCPUpstreamMutation) ResetURL() { + m.url = nil +} + +// SetHeaders sets the "headers" field. +func (m *MCPUpstreamMutation) SetHeaders(value map[string]string) { + m.headers = &value +} + +// Headers returns the value of the "headers" field in the mutation. +func (m *MCPUpstreamMutation) Headers() (r map[string]string, exists bool) { + v := m.headers + if v == nil { + return + } + return *v, true +} + +// OldHeaders returns the old "headers" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldHeaders(ctx context.Context) (v map[string]string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeaders is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeaders requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeaders: %w", err) + } + return oldValue.Headers, nil +} + +// ClearHeaders clears the value of the "headers" field. +func (m *MCPUpstreamMutation) ClearHeaders() { + m.headers = nil + m.clearedFields[mcpupstream.FieldHeaders] = struct{}{} +} + +// HeadersCleared returns if the "headers" field was cleared in this mutation. +func (m *MCPUpstreamMutation) HeadersCleared() bool { + _, ok := m.clearedFields[mcpupstream.FieldHeaders] + return ok +} + +// ResetHeaders resets all changes to the "headers" field. +func (m *MCPUpstreamMutation) ResetHeaders() { + m.headers = nil + delete(m.clearedFields, mcpupstream.FieldHeaders) +} + +// SetDescription sets the "description" field. +func (m *MCPUpstreamMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *MCPUpstreamMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *MCPUpstreamMutation) ClearDescription() { + m.description = nil + m.clearedFields[mcpupstream.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *MCPUpstreamMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[mcpupstream.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *MCPUpstreamMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, mcpupstream.FieldDescription) +} + +// SetEnabled sets the "enabled" field. +func (m *MCPUpstreamMutation) SetEnabled(b bool) { + m.enabled = &b +} + +// Enabled returns the value of the "enabled" field in the mutation. +func (m *MCPUpstreamMutation) Enabled() (r bool, exists bool) { + v := m.enabled + if v == nil { + return + } + return *v, true +} + +// OldEnabled returns the old "enabled" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEnabled: %w", err) + } + return oldValue.Enabled, nil +} + +// ResetEnabled resets all changes to the "enabled" field. +func (m *MCPUpstreamMutation) ResetEnabled() { + m.enabled = nil +} + +// SetHealthStatus sets the "health_status" field. +func (m *MCPUpstreamMutation) SetHealthStatus(s string) { + m.health_status = &s +} + +// HealthStatus returns the value of the "health_status" field in the mutation. +func (m *MCPUpstreamMutation) HealthStatus() (r string, exists bool) { + v := m.health_status + if v == nil { + return + } + return *v, true +} + +// OldHealthStatus returns the old "health_status" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldHealthStatus(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHealthStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHealthStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHealthStatus: %w", err) + } + return oldValue.HealthStatus, nil +} + +// ResetHealthStatus resets all changes to the "health_status" field. +func (m *MCPUpstreamMutation) ResetHealthStatus() { + m.health_status = nil +} + +// SetSyncStatus sets the "sync_status" field. +func (m *MCPUpstreamMutation) SetSyncStatus(s string) { + m.sync_status = &s +} + +// SyncStatus returns the value of the "sync_status" field in the mutation. +func (m *MCPUpstreamMutation) SyncStatus() (r string, exists bool) { + v := m.sync_status + if v == nil { + return + } + return *v, true +} + +// OldSyncStatus returns the old "sync_status" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldSyncStatus(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSyncStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSyncStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSyncStatus: %w", err) + } + return oldValue.SyncStatus, nil +} + +// ResetSyncStatus resets all changes to the "sync_status" field. +func (m *MCPUpstreamMutation) ResetSyncStatus() { + m.sync_status = nil +} + +// SetHealthCheckedAt sets the "health_checked_at" field. +func (m *MCPUpstreamMutation) SetHealthCheckedAt(t time.Time) { + m.health_checked_at = &t +} + +// HealthCheckedAt returns the value of the "health_checked_at" field in the mutation. +func (m *MCPUpstreamMutation) HealthCheckedAt() (r time.Time, exists bool) { + v := m.health_checked_at + if v == nil { + return + } + return *v, true +} + +// OldHealthCheckedAt returns the old "health_checked_at" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldHealthCheckedAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHealthCheckedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHealthCheckedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHealthCheckedAt: %w", err) + } + return oldValue.HealthCheckedAt, nil +} + +// ClearHealthCheckedAt clears the value of the "health_checked_at" field. +func (m *MCPUpstreamMutation) ClearHealthCheckedAt() { + m.health_checked_at = nil + m.clearedFields[mcpupstream.FieldHealthCheckedAt] = struct{}{} +} + +// HealthCheckedAtCleared returns if the "health_checked_at" field was cleared in this mutation. +func (m *MCPUpstreamMutation) HealthCheckedAtCleared() bool { + _, ok := m.clearedFields[mcpupstream.FieldHealthCheckedAt] + return ok +} + +// ResetHealthCheckedAt resets all changes to the "health_checked_at" field. +func (m *MCPUpstreamMutation) ResetHealthCheckedAt() { + m.health_checked_at = nil + delete(m.clearedFields, mcpupstream.FieldHealthCheckedAt) +} + +// SetLastSyncedAt sets the "last_synced_at" field. +func (m *MCPUpstreamMutation) SetLastSyncedAt(t time.Time) { + m.last_synced_at = &t +} + +// LastSyncedAt returns the value of the "last_synced_at" field in the mutation. +func (m *MCPUpstreamMutation) LastSyncedAt() (r time.Time, exists bool) { + v := m.last_synced_at + if v == nil { + return + } + return *v, true +} + +// OldLastSyncedAt returns the old "last_synced_at" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldLastSyncedAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastSyncedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastSyncedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastSyncedAt: %w", err) + } + return oldValue.LastSyncedAt, nil +} + +// ClearLastSyncedAt clears the value of the "last_synced_at" field. +func (m *MCPUpstreamMutation) ClearLastSyncedAt() { + m.last_synced_at = nil + m.clearedFields[mcpupstream.FieldLastSyncedAt] = struct{}{} +} + +// LastSyncedAtCleared returns if the "last_synced_at" field was cleared in this mutation. +func (m *MCPUpstreamMutation) LastSyncedAtCleared() bool { + _, ok := m.clearedFields[mcpupstream.FieldLastSyncedAt] + return ok +} + +// ResetLastSyncedAt resets all changes to the "last_synced_at" field. +func (m *MCPUpstreamMutation) ResetLastSyncedAt() { + m.last_synced_at = nil + delete(m.clearedFields, mcpupstream.FieldLastSyncedAt) +} + +// SetCreatedAt sets the "created_at" field. +func (m *MCPUpstreamMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *MCPUpstreamMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *MCPUpstreamMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *MCPUpstreamMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *MCPUpstreamMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the MCPUpstream entity. +// If the MCPUpstream object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUpstreamMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *MCPUpstreamMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// AddToolIDs adds the "tools" edge to the MCPTool entity by ids. +func (m *MCPUpstreamMutation) AddToolIDs(ids ...uuid.UUID) { + if m.tools == nil { + m.tools = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.tools[ids[i]] = struct{}{} + } +} + +// ClearTools clears the "tools" edge to the MCPTool entity. +func (m *MCPUpstreamMutation) ClearTools() { + m.clearedtools = true +} + +// ToolsCleared reports if the "tools" edge to the MCPTool entity was cleared. +func (m *MCPUpstreamMutation) ToolsCleared() bool { + return m.clearedtools +} + +// RemoveToolIDs removes the "tools" edge to the MCPTool entity by IDs. +func (m *MCPUpstreamMutation) RemoveToolIDs(ids ...uuid.UUID) { + if m.removedtools == nil { + m.removedtools = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.tools, ids[i]) + m.removedtools[ids[i]] = struct{}{} + } +} + +// RemovedTools returns the removed IDs of the "tools" edge to the MCPTool entity. +func (m *MCPUpstreamMutation) RemovedToolsIDs() (ids []uuid.UUID) { + for id := range m.removedtools { + ids = append(ids, id) + } + return +} + +// ToolsIDs returns the "tools" edge IDs in the mutation. +func (m *MCPUpstreamMutation) ToolsIDs() (ids []uuid.UUID) { + for id := range m.tools { + ids = append(ids, id) + } + return +} + +// ResetTools resets all changes to the "tools" edge. +func (m *MCPUpstreamMutation) ResetTools() { + m.tools = nil + m.clearedtools = false + m.removedtools = nil +} + +// ClearUser clears the "user" edge to the User entity. +func (m *MCPUpstreamMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[mcpupstream.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *MCPUpstreamMutation) UserCleared() bool { + return m.UserIDCleared() || m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *MCPUpstreamMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *MCPUpstreamMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// Where appends a list predicates to the MCPUpstreamMutation builder. +func (m *MCPUpstreamMutation) Where(ps ...predicate.MCPUpstream) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the MCPUpstreamMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *MCPUpstreamMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.MCPUpstream, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *MCPUpstreamMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *MCPUpstreamMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (MCPUpstream). +func (m *MCPUpstreamMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *MCPUpstreamMutation) Fields() []string { + fields := make([]string, 0, 16) + if m.deleted_at != nil { + fields = append(fields, mcpupstream.FieldDeletedAt) + } + if m.name != nil { + fields = append(fields, mcpupstream.FieldName) + } + if m.slug != nil { + fields = append(fields, mcpupstream.FieldSlug) + } + if m.scope != nil { + fields = append(fields, mcpupstream.FieldScope) + } + if m.user != nil { + fields = append(fields, mcpupstream.FieldUserID) + } + if m._type != nil { + fields = append(fields, mcpupstream.FieldType) + } + if m.url != nil { + fields = append(fields, mcpupstream.FieldURL) + } + if m.headers != nil { + fields = append(fields, mcpupstream.FieldHeaders) + } + if m.description != nil { + fields = append(fields, mcpupstream.FieldDescription) + } + if m.enabled != nil { + fields = append(fields, mcpupstream.FieldEnabled) + } + if m.health_status != nil { + fields = append(fields, mcpupstream.FieldHealthStatus) + } + if m.sync_status != nil { + fields = append(fields, mcpupstream.FieldSyncStatus) + } + if m.health_checked_at != nil { + fields = append(fields, mcpupstream.FieldHealthCheckedAt) + } + if m.last_synced_at != nil { + fields = append(fields, mcpupstream.FieldLastSyncedAt) + } + if m.created_at != nil { + fields = append(fields, mcpupstream.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, mcpupstream.FieldUpdatedAt) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *MCPUpstreamMutation) Field(name string) (ent.Value, bool) { + switch name { + case mcpupstream.FieldDeletedAt: + return m.DeletedAt() + case mcpupstream.FieldName: + return m.Name() + case mcpupstream.FieldSlug: + return m.Slug() + case mcpupstream.FieldScope: + return m.Scope() + case mcpupstream.FieldUserID: + return m.UserID() + case mcpupstream.FieldType: + return m.GetType() + case mcpupstream.FieldURL: + return m.URL() + case mcpupstream.FieldHeaders: + return m.Headers() + case mcpupstream.FieldDescription: + return m.Description() + case mcpupstream.FieldEnabled: + return m.Enabled() + case mcpupstream.FieldHealthStatus: + return m.HealthStatus() + case mcpupstream.FieldSyncStatus: + return m.SyncStatus() + case mcpupstream.FieldHealthCheckedAt: + return m.HealthCheckedAt() + case mcpupstream.FieldLastSyncedAt: + return m.LastSyncedAt() + case mcpupstream.FieldCreatedAt: + return m.CreatedAt() + case mcpupstream.FieldUpdatedAt: + return m.UpdatedAt() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *MCPUpstreamMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case mcpupstream.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case mcpupstream.FieldName: + return m.OldName(ctx) + case mcpupstream.FieldSlug: + return m.OldSlug(ctx) + case mcpupstream.FieldScope: + return m.OldScope(ctx) + case mcpupstream.FieldUserID: + return m.OldUserID(ctx) + case mcpupstream.FieldType: + return m.OldType(ctx) + case mcpupstream.FieldURL: + return m.OldURL(ctx) + case mcpupstream.FieldHeaders: + return m.OldHeaders(ctx) + case mcpupstream.FieldDescription: + return m.OldDescription(ctx) + case mcpupstream.FieldEnabled: + return m.OldEnabled(ctx) + case mcpupstream.FieldHealthStatus: + return m.OldHealthStatus(ctx) + case mcpupstream.FieldSyncStatus: + return m.OldSyncStatus(ctx) + case mcpupstream.FieldHealthCheckedAt: + return m.OldHealthCheckedAt(ctx) + case mcpupstream.FieldLastSyncedAt: + return m.OldLastSyncedAt(ctx) + case mcpupstream.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case mcpupstream.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + } + return nil, fmt.Errorf("unknown MCPUpstream field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MCPUpstreamMutation) SetField(name string, value ent.Value) error { + switch name { + case mcpupstream.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case mcpupstream.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case mcpupstream.FieldSlug: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSlug(v) + return nil + case mcpupstream.FieldScope: + v, ok := value.(mcpupstream.Scope) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScope(v) + return nil + case mcpupstream.FieldUserID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case mcpupstream.FieldType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case mcpupstream.FieldURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetURL(v) + return nil + case mcpupstream.FieldHeaders: + v, ok := value.(map[string]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeaders(v) + return nil + case mcpupstream.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case mcpupstream.FieldEnabled: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEnabled(v) + return nil + case mcpupstream.FieldHealthStatus: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHealthStatus(v) + return nil + case mcpupstream.FieldSyncStatus: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSyncStatus(v) + return nil + case mcpupstream.FieldHealthCheckedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHealthCheckedAt(v) + return nil + case mcpupstream.FieldLastSyncedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastSyncedAt(v) + return nil + case mcpupstream.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case mcpupstream.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + } + return fmt.Errorf("unknown MCPUpstream field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *MCPUpstreamMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *MCPUpstreamMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MCPUpstreamMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown MCPUpstream numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *MCPUpstreamMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(mcpupstream.FieldDeletedAt) { + fields = append(fields, mcpupstream.FieldDeletedAt) + } + if m.FieldCleared(mcpupstream.FieldUserID) { + fields = append(fields, mcpupstream.FieldUserID) + } + if m.FieldCleared(mcpupstream.FieldHeaders) { + fields = append(fields, mcpupstream.FieldHeaders) + } + if m.FieldCleared(mcpupstream.FieldDescription) { + fields = append(fields, mcpupstream.FieldDescription) + } + if m.FieldCleared(mcpupstream.FieldHealthCheckedAt) { + fields = append(fields, mcpupstream.FieldHealthCheckedAt) + } + if m.FieldCleared(mcpupstream.FieldLastSyncedAt) { + fields = append(fields, mcpupstream.FieldLastSyncedAt) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *MCPUpstreamMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *MCPUpstreamMutation) ClearField(name string) error { + switch name { + case mcpupstream.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case mcpupstream.FieldUserID: + m.ClearUserID() + return nil + case mcpupstream.FieldHeaders: + m.ClearHeaders() + return nil + case mcpupstream.FieldDescription: + m.ClearDescription() + return nil + case mcpupstream.FieldHealthCheckedAt: + m.ClearHealthCheckedAt() + return nil + case mcpupstream.FieldLastSyncedAt: + m.ClearLastSyncedAt() + return nil + } + return fmt.Errorf("unknown MCPUpstream nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *MCPUpstreamMutation) ResetField(name string) error { + switch name { + case mcpupstream.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case mcpupstream.FieldName: + m.ResetName() + return nil + case mcpupstream.FieldSlug: + m.ResetSlug() + return nil + case mcpupstream.FieldScope: + m.ResetScope() + return nil + case mcpupstream.FieldUserID: + m.ResetUserID() + return nil + case mcpupstream.FieldType: + m.ResetType() + return nil + case mcpupstream.FieldURL: + m.ResetURL() + return nil + case mcpupstream.FieldHeaders: + m.ResetHeaders() + return nil + case mcpupstream.FieldDescription: + m.ResetDescription() + return nil + case mcpupstream.FieldEnabled: + m.ResetEnabled() + return nil + case mcpupstream.FieldHealthStatus: + m.ResetHealthStatus() + return nil + case mcpupstream.FieldSyncStatus: + m.ResetSyncStatus() + return nil + case mcpupstream.FieldHealthCheckedAt: + m.ResetHealthCheckedAt() + return nil + case mcpupstream.FieldLastSyncedAt: + m.ResetLastSyncedAt() + return nil + case mcpupstream.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case mcpupstream.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + } + return fmt.Errorf("unknown MCPUpstream field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *MCPUpstreamMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.tools != nil { + edges = append(edges, mcpupstream.EdgeTools) + } + if m.user != nil { + edges = append(edges, mcpupstream.EdgeUser) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *MCPUpstreamMutation) AddedIDs(name string) []ent.Value { + switch name { + case mcpupstream.EdgeTools: + ids := make([]ent.Value, 0, len(m.tools)) + for id := range m.tools { + ids = append(ids, id) + } + return ids + case mcpupstream.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *MCPUpstreamMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedtools != nil { + edges = append(edges, mcpupstream.EdgeTools) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *MCPUpstreamMutation) RemovedIDs(name string) []ent.Value { + switch name { + case mcpupstream.EdgeTools: + ids := make([]ent.Value, 0, len(m.removedtools)) + for id := range m.removedtools { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *MCPUpstreamMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedtools { + edges = append(edges, mcpupstream.EdgeTools) + } + if m.cleareduser { + edges = append(edges, mcpupstream.EdgeUser) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *MCPUpstreamMutation) EdgeCleared(name string) bool { + switch name { + case mcpupstream.EdgeTools: + return m.clearedtools + case mcpupstream.EdgeUser: + return m.cleareduser + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *MCPUpstreamMutation) ClearEdge(name string) error { + switch name { + case mcpupstream.EdgeUser: + m.ClearUser() + return nil + } + return fmt.Errorf("unknown MCPUpstream unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *MCPUpstreamMutation) ResetEdge(name string) error { + switch name { + case mcpupstream.EdgeTools: + m.ResetTools() + return nil + case mcpupstream.EdgeUser: + m.ResetUser() + return nil + } + return fmt.Errorf("unknown MCPUpstream edge %s", name) +} + +// MCPUserToolSettingMutation represents an operation that mutates the MCPUserToolSetting nodes in the graph. +type MCPUserToolSettingMutation struct { + config + op Op + typ string + id *uuid.UUID + user_id *uuid.UUID + tool_id *uuid.UUID + enabled *bool + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*MCPUserToolSetting, error) + predicates []predicate.MCPUserToolSetting +} + +var _ ent.Mutation = (*MCPUserToolSettingMutation)(nil) + +// mcpusertoolsettingOption allows management of the mutation configuration using functional options. +type mcpusertoolsettingOption func(*MCPUserToolSettingMutation) + +// newMCPUserToolSettingMutation creates new mutation for the MCPUserToolSetting entity. +func newMCPUserToolSettingMutation(c config, op Op, opts ...mcpusertoolsettingOption) *MCPUserToolSettingMutation { + m := &MCPUserToolSettingMutation{ + config: c, + op: op, + typ: TypeMCPUserToolSetting, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withMCPUserToolSettingID sets the ID field of the mutation. +func withMCPUserToolSettingID(id uuid.UUID) mcpusertoolsettingOption { + return func(m *MCPUserToolSettingMutation) { + var ( + err error + once sync.Once + value *MCPUserToolSetting + ) + m.oldValue = func(ctx context.Context) (*MCPUserToolSetting, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().MCPUserToolSetting.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withMCPUserToolSetting sets the old MCPUserToolSetting of the mutation. +func withMCPUserToolSetting(node *MCPUserToolSetting) mcpusertoolsettingOption { + return func(m *MCPUserToolSettingMutation) { + m.oldValue = func(context.Context) (*MCPUserToolSetting, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m MCPUserToolSettingMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m MCPUserToolSettingMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of MCPUserToolSetting entities. +func (m *MCPUserToolSettingMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *MCPUserToolSettingMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *MCPUserToolSettingMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().MCPUserToolSetting.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetUserID sets the "user_id" field. +func (m *MCPUserToolSettingMutation) SetUserID(u uuid.UUID) { + m.user_id = &u +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *MCPUserToolSettingMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user_id + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the MCPUserToolSetting entity. +// If the MCPUserToolSetting object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUserToolSettingMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *MCPUserToolSettingMutation) ResetUserID() { + m.user_id = nil +} + +// SetToolID sets the "tool_id" field. +func (m *MCPUserToolSettingMutation) SetToolID(u uuid.UUID) { + m.tool_id = &u +} + +// ToolID returns the value of the "tool_id" field in the mutation. +func (m *MCPUserToolSettingMutation) ToolID() (r uuid.UUID, exists bool) { + v := m.tool_id + if v == nil { + return + } + return *v, true +} + +// OldToolID returns the old "tool_id" field's value of the MCPUserToolSetting entity. +// If the MCPUserToolSetting object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUserToolSettingMutation) OldToolID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldToolID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldToolID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldToolID: %w", err) + } + return oldValue.ToolID, nil +} + +// ResetToolID resets all changes to the "tool_id" field. +func (m *MCPUserToolSettingMutation) ResetToolID() { + m.tool_id = nil +} + +// SetEnabled sets the "enabled" field. +func (m *MCPUserToolSettingMutation) SetEnabled(b bool) { + m.enabled = &b +} + +// Enabled returns the value of the "enabled" field in the mutation. +func (m *MCPUserToolSettingMutation) Enabled() (r bool, exists bool) { + v := m.enabled + if v == nil { + return + } + return *v, true +} + +// OldEnabled returns the old "enabled" field's value of the MCPUserToolSetting entity. +// If the MCPUserToolSetting object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUserToolSettingMutation) OldEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEnabled: %w", err) + } + return oldValue.Enabled, nil +} + +// ResetEnabled resets all changes to the "enabled" field. +func (m *MCPUserToolSettingMutation) ResetEnabled() { + m.enabled = nil +} + +// SetCreatedAt sets the "created_at" field. +func (m *MCPUserToolSettingMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *MCPUserToolSettingMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the MCPUserToolSetting entity. +// If the MCPUserToolSetting object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUserToolSettingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *MCPUserToolSettingMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *MCPUserToolSettingMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *MCPUserToolSettingMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the MCPUserToolSetting entity. +// If the MCPUserToolSetting object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MCPUserToolSettingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *MCPUserToolSettingMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// Where appends a list predicates to the MCPUserToolSettingMutation builder. +func (m *MCPUserToolSettingMutation) Where(ps ...predicate.MCPUserToolSetting) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the MCPUserToolSettingMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *MCPUserToolSettingMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.MCPUserToolSetting, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *MCPUserToolSettingMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *MCPUserToolSettingMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (MCPUserToolSetting). +func (m *MCPUserToolSettingMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *MCPUserToolSettingMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.user_id != nil { + fields = append(fields, mcpusertoolsetting.FieldUserID) + } + if m.tool_id != nil { + fields = append(fields, mcpusertoolsetting.FieldToolID) + } + if m.enabled != nil { + fields = append(fields, mcpusertoolsetting.FieldEnabled) + } + if m.created_at != nil { + fields = append(fields, mcpusertoolsetting.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, mcpusertoolsetting.FieldUpdatedAt) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *MCPUserToolSettingMutation) Field(name string) (ent.Value, bool) { + switch name { + case mcpusertoolsetting.FieldUserID: + return m.UserID() + case mcpusertoolsetting.FieldToolID: + return m.ToolID() + case mcpusertoolsetting.FieldEnabled: + return m.Enabled() + case mcpusertoolsetting.FieldCreatedAt: + return m.CreatedAt() + case mcpusertoolsetting.FieldUpdatedAt: + return m.UpdatedAt() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *MCPUserToolSettingMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case mcpusertoolsetting.FieldUserID: + return m.OldUserID(ctx) + case mcpusertoolsetting.FieldToolID: + return m.OldToolID(ctx) + case mcpusertoolsetting.FieldEnabled: + return m.OldEnabled(ctx) + case mcpusertoolsetting.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case mcpusertoolsetting.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + } + return nil, fmt.Errorf("unknown MCPUserToolSetting field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MCPUserToolSettingMutation) SetField(name string, value ent.Value) error { + switch name { + case mcpusertoolsetting.FieldUserID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case mcpusertoolsetting.FieldToolID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetToolID(v) + return nil + case mcpusertoolsetting.FieldEnabled: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEnabled(v) + return nil + case mcpusertoolsetting.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case mcpusertoolsetting.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + } + return fmt.Errorf("unknown MCPUserToolSetting field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *MCPUserToolSettingMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *MCPUserToolSettingMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MCPUserToolSettingMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown MCPUserToolSetting numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *MCPUserToolSettingMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *MCPUserToolSettingMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *MCPUserToolSettingMutation) ClearField(name string) error { + return fmt.Errorf("unknown MCPUserToolSetting nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *MCPUserToolSettingMutation) ResetField(name string) error { + switch name { + case mcpusertoolsetting.FieldUserID: + m.ResetUserID() + return nil + case mcpusertoolsetting.FieldToolID: + m.ResetToolID() + return nil + case mcpusertoolsetting.FieldEnabled: + m.ResetEnabled() + return nil + case mcpusertoolsetting.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case mcpusertoolsetting.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + } + return fmt.Errorf("unknown MCPUserToolSetting field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *MCPUserToolSettingMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *MCPUserToolSettingMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *MCPUserToolSettingMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *MCPUserToolSettingMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *MCPUserToolSettingMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *MCPUserToolSettingMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *MCPUserToolSettingMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown MCPUserToolSetting unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *MCPUserToolSettingMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown MCPUserToolSetting edge %s", name) +} + +// ModelMutation represents an operation that mutates the Model nodes in the graph. +type ModelMutation struct { + config + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + provider *string + api_key *string + base_url *string + model *string + remark *string + temperature *float64 + addtemperature *float64 + interface_type *string + weight *int + addweight *int + thinking_enabled *bool + support_image *bool + is_hidden *bool + context_limit *int + addcontext_limit *int + output_limit *int + addoutput_limit *int + last_check_at *time.Time + last_check_success *bool + last_check_error *string + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + user *uuid.UUID + cleareduser bool + teams map[uuid.UUID]struct{} + removedteams map[uuid.UUID]struct{} + clearedteams bool + groups map[uuid.UUID]struct{} + removedgroups map[uuid.UUID]struct{} + clearedgroups bool + vms map[string]struct{} + removedvms map[string]struct{} + clearedvms bool + project_tasks map[uuid.UUID]struct{} + removedproject_tasks map[uuid.UUID]struct{} + clearedproject_tasks bool + pricing *uuid.UUID + clearedpricing bool + apikeys map[uuid.UUID]struct{} + removedapikeys map[uuid.UUID]struct{} + clearedapikeys bool + switches_from map[uuid.UUID]struct{} + removedswitches_from map[uuid.UUID]struct{} + clearedswitches_from bool + switches_to map[uuid.UUID]struct{} + removedswitches_to map[uuid.UUID]struct{} + clearedswitches_to bool + team_models map[uuid.UUID]struct{} + removedteam_models map[uuid.UUID]struct{} + clearedteam_models bool + team_group_models map[uuid.UUID]struct{} + removedteam_group_models map[uuid.UUID]struct{} + clearedteam_group_models bool + done bool + oldValue func(context.Context) (*Model, error) + predicates []predicate.Model +} + +var _ ent.Mutation = (*ModelMutation)(nil) + +// modelOption allows management of the mutation configuration using functional options. +type modelOption func(*ModelMutation) + +// newModelMutation creates new mutation for the Model entity. +func newModelMutation(c config, op Op, opts ...modelOption) *ModelMutation { + m := &ModelMutation{ + config: c, + op: op, + typ: TypeModel, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withModelID sets the ID field of the mutation. +func withModelID(id uuid.UUID) modelOption { + return func(m *ModelMutation) { + var ( + err error + once sync.Once + value *Model + ) + m.oldValue = func(ctx context.Context) (*Model, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Model.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withModel sets the old Model of the mutation. +func withModel(node *Model) modelOption { + return func(m *ModelMutation) { + m.oldValue = func(context.Context) (*Model, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ModelMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ModelMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Model entities. +func (m *ModelMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ModelMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ModelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Model.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *ModelMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *ModelMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *ModelMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[model.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *ModelMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[model.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *ModelMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, model.FieldDeletedAt) +} + +// SetUserID sets the "user_id" field. +func (m *ModelMutation) SetUserID(u uuid.UUID) { + m.user = &u +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *ModelMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *ModelMutation) ResetUserID() { + m.user = nil +} + +// SetProvider sets the "provider" field. +func (m *ModelMutation) SetProvider(s string) { + m.provider = &s +} + +// Provider returns the value of the "provider" field in the mutation. +func (m *ModelMutation) Provider() (r string, exists bool) { + v := m.provider + if v == nil { + return + } + return *v, true +} + +// OldProvider returns the old "provider" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldProvider(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProvider is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProvider requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProvider: %w", err) + } + return oldValue.Provider, nil +} + +// ResetProvider resets all changes to the "provider" field. +func (m *ModelMutation) ResetProvider() { + m.provider = nil +} + +// SetAPIKey sets the "api_key" field. +func (m *ModelMutation) SetAPIKey(s string) { + m.api_key = &s +} + +// APIKey returns the value of the "api_key" field in the mutation. +func (m *ModelMutation) APIKey() (r string, exists bool) { + v := m.api_key + if v == nil { + return + } + return *v, true +} + +// OldAPIKey returns the old "api_key" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldAPIKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAPIKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAPIKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAPIKey: %w", err) + } + return oldValue.APIKey, nil +} + +// ResetAPIKey resets all changes to the "api_key" field. +func (m *ModelMutation) ResetAPIKey() { + m.api_key = nil +} + +// SetBaseURL sets the "base_url" field. +func (m *ModelMutation) SetBaseURL(s string) { + m.base_url = &s +} + +// BaseURL returns the value of the "base_url" field in the mutation. +func (m *ModelMutation) BaseURL() (r string, exists bool) { + v := m.base_url + if v == nil { + return + } + return *v, true +} + +// OldBaseURL returns the old "base_url" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldBaseURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBaseURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBaseURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBaseURL: %w", err) + } + return oldValue.BaseURL, nil +} + +// ResetBaseURL resets all changes to the "base_url" field. +func (m *ModelMutation) ResetBaseURL() { + m.base_url = nil +} + +// SetModel sets the "model" field. +func (m *ModelMutation) SetModel(s string) { + m.model = &s +} + +// Model returns the value of the "model" field in the mutation. +func (m *ModelMutation) Model() (r string, exists bool) { + v := m.model + if v == nil { + return + } + return *v, true +} + +// OldModel returns the old "model" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldModel(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModel: %w", err) + } + return oldValue.Model, nil +} + +// ResetModel resets all changes to the "model" field. +func (m *ModelMutation) ResetModel() { + m.model = nil +} + +// SetRemark sets the "remark" field. +func (m *ModelMutation) SetRemark(s string) { + m.remark = &s +} + +// Remark returns the value of the "remark" field in the mutation. +func (m *ModelMutation) Remark() (r string, exists bool) { + v := m.remark + if v == nil { + return + } + return *v, true +} + +// OldRemark returns the old "remark" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldRemark(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRemark is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRemark requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRemark: %w", err) + } + return oldValue.Remark, nil +} + +// ClearRemark clears the value of the "remark" field. +func (m *ModelMutation) ClearRemark() { + m.remark = nil + m.clearedFields[model.FieldRemark] = struct{}{} +} + +// RemarkCleared returns if the "remark" field was cleared in this mutation. +func (m *ModelMutation) RemarkCleared() bool { + _, ok := m.clearedFields[model.FieldRemark] + return ok +} + +// ResetRemark resets all changes to the "remark" field. +func (m *ModelMutation) ResetRemark() { + m.remark = nil + delete(m.clearedFields, model.FieldRemark) +} + +// SetTemperature sets the "temperature" field. +func (m *ModelMutation) SetTemperature(f float64) { + m.temperature = &f + m.addtemperature = nil +} + +// Temperature returns the value of the "temperature" field in the mutation. +func (m *ModelMutation) Temperature() (r float64, exists bool) { + v := m.temperature + if v == nil { + return + } + return *v, true +} + +// OldTemperature returns the old "temperature" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldTemperature(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTemperature is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTemperature requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTemperature: %w", err) + } + return oldValue.Temperature, nil +} + +// AddTemperature adds f to the "temperature" field. +func (m *ModelMutation) AddTemperature(f float64) { + if m.addtemperature != nil { + *m.addtemperature += f + } else { + m.addtemperature = &f + } +} + +// AddedTemperature returns the value that was added to the "temperature" field in this mutation. +func (m *ModelMutation) AddedTemperature() (r float64, exists bool) { + v := m.addtemperature + if v == nil { + return + } + return *v, true +} + +// ClearTemperature clears the value of the "temperature" field. +func (m *ModelMutation) ClearTemperature() { + m.temperature = nil + m.addtemperature = nil + m.clearedFields[model.FieldTemperature] = struct{}{} +} + +// TemperatureCleared returns if the "temperature" field was cleared in this mutation. +func (m *ModelMutation) TemperatureCleared() bool { + _, ok := m.clearedFields[model.FieldTemperature] + return ok +} + +// ResetTemperature resets all changes to the "temperature" field. +func (m *ModelMutation) ResetTemperature() { + m.temperature = nil + m.addtemperature = nil + delete(m.clearedFields, model.FieldTemperature) +} + +// SetInterfaceType sets the "interface_type" field. +func (m *ModelMutation) SetInterfaceType(s string) { + m.interface_type = &s +} + +// InterfaceType returns the value of the "interface_type" field in the mutation. +func (m *ModelMutation) InterfaceType() (r string, exists bool) { + v := m.interface_type + if v == nil { + return + } + return *v, true +} + +// OldInterfaceType returns the old "interface_type" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldInterfaceType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInterfaceType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInterfaceType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInterfaceType: %w", err) + } + return oldValue.InterfaceType, nil +} + +// ClearInterfaceType clears the value of the "interface_type" field. +func (m *ModelMutation) ClearInterfaceType() { + m.interface_type = nil + m.clearedFields[model.FieldInterfaceType] = struct{}{} +} + +// InterfaceTypeCleared returns if the "interface_type" field was cleared in this mutation. +func (m *ModelMutation) InterfaceTypeCleared() bool { + _, ok := m.clearedFields[model.FieldInterfaceType] + return ok +} + +// ResetInterfaceType resets all changes to the "interface_type" field. +func (m *ModelMutation) ResetInterfaceType() { + m.interface_type = nil + delete(m.clearedFields, model.FieldInterfaceType) +} + +// SetWeight sets the "weight" field. +func (m *ModelMutation) SetWeight(i int) { + m.weight = &i + m.addweight = nil +} + +// Weight returns the value of the "weight" field in the mutation. +func (m *ModelMutation) Weight() (r int, exists bool) { + v := m.weight + if v == nil { + return + } + return *v, true +} + +// OldWeight returns the old "weight" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldWeight(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWeight is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWeight requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWeight: %w", err) + } + return oldValue.Weight, nil +} + +// AddWeight adds i to the "weight" field. +func (m *ModelMutation) AddWeight(i int) { + if m.addweight != nil { + *m.addweight += i + } else { + m.addweight = &i + } +} + +// AddedWeight returns the value that was added to the "weight" field in this mutation. +func (m *ModelMutation) AddedWeight() (r int, exists bool) { + v := m.addweight + if v == nil { + return + } + return *v, true +} + +// ResetWeight resets all changes to the "weight" field. +func (m *ModelMutation) ResetWeight() { + m.weight = nil + m.addweight = nil +} + +// SetThinkingEnabled sets the "thinking_enabled" field. +func (m *ModelMutation) SetThinkingEnabled(b bool) { + m.thinking_enabled = &b +} + +// ThinkingEnabled returns the value of the "thinking_enabled" field in the mutation. +func (m *ModelMutation) ThinkingEnabled() (r bool, exists bool) { + v := m.thinking_enabled + if v == nil { + return + } + return *v, true +} + +// OldThinkingEnabled returns the old "thinking_enabled" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldThinkingEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldThinkingEnabled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldThinkingEnabled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldThinkingEnabled: %w", err) + } + return oldValue.ThinkingEnabled, nil +} + +// ResetThinkingEnabled resets all changes to the "thinking_enabled" field. +func (m *ModelMutation) ResetThinkingEnabled() { + m.thinking_enabled = nil +} + +// SetSupportImage sets the "support_image" field. +func (m *ModelMutation) SetSupportImage(b bool) { + m.support_image = &b +} + +// SupportImage returns the value of the "support_image" field in the mutation. +func (m *ModelMutation) SupportImage() (r bool, exists bool) { + v := m.support_image + if v == nil { + return + } + return *v, true +} + +// OldSupportImage returns the old "support_image" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldSupportImage(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSupportImage is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSupportImage requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSupportImage: %w", err) + } + return oldValue.SupportImage, nil +} + +// ResetSupportImage resets all changes to the "support_image" field. +func (m *ModelMutation) ResetSupportImage() { + m.support_image = nil +} + +// SetIsHidden sets the "is_hidden" field. +func (m *ModelMutation) SetIsHidden(b bool) { + m.is_hidden = &b +} + +// IsHidden returns the value of the "is_hidden" field in the mutation. +func (m *ModelMutation) IsHidden() (r bool, exists bool) { + v := m.is_hidden + if v == nil { + return + } + return *v, true +} + +// OldIsHidden returns the old "is_hidden" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldIsHidden(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsHidden is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsHidden requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsHidden: %w", err) + } + return oldValue.IsHidden, nil +} + +// ResetIsHidden resets all changes to the "is_hidden" field. +func (m *ModelMutation) ResetIsHidden() { + m.is_hidden = nil +} + +// SetContextLimit sets the "context_limit" field. +func (m *ModelMutation) SetContextLimit(i int) { + m.context_limit = &i + m.addcontext_limit = nil +} + +// ContextLimit returns the value of the "context_limit" field in the mutation. +func (m *ModelMutation) ContextLimit() (r int, exists bool) { + v := m.context_limit + if v == nil { + return + } + return *v, true +} + +// OldContextLimit returns the old "context_limit" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldContextLimit(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldContextLimit is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldContextLimit requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldContextLimit: %w", err) + } + return oldValue.ContextLimit, nil +} + +// AddContextLimit adds i to the "context_limit" field. +func (m *ModelMutation) AddContextLimit(i int) { + if m.addcontext_limit != nil { + *m.addcontext_limit += i + } else { + m.addcontext_limit = &i + } +} + +// AddedContextLimit returns the value that was added to the "context_limit" field in this mutation. +func (m *ModelMutation) AddedContextLimit() (r int, exists bool) { + v := m.addcontext_limit + if v == nil { + return + } + return *v, true +} + +// ResetContextLimit resets all changes to the "context_limit" field. +func (m *ModelMutation) ResetContextLimit() { + m.context_limit = nil + m.addcontext_limit = nil +} + +// SetOutputLimit sets the "output_limit" field. +func (m *ModelMutation) SetOutputLimit(i int) { + m.output_limit = &i + m.addoutput_limit = nil +} + +// OutputLimit returns the value of the "output_limit" field in the mutation. +func (m *ModelMutation) OutputLimit() (r int, exists bool) { + v := m.output_limit + if v == nil { + return + } + return *v, true +} + +// OldOutputLimit returns the old "output_limit" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldOutputLimit(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOutputLimit is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOutputLimit requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOutputLimit: %w", err) + } + return oldValue.OutputLimit, nil +} + +// AddOutputLimit adds i to the "output_limit" field. +func (m *ModelMutation) AddOutputLimit(i int) { + if m.addoutput_limit != nil { + *m.addoutput_limit += i + } else { + m.addoutput_limit = &i + } +} + +// AddedOutputLimit returns the value that was added to the "output_limit" field in this mutation. +func (m *ModelMutation) AddedOutputLimit() (r int, exists bool) { + v := m.addoutput_limit + if v == nil { + return + } + return *v, true +} + +// ResetOutputLimit resets all changes to the "output_limit" field. +func (m *ModelMutation) ResetOutputLimit() { + m.output_limit = nil + m.addoutput_limit = nil +} + +// SetLastCheckAt sets the "last_check_at" field. +func (m *ModelMutation) SetLastCheckAt(t time.Time) { + m.last_check_at = &t +} + +// LastCheckAt returns the value of the "last_check_at" field in the mutation. +func (m *ModelMutation) LastCheckAt() (r time.Time, exists bool) { + v := m.last_check_at + if v == nil { + return + } + return *v, true } -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *ModelMutation) AddedEdges() []string { - edges := make([]string, 0, 11) - if m.user != nil { - edges = append(edges, model.EdgeUser) +// OldLastCheckAt returns the old "last_check_at" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldLastCheckAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastCheckAt is only allowed on UpdateOne operations") } - if m.teams != nil { - edges = append(edges, model.EdgeTeams) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastCheckAt requires an ID field in the mutation") } - if m.groups != nil { - edges = append(edges, model.EdgeGroups) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastCheckAt: %w", err) } - if m.vms != nil { - edges = append(edges, model.EdgeVms) + return oldValue.LastCheckAt, nil +} + +// ClearLastCheckAt clears the value of the "last_check_at" field. +func (m *ModelMutation) ClearLastCheckAt() { + m.last_check_at = nil + m.clearedFields[model.FieldLastCheckAt] = struct{}{} +} + +// LastCheckAtCleared returns if the "last_check_at" field was cleared in this mutation. +func (m *ModelMutation) LastCheckAtCleared() bool { + _, ok := m.clearedFields[model.FieldLastCheckAt] + return ok +} + +// ResetLastCheckAt resets all changes to the "last_check_at" field. +func (m *ModelMutation) ResetLastCheckAt() { + m.last_check_at = nil + delete(m.clearedFields, model.FieldLastCheckAt) +} + +// SetLastCheckSuccess sets the "last_check_success" field. +func (m *ModelMutation) SetLastCheckSuccess(b bool) { + m.last_check_success = &b +} + +// LastCheckSuccess returns the value of the "last_check_success" field in the mutation. +func (m *ModelMutation) LastCheckSuccess() (r bool, exists bool) { + v := m.last_check_success + if v == nil { + return } - if m.project_tasks != nil { - edges = append(edges, model.EdgeProjectTasks) + return *v, true +} + +// OldLastCheckSuccess returns the old "last_check_success" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldLastCheckSuccess(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastCheckSuccess is only allowed on UpdateOne operations") } - if m.pricing != nil { - edges = append(edges, model.EdgePricing) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastCheckSuccess requires an ID field in the mutation") } - if m.apikeys != nil { - edges = append(edges, model.EdgeApikeys) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastCheckSuccess: %w", err) } - if m.switches_from != nil { - edges = append(edges, model.EdgeSwitchesFrom) + return oldValue.LastCheckSuccess, nil +} + +// ClearLastCheckSuccess clears the value of the "last_check_success" field. +func (m *ModelMutation) ClearLastCheckSuccess() { + m.last_check_success = nil + m.clearedFields[model.FieldLastCheckSuccess] = struct{}{} +} + +// LastCheckSuccessCleared returns if the "last_check_success" field was cleared in this mutation. +func (m *ModelMutation) LastCheckSuccessCleared() bool { + _, ok := m.clearedFields[model.FieldLastCheckSuccess] + return ok +} + +// ResetLastCheckSuccess resets all changes to the "last_check_success" field. +func (m *ModelMutation) ResetLastCheckSuccess() { + m.last_check_success = nil + delete(m.clearedFields, model.FieldLastCheckSuccess) +} + +// SetLastCheckError sets the "last_check_error" field. +func (m *ModelMutation) SetLastCheckError(s string) { + m.last_check_error = &s +} + +// LastCheckError returns the value of the "last_check_error" field in the mutation. +func (m *ModelMutation) LastCheckError() (r string, exists bool) { + v := m.last_check_error + if v == nil { + return } - if m.switches_to != nil { - edges = append(edges, model.EdgeSwitchesTo) + return *v, true +} + +// OldLastCheckError returns the old "last_check_error" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldLastCheckError(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastCheckError is only allowed on UpdateOne operations") } - if m.team_models != nil { - edges = append(edges, model.EdgeTeamModels) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastCheckError requires an ID field in the mutation") } - if m.team_group_models != nil { - edges = append(edges, model.EdgeTeamGroupModels) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastCheckError: %w", err) } - return edges + return oldValue.LastCheckError, nil } -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *ModelMutation) AddedIDs(name string) []ent.Value { - switch name { - case model.EdgeUser: - if id := m.user; id != nil { - return []ent.Value{*id} - } - case model.EdgeTeams: - ids := make([]ent.Value, 0, len(m.teams)) - for id := range m.teams { - ids = append(ids, id) - } - return ids - case model.EdgeGroups: - ids := make([]ent.Value, 0, len(m.groups)) - for id := range m.groups { - ids = append(ids, id) - } - return ids - case model.EdgeVms: - ids := make([]ent.Value, 0, len(m.vms)) - for id := range m.vms { - ids = append(ids, id) - } - return ids - case model.EdgeProjectTasks: - ids := make([]ent.Value, 0, len(m.project_tasks)) - for id := range m.project_tasks { - ids = append(ids, id) - } - return ids - case model.EdgePricing: - if id := m.pricing; id != nil { - return []ent.Value{*id} - } - case model.EdgeApikeys: - ids := make([]ent.Value, 0, len(m.apikeys)) - for id := range m.apikeys { - ids = append(ids, id) - } - return ids - case model.EdgeSwitchesFrom: - ids := make([]ent.Value, 0, len(m.switches_from)) - for id := range m.switches_from { - ids = append(ids, id) - } - return ids - case model.EdgeSwitchesTo: - ids := make([]ent.Value, 0, len(m.switches_to)) - for id := range m.switches_to { - ids = append(ids, id) - } - return ids - case model.EdgeTeamModels: - ids := make([]ent.Value, 0, len(m.team_models)) - for id := range m.team_models { - ids = append(ids, id) - } - return ids - case model.EdgeTeamGroupModels: - ids := make([]ent.Value, 0, len(m.team_group_models)) - for id := range m.team_group_models { - ids = append(ids, id) - } - return ids +// ClearLastCheckError clears the value of the "last_check_error" field. +func (m *ModelMutation) ClearLastCheckError() { + m.last_check_error = nil + m.clearedFields[model.FieldLastCheckError] = struct{}{} +} + +// LastCheckErrorCleared returns if the "last_check_error" field was cleared in this mutation. +func (m *ModelMutation) LastCheckErrorCleared() bool { + _, ok := m.clearedFields[model.FieldLastCheckError] + return ok +} + +// ResetLastCheckError resets all changes to the "last_check_error" field. +func (m *ModelMutation) ResetLastCheckError() { + m.last_check_error = nil + delete(m.clearedFields, model.FieldLastCheckError) +} + +// SetCreatedAt sets the "created_at" field. +func (m *ModelMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ModelMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return } - return nil + return *v, true } -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *ModelMutation) RemovedEdges() []string { - edges := make([]string, 0, 11) - if m.removedteams != nil { - edges = append(edges, model.EdgeTeams) +// OldCreatedAt returns the old "created_at" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } - if m.removedgroups != nil { - edges = append(edges, model.EdgeGroups) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } - if m.removedvms != nil { - edges = append(edges, model.EdgeVms) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - if m.removedproject_tasks != nil { - edges = append(edges, model.EdgeProjectTasks) + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ModelMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *ModelMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ModelMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return } - if m.removedapikeys != nil { - edges = append(edges, model.EdgeApikeys) + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Model entity. +// If the Model object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ModelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } - if m.removedswitches_from != nil { - edges = append(edges, model.EdgeSwitchesFrom) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } - if m.removedswitches_to != nil { - edges = append(edges, model.EdgeSwitchesTo) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } - if m.removedteam_models != nil { - edges = append(edges, model.EdgeTeamModels) + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ModelMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// ClearUser clears the "user" edge to the User entity. +func (m *ModelMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[model.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *ModelMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *ModelMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { + ids = append(ids, *id) } - if m.removedteam_group_models != nil { - edges = append(edges, model.EdgeTeamGroupModels) + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *ModelMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// AddTeamIDs adds the "teams" edge to the Team entity by ids. +func (m *ModelMutation) AddTeamIDs(ids ...uuid.UUID) { + if m.teams == nil { + m.teams = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.teams[ids[i]] = struct{}{} } - return edges } -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *ModelMutation) RemovedIDs(name string) []ent.Value { - switch name { - case model.EdgeTeams: - ids := make([]ent.Value, 0, len(m.removedteams)) - for id := range m.removedteams { - ids = append(ids, id) - } - return ids - case model.EdgeGroups: - ids := make([]ent.Value, 0, len(m.removedgroups)) - for id := range m.removedgroups { - ids = append(ids, id) - } - return ids - case model.EdgeVms: - ids := make([]ent.Value, 0, len(m.removedvms)) - for id := range m.removedvms { - ids = append(ids, id) - } - return ids - case model.EdgeProjectTasks: - ids := make([]ent.Value, 0, len(m.removedproject_tasks)) - for id := range m.removedproject_tasks { - ids = append(ids, id) - } - return ids - case model.EdgeApikeys: - ids := make([]ent.Value, 0, len(m.removedapikeys)) - for id := range m.removedapikeys { - ids = append(ids, id) - } - return ids - case model.EdgeSwitchesFrom: - ids := make([]ent.Value, 0, len(m.removedswitches_from)) - for id := range m.removedswitches_from { - ids = append(ids, id) - } - return ids - case model.EdgeSwitchesTo: - ids := make([]ent.Value, 0, len(m.removedswitches_to)) - for id := range m.removedswitches_to { - ids = append(ids, id) - } - return ids - case model.EdgeTeamModels: - ids := make([]ent.Value, 0, len(m.removedteam_models)) - for id := range m.removedteam_models { - ids = append(ids, id) - } - return ids - case model.EdgeTeamGroupModels: - ids := make([]ent.Value, 0, len(m.removedteam_group_models)) - for id := range m.removedteam_group_models { - ids = append(ids, id) - } - return ids +// ClearTeams clears the "teams" edge to the Team entity. +func (m *ModelMutation) ClearTeams() { + m.clearedteams = true +} + +// TeamsCleared reports if the "teams" edge to the Team entity was cleared. +func (m *ModelMutation) TeamsCleared() bool { + return m.clearedteams +} + +// RemoveTeamIDs removes the "teams" edge to the Team entity by IDs. +func (m *ModelMutation) RemoveTeamIDs(ids ...uuid.UUID) { + if m.removedteams == nil { + m.removedteams = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.teams, ids[i]) + m.removedteams[ids[i]] = struct{}{} } - return nil } -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ModelMutation) ClearedEdges() []string { - edges := make([]string, 0, 11) - if m.cleareduser { - edges = append(edges, model.EdgeUser) +// RemovedTeams returns the removed IDs of the "teams" edge to the Team entity. +func (m *ModelMutation) RemovedTeamsIDs() (ids []uuid.UUID) { + for id := range m.removedteams { + ids = append(ids, id) } - if m.clearedteams { - edges = append(edges, model.EdgeTeams) + return +} + +// TeamsIDs returns the "teams" edge IDs in the mutation. +func (m *ModelMutation) TeamsIDs() (ids []uuid.UUID) { + for id := range m.teams { + ids = append(ids, id) } - if m.clearedgroups { - edges = append(edges, model.EdgeGroups) + return +} + +// ResetTeams resets all changes to the "teams" edge. +func (m *ModelMutation) ResetTeams() { + m.teams = nil + m.clearedteams = false + m.removedteams = nil +} + +// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids. +func (m *ModelMutation) AddGroupIDs(ids ...uuid.UUID) { + if m.groups == nil { + m.groups = make(map[uuid.UUID]struct{}) } - if m.clearedvms { - edges = append(edges, model.EdgeVms) + for i := range ids { + m.groups[ids[i]] = struct{}{} } - if m.clearedproject_tasks { - edges = append(edges, model.EdgeProjectTasks) +} + +// ClearGroups clears the "groups" edge to the TeamGroup entity. +func (m *ModelMutation) ClearGroups() { + m.clearedgroups = true +} + +// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared. +func (m *ModelMutation) GroupsCleared() bool { + return m.clearedgroups +} + +// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs. +func (m *ModelMutation) RemoveGroupIDs(ids ...uuid.UUID) { + if m.removedgroups == nil { + m.removedgroups = make(map[uuid.UUID]struct{}) } - if m.clearedpricing { - edges = append(edges, model.EdgePricing) + for i := range ids { + delete(m.groups, ids[i]) + m.removedgroups[ids[i]] = struct{}{} } - if m.clearedapikeys { - edges = append(edges, model.EdgeApikeys) +} + +// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity. +func (m *ModelMutation) RemovedGroupsIDs() (ids []uuid.UUID) { + for id := range m.removedgroups { + ids = append(ids, id) } - if m.clearedswitches_from { - edges = append(edges, model.EdgeSwitchesFrom) + return +} + +// GroupsIDs returns the "groups" edge IDs in the mutation. +func (m *ModelMutation) GroupsIDs() (ids []uuid.UUID) { + for id := range m.groups { + ids = append(ids, id) + } + return +} + +// ResetGroups resets all changes to the "groups" edge. +func (m *ModelMutation) ResetGroups() { + m.groups = nil + m.clearedgroups = false + m.removedgroups = nil +} + +// AddVMIDs adds the "vms" edge to the VirtualMachine entity by ids. +func (m *ModelMutation) AddVMIDs(ids ...string) { + if m.vms == nil { + m.vms = make(map[string]struct{}) } - if m.clearedswitches_to { - edges = append(edges, model.EdgeSwitchesTo) + for i := range ids { + m.vms[ids[i]] = struct{}{} } - if m.clearedteam_models { - edges = append(edges, model.EdgeTeamModels) +} + +// ClearVms clears the "vms" edge to the VirtualMachine entity. +func (m *ModelMutation) ClearVms() { + m.clearedvms = true +} + +// VmsCleared reports if the "vms" edge to the VirtualMachine entity was cleared. +func (m *ModelMutation) VmsCleared() bool { + return m.clearedvms +} + +// RemoveVMIDs removes the "vms" edge to the VirtualMachine entity by IDs. +func (m *ModelMutation) RemoveVMIDs(ids ...string) { + if m.removedvms == nil { + m.removedvms = make(map[string]struct{}) } - if m.clearedteam_group_models { - edges = append(edges, model.EdgeTeamGroupModels) + for i := range ids { + delete(m.vms, ids[i]) + m.removedvms[ids[i]] = struct{}{} } - return edges } -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *ModelMutation) EdgeCleared(name string) bool { - switch name { - case model.EdgeUser: - return m.cleareduser - case model.EdgeTeams: - return m.clearedteams - case model.EdgeGroups: - return m.clearedgroups - case model.EdgeVms: - return m.clearedvms - case model.EdgeProjectTasks: - return m.clearedproject_tasks - case model.EdgePricing: - return m.clearedpricing - case model.EdgeApikeys: - return m.clearedapikeys - case model.EdgeSwitchesFrom: - return m.clearedswitches_from - case model.EdgeSwitchesTo: - return m.clearedswitches_to - case model.EdgeTeamModels: - return m.clearedteam_models - case model.EdgeTeamGroupModels: - return m.clearedteam_group_models +// RemovedVms returns the removed IDs of the "vms" edge to the VirtualMachine entity. +func (m *ModelMutation) RemovedVmsIDs() (ids []string) { + for id := range m.removedvms { + ids = append(ids, id) } - return false + return } -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *ModelMutation) ClearEdge(name string) error { - switch name { - case model.EdgeUser: - m.ClearUser() - return nil - case model.EdgePricing: - m.ClearPricing() - return nil +// VmsIDs returns the "vms" edge IDs in the mutation. +func (m *ModelMutation) VmsIDs() (ids []string) { + for id := range m.vms { + ids = append(ids, id) } - return fmt.Errorf("unknown Model unique edge %s", name) + return } -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *ModelMutation) ResetEdge(name string) error { - switch name { - case model.EdgeUser: - m.ResetUser() - return nil - case model.EdgeTeams: - m.ResetTeams() - return nil - case model.EdgeGroups: - m.ResetGroups() - return nil - case model.EdgeVms: - m.ResetVms() - return nil - case model.EdgeProjectTasks: - m.ResetProjectTasks() - return nil - case model.EdgePricing: - m.ResetPricing() - return nil - case model.EdgeApikeys: - m.ResetApikeys() - return nil - case model.EdgeSwitchesFrom: - m.ResetSwitchesFrom() - return nil - case model.EdgeSwitchesTo: - m.ResetSwitchesTo() - return nil - case model.EdgeTeamModels: - m.ResetTeamModels() - return nil - case model.EdgeTeamGroupModels: - m.ResetTeamGroupModels() - return nil - } - return fmt.Errorf("unknown Model edge %s", name) +// ResetVms resets all changes to the "vms" edge. +func (m *ModelMutation) ResetVms() { + m.vms = nil + m.clearedvms = false + m.removedvms = nil } -// ModelApiKeyMutation represents an operation that mutates the ModelApiKey nodes in the graph. -type ModelApiKeyMutation struct { - config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - user_id *uuid.UUID - virtualmachine_id *string - api_key *string - created_at *time.Time - clearedFields map[string]struct{} - model *uuid.UUID - clearedmodel bool - done bool - oldValue func(context.Context) (*ModelApiKey, error) - predicates []predicate.ModelApiKey +// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids. +func (m *ModelMutation) AddProjectTaskIDs(ids ...uuid.UUID) { + if m.project_tasks == nil { + m.project_tasks = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.project_tasks[ids[i]] = struct{}{} + } } -var _ ent.Mutation = (*ModelApiKeyMutation)(nil) +// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity. +func (m *ModelMutation) ClearProjectTasks() { + m.clearedproject_tasks = true +} -// modelapikeyOption allows management of the mutation configuration using functional options. -type modelapikeyOption func(*ModelApiKeyMutation) +// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared. +func (m *ModelMutation) ProjectTasksCleared() bool { + return m.clearedproject_tasks +} -// newModelApiKeyMutation creates new mutation for the ModelApiKey entity. -func newModelApiKeyMutation(c config, op Op, opts ...modelapikeyOption) *ModelApiKeyMutation { - m := &ModelApiKeyMutation{ - config: c, - op: op, - typ: TypeModelApiKey, - clearedFields: make(map[string]struct{}), +// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs. +func (m *ModelMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) { + if m.removedproject_tasks == nil { + m.removedproject_tasks = make(map[uuid.UUID]struct{}) } - for _, opt := range opts { - opt(m) + for i := range ids { + delete(m.project_tasks, ids[i]) + m.removedproject_tasks[ids[i]] = struct{}{} } - return m } -// withModelApiKeyID sets the ID field of the mutation. -func withModelApiKeyID(id uuid.UUID) modelapikeyOption { - return func(m *ModelApiKeyMutation) { - var ( - err error - once sync.Once - value *ModelApiKey - ) - m.oldValue = func(ctx context.Context) (*ModelApiKey, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().ModelApiKey.Get(ctx, id) - } - }) - return value, err - } - m.id = &id +// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity. +func (m *ModelMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) { + for id := range m.removedproject_tasks { + ids = append(ids, id) } + return } -// withModelApiKey sets the old ModelApiKey of the mutation. -func withModelApiKey(node *ModelApiKey) modelapikeyOption { - return func(m *ModelApiKeyMutation) { - m.oldValue = func(context.Context) (*ModelApiKey, error) { - return node, nil - } - m.id = &node.ID +// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation. +func (m *ModelMutation) ProjectTasksIDs() (ids []uuid.UUID) { + for id := range m.project_tasks { + ids = append(ids, id) } + return } -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m ModelApiKeyMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client +// ResetProjectTasks resets all changes to the "project_tasks" edge. +func (m *ModelMutation) ResetProjectTasks() { + m.project_tasks = nil + m.clearedproject_tasks = false + m.removedproject_tasks = nil } -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m ModelApiKeyMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("db: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil +// SetPricingID sets the "pricing" edge to the ModelPricing entity by id. +func (m *ModelMutation) SetPricingID(id uuid.UUID) { + m.pricing = &id } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of ModelApiKey entities. -func (m *ModelApiKeyMutation) SetID(id uuid.UUID) { - m.id = &id +// ClearPricing clears the "pricing" edge to the ModelPricing entity. +func (m *ModelMutation) ClearPricing() { + m.clearedpricing = true } -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *ModelApiKeyMutation) ID() (id uuid.UUID, exists bool) { - if m.id == nil { - return - } - return *m.id, true +// PricingCleared reports if the "pricing" edge to the ModelPricing entity was cleared. +func (m *ModelMutation) PricingCleared() bool { + return m.clearedpricing } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *ModelApiKeyMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []uuid.UUID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().ModelApiKey.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) +// PricingID returns the "pricing" edge ID in the mutation. +func (m *ModelMutation) PricingID() (id uuid.UUID, exists bool) { + if m.pricing != nil { + return *m.pricing, true } + return } -// SetDeletedAt sets the "deleted_at" field. -func (m *ModelApiKeyMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t +// PricingIDs returns the "pricing" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PricingID instead. It exists only for internal usage by the builders. +func (m *ModelMutation) PricingIDs() (ids []uuid.UUID) { + if id := m.pricing; id != nil { + ids = append(ids, *id) + } + return } -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *ModelApiKeyMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at - if v == nil { - return - } - return *v, true +// ResetPricing resets all changes to the "pricing" edge. +func (m *ModelMutation) ResetPricing() { + m.pricing = nil + m.clearedpricing = false } -// OldDeletedAt returns the old "deleted_at" field's value of the ModelApiKey entity. -// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") +// AddApikeyIDs adds the "apikeys" edge to the ModelApiKey entity by ids. +func (m *ModelMutation) AddApikeyIDs(ids ...uuid.UUID) { + if m.apikeys == nil { + m.apikeys = make(map[uuid.UUID]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + for i := range ids { + m.apikeys[ids[i]] = struct{}{} } - return oldValue.DeletedAt, nil } -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *ModelApiKeyMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[modelapikey.FieldDeletedAt] = struct{}{} +// ClearApikeys clears the "apikeys" edge to the ModelApiKey entity. +func (m *ModelMutation) ClearApikeys() { + m.clearedapikeys = true } -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *ModelApiKeyMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[modelapikey.FieldDeletedAt] - return ok +// ApikeysCleared reports if the "apikeys" edge to the ModelApiKey entity was cleared. +func (m *ModelMutation) ApikeysCleared() bool { + return m.clearedapikeys } -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *ModelApiKeyMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, modelapikey.FieldDeletedAt) +// RemoveApikeyIDs removes the "apikeys" edge to the ModelApiKey entity by IDs. +func (m *ModelMutation) RemoveApikeyIDs(ids ...uuid.UUID) { + if m.removedapikeys == nil { + m.removedapikeys = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.apikeys, ids[i]) + m.removedapikeys[ids[i]] = struct{}{} + } } -// SetModelID sets the "model_id" field. -func (m *ModelApiKeyMutation) SetModelID(u uuid.UUID) { - m.model = &u +// RemovedApikeys returns the removed IDs of the "apikeys" edge to the ModelApiKey entity. +func (m *ModelMutation) RemovedApikeysIDs() (ids []uuid.UUID) { + for id := range m.removedapikeys { + ids = append(ids, id) + } + return } -// ModelID returns the value of the "model_id" field in the mutation. -func (m *ModelApiKeyMutation) ModelID() (r uuid.UUID, exists bool) { - v := m.model - if v == nil { - return +// ApikeysIDs returns the "apikeys" edge IDs in the mutation. +func (m *ModelMutation) ApikeysIDs() (ids []uuid.UUID) { + for id := range m.apikeys { + ids = append(ids, id) } - return *v, true + return } -// OldModelID returns the old "model_id" field's value of the ModelApiKey entity. -// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelApiKeyMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModelID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModelID requires an ID field in the mutation") +// ResetApikeys resets all changes to the "apikeys" edge. +func (m *ModelMutation) ResetApikeys() { + m.apikeys = nil + m.clearedapikeys = false + m.removedapikeys = nil +} + +// AddSwitchesFromIDs adds the "switches_from" edge to the TaskModelSwitch entity by ids. +func (m *ModelMutation) AddSwitchesFromIDs(ids ...uuid.UUID) { + if m.switches_from == nil { + m.switches_from = make(map[uuid.UUID]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModelID: %w", err) + for i := range ids { + m.switches_from[ids[i]] = struct{}{} } - return oldValue.ModelID, nil } -// ResetModelID resets all changes to the "model_id" field. -func (m *ModelApiKeyMutation) ResetModelID() { - m.model = nil +// ClearSwitchesFrom clears the "switches_from" edge to the TaskModelSwitch entity. +func (m *ModelMutation) ClearSwitchesFrom() { + m.clearedswitches_from = true } -// SetUserID sets the "user_id" field. -func (m *ModelApiKeyMutation) SetUserID(u uuid.UUID) { - m.user_id = &u +// SwitchesFromCleared reports if the "switches_from" edge to the TaskModelSwitch entity was cleared. +func (m *ModelMutation) SwitchesFromCleared() bool { + return m.clearedswitches_from } -// UserID returns the value of the "user_id" field in the mutation. -func (m *ModelApiKeyMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user_id - if v == nil { - return +// RemoveSwitchesFromIDs removes the "switches_from" edge to the TaskModelSwitch entity by IDs. +func (m *ModelMutation) RemoveSwitchesFromIDs(ids ...uuid.UUID) { + if m.removedswitches_from == nil { + m.removedswitches_from = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.switches_from, ids[i]) + m.removedswitches_from[ids[i]] = struct{}{} } - return *v, true } -// OldUserID returns the old "user_id" field's value of the ModelApiKey entity. -// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelApiKeyMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) +// RemovedSwitchesFrom returns the removed IDs of the "switches_from" edge to the TaskModelSwitch entity. +func (m *ModelMutation) RemovedSwitchesFromIDs() (ids []uuid.UUID) { + for id := range m.removedswitches_from { + ids = append(ids, id) } - return oldValue.UserID, nil + return } -// ResetUserID resets all changes to the "user_id" field. -func (m *ModelApiKeyMutation) ResetUserID() { - m.user_id = nil +// SwitchesFromIDs returns the "switches_from" edge IDs in the mutation. +func (m *ModelMutation) SwitchesFromIDs() (ids []uuid.UUID) { + for id := range m.switches_from { + ids = append(ids, id) + } + return } -// SetVirtualmachineID sets the "virtualmachine_id" field. -func (m *ModelApiKeyMutation) SetVirtualmachineID(s string) { - m.virtualmachine_id = &s +// ResetSwitchesFrom resets all changes to the "switches_from" edge. +func (m *ModelMutation) ResetSwitchesFrom() { + m.switches_from = nil + m.clearedswitches_from = false + m.removedswitches_from = nil } -// VirtualmachineID returns the value of the "virtualmachine_id" field in the mutation. -func (m *ModelApiKeyMutation) VirtualmachineID() (r string, exists bool) { - v := m.virtualmachine_id - if v == nil { - return +// AddSwitchesToIDs adds the "switches_to" edge to the TaskModelSwitch entity by ids. +func (m *ModelMutation) AddSwitchesToIDs(ids ...uuid.UUID) { + if m.switches_to == nil { + m.switches_to = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.switches_to[ids[i]] = struct{}{} } - return *v, true } -// OldVirtualmachineID returns the old "virtualmachine_id" field's value of the ModelApiKey entity. -// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelApiKeyMutation) OldVirtualmachineID(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVirtualmachineID is only allowed on UpdateOne operations") +// ClearSwitchesTo clears the "switches_to" edge to the TaskModelSwitch entity. +func (m *ModelMutation) ClearSwitchesTo() { + m.clearedswitches_to = true +} + +// SwitchesToCleared reports if the "switches_to" edge to the TaskModelSwitch entity was cleared. +func (m *ModelMutation) SwitchesToCleared() bool { + return m.clearedswitches_to +} + +// RemoveSwitchesToIDs removes the "switches_to" edge to the TaskModelSwitch entity by IDs. +func (m *ModelMutation) RemoveSwitchesToIDs(ids ...uuid.UUID) { + if m.removedswitches_to == nil { + m.removedswitches_to = make(map[uuid.UUID]struct{}) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVirtualmachineID requires an ID field in the mutation") + for i := range ids { + delete(m.switches_to, ids[i]) + m.removedswitches_to[ids[i]] = struct{}{} } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVirtualmachineID: %w", err) +} + +// RemovedSwitchesTo returns the removed IDs of the "switches_to" edge to the TaskModelSwitch entity. +func (m *ModelMutation) RemovedSwitchesToIDs() (ids []uuid.UUID) { + for id := range m.removedswitches_to { + ids = append(ids, id) } - return oldValue.VirtualmachineID, nil + return } -// ClearVirtualmachineID clears the value of the "virtualmachine_id" field. -func (m *ModelApiKeyMutation) ClearVirtualmachineID() { - m.virtualmachine_id = nil - m.clearedFields[modelapikey.FieldVirtualmachineID] = struct{}{} +// SwitchesToIDs returns the "switches_to" edge IDs in the mutation. +func (m *ModelMutation) SwitchesToIDs() (ids []uuid.UUID) { + for id := range m.switches_to { + ids = append(ids, id) + } + return } -// VirtualmachineIDCleared returns if the "virtualmachine_id" field was cleared in this mutation. -func (m *ModelApiKeyMutation) VirtualmachineIDCleared() bool { - _, ok := m.clearedFields[modelapikey.FieldVirtualmachineID] - return ok +// ResetSwitchesTo resets all changes to the "switches_to" edge. +func (m *ModelMutation) ResetSwitchesTo() { + m.switches_to = nil + m.clearedswitches_to = false + m.removedswitches_to = nil } -// ResetVirtualmachineID resets all changes to the "virtualmachine_id" field. -func (m *ModelApiKeyMutation) ResetVirtualmachineID() { - m.virtualmachine_id = nil - delete(m.clearedFields, modelapikey.FieldVirtualmachineID) +// AddTeamModelIDs adds the "team_models" edge to the TeamModel entity by ids. +func (m *ModelMutation) AddTeamModelIDs(ids ...uuid.UUID) { + if m.team_models == nil { + m.team_models = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.team_models[ids[i]] = struct{}{} + } } -// SetAPIKey sets the "api_key" field. -func (m *ModelApiKeyMutation) SetAPIKey(s string) { - m.api_key = &s +// ClearTeamModels clears the "team_models" edge to the TeamModel entity. +func (m *ModelMutation) ClearTeamModels() { + m.clearedteam_models = true } -// APIKey returns the value of the "api_key" field in the mutation. -func (m *ModelApiKeyMutation) APIKey() (r string, exists bool) { - v := m.api_key - if v == nil { - return - } - return *v, true +// TeamModelsCleared reports if the "team_models" edge to the TeamModel entity was cleared. +func (m *ModelMutation) TeamModelsCleared() bool { + return m.clearedteam_models } -// OldAPIKey returns the old "api_key" field's value of the ModelApiKey entity. -// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelApiKeyMutation) OldAPIKey(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAPIKey is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAPIKey requires an ID field in the mutation") +// RemoveTeamModelIDs removes the "team_models" edge to the TeamModel entity by IDs. +func (m *ModelMutation) RemoveTeamModelIDs(ids ...uuid.UUID) { + if m.removedteam_models == nil { + m.removedteam_models = make(map[uuid.UUID]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAPIKey: %w", err) + for i := range ids { + delete(m.team_models, ids[i]) + m.removedteam_models[ids[i]] = struct{}{} } - return oldValue.APIKey, nil } -// ResetAPIKey resets all changes to the "api_key" field. -func (m *ModelApiKeyMutation) ResetAPIKey() { - m.api_key = nil +// RemovedTeamModels returns the removed IDs of the "team_models" edge to the TeamModel entity. +func (m *ModelMutation) RemovedTeamModelsIDs() (ids []uuid.UUID) { + for id := range m.removedteam_models { + ids = append(ids, id) + } + return } -// SetCreatedAt sets the "created_at" field. -func (m *ModelApiKeyMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// TeamModelsIDs returns the "team_models" edge IDs in the mutation. +func (m *ModelMutation) TeamModelsIDs() (ids []uuid.UUID) { + for id := range m.team_models { + ids = append(ids, id) + } + return } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ModelApiKeyMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true +// ResetTeamModels resets all changes to the "team_models" edge. +func (m *ModelMutation) ResetTeamModels() { + m.team_models = nil + m.clearedteam_models = false + m.removedteam_models = nil } -// OldCreatedAt returns the old "created_at" field's value of the ModelApiKey entity. -// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") +// AddTeamGroupModelIDs adds the "team_group_models" edge to the TeamGroupModel entity by ids. +func (m *ModelMutation) AddTeamGroupModelIDs(ids ...uuid.UUID) { + if m.team_group_models == nil { + m.team_group_models = make(map[uuid.UUID]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + for i := range ids { + m.team_group_models[ids[i]] = struct{}{} } - return oldValue.CreatedAt, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *ModelApiKeyMutation) ResetCreatedAt() { - m.created_at = nil +// ClearTeamGroupModels clears the "team_group_models" edge to the TeamGroupModel entity. +func (m *ModelMutation) ClearTeamGroupModels() { + m.clearedteam_group_models = true } -// ClearModel clears the "model" edge to the Model entity. -func (m *ModelApiKeyMutation) ClearModel() { - m.clearedmodel = true - m.clearedFields[modelapikey.FieldModelID] = struct{}{} +// TeamGroupModelsCleared reports if the "team_group_models" edge to the TeamGroupModel entity was cleared. +func (m *ModelMutation) TeamGroupModelsCleared() bool { + return m.clearedteam_group_models } -// ModelCleared reports if the "model" edge to the Model entity was cleared. -func (m *ModelApiKeyMutation) ModelCleared() bool { - return m.clearedmodel +// RemoveTeamGroupModelIDs removes the "team_group_models" edge to the TeamGroupModel entity by IDs. +func (m *ModelMutation) RemoveTeamGroupModelIDs(ids ...uuid.UUID) { + if m.removedteam_group_models == nil { + m.removedteam_group_models = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.team_group_models, ids[i]) + m.removedteam_group_models[ids[i]] = struct{}{} + } } -// ModelIDs returns the "model" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ModelID instead. It exists only for internal usage by the builders. -func (m *ModelApiKeyMutation) ModelIDs() (ids []uuid.UUID) { - if id := m.model; id != nil { - ids = append(ids, *id) +// RemovedTeamGroupModels returns the removed IDs of the "team_group_models" edge to the TeamGroupModel entity. +func (m *ModelMutation) RemovedTeamGroupModelsIDs() (ids []uuid.UUID) { + for id := range m.removedteam_group_models { + ids = append(ids, id) } return } -// ResetModel resets all changes to the "model" edge. -func (m *ModelApiKeyMutation) ResetModel() { - m.model = nil - m.clearedmodel = false +// TeamGroupModelsIDs returns the "team_group_models" edge IDs in the mutation. +func (m *ModelMutation) TeamGroupModelsIDs() (ids []uuid.UUID) { + for id := range m.team_group_models { + ids = append(ids, id) + } + return } -// Where appends a list predicates to the ModelApiKeyMutation builder. -func (m *ModelApiKeyMutation) Where(ps ...predicate.ModelApiKey) { +// ResetTeamGroupModels resets all changes to the "team_group_models" edge. +func (m *ModelMutation) ResetTeamGroupModels() { + m.team_group_models = nil + m.clearedteam_group_models = false + m.removedteam_group_models = nil +} + +// Where appends a list predicates to the ModelMutation builder. +func (m *ModelMutation) Where(ps ...predicate.Model) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ModelApiKeyMutation builder. Using this method, +// WhereP appends storage-level predicates to the ModelMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ModelApiKeyMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.ModelApiKey, len(ps)) +func (m *ModelMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Model, len(ps)) for i := range ps { p[i] = ps[i] } @@ -15396,42 +23794,84 @@ func (m *ModelApiKeyMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ModelApiKeyMutation) Op() Op { +func (m *ModelMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ModelApiKeyMutation) SetOp(op Op) { +func (m *ModelMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (ModelApiKey). -func (m *ModelApiKeyMutation) Type() string { +// Type returns the node type of this mutation (Model). +func (m *ModelMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ModelApiKeyMutation) Fields() []string { - fields := make([]string, 0, 6) +func (m *ModelMutation) Fields() []string { + fields := make([]string, 0, 20) if m.deleted_at != nil { - fields = append(fields, modelapikey.FieldDeletedAt) + fields = append(fields, model.FieldDeletedAt) + } + if m.user != nil { + fields = append(fields, model.FieldUserID) + } + if m.provider != nil { + fields = append(fields, model.FieldProvider) + } + if m.api_key != nil { + fields = append(fields, model.FieldAPIKey) + } + if m.base_url != nil { + fields = append(fields, model.FieldBaseURL) } if m.model != nil { - fields = append(fields, modelapikey.FieldModelID) + fields = append(fields, model.FieldModel) } - if m.user_id != nil { - fields = append(fields, modelapikey.FieldUserID) + if m.remark != nil { + fields = append(fields, model.FieldRemark) } - if m.virtualmachine_id != nil { - fields = append(fields, modelapikey.FieldVirtualmachineID) + if m.temperature != nil { + fields = append(fields, model.FieldTemperature) } - if m.api_key != nil { - fields = append(fields, modelapikey.FieldAPIKey) + if m.interface_type != nil { + fields = append(fields, model.FieldInterfaceType) + } + if m.weight != nil { + fields = append(fields, model.FieldWeight) + } + if m.thinking_enabled != nil { + fields = append(fields, model.FieldThinkingEnabled) + } + if m.support_image != nil { + fields = append(fields, model.FieldSupportImage) + } + if m.is_hidden != nil { + fields = append(fields, model.FieldIsHidden) + } + if m.context_limit != nil { + fields = append(fields, model.FieldContextLimit) + } + if m.output_limit != nil { + fields = append(fields, model.FieldOutputLimit) + } + if m.last_check_at != nil { + fields = append(fields, model.FieldLastCheckAt) + } + if m.last_check_success != nil { + fields = append(fields, model.FieldLastCheckSuccess) + } + if m.last_check_error != nil { + fields = append(fields, model.FieldLastCheckError) } if m.created_at != nil { - fields = append(fields, modelapikey.FieldCreatedAt) + fields = append(fields, model.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, model.FieldUpdatedAt) } return fields } @@ -15439,20 +23879,48 @@ func (m *ModelApiKeyMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ModelApiKeyMutation) Field(name string) (ent.Value, bool) { +func (m *ModelMutation) Field(name string) (ent.Value, bool) { switch name { - case modelapikey.FieldDeletedAt: + case model.FieldDeletedAt: return m.DeletedAt() - case modelapikey.FieldModelID: - return m.ModelID() - case modelapikey.FieldUserID: + case model.FieldUserID: return m.UserID() - case modelapikey.FieldVirtualmachineID: - return m.VirtualmachineID() - case modelapikey.FieldAPIKey: + case model.FieldProvider: + return m.Provider() + case model.FieldAPIKey: return m.APIKey() - case modelapikey.FieldCreatedAt: + case model.FieldBaseURL: + return m.BaseURL() + case model.FieldModel: + return m.Model() + case model.FieldRemark: + return m.Remark() + case model.FieldTemperature: + return m.Temperature() + case model.FieldInterfaceType: + return m.InterfaceType() + case model.FieldWeight: + return m.Weight() + case model.FieldThinkingEnabled: + return m.ThinkingEnabled() + case model.FieldSupportImage: + return m.SupportImage() + case model.FieldIsHidden: + return m.IsHidden() + case model.FieldContextLimit: + return m.ContextLimit() + case model.FieldOutputLimit: + return m.OutputLimit() + case model.FieldLastCheckAt: + return m.LastCheckAt() + case model.FieldLastCheckSuccess: + return m.LastCheckSuccess() + case model.FieldLastCheckError: + return m.LastCheckError() + case model.FieldCreatedAt: return m.CreatedAt() + case model.FieldUpdatedAt: + return m.UpdatedAt() } return nil, false } @@ -15460,264 +23928,764 @@ func (m *ModelApiKeyMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ModelApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ModelMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case modelapikey.FieldDeletedAt: + case model.FieldDeletedAt: return m.OldDeletedAt(ctx) - case modelapikey.FieldModelID: - return m.OldModelID(ctx) - case modelapikey.FieldUserID: + case model.FieldUserID: return m.OldUserID(ctx) - case modelapikey.FieldVirtualmachineID: - return m.OldVirtualmachineID(ctx) - case modelapikey.FieldAPIKey: + case model.FieldProvider: + return m.OldProvider(ctx) + case model.FieldAPIKey: return m.OldAPIKey(ctx) - case modelapikey.FieldCreatedAt: + case model.FieldBaseURL: + return m.OldBaseURL(ctx) + case model.FieldModel: + return m.OldModel(ctx) + case model.FieldRemark: + return m.OldRemark(ctx) + case model.FieldTemperature: + return m.OldTemperature(ctx) + case model.FieldInterfaceType: + return m.OldInterfaceType(ctx) + case model.FieldWeight: + return m.OldWeight(ctx) + case model.FieldThinkingEnabled: + return m.OldThinkingEnabled(ctx) + case model.FieldSupportImage: + return m.OldSupportImage(ctx) + case model.FieldIsHidden: + return m.OldIsHidden(ctx) + case model.FieldContextLimit: + return m.OldContextLimit(ctx) + case model.FieldOutputLimit: + return m.OldOutputLimit(ctx) + case model.FieldLastCheckAt: + return m.OldLastCheckAt(ctx) + case model.FieldLastCheckSuccess: + return m.OldLastCheckSuccess(ctx) + case model.FieldLastCheckError: + return m.OldLastCheckError(ctx) + case model.FieldCreatedAt: return m.OldCreatedAt(ctx) + case model.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown ModelApiKey field %s", name) + return nil, fmt.Errorf("unknown Model field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ModelApiKeyMutation) SetField(name string, value ent.Value) error { +func (m *ModelMutation) SetField(name string, value ent.Value) error { switch name { - case modelapikey.FieldDeletedAt: + case model.FieldDeletedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDeletedAt(v) return nil - case modelapikey.FieldModelID: + case model.FieldUserID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModelID(v) + m.SetUserID(v) return nil - case modelapikey.FieldUserID: - v, ok := value.(uuid.UUID) + case model.FieldProvider: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) + m.SetProvider(v) + return nil + case model.FieldAPIKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAPIKey(v) + return nil + case model.FieldBaseURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBaseURL(v) + return nil + case model.FieldModel: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModel(v) + return nil + case model.FieldRemark: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRemark(v) + return nil + case model.FieldTemperature: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTemperature(v) + return nil + case model.FieldInterfaceType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInterfaceType(v) + return nil + case model.FieldWeight: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWeight(v) + return nil + case model.FieldThinkingEnabled: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetThinkingEnabled(v) + return nil + case model.FieldSupportImage: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSupportImage(v) + return nil + case model.FieldIsHidden: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsHidden(v) + return nil + case model.FieldContextLimit: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetContextLimit(v) + return nil + case model.FieldOutputLimit: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOutputLimit(v) + return nil + case model.FieldLastCheckAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastCheckAt(v) + return nil + case model.FieldLastCheckSuccess: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastCheckSuccess(v) + return nil + case model.FieldLastCheckError: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastCheckError(v) + return nil + case model.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case model.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + } + return fmt.Errorf("unknown Model field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ModelMutation) AddedFields() []string { + var fields []string + if m.addtemperature != nil { + fields = append(fields, model.FieldTemperature) + } + if m.addweight != nil { + fields = append(fields, model.FieldWeight) + } + if m.addcontext_limit != nil { + fields = append(fields, model.FieldContextLimit) + } + if m.addoutput_limit != nil { + fields = append(fields, model.FieldOutputLimit) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ModelMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case model.FieldTemperature: + return m.AddedTemperature() + case model.FieldWeight: + return m.AddedWeight() + case model.FieldContextLimit: + return m.AddedContextLimit() + case model.FieldOutputLimit: + return m.AddedOutputLimit() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ModelMutation) AddField(name string, value ent.Value) error { + switch name { + case model.FieldTemperature: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTemperature(v) return nil - case modelapikey.FieldVirtualmachineID: - v, ok := value.(string) + case model.FieldWeight: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetVirtualmachineID(v) + m.AddWeight(v) return nil - case modelapikey.FieldAPIKey: - v, ok := value.(string) + case model.FieldContextLimit: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetAPIKey(v) + m.AddContextLimit(v) return nil - case modelapikey.FieldCreatedAt: - v, ok := value.(time.Time) + case model.FieldOutputLimit: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreatedAt(v) + m.AddOutputLimit(v) return nil } - return fmt.Errorf("unknown ModelApiKey field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *ModelApiKeyMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *ModelApiKeyMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *ModelApiKeyMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown ModelApiKey numeric field %s", name) + return fmt.Errorf("unknown Model numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ModelApiKeyMutation) ClearedFields() []string { +func (m *ModelMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(modelapikey.FieldDeletedAt) { - fields = append(fields, modelapikey.FieldDeletedAt) + if m.FieldCleared(model.FieldDeletedAt) { + fields = append(fields, model.FieldDeletedAt) } - if m.FieldCleared(modelapikey.FieldVirtualmachineID) { - fields = append(fields, modelapikey.FieldVirtualmachineID) + if m.FieldCleared(model.FieldRemark) { + fields = append(fields, model.FieldRemark) + } + if m.FieldCleared(model.FieldTemperature) { + fields = append(fields, model.FieldTemperature) + } + if m.FieldCleared(model.FieldInterfaceType) { + fields = append(fields, model.FieldInterfaceType) + } + if m.FieldCleared(model.FieldLastCheckAt) { + fields = append(fields, model.FieldLastCheckAt) + } + if m.FieldCleared(model.FieldLastCheckSuccess) { + fields = append(fields, model.FieldLastCheckSuccess) + } + if m.FieldCleared(model.FieldLastCheckError) { + fields = append(fields, model.FieldLastCheckError) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ModelApiKeyMutation) FieldCleared(name string) bool { +func (m *ModelMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ModelApiKeyMutation) ClearField(name string) error { +func (m *ModelMutation) ClearField(name string) error { switch name { - case modelapikey.FieldDeletedAt: + case model.FieldDeletedAt: m.ClearDeletedAt() return nil - case modelapikey.FieldVirtualmachineID: - m.ClearVirtualmachineID() + case model.FieldRemark: + m.ClearRemark() + return nil + case model.FieldTemperature: + m.ClearTemperature() + return nil + case model.FieldInterfaceType: + m.ClearInterfaceType() + return nil + case model.FieldLastCheckAt: + m.ClearLastCheckAt() + return nil + case model.FieldLastCheckSuccess: + m.ClearLastCheckSuccess() + return nil + case model.FieldLastCheckError: + m.ClearLastCheckError() return nil } - return fmt.Errorf("unknown ModelApiKey nullable field %s", name) + return fmt.Errorf("unknown Model nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ModelApiKeyMutation) ResetField(name string) error { +func (m *ModelMutation) ResetField(name string) error { switch name { - case modelapikey.FieldDeletedAt: + case model.FieldDeletedAt: m.ResetDeletedAt() return nil - case modelapikey.FieldModelID: - m.ResetModelID() - return nil - case modelapikey.FieldUserID: + case model.FieldUserID: m.ResetUserID() return nil - case modelapikey.FieldVirtualmachineID: - m.ResetVirtualmachineID() + case model.FieldProvider: + m.ResetProvider() return nil - case modelapikey.FieldAPIKey: + case model.FieldAPIKey: m.ResetAPIKey() return nil - case modelapikey.FieldCreatedAt: + case model.FieldBaseURL: + m.ResetBaseURL() + return nil + case model.FieldModel: + m.ResetModel() + return nil + case model.FieldRemark: + m.ResetRemark() + return nil + case model.FieldTemperature: + m.ResetTemperature() + return nil + case model.FieldInterfaceType: + m.ResetInterfaceType() + return nil + case model.FieldWeight: + m.ResetWeight() + return nil + case model.FieldThinkingEnabled: + m.ResetThinkingEnabled() + return nil + case model.FieldSupportImage: + m.ResetSupportImage() + return nil + case model.FieldIsHidden: + m.ResetIsHidden() + return nil + case model.FieldContextLimit: + m.ResetContextLimit() + return nil + case model.FieldOutputLimit: + m.ResetOutputLimit() + return nil + case model.FieldLastCheckAt: + m.ResetLastCheckAt() + return nil + case model.FieldLastCheckSuccess: + m.ResetLastCheckSuccess() + return nil + case model.FieldLastCheckError: + m.ResetLastCheckError() + return nil + case model.FieldCreatedAt: m.ResetCreatedAt() return nil + case model.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil } - return fmt.Errorf("unknown ModelApiKey field %s", name) + return fmt.Errorf("unknown Model field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ModelApiKeyMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.model != nil { - edges = append(edges, modelapikey.EdgeModel) +func (m *ModelMutation) AddedEdges() []string { + edges := make([]string, 0, 11) + if m.user != nil { + edges = append(edges, model.EdgeUser) + } + if m.teams != nil { + edges = append(edges, model.EdgeTeams) + } + if m.groups != nil { + edges = append(edges, model.EdgeGroups) + } + if m.vms != nil { + edges = append(edges, model.EdgeVms) + } + if m.project_tasks != nil { + edges = append(edges, model.EdgeProjectTasks) + } + if m.pricing != nil { + edges = append(edges, model.EdgePricing) + } + if m.apikeys != nil { + edges = append(edges, model.EdgeApikeys) + } + if m.switches_from != nil { + edges = append(edges, model.EdgeSwitchesFrom) + } + if m.switches_to != nil { + edges = append(edges, model.EdgeSwitchesTo) + } + if m.team_models != nil { + edges = append(edges, model.EdgeTeamModels) + } + if m.team_group_models != nil { + edges = append(edges, model.EdgeTeamGroupModels) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ModelApiKeyMutation) AddedIDs(name string) []ent.Value { +func (m *ModelMutation) AddedIDs(name string) []ent.Value { switch name { - case modelapikey.EdgeModel: - if id := m.model; id != nil { + case model.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + case model.EdgeTeams: + ids := make([]ent.Value, 0, len(m.teams)) + for id := range m.teams { + ids = append(ids, id) + } + return ids + case model.EdgeGroups: + ids := make([]ent.Value, 0, len(m.groups)) + for id := range m.groups { + ids = append(ids, id) + } + return ids + case model.EdgeVms: + ids := make([]ent.Value, 0, len(m.vms)) + for id := range m.vms { + ids = append(ids, id) + } + return ids + case model.EdgeProjectTasks: + ids := make([]ent.Value, 0, len(m.project_tasks)) + for id := range m.project_tasks { + ids = append(ids, id) + } + return ids + case model.EdgePricing: + if id := m.pricing; id != nil { return []ent.Value{*id} } + case model.EdgeApikeys: + ids := make([]ent.Value, 0, len(m.apikeys)) + for id := range m.apikeys { + ids = append(ids, id) + } + return ids + case model.EdgeSwitchesFrom: + ids := make([]ent.Value, 0, len(m.switches_from)) + for id := range m.switches_from { + ids = append(ids, id) + } + return ids + case model.EdgeSwitchesTo: + ids := make([]ent.Value, 0, len(m.switches_to)) + for id := range m.switches_to { + ids = append(ids, id) + } + return ids + case model.EdgeTeamModels: + ids := make([]ent.Value, 0, len(m.team_models)) + for id := range m.team_models { + ids = append(ids, id) + } + return ids + case model.EdgeTeamGroupModels: + ids := make([]ent.Value, 0, len(m.team_group_models)) + for id := range m.team_group_models { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ModelApiKeyMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) +func (m *ModelMutation) RemovedEdges() []string { + edges := make([]string, 0, 11) + if m.removedteams != nil { + edges = append(edges, model.EdgeTeams) + } + if m.removedgroups != nil { + edges = append(edges, model.EdgeGroups) + } + if m.removedvms != nil { + edges = append(edges, model.EdgeVms) + } + if m.removedproject_tasks != nil { + edges = append(edges, model.EdgeProjectTasks) + } + if m.removedapikeys != nil { + edges = append(edges, model.EdgeApikeys) + } + if m.removedswitches_from != nil { + edges = append(edges, model.EdgeSwitchesFrom) + } + if m.removedswitches_to != nil { + edges = append(edges, model.EdgeSwitchesTo) + } + if m.removedteam_models != nil { + edges = append(edges, model.EdgeTeamModels) + } + if m.removedteam_group_models != nil { + edges = append(edges, model.EdgeTeamGroupModels) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ModelApiKeyMutation) RemovedIDs(name string) []ent.Value { +func (m *ModelMutation) RemovedIDs(name string) []ent.Value { + switch name { + case model.EdgeTeams: + ids := make([]ent.Value, 0, len(m.removedteams)) + for id := range m.removedteams { + ids = append(ids, id) + } + return ids + case model.EdgeGroups: + ids := make([]ent.Value, 0, len(m.removedgroups)) + for id := range m.removedgroups { + ids = append(ids, id) + } + return ids + case model.EdgeVms: + ids := make([]ent.Value, 0, len(m.removedvms)) + for id := range m.removedvms { + ids = append(ids, id) + } + return ids + case model.EdgeProjectTasks: + ids := make([]ent.Value, 0, len(m.removedproject_tasks)) + for id := range m.removedproject_tasks { + ids = append(ids, id) + } + return ids + case model.EdgeApikeys: + ids := make([]ent.Value, 0, len(m.removedapikeys)) + for id := range m.removedapikeys { + ids = append(ids, id) + } + return ids + case model.EdgeSwitchesFrom: + ids := make([]ent.Value, 0, len(m.removedswitches_from)) + for id := range m.removedswitches_from { + ids = append(ids, id) + } + return ids + case model.EdgeSwitchesTo: + ids := make([]ent.Value, 0, len(m.removedswitches_to)) + for id := range m.removedswitches_to { + ids = append(ids, id) + } + return ids + case model.EdgeTeamModels: + ids := make([]ent.Value, 0, len(m.removedteam_models)) + for id := range m.removedteam_models { + ids = append(ids, id) + } + return ids + case model.EdgeTeamGroupModels: + ids := make([]ent.Value, 0, len(m.removedteam_group_models)) + for id := range m.removedteam_group_models { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ModelApiKeyMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedmodel { - edges = append(edges, modelapikey.EdgeModel) +func (m *ModelMutation) ClearedEdges() []string { + edges := make([]string, 0, 11) + if m.cleareduser { + edges = append(edges, model.EdgeUser) + } + if m.clearedteams { + edges = append(edges, model.EdgeTeams) + } + if m.clearedgroups { + edges = append(edges, model.EdgeGroups) + } + if m.clearedvms { + edges = append(edges, model.EdgeVms) + } + if m.clearedproject_tasks { + edges = append(edges, model.EdgeProjectTasks) + } + if m.clearedpricing { + edges = append(edges, model.EdgePricing) + } + if m.clearedapikeys { + edges = append(edges, model.EdgeApikeys) + } + if m.clearedswitches_from { + edges = append(edges, model.EdgeSwitchesFrom) + } + if m.clearedswitches_to { + edges = append(edges, model.EdgeSwitchesTo) + } + if m.clearedteam_models { + edges = append(edges, model.EdgeTeamModels) + } + if m.clearedteam_group_models { + edges = append(edges, model.EdgeTeamGroupModels) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ModelApiKeyMutation) EdgeCleared(name string) bool { +func (m *ModelMutation) EdgeCleared(name string) bool { switch name { - case modelapikey.EdgeModel: - return m.clearedmodel + case model.EdgeUser: + return m.cleareduser + case model.EdgeTeams: + return m.clearedteams + case model.EdgeGroups: + return m.clearedgroups + case model.EdgeVms: + return m.clearedvms + case model.EdgeProjectTasks: + return m.clearedproject_tasks + case model.EdgePricing: + return m.clearedpricing + case model.EdgeApikeys: + return m.clearedapikeys + case model.EdgeSwitchesFrom: + return m.clearedswitches_from + case model.EdgeSwitchesTo: + return m.clearedswitches_to + case model.EdgeTeamModels: + return m.clearedteam_models + case model.EdgeTeamGroupModels: + return m.clearedteam_group_models } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ModelApiKeyMutation) ClearEdge(name string) error { +func (m *ModelMutation) ClearEdge(name string) error { switch name { - case modelapikey.EdgeModel: - m.ClearModel() + case model.EdgeUser: + m.ClearUser() + return nil + case model.EdgePricing: + m.ClearPricing() return nil } - return fmt.Errorf("unknown ModelApiKey unique edge %s", name) + return fmt.Errorf("unknown Model unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ModelApiKeyMutation) ResetEdge(name string) error { +func (m *ModelMutation) ResetEdge(name string) error { switch name { - case modelapikey.EdgeModel: - m.ResetModel() + case model.EdgeUser: + m.ResetUser() + return nil + case model.EdgeTeams: + m.ResetTeams() + return nil + case model.EdgeGroups: + m.ResetGroups() + return nil + case model.EdgeVms: + m.ResetVms() + return nil + case model.EdgeProjectTasks: + m.ResetProjectTasks() + return nil + case model.EdgePricing: + m.ResetPricing() + return nil + case model.EdgeApikeys: + m.ResetApikeys() + return nil + case model.EdgeSwitchesFrom: + m.ResetSwitchesFrom() + return nil + case model.EdgeSwitchesTo: + m.ResetSwitchesTo() + return nil + case model.EdgeTeamModels: + m.ResetTeamModels() + return nil + case model.EdgeTeamGroupModels: + m.ResetTeamGroupModels() return nil } - return fmt.Errorf("unknown ModelApiKey edge %s", name) + return fmt.Errorf("unknown Model edge %s", name) } -// ModelPricingMutation represents an operation that mutates the ModelPricing nodes in the graph. -type ModelPricingMutation struct { +// ModelApiKeyMutation represents an operation that mutates the ModelApiKey nodes in the graph. +type ModelApiKeyMutation struct { config - op Op - typ string - id *uuid.UUID - access_level *string - is_free *bool - input_price *int64 - addinput_price *int64 - output_price *int64 - addoutput_price *int64 - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - model *uuid.UUID - clearedmodel bool - done bool - oldValue func(context.Context) (*ModelPricing, error) - predicates []predicate.ModelPricing + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + user_id *uuid.UUID + virtualmachine_id *string + api_key *string + created_at *time.Time + clearedFields map[string]struct{} + model *uuid.UUID + clearedmodel bool + done bool + oldValue func(context.Context) (*ModelApiKey, error) + predicates []predicate.ModelApiKey } -var _ ent.Mutation = (*ModelPricingMutation)(nil) +var _ ent.Mutation = (*ModelApiKeyMutation)(nil) -// modelpricingOption allows management of the mutation configuration using functional options. -type modelpricingOption func(*ModelPricingMutation) +// modelapikeyOption allows management of the mutation configuration using functional options. +type modelapikeyOption func(*ModelApiKeyMutation) -// newModelPricingMutation creates new mutation for the ModelPricing entity. -func newModelPricingMutation(c config, op Op, opts ...modelpricingOption) *ModelPricingMutation { - m := &ModelPricingMutation{ +// newModelApiKeyMutation creates new mutation for the ModelApiKey entity. +func newModelApiKeyMutation(c config, op Op, opts ...modelapikeyOption) *ModelApiKeyMutation { + m := &ModelApiKeyMutation{ config: c, op: op, - typ: TypeModelPricing, + typ: TypeModelApiKey, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -15726,20 +24694,20 @@ func newModelPricingMutation(c config, op Op, opts ...modelpricingOption) *Model return m } -// withModelPricingID sets the ID field of the mutation. -func withModelPricingID(id uuid.UUID) modelpricingOption { - return func(m *ModelPricingMutation) { +// withModelApiKeyID sets the ID field of the mutation. +func withModelApiKeyID(id uuid.UUID) modelapikeyOption { + return func(m *ModelApiKeyMutation) { var ( err error once sync.Once - value *ModelPricing + value *ModelApiKey ) - m.oldValue = func(ctx context.Context) (*ModelPricing, error) { + m.oldValue = func(ctx context.Context) (*ModelApiKey, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().ModelPricing.Get(ctx, id) + value, err = m.Client().ModelApiKey.Get(ctx, id) } }) return value, err @@ -15748,10 +24716,10 @@ func withModelPricingID(id uuid.UUID) modelpricingOption { } } -// withModelPricing sets the old ModelPricing of the mutation. -func withModelPricing(node *ModelPricing) modelpricingOption { - return func(m *ModelPricingMutation) { - m.oldValue = func(context.Context) (*ModelPricing, error) { +// withModelApiKey sets the old ModelApiKey of the mutation. +func withModelApiKey(node *ModelApiKey) modelapikeyOption { + return func(m *ModelApiKeyMutation) { + m.oldValue = func(context.Context) (*ModelApiKey, error) { return node, nil } m.id = &node.ID @@ -15760,7 +24728,7 @@ func withModelPricing(node *ModelPricing) modelpricingOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ModelPricingMutation) Client() *Client { +func (m ModelApiKeyMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -15768,7 +24736,7 @@ func (m ModelPricingMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ModelPricingMutation) Tx() (*Tx, error) { +func (m ModelApiKeyMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -15778,14 +24746,14 @@ func (m ModelPricingMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of ModelPricing entities. -func (m *ModelPricingMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of ModelApiKey entities. +func (m *ModelApiKeyMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ModelPricingMutation) ID() (id uuid.UUID, exists bool) { +func (m *ModelApiKeyMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -15796,7 +24764,7 @@ func (m *ModelPricingMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ModelPricingMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *ModelApiKeyMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -15805,239 +24773,225 @@ func (m *ModelPricingMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().ModelPricing.Query().Where(m.predicates...).IDs(ctx) + return m.Client().ModelApiKey.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetModelID sets the "model_id" field. -func (m *ModelPricingMutation) SetModelID(u uuid.UUID) { - m.model = &u +// SetDeletedAt sets the "deleted_at" field. +func (m *ModelApiKeyMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t } -// ModelID returns the value of the "model_id" field in the mutation. -func (m *ModelPricingMutation) ModelID() (r uuid.UUID, exists bool) { - v := m.model +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *ModelApiKeyMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at if v == nil { return } return *v, true } -// OldModelID returns the old "model_id" field's value of the ModelPricing entity. -// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. +// OldDeletedAt returns the old "deleted_at" field's value of the ModelApiKey entity. +// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelPricingMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ModelApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModelID is only allowed on UpdateOne operations") + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModelID requires an ID field in the mutation") + return v, errors.New("OldDeletedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldModelID: %w", err) + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) } - return oldValue.ModelID, nil + return oldValue.DeletedAt, nil } -// ResetModelID resets all changes to the "model_id" field. -func (m *ModelPricingMutation) ResetModelID() { - m.model = nil +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *ModelApiKeyMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[modelapikey.FieldDeletedAt] = struct{}{} } -// SetAccessLevel sets the "access_level" field. -func (m *ModelPricingMutation) SetAccessLevel(s string) { - m.access_level = &s +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *ModelApiKeyMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[modelapikey.FieldDeletedAt] + return ok } -// AccessLevel returns the value of the "access_level" field in the mutation. -func (m *ModelPricingMutation) AccessLevel() (r string, exists bool) { - v := m.access_level +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *ModelApiKeyMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, modelapikey.FieldDeletedAt) +} + +// SetModelID sets the "model_id" field. +func (m *ModelApiKeyMutation) SetModelID(u uuid.UUID) { + m.model = &u +} + +// ModelID returns the value of the "model_id" field in the mutation. +func (m *ModelApiKeyMutation) ModelID() (r uuid.UUID, exists bool) { + v := m.model if v == nil { return } return *v, true } -// OldAccessLevel returns the old "access_level" field's value of the ModelPricing entity. -// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. +// OldModelID returns the old "model_id" field's value of the ModelApiKey entity. +// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelPricingMutation) OldAccessLevel(ctx context.Context) (v string, err error) { +func (m *ModelApiKeyMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAccessLevel is only allowed on UpdateOne operations") + return v, errors.New("OldModelID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAccessLevel requires an ID field in the mutation") + return v, errors.New("OldModelID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAccessLevel: %w", err) + return v, fmt.Errorf("querying old value for OldModelID: %w", err) } - return oldValue.AccessLevel, nil + return oldValue.ModelID, nil } -// ResetAccessLevel resets all changes to the "access_level" field. -func (m *ModelPricingMutation) ResetAccessLevel() { - m.access_level = nil +// ResetModelID resets all changes to the "model_id" field. +func (m *ModelApiKeyMutation) ResetModelID() { + m.model = nil } -// SetIsFree sets the "is_free" field. -func (m *ModelPricingMutation) SetIsFree(b bool) { - m.is_free = &b +// SetUserID sets the "user_id" field. +func (m *ModelApiKeyMutation) SetUserID(u uuid.UUID) { + m.user_id = &u } -// IsFree returns the value of the "is_free" field in the mutation. -func (m *ModelPricingMutation) IsFree() (r bool, exists bool) { - v := m.is_free +// UserID returns the value of the "user_id" field in the mutation. +func (m *ModelApiKeyMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user_id if v == nil { return } return *v, true } -// OldIsFree returns the old "is_free" field's value of the ModelPricing entity. -// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the ModelApiKey entity. +// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelPricingMutation) OldIsFree(ctx context.Context) (v bool, err error) { +func (m *ModelApiKeyMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsFree is only allowed on UpdateOne operations") + return v, errors.New("OldUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsFree requires an ID field in the mutation") + return v, errors.New("OldUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldIsFree: %w", err) + return v, fmt.Errorf("querying old value for OldUserID: %w", err) } - return oldValue.IsFree, nil + return oldValue.UserID, nil } -// ResetIsFree resets all changes to the "is_free" field. -func (m *ModelPricingMutation) ResetIsFree() { - m.is_free = nil +// ResetUserID resets all changes to the "user_id" field. +func (m *ModelApiKeyMutation) ResetUserID() { + m.user_id = nil } -// SetInputPrice sets the "input_price" field. -func (m *ModelPricingMutation) SetInputPrice(i int64) { - m.input_price = &i - m.addinput_price = nil +// SetVirtualmachineID sets the "virtualmachine_id" field. +func (m *ModelApiKeyMutation) SetVirtualmachineID(s string) { + m.virtualmachine_id = &s } -// InputPrice returns the value of the "input_price" field in the mutation. -func (m *ModelPricingMutation) InputPrice() (r int64, exists bool) { - v := m.input_price +// VirtualmachineID returns the value of the "virtualmachine_id" field in the mutation. +func (m *ModelApiKeyMutation) VirtualmachineID() (r string, exists bool) { + v := m.virtualmachine_id if v == nil { return } return *v, true } -// OldInputPrice returns the old "input_price" field's value of the ModelPricing entity. -// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. +// OldVirtualmachineID returns the old "virtualmachine_id" field's value of the ModelApiKey entity. +// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelPricingMutation) OldInputPrice(ctx context.Context) (v int64, err error) { +func (m *ModelApiKeyMutation) OldVirtualmachineID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInputPrice is only allowed on UpdateOne operations") + return v, errors.New("OldVirtualmachineID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInputPrice requires an ID field in the mutation") + return v, errors.New("OldVirtualmachineID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInputPrice: %w", err) + return v, fmt.Errorf("querying old value for OldVirtualmachineID: %w", err) } - return oldValue.InputPrice, nil + return oldValue.VirtualmachineID, nil } -// AddInputPrice adds i to the "input_price" field. -func (m *ModelPricingMutation) AddInputPrice(i int64) { - if m.addinput_price != nil { - *m.addinput_price += i - } else { - m.addinput_price = &i - } +// ClearVirtualmachineID clears the value of the "virtualmachine_id" field. +func (m *ModelApiKeyMutation) ClearVirtualmachineID() { + m.virtualmachine_id = nil + m.clearedFields[modelapikey.FieldVirtualmachineID] = struct{}{} } -// AddedInputPrice returns the value that was added to the "input_price" field in this mutation. -func (m *ModelPricingMutation) AddedInputPrice() (r int64, exists bool) { - v := m.addinput_price - if v == nil { - return - } - return *v, true +// VirtualmachineIDCleared returns if the "virtualmachine_id" field was cleared in this mutation. +func (m *ModelApiKeyMutation) VirtualmachineIDCleared() bool { + _, ok := m.clearedFields[modelapikey.FieldVirtualmachineID] + return ok } -// ResetInputPrice resets all changes to the "input_price" field. -func (m *ModelPricingMutation) ResetInputPrice() { - m.input_price = nil - m.addinput_price = nil +// ResetVirtualmachineID resets all changes to the "virtualmachine_id" field. +func (m *ModelApiKeyMutation) ResetVirtualmachineID() { + m.virtualmachine_id = nil + delete(m.clearedFields, modelapikey.FieldVirtualmachineID) } -// SetOutputPrice sets the "output_price" field. -func (m *ModelPricingMutation) SetOutputPrice(i int64) { - m.output_price = &i - m.addoutput_price = nil +// SetAPIKey sets the "api_key" field. +func (m *ModelApiKeyMutation) SetAPIKey(s string) { + m.api_key = &s } -// OutputPrice returns the value of the "output_price" field in the mutation. -func (m *ModelPricingMutation) OutputPrice() (r int64, exists bool) { - v := m.output_price +// APIKey returns the value of the "api_key" field in the mutation. +func (m *ModelApiKeyMutation) APIKey() (r string, exists bool) { + v := m.api_key if v == nil { return } return *v, true } -// OldOutputPrice returns the old "output_price" field's value of the ModelPricing entity. -// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. +// OldAPIKey returns the old "api_key" field's value of the ModelApiKey entity. +// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelPricingMutation) OldOutputPrice(ctx context.Context) (v int64, err error) { +func (m *ModelApiKeyMutation) OldAPIKey(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOutputPrice is only allowed on UpdateOne operations") + return v, errors.New("OldAPIKey is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOutputPrice requires an ID field in the mutation") + return v, errors.New("OldAPIKey requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOutputPrice: %w", err) - } - return oldValue.OutputPrice, nil -} - -// AddOutputPrice adds i to the "output_price" field. -func (m *ModelPricingMutation) AddOutputPrice(i int64) { - if m.addoutput_price != nil { - *m.addoutput_price += i - } else { - m.addoutput_price = &i - } -} - -// AddedOutputPrice returns the value that was added to the "output_price" field in this mutation. -func (m *ModelPricingMutation) AddedOutputPrice() (r int64, exists bool) { - v := m.addoutput_price - if v == nil { - return + return v, fmt.Errorf("querying old value for OldAPIKey: %w", err) } - return *v, true + return oldValue.APIKey, nil } -// ResetOutputPrice resets all changes to the "output_price" field. -func (m *ModelPricingMutation) ResetOutputPrice() { - m.output_price = nil - m.addoutput_price = nil +// ResetAPIKey resets all changes to the "api_key" field. +func (m *ModelApiKeyMutation) ResetAPIKey() { + m.api_key = nil } // SetCreatedAt sets the "created_at" field. -func (m *ModelPricingMutation) SetCreatedAt(t time.Time) { +func (m *ModelApiKeyMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ModelPricingMutation) CreatedAt() (r time.Time, exists bool) { +func (m *ModelApiKeyMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -16045,10 +24999,10 @@ func (m *ModelPricingMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the ModelPricing entity. -// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the ModelApiKey entity. +// If the ModelApiKey object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelPricingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ModelApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -16063,61 +25017,25 @@ func (m *ModelPricingMutation) OldCreatedAt(ctx context.Context) (v time.Time, e } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *ModelPricingMutation) ResetCreatedAt() { +func (m *ModelApiKeyMutation) ResetCreatedAt() { m.created_at = nil } -// SetUpdatedAt sets the "updated_at" field. -func (m *ModelPricingMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *ModelPricingMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the ModelPricing entity. -// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ModelPricingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *ModelPricingMutation) ResetUpdatedAt() { - m.updated_at = nil -} - // ClearModel clears the "model" edge to the Model entity. -func (m *ModelPricingMutation) ClearModel() { +func (m *ModelApiKeyMutation) ClearModel() { m.clearedmodel = true - m.clearedFields[modelpricing.FieldModelID] = struct{}{} + m.clearedFields[modelapikey.FieldModelID] = struct{}{} } // ModelCleared reports if the "model" edge to the Model entity was cleared. -func (m *ModelPricingMutation) ModelCleared() bool { +func (m *ModelApiKeyMutation) ModelCleared() bool { return m.clearedmodel } // ModelIDs returns the "model" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // ModelID instead. It exists only for internal usage by the builders. -func (m *ModelPricingMutation) ModelIDs() (ids []uuid.UUID) { +func (m *ModelApiKeyMutation) ModelIDs() (ids []uuid.UUID) { if id := m.model; id != nil { ids = append(ids, *id) } @@ -16125,20 +25043,20 @@ func (m *ModelPricingMutation) ModelIDs() (ids []uuid.UUID) { } // ResetModel resets all changes to the "model" edge. -func (m *ModelPricingMutation) ResetModel() { +func (m *ModelApiKeyMutation) ResetModel() { m.model = nil m.clearedmodel = false } -// Where appends a list predicates to the ModelPricingMutation builder. -func (m *ModelPricingMutation) Where(ps ...predicate.ModelPricing) { +// Where appends a list predicates to the ModelApiKeyMutation builder. +func (m *ModelApiKeyMutation) Where(ps ...predicate.ModelApiKey) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ModelPricingMutation builder. Using this method, +// WhereP appends storage-level predicates to the ModelApiKeyMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ModelPricingMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.ModelPricing, len(ps)) +func (m *ModelApiKeyMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ModelApiKey, len(ps)) for i := range ps { p[i] = ps[i] } @@ -16146,45 +25064,42 @@ func (m *ModelPricingMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ModelPricingMutation) Op() Op { +func (m *ModelApiKeyMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ModelPricingMutation) SetOp(op Op) { +func (m *ModelApiKeyMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (ModelPricing). -func (m *ModelPricingMutation) Type() string { +// Type returns the node type of this mutation (ModelApiKey). +func (m *ModelApiKeyMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ModelPricingMutation) Fields() []string { - fields := make([]string, 0, 7) - if m.model != nil { - fields = append(fields, modelpricing.FieldModelID) +func (m *ModelApiKeyMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.deleted_at != nil { + fields = append(fields, modelapikey.FieldDeletedAt) } - if m.access_level != nil { - fields = append(fields, modelpricing.FieldAccessLevel) + if m.model != nil { + fields = append(fields, modelapikey.FieldModelID) } - if m.is_free != nil { - fields = append(fields, modelpricing.FieldIsFree) + if m.user_id != nil { + fields = append(fields, modelapikey.FieldUserID) } - if m.input_price != nil { - fields = append(fields, modelpricing.FieldInputPrice) + if m.virtualmachine_id != nil { + fields = append(fields, modelapikey.FieldVirtualmachineID) } - if m.output_price != nil { - fields = append(fields, modelpricing.FieldOutputPrice) + if m.api_key != nil { + fields = append(fields, modelapikey.FieldAPIKey) } if m.created_at != nil { - fields = append(fields, modelpricing.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, modelpricing.FieldUpdatedAt) + fields = append(fields, modelapikey.FieldCreatedAt) } return fields } @@ -16192,22 +25107,20 @@ func (m *ModelPricingMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ModelPricingMutation) Field(name string) (ent.Value, bool) { +func (m *ModelApiKeyMutation) Field(name string) (ent.Value, bool) { switch name { - case modelpricing.FieldModelID: + case modelapikey.FieldDeletedAt: + return m.DeletedAt() + case modelapikey.FieldModelID: return m.ModelID() - case modelpricing.FieldAccessLevel: - return m.AccessLevel() - case modelpricing.FieldIsFree: - return m.IsFree() - case modelpricing.FieldInputPrice: - return m.InputPrice() - case modelpricing.FieldOutputPrice: - return m.OutputPrice() - case modelpricing.FieldCreatedAt: + case modelapikey.FieldUserID: + return m.UserID() + case modelapikey.FieldVirtualmachineID: + return m.VirtualmachineID() + case modelapikey.FieldAPIKey: + return m.APIKey() + case modelapikey.FieldCreatedAt: return m.CreatedAt() - case modelpricing.FieldUpdatedAt: - return m.UpdatedAt() } return nil, false } @@ -16215,195 +25128,171 @@ func (m *ModelPricingMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ModelPricingMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ModelApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case modelpricing.FieldModelID: + case modelapikey.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case modelapikey.FieldModelID: return m.OldModelID(ctx) - case modelpricing.FieldAccessLevel: - return m.OldAccessLevel(ctx) - case modelpricing.FieldIsFree: - return m.OldIsFree(ctx) - case modelpricing.FieldInputPrice: - return m.OldInputPrice(ctx) - case modelpricing.FieldOutputPrice: - return m.OldOutputPrice(ctx) - case modelpricing.FieldCreatedAt: + case modelapikey.FieldUserID: + return m.OldUserID(ctx) + case modelapikey.FieldVirtualmachineID: + return m.OldVirtualmachineID(ctx) + case modelapikey.FieldAPIKey: + return m.OldAPIKey(ctx) + case modelapikey.FieldCreatedAt: return m.OldCreatedAt(ctx) - case modelpricing.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown ModelPricing field %s", name) + return nil, fmt.Errorf("unknown ModelApiKey field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ModelPricingMutation) SetField(name string, value ent.Value) error { +func (m *ModelApiKeyMutation) SetField(name string, value ent.Value) error { switch name { - case modelpricing.FieldModelID: - v, ok := value.(uuid.UUID) + case modelapikey.FieldDeletedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModelID(v) + m.SetDeletedAt(v) return nil - case modelpricing.FieldAccessLevel: - v, ok := value.(string) + case modelapikey.FieldModelID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetAccessLevel(v) + m.SetModelID(v) return nil - case modelpricing.FieldIsFree: - v, ok := value.(bool) + case modelapikey.FieldUserID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetIsFree(v) + m.SetUserID(v) return nil - case modelpricing.FieldInputPrice: - v, ok := value.(int64) + case modelapikey.FieldVirtualmachineID: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInputPrice(v) + m.SetVirtualmachineID(v) return nil - case modelpricing.FieldOutputPrice: - v, ok := value.(int64) + case modelapikey.FieldAPIKey: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOutputPrice(v) + m.SetAPIKey(v) return nil - case modelpricing.FieldCreatedAt: + case modelapikey.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case modelpricing.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil } - return fmt.Errorf("unknown ModelPricing field %s", name) + return fmt.Errorf("unknown ModelApiKey field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ModelPricingMutation) AddedFields() []string { - var fields []string - if m.addinput_price != nil { - fields = append(fields, modelpricing.FieldInputPrice) - } - if m.addoutput_price != nil { - fields = append(fields, modelpricing.FieldOutputPrice) - } - return fields +func (m *ModelApiKeyMutation) AddedFields() []string { + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ModelPricingMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case modelpricing.FieldInputPrice: - return m.AddedInputPrice() - case modelpricing.FieldOutputPrice: - return m.AddedOutputPrice() - } +func (m *ModelApiKeyMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ModelPricingMutation) AddField(name string, value ent.Value) error { +func (m *ModelApiKeyMutation) AddField(name string, value ent.Value) error { switch name { - case modelpricing.FieldInputPrice: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddInputPrice(v) - return nil - case modelpricing.FieldOutputPrice: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddOutputPrice(v) - return nil } - return fmt.Errorf("unknown ModelPricing numeric field %s", name) + return fmt.Errorf("unknown ModelApiKey numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ModelPricingMutation) ClearedFields() []string { - return nil +func (m *ModelApiKeyMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(modelapikey.FieldDeletedAt) { + fields = append(fields, modelapikey.FieldDeletedAt) + } + if m.FieldCleared(modelapikey.FieldVirtualmachineID) { + fields = append(fields, modelapikey.FieldVirtualmachineID) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ModelPricingMutation) FieldCleared(name string) bool { +func (m *ModelApiKeyMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ModelPricingMutation) ClearField(name string) error { - return fmt.Errorf("unknown ModelPricing nullable field %s", name) +func (m *ModelApiKeyMutation) ClearField(name string) error { + switch name { + case modelapikey.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case modelapikey.FieldVirtualmachineID: + m.ClearVirtualmachineID() + return nil + } + return fmt.Errorf("unknown ModelApiKey nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ModelPricingMutation) ResetField(name string) error { +func (m *ModelApiKeyMutation) ResetField(name string) error { switch name { - case modelpricing.FieldModelID: - m.ResetModelID() + case modelapikey.FieldDeletedAt: + m.ResetDeletedAt() return nil - case modelpricing.FieldAccessLevel: - m.ResetAccessLevel() + case modelapikey.FieldModelID: + m.ResetModelID() return nil - case modelpricing.FieldIsFree: - m.ResetIsFree() + case modelapikey.FieldUserID: + m.ResetUserID() return nil - case modelpricing.FieldInputPrice: - m.ResetInputPrice() + case modelapikey.FieldVirtualmachineID: + m.ResetVirtualmachineID() return nil - case modelpricing.FieldOutputPrice: - m.ResetOutputPrice() + case modelapikey.FieldAPIKey: + m.ResetAPIKey() return nil - case modelpricing.FieldCreatedAt: + case modelapikey.FieldCreatedAt: m.ResetCreatedAt() return nil - case modelpricing.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil } - return fmt.Errorf("unknown ModelPricing field %s", name) + return fmt.Errorf("unknown ModelApiKey field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ModelPricingMutation) AddedEdges() []string { +func (m *ModelApiKeyMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.model != nil { - edges = append(edges, modelpricing.EdgeModel) + edges = append(edges, modelapikey.EdgeModel) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ModelPricingMutation) AddedIDs(name string) []ent.Value { +func (m *ModelApiKeyMutation) AddedIDs(name string) []ent.Value { switch name { - case modelpricing.EdgeModel: + case modelapikey.EdgeModel: if id := m.model; id != nil { return []ent.Value{*id} } @@ -16412,31 +25301,31 @@ func (m *ModelPricingMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ModelPricingMutation) RemovedEdges() []string { +func (m *ModelApiKeyMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ModelPricingMutation) RemovedIDs(name string) []ent.Value { +func (m *ModelApiKeyMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ModelPricingMutation) ClearedEdges() []string { +func (m *ModelApiKeyMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedmodel { - edges = append(edges, modelpricing.EdgeModel) + edges = append(edges, modelapikey.EdgeModel) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ModelPricingMutation) EdgeCleared(name string) bool { +func (m *ModelApiKeyMutation) EdgeCleared(name string) bool { switch name { - case modelpricing.EdgeModel: + case modelapikey.EdgeModel: return m.clearedmodel } return false @@ -16444,65 +25333,59 @@ func (m *ModelPricingMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ModelPricingMutation) ClearEdge(name string) error { +func (m *ModelApiKeyMutation) ClearEdge(name string) error { switch name { - case modelpricing.EdgeModel: + case modelapikey.EdgeModel: m.ClearModel() return nil } - return fmt.Errorf("unknown ModelPricing unique edge %s", name) + return fmt.Errorf("unknown ModelApiKey unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ModelPricingMutation) ResetEdge(name string) error { +func (m *ModelApiKeyMutation) ResetEdge(name string) error { switch name { - case modelpricing.EdgeModel: + case modelapikey.EdgeModel: m.ResetModel() return nil } - return fmt.Errorf("unknown ModelPricing edge %s", name) + return fmt.Errorf("unknown ModelApiKey edge %s", name) } -// NotifyChannelMutation represents an operation that mutates the NotifyChannel nodes in the graph. -type NotifyChannelMutation struct { +// ModelPricingMutation represents an operation that mutates the ModelPricing nodes in the graph. +type ModelPricingMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - owner_id *uuid.UUID - owner_type *consts.NotifyOwnerType - name *string - kind *consts.NotifyChannelKind - webhook_url *string - secret *string - headers *map[string]string - metadata *map[string]string - target_id *string - enabled *bool - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - subscriptions map[uuid.UUID]struct{} - removedsubscriptions map[uuid.UUID]struct{} - clearedsubscriptions bool - done bool - oldValue func(context.Context) (*NotifyChannel, error) - predicates []predicate.NotifyChannel + op Op + typ string + id *uuid.UUID + access_level *string + is_free *bool + input_price *int64 + addinput_price *int64 + output_price *int64 + addoutput_price *int64 + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + model *uuid.UUID + clearedmodel bool + done bool + oldValue func(context.Context) (*ModelPricing, error) + predicates []predicate.ModelPricing } -var _ ent.Mutation = (*NotifyChannelMutation)(nil) +var _ ent.Mutation = (*ModelPricingMutation)(nil) -// notifychannelOption allows management of the mutation configuration using functional options. -type notifychannelOption func(*NotifyChannelMutation) +// modelpricingOption allows management of the mutation configuration using functional options. +type modelpricingOption func(*ModelPricingMutation) -// newNotifyChannelMutation creates new mutation for the NotifyChannel entity. -func newNotifyChannelMutation(c config, op Op, opts ...notifychannelOption) *NotifyChannelMutation { - m := &NotifyChannelMutation{ +// newModelPricingMutation creates new mutation for the ModelPricing entity. +func newModelPricingMutation(c config, op Op, opts ...modelpricingOption) *ModelPricingMutation { + m := &ModelPricingMutation{ config: c, op: op, - typ: TypeNotifyChannel, + typ: TypeModelPricing, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -16511,20 +25394,20 @@ func newNotifyChannelMutation(c config, op Op, opts ...notifychannelOption) *Not return m } -// withNotifyChannelID sets the ID field of the mutation. -func withNotifyChannelID(id uuid.UUID) notifychannelOption { - return func(m *NotifyChannelMutation) { +// withModelPricingID sets the ID field of the mutation. +func withModelPricingID(id uuid.UUID) modelpricingOption { + return func(m *ModelPricingMutation) { var ( err error once sync.Once - value *NotifyChannel + value *ModelPricing ) - m.oldValue = func(ctx context.Context) (*NotifyChannel, error) { + m.oldValue = func(ctx context.Context) (*ModelPricing, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().NotifyChannel.Get(ctx, id) + value, err = m.Client().ModelPricing.Get(ctx, id) } }) return value, err @@ -16533,10 +25416,10 @@ func withNotifyChannelID(id uuid.UUID) notifychannelOption { } } -// withNotifyChannel sets the old NotifyChannel of the mutation. -func withNotifyChannel(node *NotifyChannel) notifychannelOption { - return func(m *NotifyChannelMutation) { - m.oldValue = func(context.Context) (*NotifyChannel, error) { +// withModelPricing sets the old ModelPricing of the mutation. +func withModelPricing(node *ModelPricing) modelpricingOption { + return func(m *ModelPricingMutation) { + m.oldValue = func(context.Context) (*ModelPricing, error) { return node, nil } m.id = &node.ID @@ -16545,7 +25428,7 @@ func withNotifyChannel(node *NotifyChannel) notifychannelOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m NotifyChannelMutation) Client() *Client { +func (m ModelPricingMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -16553,7 +25436,7 @@ func (m NotifyChannelMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m NotifyChannelMutation) Tx() (*Tx, error) { +func (m ModelPricingMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -16563,14 +25446,14 @@ func (m NotifyChannelMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of NotifyChannel entities. -func (m *NotifyChannelMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of ModelPricing entities. +func (m *ModelPricingMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *NotifyChannelMutation) ID() (id uuid.UUID, exists bool) { +func (m *ModelPricingMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -16581,7 +25464,7 @@ func (m *NotifyChannelMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *NotifyChannelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *ModelPricingMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -16590,467 +25473,239 @@ func (m *NotifyChannelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().NotifyChannel.Query().Where(m.predicates...).IDs(ctx) + return m.Client().ModelPricing.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetDeletedAt sets the "deleted_at" field. -func (m *NotifyChannelMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t -} - -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *NotifyChannelMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at - if v == nil { - return - } - return *v, true -} - -// OldDeletedAt returns the old "deleted_at" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) - } - return oldValue.DeletedAt, nil -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *NotifyChannelMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[notifychannel.FieldDeletedAt] = struct{}{} -} - -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *NotifyChannelMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[notifychannel.FieldDeletedAt] - return ok -} - -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *NotifyChannelMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, notifychannel.FieldDeletedAt) -} - -// SetOwnerID sets the "owner_id" field. -func (m *NotifyChannelMutation) SetOwnerID(u uuid.UUID) { - m.owner_id = &u -} - -// OwnerID returns the value of the "owner_id" field in the mutation. -func (m *NotifyChannelMutation) OwnerID() (r uuid.UUID, exists bool) { - v := m.owner_id - if v == nil { - return - } - return *v, true -} - -// OldOwnerID returns the old "owner_id" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldOwnerID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOwnerID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOwnerID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldOwnerID: %w", err) - } - return oldValue.OwnerID, nil -} - -// ResetOwnerID resets all changes to the "owner_id" field. -func (m *NotifyChannelMutation) ResetOwnerID() { - m.owner_id = nil -} - -// SetOwnerType sets the "owner_type" field. -func (m *NotifyChannelMutation) SetOwnerType(cot consts.NotifyOwnerType) { - m.owner_type = &cot -} - -// OwnerType returns the value of the "owner_type" field in the mutation. -func (m *NotifyChannelMutation) OwnerType() (r consts.NotifyOwnerType, exists bool) { - v := m.owner_type - if v == nil { - return - } - return *v, true -} - -// OldOwnerType returns the old "owner_type" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldOwnerType(ctx context.Context) (v consts.NotifyOwnerType, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOwnerType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOwnerType requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldOwnerType: %w", err) - } - return oldValue.OwnerType, nil -} - -// ResetOwnerType resets all changes to the "owner_type" field. -func (m *NotifyChannelMutation) ResetOwnerType() { - m.owner_type = nil -} - -// SetName sets the "name" field. -func (m *NotifyChannelMutation) SetName(s string) { - m.name = &s +// SetModelID sets the "model_id" field. +func (m *ModelPricingMutation) SetModelID(u uuid.UUID) { + m.model = &u } -// Name returns the value of the "name" field in the mutation. -func (m *NotifyChannelMutation) Name() (r string, exists bool) { - v := m.name +// ModelID returns the value of the "model_id" field in the mutation. +func (m *ModelPricingMutation) ModelID() (r uuid.UUID, exists bool) { + v := m.model if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// OldModelID returns the old "model_id" field's value of the ModelPricing entity. +// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldName(ctx context.Context) (v string, err error) { +func (m *ModelPricingMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldModelID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldModelID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldModelID: %w", err) } - return oldValue.Name, nil + return oldValue.ModelID, nil } -// ResetName resets all changes to the "name" field. -func (m *NotifyChannelMutation) ResetName() { - m.name = nil +// ResetModelID resets all changes to the "model_id" field. +func (m *ModelPricingMutation) ResetModelID() { + m.model = nil } -// SetKind sets the "kind" field. -func (m *NotifyChannelMutation) SetKind(cck consts.NotifyChannelKind) { - m.kind = &cck +// SetAccessLevel sets the "access_level" field. +func (m *ModelPricingMutation) SetAccessLevel(s string) { + m.access_level = &s } -// Kind returns the value of the "kind" field in the mutation. -func (m *NotifyChannelMutation) Kind() (r consts.NotifyChannelKind, exists bool) { - v := m.kind +// AccessLevel returns the value of the "access_level" field in the mutation. +func (m *ModelPricingMutation) AccessLevel() (r string, exists bool) { + v := m.access_level if v == nil { return } return *v, true } -// OldKind returns the old "kind" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// OldAccessLevel returns the old "access_level" field's value of the ModelPricing entity. +// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldKind(ctx context.Context) (v consts.NotifyChannelKind, err error) { +func (m *ModelPricingMutation) OldAccessLevel(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKind is only allowed on UpdateOne operations") + return v, errors.New("OldAccessLevel is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKind requires an ID field in the mutation") + return v, errors.New("OldAccessLevel requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldKind: %w", err) + return v, fmt.Errorf("querying old value for OldAccessLevel: %w", err) } - return oldValue.Kind, nil + return oldValue.AccessLevel, nil } -// ResetKind resets all changes to the "kind" field. -func (m *NotifyChannelMutation) ResetKind() { - m.kind = nil +// ResetAccessLevel resets all changes to the "access_level" field. +func (m *ModelPricingMutation) ResetAccessLevel() { + m.access_level = nil } -// SetWebhookURL sets the "webhook_url" field. -func (m *NotifyChannelMutation) SetWebhookURL(s string) { - m.webhook_url = &s +// SetIsFree sets the "is_free" field. +func (m *ModelPricingMutation) SetIsFree(b bool) { + m.is_free = &b } -// WebhookURL returns the value of the "webhook_url" field in the mutation. -func (m *NotifyChannelMutation) WebhookURL() (r string, exists bool) { - v := m.webhook_url +// IsFree returns the value of the "is_free" field in the mutation. +func (m *ModelPricingMutation) IsFree() (r bool, exists bool) { + v := m.is_free if v == nil { return } return *v, true } -// OldWebhookURL returns the old "webhook_url" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// OldIsFree returns the old "is_free" field's value of the ModelPricing entity. +// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldWebhookURL(ctx context.Context) (v string, err error) { +func (m *ModelPricingMutation) OldIsFree(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWebhookURL is only allowed on UpdateOne operations") + return v, errors.New("OldIsFree is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWebhookURL requires an ID field in the mutation") + return v, errors.New("OldIsFree requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldWebhookURL: %w", err) + return v, fmt.Errorf("querying old value for OldIsFree: %w", err) } - return oldValue.WebhookURL, nil + return oldValue.IsFree, nil } -// ResetWebhookURL resets all changes to the "webhook_url" field. -func (m *NotifyChannelMutation) ResetWebhookURL() { - m.webhook_url = nil +// ResetIsFree resets all changes to the "is_free" field. +func (m *ModelPricingMutation) ResetIsFree() { + m.is_free = nil } -// SetSecret sets the "secret" field. -func (m *NotifyChannelMutation) SetSecret(s string) { - m.secret = &s +// SetInputPrice sets the "input_price" field. +func (m *ModelPricingMutation) SetInputPrice(i int64) { + m.input_price = &i + m.addinput_price = nil } -// Secret returns the value of the "secret" field in the mutation. -func (m *NotifyChannelMutation) Secret() (r string, exists bool) { - v := m.secret +// InputPrice returns the value of the "input_price" field in the mutation. +func (m *ModelPricingMutation) InputPrice() (r int64, exists bool) { + v := m.input_price if v == nil { return } return *v, true } -// OldSecret returns the old "secret" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// OldInputPrice returns the old "input_price" field's value of the ModelPricing entity. +// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldSecret(ctx context.Context) (v string, err error) { +func (m *ModelPricingMutation) OldInputPrice(ctx context.Context) (v int64, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSecret is only allowed on UpdateOne operations") + return v, errors.New("OldInputPrice is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSecret requires an ID field in the mutation") + return v, errors.New("OldInputPrice requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSecret: %w", err) - } - return oldValue.Secret, nil -} - -// ClearSecret clears the value of the "secret" field. -func (m *NotifyChannelMutation) ClearSecret() { - m.secret = nil - m.clearedFields[notifychannel.FieldSecret] = struct{}{} -} - -// SecretCleared returns if the "secret" field was cleared in this mutation. -func (m *NotifyChannelMutation) SecretCleared() bool { - _, ok := m.clearedFields[notifychannel.FieldSecret] - return ok -} - -// ResetSecret resets all changes to the "secret" field. -func (m *NotifyChannelMutation) ResetSecret() { - m.secret = nil - delete(m.clearedFields, notifychannel.FieldSecret) -} - -// SetHeaders sets the "headers" field. -func (m *NotifyChannelMutation) SetHeaders(value map[string]string) { - m.headers = &value -} - -// Headers returns the value of the "headers" field in the mutation. -func (m *NotifyChannelMutation) Headers() (r map[string]string, exists bool) { - v := m.headers - if v == nil { - return + return v, fmt.Errorf("querying old value for OldInputPrice: %w", err) } - return *v, true + return oldValue.InputPrice, nil } -// OldHeaders returns the old "headers" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldHeaders(ctx context.Context) (v map[string]string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHeaders is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHeaders requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldHeaders: %w", err) +// AddInputPrice adds i to the "input_price" field. +func (m *ModelPricingMutation) AddInputPrice(i int64) { + if m.addinput_price != nil { + *m.addinput_price += i + } else { + m.addinput_price = &i } - return oldValue.Headers, nil -} - -// ClearHeaders clears the value of the "headers" field. -func (m *NotifyChannelMutation) ClearHeaders() { - m.headers = nil - m.clearedFields[notifychannel.FieldHeaders] = struct{}{} -} - -// HeadersCleared returns if the "headers" field was cleared in this mutation. -func (m *NotifyChannelMutation) HeadersCleared() bool { - _, ok := m.clearedFields[notifychannel.FieldHeaders] - return ok -} - -// ResetHeaders resets all changes to the "headers" field. -func (m *NotifyChannelMutation) ResetHeaders() { - m.headers = nil - delete(m.clearedFields, notifychannel.FieldHeaders) -} - -// SetMetadata sets the "metadata" field. -func (m *NotifyChannelMutation) SetMetadata(value map[string]string) { - m.metadata = &value } -// Metadata returns the value of the "metadata" field in the mutation. -func (m *NotifyChannelMutation) Metadata() (r map[string]string, exists bool) { - v := m.metadata +// AddedInputPrice returns the value that was added to the "input_price" field in this mutation. +func (m *ModelPricingMutation) AddedInputPrice() (r int64, exists bool) { + v := m.addinput_price if v == nil { return } return *v, true } - -// OldMetadata returns the old "metadata" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldMetadata(ctx context.Context) (v map[string]string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMetadata is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMetadata requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMetadata: %w", err) - } - return oldValue.Metadata, nil -} - -// ClearMetadata clears the value of the "metadata" field. -func (m *NotifyChannelMutation) ClearMetadata() { - m.metadata = nil - m.clearedFields[notifychannel.FieldMetadata] = struct{}{} -} - -// MetadataCleared returns if the "metadata" field was cleared in this mutation. -func (m *NotifyChannelMutation) MetadataCleared() bool { - _, ok := m.clearedFields[notifychannel.FieldMetadata] - return ok -} - -// ResetMetadata resets all changes to the "metadata" field. -func (m *NotifyChannelMutation) ResetMetadata() { - m.metadata = nil - delete(m.clearedFields, notifychannel.FieldMetadata) + +// ResetInputPrice resets all changes to the "input_price" field. +func (m *ModelPricingMutation) ResetInputPrice() { + m.input_price = nil + m.addinput_price = nil } -// SetTargetID sets the "target_id" field. -func (m *NotifyChannelMutation) SetTargetID(s string) { - m.target_id = &s +// SetOutputPrice sets the "output_price" field. +func (m *ModelPricingMutation) SetOutputPrice(i int64) { + m.output_price = &i + m.addoutput_price = nil } -// TargetID returns the value of the "target_id" field in the mutation. -func (m *NotifyChannelMutation) TargetID() (r string, exists bool) { - v := m.target_id +// OutputPrice returns the value of the "output_price" field in the mutation. +func (m *ModelPricingMutation) OutputPrice() (r int64, exists bool) { + v := m.output_price if v == nil { return } return *v, true } -// OldTargetID returns the old "target_id" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// OldOutputPrice returns the old "output_price" field's value of the ModelPricing entity. +// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldTargetID(ctx context.Context) (v string, err error) { +func (m *ModelPricingMutation) OldOutputPrice(ctx context.Context) (v int64, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTargetID is only allowed on UpdateOne operations") + return v, errors.New("OldOutputPrice is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTargetID requires an ID field in the mutation") + return v, errors.New("OldOutputPrice requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTargetID: %w", err) + return v, fmt.Errorf("querying old value for OldOutputPrice: %w", err) } - return oldValue.TargetID, nil -} - -// ResetTargetID resets all changes to the "target_id" field. -func (m *NotifyChannelMutation) ResetTargetID() { - m.target_id = nil + return oldValue.OutputPrice, nil } -// SetEnabled sets the "enabled" field. -func (m *NotifyChannelMutation) SetEnabled(b bool) { - m.enabled = &b +// AddOutputPrice adds i to the "output_price" field. +func (m *ModelPricingMutation) AddOutputPrice(i int64) { + if m.addoutput_price != nil { + *m.addoutput_price += i + } else { + m.addoutput_price = &i + } } -// Enabled returns the value of the "enabled" field in the mutation. -func (m *NotifyChannelMutation) Enabled() (r bool, exists bool) { - v := m.enabled +// AddedOutputPrice returns the value that was added to the "output_price" field in this mutation. +func (m *ModelPricingMutation) AddedOutputPrice() (r int64, exists bool) { + v := m.addoutput_price if v == nil { return } return *v, true } -// OldEnabled returns the old "enabled" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldEnabled(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEnabled is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEnabled requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEnabled: %w", err) - } - return oldValue.Enabled, nil -} - -// ResetEnabled resets all changes to the "enabled" field. -func (m *NotifyChannelMutation) ResetEnabled() { - m.enabled = nil +// ResetOutputPrice resets all changes to the "output_price" field. +func (m *ModelPricingMutation) ResetOutputPrice() { + m.output_price = nil + m.addoutput_price = nil } // SetCreatedAt sets the "created_at" field. -func (m *NotifyChannelMutation) SetCreatedAt(t time.Time) { +func (m *ModelPricingMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *NotifyChannelMutation) CreatedAt() (r time.Time, exists bool) { +func (m *ModelPricingMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -17058,10 +25713,10 @@ func (m *NotifyChannelMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the ModelPricing entity. +// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ModelPricingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -17076,17 +25731,17 @@ func (m *NotifyChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *NotifyChannelMutation) ResetCreatedAt() { +func (m *ModelPricingMutation) ResetCreatedAt() { m.created_at = nil } // SetUpdatedAt sets the "updated_at" field. -func (m *NotifyChannelMutation) SetUpdatedAt(t time.Time) { +func (m *ModelPricingMutation) SetUpdatedAt(t time.Time) { m.updated_at = &t } // UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *NotifyChannelMutation) UpdatedAt() (r time.Time, exists bool) { +func (m *ModelPricingMutation) UpdatedAt() (r time.Time, exists bool) { v := m.updated_at if v == nil { return @@ -17094,10 +25749,10 @@ func (m *NotifyChannelMutation) UpdatedAt() (r time.Time, exists bool) { return *v, true } -// OldUpdatedAt returns the old "updated_at" field's value of the NotifyChannel entity. -// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// OldUpdatedAt returns the old "updated_at" field's value of the ModelPricing entity. +// If the ModelPricing object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifyChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ModelPricingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } @@ -17112,73 +25767,46 @@ func (m *NotifyChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, } // ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *NotifyChannelMutation) ResetUpdatedAt() { +func (m *ModelPricingMutation) ResetUpdatedAt() { m.updated_at = nil } -// AddSubscriptionIDs adds the "subscriptions" edge to the NotifySubscription entity by ids. -func (m *NotifyChannelMutation) AddSubscriptionIDs(ids ...uuid.UUID) { - if m.subscriptions == nil { - m.subscriptions = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.subscriptions[ids[i]] = struct{}{} - } -} - -// ClearSubscriptions clears the "subscriptions" edge to the NotifySubscription entity. -func (m *NotifyChannelMutation) ClearSubscriptions() { - m.clearedsubscriptions = true -} - -// SubscriptionsCleared reports if the "subscriptions" edge to the NotifySubscription entity was cleared. -func (m *NotifyChannelMutation) SubscriptionsCleared() bool { - return m.clearedsubscriptions -} - -// RemoveSubscriptionIDs removes the "subscriptions" edge to the NotifySubscription entity by IDs. -func (m *NotifyChannelMutation) RemoveSubscriptionIDs(ids ...uuid.UUID) { - if m.removedsubscriptions == nil { - m.removedsubscriptions = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.subscriptions, ids[i]) - m.removedsubscriptions[ids[i]] = struct{}{} - } +// ClearModel clears the "model" edge to the Model entity. +func (m *ModelPricingMutation) ClearModel() { + m.clearedmodel = true + m.clearedFields[modelpricing.FieldModelID] = struct{}{} } -// RemovedSubscriptions returns the removed IDs of the "subscriptions" edge to the NotifySubscription entity. -func (m *NotifyChannelMutation) RemovedSubscriptionsIDs() (ids []uuid.UUID) { - for id := range m.removedsubscriptions { - ids = append(ids, id) - } - return +// ModelCleared reports if the "model" edge to the Model entity was cleared. +func (m *ModelPricingMutation) ModelCleared() bool { + return m.clearedmodel } -// SubscriptionsIDs returns the "subscriptions" edge IDs in the mutation. -func (m *NotifyChannelMutation) SubscriptionsIDs() (ids []uuid.UUID) { - for id := range m.subscriptions { - ids = append(ids, id) +// ModelIDs returns the "model" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ModelID instead. It exists only for internal usage by the builders. +func (m *ModelPricingMutation) ModelIDs() (ids []uuid.UUID) { + if id := m.model; id != nil { + ids = append(ids, *id) } return } -// ResetSubscriptions resets all changes to the "subscriptions" edge. -func (m *NotifyChannelMutation) ResetSubscriptions() { - m.subscriptions = nil - m.clearedsubscriptions = false - m.removedsubscriptions = nil +// ResetModel resets all changes to the "model" edge. +func (m *ModelPricingMutation) ResetModel() { + m.model = nil + m.clearedmodel = false } -// Where appends a list predicates to the NotifyChannelMutation builder. -func (m *NotifyChannelMutation) Where(ps ...predicate.NotifyChannel) { +// Where appends a list predicates to the ModelPricingMutation builder. +func (m *ModelPricingMutation) Where(ps ...predicate.ModelPricing) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the NotifyChannelMutation builder. Using this method, +// WhereP appends storage-level predicates to the ModelPricingMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *NotifyChannelMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.NotifyChannel, len(ps)) +func (m *ModelPricingMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ModelPricing, len(ps)) for i := range ps { p[i] = ps[i] } @@ -17186,63 +25814,45 @@ func (m *NotifyChannelMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *NotifyChannelMutation) Op() Op { +func (m *ModelPricingMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *NotifyChannelMutation) SetOp(op Op) { +func (m *ModelPricingMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (NotifyChannel). -func (m *NotifyChannelMutation) Type() string { +// Type returns the node type of this mutation (ModelPricing). +func (m *ModelPricingMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *NotifyChannelMutation) Fields() []string { - fields := make([]string, 0, 13) - if m.deleted_at != nil { - fields = append(fields, notifychannel.FieldDeletedAt) - } - if m.owner_id != nil { - fields = append(fields, notifychannel.FieldOwnerID) - } - if m.owner_type != nil { - fields = append(fields, notifychannel.FieldOwnerType) - } - if m.name != nil { - fields = append(fields, notifychannel.FieldName) - } - if m.kind != nil { - fields = append(fields, notifychannel.FieldKind) - } - if m.webhook_url != nil { - fields = append(fields, notifychannel.FieldWebhookURL) - } - if m.secret != nil { - fields = append(fields, notifychannel.FieldSecret) +func (m *ModelPricingMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.model != nil { + fields = append(fields, modelpricing.FieldModelID) } - if m.headers != nil { - fields = append(fields, notifychannel.FieldHeaders) + if m.access_level != nil { + fields = append(fields, modelpricing.FieldAccessLevel) } - if m.metadata != nil { - fields = append(fields, notifychannel.FieldMetadata) + if m.is_free != nil { + fields = append(fields, modelpricing.FieldIsFree) } - if m.target_id != nil { - fields = append(fields, notifychannel.FieldTargetID) + if m.input_price != nil { + fields = append(fields, modelpricing.FieldInputPrice) } - if m.enabled != nil { - fields = append(fields, notifychannel.FieldEnabled) + if m.output_price != nil { + fields = append(fields, modelpricing.FieldOutputPrice) } if m.created_at != nil { - fields = append(fields, notifychannel.FieldCreatedAt) + fields = append(fields, modelpricing.FieldCreatedAt) } if m.updated_at != nil { - fields = append(fields, notifychannel.FieldUpdatedAt) + fields = append(fields, modelpricing.FieldUpdatedAt) } return fields } @@ -17250,33 +25860,21 @@ func (m *NotifyChannelMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *NotifyChannelMutation) Field(name string) (ent.Value, bool) { +func (m *ModelPricingMutation) Field(name string) (ent.Value, bool) { switch name { - case notifychannel.FieldDeletedAt: - return m.DeletedAt() - case notifychannel.FieldOwnerID: - return m.OwnerID() - case notifychannel.FieldOwnerType: - return m.OwnerType() - case notifychannel.FieldName: - return m.Name() - case notifychannel.FieldKind: - return m.Kind() - case notifychannel.FieldWebhookURL: - return m.WebhookURL() - case notifychannel.FieldSecret: - return m.Secret() - case notifychannel.FieldHeaders: - return m.Headers() - case notifychannel.FieldMetadata: - return m.Metadata() - case notifychannel.FieldTargetID: - return m.TargetID() - case notifychannel.FieldEnabled: - return m.Enabled() - case notifychannel.FieldCreatedAt: + case modelpricing.FieldModelID: + return m.ModelID() + case modelpricing.FieldAccessLevel: + return m.AccessLevel() + case modelpricing.FieldIsFree: + return m.IsFree() + case modelpricing.FieldInputPrice: + return m.InputPrice() + case modelpricing.FieldOutputPrice: + return m.OutputPrice() + case modelpricing.FieldCreatedAt: return m.CreatedAt() - case notifychannel.FieldUpdatedAt: + case modelpricing.FieldUpdatedAt: return m.UpdatedAt() } return nil, false @@ -17285,128 +25883,74 @@ func (m *NotifyChannelMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *NotifyChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ModelPricingMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case notifychannel.FieldDeletedAt: - return m.OldDeletedAt(ctx) - case notifychannel.FieldOwnerID: - return m.OldOwnerID(ctx) - case notifychannel.FieldOwnerType: - return m.OldOwnerType(ctx) - case notifychannel.FieldName: - return m.OldName(ctx) - case notifychannel.FieldKind: - return m.OldKind(ctx) - case notifychannel.FieldWebhookURL: - return m.OldWebhookURL(ctx) - case notifychannel.FieldSecret: - return m.OldSecret(ctx) - case notifychannel.FieldHeaders: - return m.OldHeaders(ctx) - case notifychannel.FieldMetadata: - return m.OldMetadata(ctx) - case notifychannel.FieldTargetID: - return m.OldTargetID(ctx) - case notifychannel.FieldEnabled: - return m.OldEnabled(ctx) - case notifychannel.FieldCreatedAt: + case modelpricing.FieldModelID: + return m.OldModelID(ctx) + case modelpricing.FieldAccessLevel: + return m.OldAccessLevel(ctx) + case modelpricing.FieldIsFree: + return m.OldIsFree(ctx) + case modelpricing.FieldInputPrice: + return m.OldInputPrice(ctx) + case modelpricing.FieldOutputPrice: + return m.OldOutputPrice(ctx) + case modelpricing.FieldCreatedAt: return m.OldCreatedAt(ctx) - case notifychannel.FieldUpdatedAt: + case modelpricing.FieldUpdatedAt: return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown NotifyChannel field %s", name) + return nil, fmt.Errorf("unknown ModelPricing field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *NotifyChannelMutation) SetField(name string, value ent.Value) error { +func (m *ModelPricingMutation) SetField(name string, value ent.Value) error { switch name { - case notifychannel.FieldDeletedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDeletedAt(v) - return nil - case notifychannel.FieldOwnerID: + case modelpricing.FieldModelID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOwnerID(v) - return nil - case notifychannel.FieldOwnerType: - v, ok := value.(consts.NotifyOwnerType) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetOwnerType(v) - return nil - case notifychannel.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case notifychannel.FieldKind: - v, ok := value.(consts.NotifyChannelKind) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKind(v) - return nil - case notifychannel.FieldWebhookURL: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetWebhookURL(v) + m.SetModelID(v) return nil - case notifychannel.FieldSecret: + case modelpricing.FieldAccessLevel: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSecret(v) - return nil - case notifychannel.FieldHeaders: - v, ok := value.(map[string]string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHeaders(v) + m.SetAccessLevel(v) return nil - case notifychannel.FieldMetadata: - v, ok := value.(map[string]string) + case modelpricing.FieldIsFree: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetMetadata(v) + m.SetIsFree(v) return nil - case notifychannel.FieldTargetID: - v, ok := value.(string) + case modelpricing.FieldInputPrice: + v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetTargetID(v) + m.SetInputPrice(v) return nil - case notifychannel.FieldEnabled: - v, ok := value.(bool) + case modelpricing.FieldOutputPrice: + v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetEnabled(v) + m.SetOutputPrice(v) return nil - case notifychannel.FieldCreatedAt: + case modelpricing.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case notifychannel.FieldUpdatedAt: + case modelpricing.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) @@ -17414,238 +25958,219 @@ func (m *NotifyChannelMutation) SetField(name string, value ent.Value) error { m.SetUpdatedAt(v) return nil } - return fmt.Errorf("unknown NotifyChannel field %s", name) + return fmt.Errorf("unknown ModelPricing field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *NotifyChannelMutation) AddedFields() []string { - return nil +func (m *ModelPricingMutation) AddedFields() []string { + var fields []string + if m.addinput_price != nil { + fields = append(fields, modelpricing.FieldInputPrice) + } + if m.addoutput_price != nil { + fields = append(fields, modelpricing.FieldOutputPrice) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *NotifyChannelMutation) AddedField(name string) (ent.Value, bool) { +func (m *ModelPricingMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case modelpricing.FieldInputPrice: + return m.AddedInputPrice() + case modelpricing.FieldOutputPrice: + return m.AddedOutputPrice() + } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *NotifyChannelMutation) AddField(name string, value ent.Value) error { +func (m *ModelPricingMutation) AddField(name string, value ent.Value) error { switch name { + case modelpricing.FieldInputPrice: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddInputPrice(v) + return nil + case modelpricing.FieldOutputPrice: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddOutputPrice(v) + return nil } - return fmt.Errorf("unknown NotifyChannel numeric field %s", name) + return fmt.Errorf("unknown ModelPricing numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *NotifyChannelMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(notifychannel.FieldDeletedAt) { - fields = append(fields, notifychannel.FieldDeletedAt) - } - if m.FieldCleared(notifychannel.FieldSecret) { - fields = append(fields, notifychannel.FieldSecret) - } - if m.FieldCleared(notifychannel.FieldHeaders) { - fields = append(fields, notifychannel.FieldHeaders) - } - if m.FieldCleared(notifychannel.FieldMetadata) { - fields = append(fields, notifychannel.FieldMetadata) - } - return fields +func (m *ModelPricingMutation) ClearedFields() []string { + return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *NotifyChannelMutation) FieldCleared(name string) bool { +func (m *ModelPricingMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *NotifyChannelMutation) ClearField(name string) error { - switch name { - case notifychannel.FieldDeletedAt: - m.ClearDeletedAt() - return nil - case notifychannel.FieldSecret: - m.ClearSecret() - return nil - case notifychannel.FieldHeaders: - m.ClearHeaders() - return nil - case notifychannel.FieldMetadata: - m.ClearMetadata() - return nil - } - return fmt.Errorf("unknown NotifyChannel nullable field %s", name) +func (m *ModelPricingMutation) ClearField(name string) error { + return fmt.Errorf("unknown ModelPricing nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *NotifyChannelMutation) ResetField(name string) error { +func (m *ModelPricingMutation) ResetField(name string) error { switch name { - case notifychannel.FieldDeletedAt: - m.ResetDeletedAt() - return nil - case notifychannel.FieldOwnerID: - m.ResetOwnerID() - return nil - case notifychannel.FieldOwnerType: - m.ResetOwnerType() - return nil - case notifychannel.FieldName: - m.ResetName() - return nil - case notifychannel.FieldKind: - m.ResetKind() - return nil - case notifychannel.FieldWebhookURL: - m.ResetWebhookURL() - return nil - case notifychannel.FieldSecret: - m.ResetSecret() + case modelpricing.FieldModelID: + m.ResetModelID() return nil - case notifychannel.FieldHeaders: - m.ResetHeaders() + case modelpricing.FieldAccessLevel: + m.ResetAccessLevel() return nil - case notifychannel.FieldMetadata: - m.ResetMetadata() + case modelpricing.FieldIsFree: + m.ResetIsFree() return nil - case notifychannel.FieldTargetID: - m.ResetTargetID() + case modelpricing.FieldInputPrice: + m.ResetInputPrice() return nil - case notifychannel.FieldEnabled: - m.ResetEnabled() + case modelpricing.FieldOutputPrice: + m.ResetOutputPrice() return nil - case notifychannel.FieldCreatedAt: + case modelpricing.FieldCreatedAt: m.ResetCreatedAt() return nil - case notifychannel.FieldUpdatedAt: + case modelpricing.FieldUpdatedAt: m.ResetUpdatedAt() return nil } - return fmt.Errorf("unknown NotifyChannel field %s", name) + return fmt.Errorf("unknown ModelPricing field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *NotifyChannelMutation) AddedEdges() []string { +func (m *ModelPricingMutation) AddedEdges() []string { edges := make([]string, 0, 1) - if m.subscriptions != nil { - edges = append(edges, notifychannel.EdgeSubscriptions) + if m.model != nil { + edges = append(edges, modelpricing.EdgeModel) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *NotifyChannelMutation) AddedIDs(name string) []ent.Value { +func (m *ModelPricingMutation) AddedIDs(name string) []ent.Value { switch name { - case notifychannel.EdgeSubscriptions: - ids := make([]ent.Value, 0, len(m.subscriptions)) - for id := range m.subscriptions { - ids = append(ids, id) + case modelpricing.EdgeModel: + if id := m.model; id != nil { + return []ent.Value{*id} } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *NotifyChannelMutation) RemovedEdges() []string { +func (m *ModelPricingMutation) RemovedEdges() []string { edges := make([]string, 0, 1) - if m.removedsubscriptions != nil { - edges = append(edges, notifychannel.EdgeSubscriptions) - } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *NotifyChannelMutation) RemovedIDs(name string) []ent.Value { - switch name { - case notifychannel.EdgeSubscriptions: - ids := make([]ent.Value, 0, len(m.removedsubscriptions)) - for id := range m.removedsubscriptions { - ids = append(ids, id) - } - return ids - } +func (m *ModelPricingMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *NotifyChannelMutation) ClearedEdges() []string { +func (m *ModelPricingMutation) ClearedEdges() []string { edges := make([]string, 0, 1) - if m.clearedsubscriptions { - edges = append(edges, notifychannel.EdgeSubscriptions) + if m.clearedmodel { + edges = append(edges, modelpricing.EdgeModel) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *NotifyChannelMutation) EdgeCleared(name string) bool { +func (m *ModelPricingMutation) EdgeCleared(name string) bool { switch name { - case notifychannel.EdgeSubscriptions: - return m.clearedsubscriptions + case modelpricing.EdgeModel: + return m.clearedmodel } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *NotifyChannelMutation) ClearEdge(name string) error { +func (m *ModelPricingMutation) ClearEdge(name string) error { switch name { + case modelpricing.EdgeModel: + m.ClearModel() + return nil } - return fmt.Errorf("unknown NotifyChannel unique edge %s", name) + return fmt.Errorf("unknown ModelPricing unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *NotifyChannelMutation) ResetEdge(name string) error { +func (m *ModelPricingMutation) ResetEdge(name string) error { switch name { - case notifychannel.EdgeSubscriptions: - m.ResetSubscriptions() + case modelpricing.EdgeModel: + m.ResetModel() return nil } - return fmt.Errorf("unknown NotifyChannel edge %s", name) + return fmt.Errorf("unknown ModelPricing edge %s", name) } -// NotifySendLogMutation represents an operation that mutates the NotifySendLog nodes in the graph. -type NotifySendLogMutation struct { +// NotifyChannelMutation represents an operation that mutates the NotifyChannel nodes in the graph. +type NotifyChannelMutation struct { config - op Op - typ string - id *uuid.UUID - subscription_id *uuid.UUID - channel_id *uuid.UUID - event_type *consts.NotifyEventType - event_ref_id *string - status *consts.NotifySendStatus - error *string - created_at *time.Time - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*NotifySendLog, error) - predicates []predicate.NotifySendLog + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + owner_id *uuid.UUID + owner_type *consts.NotifyOwnerType + name *string + kind *consts.NotifyChannelKind + webhook_url *string + secret *string + headers *map[string]string + metadata *map[string]string + target_id *string + enabled *bool + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + subscriptions map[uuid.UUID]struct{} + removedsubscriptions map[uuid.UUID]struct{} + clearedsubscriptions bool + done bool + oldValue func(context.Context) (*NotifyChannel, error) + predicates []predicate.NotifyChannel } -var _ ent.Mutation = (*NotifySendLogMutation)(nil) +var _ ent.Mutation = (*NotifyChannelMutation)(nil) -// notifysendlogOption allows management of the mutation configuration using functional options. -type notifysendlogOption func(*NotifySendLogMutation) +// notifychannelOption allows management of the mutation configuration using functional options. +type notifychannelOption func(*NotifyChannelMutation) -// newNotifySendLogMutation creates new mutation for the NotifySendLog entity. -func newNotifySendLogMutation(c config, op Op, opts ...notifysendlogOption) *NotifySendLogMutation { - m := &NotifySendLogMutation{ +// newNotifyChannelMutation creates new mutation for the NotifyChannel entity. +func newNotifyChannelMutation(c config, op Op, opts ...notifychannelOption) *NotifyChannelMutation { + m := &NotifyChannelMutation{ config: c, op: op, - typ: TypeNotifySendLog, + typ: TypeNotifyChannel, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -17654,20 +26179,20 @@ func newNotifySendLogMutation(c config, op Op, opts ...notifysendlogOption) *Not return m } -// withNotifySendLogID sets the ID field of the mutation. -func withNotifySendLogID(id uuid.UUID) notifysendlogOption { - return func(m *NotifySendLogMutation) { +// withNotifyChannelID sets the ID field of the mutation. +func withNotifyChannelID(id uuid.UUID) notifychannelOption { + return func(m *NotifyChannelMutation) { var ( err error once sync.Once - value *NotifySendLog + value *NotifyChannel ) - m.oldValue = func(ctx context.Context) (*NotifySendLog, error) { + m.oldValue = func(ctx context.Context) (*NotifyChannel, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().NotifySendLog.Get(ctx, id) + value, err = m.Client().NotifyChannel.Get(ctx, id) } }) return value, err @@ -17676,10 +26201,10 @@ func withNotifySendLogID(id uuid.UUID) notifysendlogOption { } } -// withNotifySendLog sets the old NotifySendLog of the mutation. -func withNotifySendLog(node *NotifySendLog) notifysendlogOption { - return func(m *NotifySendLogMutation) { - m.oldValue = func(context.Context) (*NotifySendLog, error) { +// withNotifyChannel sets the old NotifyChannel of the mutation. +func withNotifyChannel(node *NotifyChannel) notifychannelOption { + return func(m *NotifyChannelMutation) { + m.oldValue = func(context.Context) (*NotifyChannel, error) { return node, nil } m.id = &node.ID @@ -17688,7 +26213,7 @@ func withNotifySendLog(node *NotifySendLog) notifysendlogOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m NotifySendLogMutation) Client() *Client { +func (m NotifyChannelMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -17696,7 +26221,7 @@ func (m NotifySendLogMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m NotifySendLogMutation) Tx() (*Tx, error) { +func (m NotifyChannelMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -17706,14 +26231,14 @@ func (m NotifySendLogMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of NotifySendLog entities. -func (m *NotifySendLogMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of NotifyChannel entities. +func (m *NotifyChannelMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *NotifySendLogMutation) ID() (id uuid.UUID, exists bool) { +func (m *NotifyChannelMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -17724,7 +26249,7 @@ func (m *NotifySendLogMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *NotifySendLogMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *NotifyChannelMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -17733,286 +26258,595 @@ func (m *NotifySendLogMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().NotifySendLog.Query().Where(m.predicates...).IDs(ctx) + return m.Client().NotifyChannel.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetSubscriptionID sets the "subscription_id" field. -func (m *NotifySendLogMutation) SetSubscriptionID(u uuid.UUID) { - m.subscription_id = &u +// SetDeletedAt sets the "deleted_at" field. +func (m *NotifyChannelMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t } -// SubscriptionID returns the value of the "subscription_id" field in the mutation. -func (m *NotifySendLogMutation) SubscriptionID() (r uuid.UUID, exists bool) { - v := m.subscription_id +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *NotifyChannelMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at if v == nil { return } return *v, true } -// OldSubscriptionID returns the old "subscription_id" field's value of the NotifySendLog entity. -// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. +// OldDeletedAt returns the old "deleted_at" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySendLogMutation) OldSubscriptionID(ctx context.Context) (v uuid.UUID, err error) { +func (m *NotifyChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSubscriptionID is only allowed on UpdateOne operations") + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSubscriptionID requires an ID field in the mutation") + return v, errors.New("OldDeletedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSubscriptionID: %w", err) + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) } - return oldValue.SubscriptionID, nil + return oldValue.DeletedAt, nil } -// ResetSubscriptionID resets all changes to the "subscription_id" field. -func (m *NotifySendLogMutation) ResetSubscriptionID() { - m.subscription_id = nil +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *NotifyChannelMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[notifychannel.FieldDeletedAt] = struct{}{} } -// SetChannelID sets the "channel_id" field. -func (m *NotifySendLogMutation) SetChannelID(u uuid.UUID) { - m.channel_id = &u +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *NotifyChannelMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[notifychannel.FieldDeletedAt] + return ok } -// ChannelID returns the value of the "channel_id" field in the mutation. -func (m *NotifySendLogMutation) ChannelID() (r uuid.UUID, exists bool) { - v := m.channel_id +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *NotifyChannelMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, notifychannel.FieldDeletedAt) +} + +// SetOwnerID sets the "owner_id" field. +func (m *NotifyChannelMutation) SetOwnerID(u uuid.UUID) { + m.owner_id = &u +} + +// OwnerID returns the value of the "owner_id" field in the mutation. +func (m *NotifyChannelMutation) OwnerID() (r uuid.UUID, exists bool) { + v := m.owner_id if v == nil { return } return *v, true } -// OldChannelID returns the old "channel_id" field's value of the NotifySendLog entity. -// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. +// OldOwnerID returns the old "owner_id" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySendLogMutation) OldChannelID(ctx context.Context) (v uuid.UUID, err error) { +func (m *NotifyChannelMutation) OldOwnerID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChannelID is only allowed on UpdateOne operations") + return v, errors.New("OldOwnerID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChannelID requires an ID field in the mutation") + return v, errors.New("OldOwnerID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldChannelID: %w", err) + return v, fmt.Errorf("querying old value for OldOwnerID: %w", err) } - return oldValue.ChannelID, nil + return oldValue.OwnerID, nil } -// ResetChannelID resets all changes to the "channel_id" field. -func (m *NotifySendLogMutation) ResetChannelID() { - m.channel_id = nil +// ResetOwnerID resets all changes to the "owner_id" field. +func (m *NotifyChannelMutation) ResetOwnerID() { + m.owner_id = nil } -// SetEventType sets the "event_type" field. -func (m *NotifySendLogMutation) SetEventType(cet consts.NotifyEventType) { - m.event_type = &cet +// SetOwnerType sets the "owner_type" field. +func (m *NotifyChannelMutation) SetOwnerType(cot consts.NotifyOwnerType) { + m.owner_type = &cot } -// EventType returns the value of the "event_type" field in the mutation. -func (m *NotifySendLogMutation) EventType() (r consts.NotifyEventType, exists bool) { - v := m.event_type +// OwnerType returns the value of the "owner_type" field in the mutation. +func (m *NotifyChannelMutation) OwnerType() (r consts.NotifyOwnerType, exists bool) { + v := m.owner_type + if v == nil { + return + } + return *v, true +} + +// OldOwnerType returns the old "owner_type" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotifyChannelMutation) OldOwnerType(ctx context.Context) (v consts.NotifyOwnerType, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOwnerType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOwnerType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOwnerType: %w", err) + } + return oldValue.OwnerType, nil +} + +// ResetOwnerType resets all changes to the "owner_type" field. +func (m *NotifyChannelMutation) ResetOwnerType() { + m.owner_type = nil +} + +// SetName sets the "name" field. +func (m *NotifyChannelMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *NotifyChannelMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotifyChannelMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *NotifyChannelMutation) ResetName() { + m.name = nil +} + +// SetKind sets the "kind" field. +func (m *NotifyChannelMutation) SetKind(cck consts.NotifyChannelKind) { + m.kind = &cck +} + +// Kind returns the value of the "kind" field in the mutation. +func (m *NotifyChannelMutation) Kind() (r consts.NotifyChannelKind, exists bool) { + v := m.kind + if v == nil { + return + } + return *v, true +} + +// OldKind returns the old "kind" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotifyChannelMutation) OldKind(ctx context.Context) (v consts.NotifyChannelKind, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKind is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKind requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKind: %w", err) + } + return oldValue.Kind, nil +} + +// ResetKind resets all changes to the "kind" field. +func (m *NotifyChannelMutation) ResetKind() { + m.kind = nil +} + +// SetWebhookURL sets the "webhook_url" field. +func (m *NotifyChannelMutation) SetWebhookURL(s string) { + m.webhook_url = &s +} + +// WebhookURL returns the value of the "webhook_url" field in the mutation. +func (m *NotifyChannelMutation) WebhookURL() (r string, exists bool) { + v := m.webhook_url + if v == nil { + return + } + return *v, true +} + +// OldWebhookURL returns the old "webhook_url" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotifyChannelMutation) OldWebhookURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWebhookURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWebhookURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWebhookURL: %w", err) + } + return oldValue.WebhookURL, nil +} + +// ResetWebhookURL resets all changes to the "webhook_url" field. +func (m *NotifyChannelMutation) ResetWebhookURL() { + m.webhook_url = nil +} + +// SetSecret sets the "secret" field. +func (m *NotifyChannelMutation) SetSecret(s string) { + m.secret = &s +} + +// Secret returns the value of the "secret" field in the mutation. +func (m *NotifyChannelMutation) Secret() (r string, exists bool) { + v := m.secret + if v == nil { + return + } + return *v, true +} + +// OldSecret returns the old "secret" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotifyChannelMutation) OldSecret(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSecret is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSecret requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSecret: %w", err) + } + return oldValue.Secret, nil +} + +// ClearSecret clears the value of the "secret" field. +func (m *NotifyChannelMutation) ClearSecret() { + m.secret = nil + m.clearedFields[notifychannel.FieldSecret] = struct{}{} +} + +// SecretCleared returns if the "secret" field was cleared in this mutation. +func (m *NotifyChannelMutation) SecretCleared() bool { + _, ok := m.clearedFields[notifychannel.FieldSecret] + return ok +} + +// ResetSecret resets all changes to the "secret" field. +func (m *NotifyChannelMutation) ResetSecret() { + m.secret = nil + delete(m.clearedFields, notifychannel.FieldSecret) +} + +// SetHeaders sets the "headers" field. +func (m *NotifyChannelMutation) SetHeaders(value map[string]string) { + m.headers = &value +} + +// Headers returns the value of the "headers" field in the mutation. +func (m *NotifyChannelMutation) Headers() (r map[string]string, exists bool) { + v := m.headers + if v == nil { + return + } + return *v, true +} + +// OldHeaders returns the old "headers" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotifyChannelMutation) OldHeaders(ctx context.Context) (v map[string]string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHeaders is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHeaders requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHeaders: %w", err) + } + return oldValue.Headers, nil +} + +// ClearHeaders clears the value of the "headers" field. +func (m *NotifyChannelMutation) ClearHeaders() { + m.headers = nil + m.clearedFields[notifychannel.FieldHeaders] = struct{}{} +} + +// HeadersCleared returns if the "headers" field was cleared in this mutation. +func (m *NotifyChannelMutation) HeadersCleared() bool { + _, ok := m.clearedFields[notifychannel.FieldHeaders] + return ok +} + +// ResetHeaders resets all changes to the "headers" field. +func (m *NotifyChannelMutation) ResetHeaders() { + m.headers = nil + delete(m.clearedFields, notifychannel.FieldHeaders) +} + +// SetMetadata sets the "metadata" field. +func (m *NotifyChannelMutation) SetMetadata(value map[string]string) { + m.metadata = &value +} + +// Metadata returns the value of the "metadata" field in the mutation. +func (m *NotifyChannelMutation) Metadata() (r map[string]string, exists bool) { + v := m.metadata + if v == nil { + return + } + return *v, true +} + +// OldMetadata returns the old "metadata" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotifyChannelMutation) OldMetadata(ctx context.Context) (v map[string]string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMetadata is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMetadata requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMetadata: %w", err) + } + return oldValue.Metadata, nil +} + +// ClearMetadata clears the value of the "metadata" field. +func (m *NotifyChannelMutation) ClearMetadata() { + m.metadata = nil + m.clearedFields[notifychannel.FieldMetadata] = struct{}{} +} + +// MetadataCleared returns if the "metadata" field was cleared in this mutation. +func (m *NotifyChannelMutation) MetadataCleared() bool { + _, ok := m.clearedFields[notifychannel.FieldMetadata] + return ok +} + +// ResetMetadata resets all changes to the "metadata" field. +func (m *NotifyChannelMutation) ResetMetadata() { + m.metadata = nil + delete(m.clearedFields, notifychannel.FieldMetadata) +} + +// SetTargetID sets the "target_id" field. +func (m *NotifyChannelMutation) SetTargetID(s string) { + m.target_id = &s +} + +// TargetID returns the value of the "target_id" field in the mutation. +func (m *NotifyChannelMutation) TargetID() (r string, exists bool) { + v := m.target_id if v == nil { return } return *v, true } -// OldEventType returns the old "event_type" field's value of the NotifySendLog entity. -// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. +// OldTargetID returns the old "target_id" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySendLogMutation) OldEventType(ctx context.Context) (v consts.NotifyEventType, err error) { +func (m *NotifyChannelMutation) OldTargetID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEventType is only allowed on UpdateOne operations") + return v, errors.New("OldTargetID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEventType requires an ID field in the mutation") + return v, errors.New("OldTargetID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEventType: %w", err) + return v, fmt.Errorf("querying old value for OldTargetID: %w", err) } - return oldValue.EventType, nil + return oldValue.TargetID, nil } -// ResetEventType resets all changes to the "event_type" field. -func (m *NotifySendLogMutation) ResetEventType() { - m.event_type = nil +// ResetTargetID resets all changes to the "target_id" field. +func (m *NotifyChannelMutation) ResetTargetID() { + m.target_id = nil } -// SetEventRefID sets the "event_ref_id" field. -func (m *NotifySendLogMutation) SetEventRefID(s string) { - m.event_ref_id = &s +// SetEnabled sets the "enabled" field. +func (m *NotifyChannelMutation) SetEnabled(b bool) { + m.enabled = &b } -// EventRefID returns the value of the "event_ref_id" field in the mutation. -func (m *NotifySendLogMutation) EventRefID() (r string, exists bool) { - v := m.event_ref_id +// Enabled returns the value of the "enabled" field in the mutation. +func (m *NotifyChannelMutation) Enabled() (r bool, exists bool) { + v := m.enabled if v == nil { return } return *v, true } -// OldEventRefID returns the old "event_ref_id" field's value of the NotifySendLog entity. -// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. +// OldEnabled returns the old "enabled" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySendLogMutation) OldEventRefID(ctx context.Context) (v string, err error) { +func (m *NotifyChannelMutation) OldEnabled(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEventRefID is only allowed on UpdateOne operations") + return v, errors.New("OldEnabled is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEventRefID requires an ID field in the mutation") + return v, errors.New("OldEnabled requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEventRefID: %w", err) + return v, fmt.Errorf("querying old value for OldEnabled: %w", err) } - return oldValue.EventRefID, nil + return oldValue.Enabled, nil } -// ResetEventRefID resets all changes to the "event_ref_id" field. -func (m *NotifySendLogMutation) ResetEventRefID() { - m.event_ref_id = nil +// ResetEnabled resets all changes to the "enabled" field. +func (m *NotifyChannelMutation) ResetEnabled() { + m.enabled = nil } -// SetStatus sets the "status" field. -func (m *NotifySendLogMutation) SetStatus(css consts.NotifySendStatus) { - m.status = &css +// SetCreatedAt sets the "created_at" field. +func (m *NotifyChannelMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// Status returns the value of the "status" field in the mutation. -func (m *NotifySendLogMutation) Status() (r consts.NotifySendStatus, exists bool) { - v := m.status +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *NotifyChannelMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldStatus returns the old "status" field's value of the NotifySendLog entity. -// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySendLogMutation) OldStatus(ctx context.Context) (v consts.NotifySendStatus, err error) { +func (m *NotifyChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.Status, nil + return oldValue.CreatedAt, nil } -// ResetStatus resets all changes to the "status" field. -func (m *NotifySendLogMutation) ResetStatus() { - m.status = nil +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *NotifyChannelMutation) ResetCreatedAt() { + m.created_at = nil } -// SetError sets the "error" field. -func (m *NotifySendLogMutation) SetError(s string) { - m.error = &s +// SetUpdatedAt sets the "updated_at" field. +func (m *NotifyChannelMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t } -// Error returns the value of the "error" field in the mutation. -func (m *NotifySendLogMutation) Error() (r string, exists bool) { - v := m.error +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *NotifyChannelMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at if v == nil { return } return *v, true } -// OldError returns the old "error" field's value of the NotifySendLog entity. -// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. +// OldUpdatedAt returns the old "updated_at" field's value of the NotifyChannel entity. +// If the NotifyChannel object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySendLogMutation) OldError(ctx context.Context) (v string, err error) { +func (m *NotifyChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldError is only allowed on UpdateOne operations") + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldError requires an ID field in the mutation") + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldError: %w", err) + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } - return oldValue.Error, nil + return oldValue.UpdatedAt, nil } -// ClearError clears the value of the "error" field. -func (m *NotifySendLogMutation) ClearError() { - m.error = nil - m.clearedFields[notifysendlog.FieldError] = struct{}{} +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *NotifyChannelMutation) ResetUpdatedAt() { + m.updated_at = nil } -// ErrorCleared returns if the "error" field was cleared in this mutation. -func (m *NotifySendLogMutation) ErrorCleared() bool { - _, ok := m.clearedFields[notifysendlog.FieldError] - return ok +// AddSubscriptionIDs adds the "subscriptions" edge to the NotifySubscription entity by ids. +func (m *NotifyChannelMutation) AddSubscriptionIDs(ids ...uuid.UUID) { + if m.subscriptions == nil { + m.subscriptions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.subscriptions[ids[i]] = struct{}{} + } } -// ResetError resets all changes to the "error" field. -func (m *NotifySendLogMutation) ResetError() { - m.error = nil - delete(m.clearedFields, notifysendlog.FieldError) +// ClearSubscriptions clears the "subscriptions" edge to the NotifySubscription entity. +func (m *NotifyChannelMutation) ClearSubscriptions() { + m.clearedsubscriptions = true } -// SetCreatedAt sets the "created_at" field. -func (m *NotifySendLogMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// SubscriptionsCleared reports if the "subscriptions" edge to the NotifySubscription entity was cleared. +func (m *NotifyChannelMutation) SubscriptionsCleared() bool { + return m.clearedsubscriptions } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *NotifySendLogMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return +// RemoveSubscriptionIDs removes the "subscriptions" edge to the NotifySubscription entity by IDs. +func (m *NotifyChannelMutation) RemoveSubscriptionIDs(ids ...uuid.UUID) { + if m.removedsubscriptions == nil { + m.removedsubscriptions = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.subscriptions, ids[i]) + m.removedsubscriptions[ids[i]] = struct{}{} } - return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the NotifySendLog entity. -// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySendLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") +// RemovedSubscriptions returns the removed IDs of the "subscriptions" edge to the NotifySubscription entity. +func (m *NotifyChannelMutation) RemovedSubscriptionsIDs() (ids []uuid.UUID) { + for id := range m.removedsubscriptions { + ids = append(ids, id) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return +} + +// SubscriptionsIDs returns the "subscriptions" edge IDs in the mutation. +func (m *NotifyChannelMutation) SubscriptionsIDs() (ids []uuid.UUID) { + for id := range m.subscriptions { + ids = append(ids, id) } - return oldValue.CreatedAt, nil + return } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *NotifySendLogMutation) ResetCreatedAt() { - m.created_at = nil +// ResetSubscriptions resets all changes to the "subscriptions" edge. +func (m *NotifyChannelMutation) ResetSubscriptions() { + m.subscriptions = nil + m.clearedsubscriptions = false + m.removedsubscriptions = nil } -// Where appends a list predicates to the NotifySendLogMutation builder. -func (m *NotifySendLogMutation) Where(ps ...predicate.NotifySendLog) { +// Where appends a list predicates to the NotifyChannelMutation builder. +func (m *NotifyChannelMutation) Where(ps ...predicate.NotifyChannel) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the NotifySendLogMutation builder. Using this method, +// WhereP appends storage-level predicates to the NotifyChannelMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *NotifySendLogMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.NotifySendLog, len(ps)) +func (m *NotifyChannelMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.NotifyChannel, len(ps)) for i := range ps { p[i] = ps[i] } @@ -18020,45 +26854,63 @@ func (m *NotifySendLogMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *NotifySendLogMutation) Op() Op { +func (m *NotifyChannelMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *NotifySendLogMutation) SetOp(op Op) { +func (m *NotifyChannelMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (NotifySendLog). -func (m *NotifySendLogMutation) Type() string { +// Type returns the node type of this mutation (NotifyChannel). +func (m *NotifyChannelMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *NotifySendLogMutation) Fields() []string { - fields := make([]string, 0, 7) - if m.subscription_id != nil { - fields = append(fields, notifysendlog.FieldSubscriptionID) +func (m *NotifyChannelMutation) Fields() []string { + fields := make([]string, 0, 13) + if m.deleted_at != nil { + fields = append(fields, notifychannel.FieldDeletedAt) } - if m.channel_id != nil { - fields = append(fields, notifysendlog.FieldChannelID) + if m.owner_id != nil { + fields = append(fields, notifychannel.FieldOwnerID) } - if m.event_type != nil { - fields = append(fields, notifysendlog.FieldEventType) + if m.owner_type != nil { + fields = append(fields, notifychannel.FieldOwnerType) } - if m.event_ref_id != nil { - fields = append(fields, notifysendlog.FieldEventRefID) + if m.name != nil { + fields = append(fields, notifychannel.FieldName) } - if m.status != nil { - fields = append(fields, notifysendlog.FieldStatus) + if m.kind != nil { + fields = append(fields, notifychannel.FieldKind) } - if m.error != nil { - fields = append(fields, notifysendlog.FieldError) + if m.webhook_url != nil { + fields = append(fields, notifychannel.FieldWebhookURL) + } + if m.secret != nil { + fields = append(fields, notifychannel.FieldSecret) + } + if m.headers != nil { + fields = append(fields, notifychannel.FieldHeaders) + } + if m.metadata != nil { + fields = append(fields, notifychannel.FieldMetadata) + } + if m.target_id != nil { + fields = append(fields, notifychannel.FieldTargetID) + } + if m.enabled != nil { + fields = append(fields, notifychannel.FieldEnabled) } if m.created_at != nil { - fields = append(fields, notifysendlog.FieldCreatedAt) + fields = append(fields, notifychannel.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, notifychannel.FieldUpdatedAt) } return fields } @@ -18066,22 +26918,34 @@ func (m *NotifySendLogMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *NotifySendLogMutation) Field(name string) (ent.Value, bool) { +func (m *NotifyChannelMutation) Field(name string) (ent.Value, bool) { switch name { - case notifysendlog.FieldSubscriptionID: - return m.SubscriptionID() - case notifysendlog.FieldChannelID: - return m.ChannelID() - case notifysendlog.FieldEventType: - return m.EventType() - case notifysendlog.FieldEventRefID: - return m.EventRefID() - case notifysendlog.FieldStatus: - return m.Status() - case notifysendlog.FieldError: - return m.Error() - case notifysendlog.FieldCreatedAt: + case notifychannel.FieldDeletedAt: + return m.DeletedAt() + case notifychannel.FieldOwnerID: + return m.OwnerID() + case notifychannel.FieldOwnerType: + return m.OwnerType() + case notifychannel.FieldName: + return m.Name() + case notifychannel.FieldKind: + return m.Kind() + case notifychannel.FieldWebhookURL: + return m.WebhookURL() + case notifychannel.FieldSecret: + return m.Secret() + case notifychannel.FieldHeaders: + return m.Headers() + case notifychannel.FieldMetadata: + return m.Metadata() + case notifychannel.FieldTargetID: + return m.TargetID() + case notifychannel.FieldEnabled: + return m.Enabled() + case notifychannel.FieldCreatedAt: return m.CreatedAt() + case notifychannel.FieldUpdatedAt: + return m.UpdatedAt() } return nil, false } @@ -18089,243 +26953,367 @@ func (m *NotifySendLogMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *NotifySendLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *NotifyChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case notifysendlog.FieldSubscriptionID: - return m.OldSubscriptionID(ctx) - case notifysendlog.FieldChannelID: - return m.OldChannelID(ctx) - case notifysendlog.FieldEventType: - return m.OldEventType(ctx) - case notifysendlog.FieldEventRefID: - return m.OldEventRefID(ctx) - case notifysendlog.FieldStatus: - return m.OldStatus(ctx) - case notifysendlog.FieldError: - return m.OldError(ctx) - case notifysendlog.FieldCreatedAt: + case notifychannel.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case notifychannel.FieldOwnerID: + return m.OldOwnerID(ctx) + case notifychannel.FieldOwnerType: + return m.OldOwnerType(ctx) + case notifychannel.FieldName: + return m.OldName(ctx) + case notifychannel.FieldKind: + return m.OldKind(ctx) + case notifychannel.FieldWebhookURL: + return m.OldWebhookURL(ctx) + case notifychannel.FieldSecret: + return m.OldSecret(ctx) + case notifychannel.FieldHeaders: + return m.OldHeaders(ctx) + case notifychannel.FieldMetadata: + return m.OldMetadata(ctx) + case notifychannel.FieldTargetID: + return m.OldTargetID(ctx) + case notifychannel.FieldEnabled: + return m.OldEnabled(ctx) + case notifychannel.FieldCreatedAt: return m.OldCreatedAt(ctx) + case notifychannel.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown NotifySendLog field %s", name) + return nil, fmt.Errorf("unknown NotifyChannel field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *NotifySendLogMutation) SetField(name string, value ent.Value) error { +func (m *NotifyChannelMutation) SetField(name string, value ent.Value) error { switch name { - case notifysendlog.FieldSubscriptionID: - v, ok := value.(uuid.UUID) + case notifychannel.FieldDeletedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSubscriptionID(v) + m.SetDeletedAt(v) return nil - case notifysendlog.FieldChannelID: + case notifychannel.FieldOwnerID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetChannelID(v) + m.SetOwnerID(v) return nil - case notifysendlog.FieldEventType: - v, ok := value.(consts.NotifyEventType) + case notifychannel.FieldOwnerType: + v, ok := value.(consts.NotifyOwnerType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetEventType(v) + m.SetOwnerType(v) return nil - case notifysendlog.FieldEventRefID: + case notifychannel.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetEventRefID(v) + m.SetName(v) return nil - case notifysendlog.FieldStatus: - v, ok := value.(consts.NotifySendStatus) + case notifychannel.FieldKind: + v, ok := value.(consts.NotifyChannelKind) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetStatus(v) + m.SetKind(v) return nil - case notifysendlog.FieldError: + case notifychannel.FieldWebhookURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetError(v) + m.SetWebhookURL(v) return nil - case notifysendlog.FieldCreatedAt: + case notifychannel.FieldSecret: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSecret(v) + return nil + case notifychannel.FieldHeaders: + v, ok := value.(map[string]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHeaders(v) + return nil + case notifychannel.FieldMetadata: + v, ok := value.(map[string]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMetadata(v) + return nil + case notifychannel.FieldTargetID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTargetID(v) + return nil + case notifychannel.FieldEnabled: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEnabled(v) + return nil + case notifychannel.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil + case notifychannel.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil } - return fmt.Errorf("unknown NotifySendLog field %s", name) + return fmt.Errorf("unknown NotifyChannel field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *NotifySendLogMutation) AddedFields() []string { +func (m *NotifyChannelMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *NotifySendLogMutation) AddedField(name string) (ent.Value, bool) { +func (m *NotifyChannelMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *NotifySendLogMutation) AddField(name string, value ent.Value) error { +func (m *NotifyChannelMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown NotifySendLog numeric field %s", name) + return fmt.Errorf("unknown NotifyChannel numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *NotifySendLogMutation) ClearedFields() []string { +func (m *NotifyChannelMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(notifysendlog.FieldError) { - fields = append(fields, notifysendlog.FieldError) + if m.FieldCleared(notifychannel.FieldDeletedAt) { + fields = append(fields, notifychannel.FieldDeletedAt) + } + if m.FieldCleared(notifychannel.FieldSecret) { + fields = append(fields, notifychannel.FieldSecret) + } + if m.FieldCleared(notifychannel.FieldHeaders) { + fields = append(fields, notifychannel.FieldHeaders) + } + if m.FieldCleared(notifychannel.FieldMetadata) { + fields = append(fields, notifychannel.FieldMetadata) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *NotifySendLogMutation) FieldCleared(name string) bool { +func (m *NotifyChannelMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *NotifySendLogMutation) ClearField(name string) error { +func (m *NotifyChannelMutation) ClearField(name string) error { switch name { - case notifysendlog.FieldError: - m.ClearError() + case notifychannel.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case notifychannel.FieldSecret: + m.ClearSecret() + return nil + case notifychannel.FieldHeaders: + m.ClearHeaders() + return nil + case notifychannel.FieldMetadata: + m.ClearMetadata() return nil } - return fmt.Errorf("unknown NotifySendLog nullable field %s", name) + return fmt.Errorf("unknown NotifyChannel nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *NotifySendLogMutation) ResetField(name string) error { +func (m *NotifyChannelMutation) ResetField(name string) error { switch name { - case notifysendlog.FieldSubscriptionID: - m.ResetSubscriptionID() + case notifychannel.FieldDeletedAt: + m.ResetDeletedAt() return nil - case notifysendlog.FieldChannelID: - m.ResetChannelID() + case notifychannel.FieldOwnerID: + m.ResetOwnerID() return nil - case notifysendlog.FieldEventType: - m.ResetEventType() + case notifychannel.FieldOwnerType: + m.ResetOwnerType() return nil - case notifysendlog.FieldEventRefID: - m.ResetEventRefID() + case notifychannel.FieldName: + m.ResetName() return nil - case notifysendlog.FieldStatus: - m.ResetStatus() + case notifychannel.FieldKind: + m.ResetKind() return nil - case notifysendlog.FieldError: - m.ResetError() + case notifychannel.FieldWebhookURL: + m.ResetWebhookURL() return nil - case notifysendlog.FieldCreatedAt: + case notifychannel.FieldSecret: + m.ResetSecret() + return nil + case notifychannel.FieldHeaders: + m.ResetHeaders() + return nil + case notifychannel.FieldMetadata: + m.ResetMetadata() + return nil + case notifychannel.FieldTargetID: + m.ResetTargetID() + return nil + case notifychannel.FieldEnabled: + m.ResetEnabled() + return nil + case notifychannel.FieldCreatedAt: m.ResetCreatedAt() return nil + case notifychannel.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil } - return fmt.Errorf("unknown NotifySendLog field %s", name) + return fmt.Errorf("unknown NotifyChannel field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *NotifySendLogMutation) AddedEdges() []string { - edges := make([]string, 0, 0) +func (m *NotifyChannelMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.subscriptions != nil { + edges = append(edges, notifychannel.EdgeSubscriptions) + } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *NotifySendLogMutation) AddedIDs(name string) []ent.Value { +func (m *NotifyChannelMutation) AddedIDs(name string) []ent.Value { + switch name { + case notifychannel.EdgeSubscriptions: + ids := make([]ent.Value, 0, len(m.subscriptions)) + for id := range m.subscriptions { + ids = append(ids, id) + } + return ids + } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *NotifySendLogMutation) RemovedEdges() []string { - edges := make([]string, 0, 0) +func (m *NotifyChannelMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + if m.removedsubscriptions != nil { + edges = append(edges, notifychannel.EdgeSubscriptions) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *NotifySendLogMutation) RemovedIDs(name string) []ent.Value { +func (m *NotifyChannelMutation) RemovedIDs(name string) []ent.Value { + switch name { + case notifychannel.EdgeSubscriptions: + ids := make([]ent.Value, 0, len(m.removedsubscriptions)) + for id := range m.removedsubscriptions { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *NotifySendLogMutation) ClearedEdges() []string { - edges := make([]string, 0, 0) +func (m *NotifyChannelMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedsubscriptions { + edges = append(edges, notifychannel.EdgeSubscriptions) + } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *NotifySendLogMutation) EdgeCleared(name string) bool { +func (m *NotifyChannelMutation) EdgeCleared(name string) bool { + switch name { + case notifychannel.EdgeSubscriptions: + return m.clearedsubscriptions + } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *NotifySendLogMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown NotifySendLog unique edge %s", name) +func (m *NotifyChannelMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown NotifyChannel unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *NotifySendLogMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown NotifySendLog edge %s", name) +func (m *NotifyChannelMutation) ResetEdge(name string) error { + switch name { + case notifychannel.EdgeSubscriptions: + m.ResetSubscriptions() + return nil + } + return fmt.Errorf("unknown NotifyChannel edge %s", name) } -// NotifySubscriptionMutation represents an operation that mutates the NotifySubscription nodes in the graph. -type NotifySubscriptionMutation struct { +// NotifySendLogMutation represents an operation that mutates the NotifySendLog nodes in the graph. +type NotifySendLogMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - scope *string - event_types *[]consts.NotifyEventType - appendevent_types []consts.NotifyEventType - enabled *bool - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - channel *uuid.UUID - clearedchannel bool - done bool - oldValue func(context.Context) (*NotifySubscription, error) - predicates []predicate.NotifySubscription + op Op + typ string + id *uuid.UUID + subscription_id *uuid.UUID + channel_id *uuid.UUID + event_type *consts.NotifyEventType + event_ref_id *string + status *consts.NotifySendStatus + error *string + created_at *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*NotifySendLog, error) + predicates []predicate.NotifySendLog } -var _ ent.Mutation = (*NotifySubscriptionMutation)(nil) +var _ ent.Mutation = (*NotifySendLogMutation)(nil) -// notifysubscriptionOption allows management of the mutation configuration using functional options. -type notifysubscriptionOption func(*NotifySubscriptionMutation) +// notifysendlogOption allows management of the mutation configuration using functional options. +type notifysendlogOption func(*NotifySendLogMutation) -// newNotifySubscriptionMutation creates new mutation for the NotifySubscription entity. -func newNotifySubscriptionMutation(c config, op Op, opts ...notifysubscriptionOption) *NotifySubscriptionMutation { - m := &NotifySubscriptionMutation{ +// newNotifySendLogMutation creates new mutation for the NotifySendLog entity. +func newNotifySendLogMutation(c config, op Op, opts ...notifysendlogOption) *NotifySendLogMutation { + m := &NotifySendLogMutation{ config: c, op: op, - typ: TypeNotifySubscription, + typ: TypeNotifySendLog, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -18334,20 +27322,20 @@ func newNotifySubscriptionMutation(c config, op Op, opts ...notifysubscriptionOp return m } -// withNotifySubscriptionID sets the ID field of the mutation. -func withNotifySubscriptionID(id uuid.UUID) notifysubscriptionOption { - return func(m *NotifySubscriptionMutation) { +// withNotifySendLogID sets the ID field of the mutation. +func withNotifySendLogID(id uuid.UUID) notifysendlogOption { + return func(m *NotifySendLogMutation) { var ( err error once sync.Once - value *NotifySubscription + value *NotifySendLog ) - m.oldValue = func(ctx context.Context) (*NotifySubscription, error) { + m.oldValue = func(ctx context.Context) (*NotifySendLog, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().NotifySubscription.Get(ctx, id) + value, err = m.Client().NotifySendLog.Get(ctx, id) } }) return value, err @@ -18356,10 +27344,10 @@ func withNotifySubscriptionID(id uuid.UUID) notifysubscriptionOption { } } -// withNotifySubscription sets the old NotifySubscription of the mutation. -func withNotifySubscription(node *NotifySubscription) notifysubscriptionOption { - return func(m *NotifySubscriptionMutation) { - m.oldValue = func(context.Context) (*NotifySubscription, error) { +// withNotifySendLog sets the old NotifySendLog of the mutation. +func withNotifySendLog(node *NotifySendLog) notifysendlogOption { + return func(m *NotifySendLogMutation) { + m.oldValue = func(context.Context) (*NotifySendLog, error) { return node, nil } m.id = &node.ID @@ -18368,7 +27356,7 @@ func withNotifySubscription(node *NotifySubscription) notifysubscriptionOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m NotifySubscriptionMutation) Client() *Client { +func (m NotifySendLogMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -18376,7 +27364,7 @@ func (m NotifySubscriptionMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m NotifySubscriptionMutation) Tx() (*Tx, error) { +func (m NotifySendLogMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -18386,14 +27374,14 @@ func (m NotifySubscriptionMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of NotifySubscription entities. -func (m *NotifySubscriptionMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of NotifySendLog entities. +func (m *NotifySendLogMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *NotifySubscriptionMutation) ID() (id uuid.UUID, exists bool) { +func (m *NotifySendLogMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -18404,7 +27392,7 @@ func (m *NotifySubscriptionMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *NotifySubscriptionMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *NotifySendLogMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -18413,79 +27401,66 @@ func (m *NotifySubscriptionMutation) IDs(ctx context.Context) ([]uuid.UUID, erro } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().NotifySubscription.Query().Where(m.predicates...).IDs(ctx) + return m.Client().NotifySendLog.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetDeletedAt sets the "deleted_at" field. -func (m *NotifySubscriptionMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t +// SetSubscriptionID sets the "subscription_id" field. +func (m *NotifySendLogMutation) SetSubscriptionID(u uuid.UUID) { + m.subscription_id = &u } -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *NotifySubscriptionMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at +// SubscriptionID returns the value of the "subscription_id" field in the mutation. +func (m *NotifySendLogMutation) SubscriptionID() (r uuid.UUID, exists bool) { + v := m.subscription_id if v == nil { return } return *v, true } -// OldDeletedAt returns the old "deleted_at" field's value of the NotifySubscription entity. -// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. +// OldSubscriptionID returns the old "subscription_id" field's value of the NotifySendLog entity. +// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySubscriptionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { +func (m *NotifySendLogMutation) OldSubscriptionID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + return v, errors.New("OldSubscriptionID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") + return v, errors.New("OldSubscriptionID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + return v, fmt.Errorf("querying old value for OldSubscriptionID: %w", err) } - return oldValue.DeletedAt, nil -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *NotifySubscriptionMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[notifysubscription.FieldDeletedAt] = struct{}{} -} - -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *NotifySubscriptionMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[notifysubscription.FieldDeletedAt] - return ok + return oldValue.SubscriptionID, nil } -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *NotifySubscriptionMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, notifysubscription.FieldDeletedAt) +// ResetSubscriptionID resets all changes to the "subscription_id" field. +func (m *NotifySendLogMutation) ResetSubscriptionID() { + m.subscription_id = nil } // SetChannelID sets the "channel_id" field. -func (m *NotifySubscriptionMutation) SetChannelID(u uuid.UUID) { - m.channel = &u +func (m *NotifySendLogMutation) SetChannelID(u uuid.UUID) { + m.channel_id = &u } // ChannelID returns the value of the "channel_id" field in the mutation. -func (m *NotifySubscriptionMutation) ChannelID() (r uuid.UUID, exists bool) { - v := m.channel +func (m *NotifySendLogMutation) ChannelID() (r uuid.UUID, exists bool) { + v := m.channel_id if v == nil { return } return *v, true } -// OldChannelID returns the old "channel_id" field's value of the NotifySubscription entity. -// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. +// OldChannelID returns the old "channel_id" field's value of the NotifySendLog entity. +// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySubscriptionMutation) OldChannelID(ctx context.Context) (v uuid.UUID, err error) { +func (m *NotifySendLogMutation) OldChannelID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldChannelID is only allowed on UpdateOne operations") } @@ -18500,241 +27475,212 @@ func (m *NotifySubscriptionMutation) OldChannelID(ctx context.Context) (v uuid.U } // ResetChannelID resets all changes to the "channel_id" field. -func (m *NotifySubscriptionMutation) ResetChannelID() { - m.channel = nil +func (m *NotifySendLogMutation) ResetChannelID() { + m.channel_id = nil } -// SetScope sets the "scope" field. -func (m *NotifySubscriptionMutation) SetScope(s string) { - m.scope = &s +// SetEventType sets the "event_type" field. +func (m *NotifySendLogMutation) SetEventType(cet consts.NotifyEventType) { + m.event_type = &cet } -// Scope returns the value of the "scope" field in the mutation. -func (m *NotifySubscriptionMutation) Scope() (r string, exists bool) { - v := m.scope +// EventType returns the value of the "event_type" field in the mutation. +func (m *NotifySendLogMutation) EventType() (r consts.NotifyEventType, exists bool) { + v := m.event_type if v == nil { return } return *v, true } -// OldScope returns the old "scope" field's value of the NotifySubscription entity. -// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. +// OldEventType returns the old "event_type" field's value of the NotifySendLog entity. +// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySubscriptionMutation) OldScope(ctx context.Context) (v string, err error) { +func (m *NotifySendLogMutation) OldEventType(ctx context.Context) (v consts.NotifyEventType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldScope is only allowed on UpdateOne operations") + return v, errors.New("OldEventType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldScope requires an ID field in the mutation") + return v, errors.New("OldEventType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldScope: %w", err) + return v, fmt.Errorf("querying old value for OldEventType: %w", err) } - return oldValue.Scope, nil + return oldValue.EventType, nil } -// ResetScope resets all changes to the "scope" field. -func (m *NotifySubscriptionMutation) ResetScope() { - m.scope = nil +// ResetEventType resets all changes to the "event_type" field. +func (m *NotifySendLogMutation) ResetEventType() { + m.event_type = nil } -// SetEventTypes sets the "event_types" field. -func (m *NotifySubscriptionMutation) SetEventTypes(cet []consts.NotifyEventType) { - m.event_types = &cet - m.appendevent_types = nil +// SetEventRefID sets the "event_ref_id" field. +func (m *NotifySendLogMutation) SetEventRefID(s string) { + m.event_ref_id = &s } -// EventTypes returns the value of the "event_types" field in the mutation. -func (m *NotifySubscriptionMutation) EventTypes() (r []consts.NotifyEventType, exists bool) { - v := m.event_types +// EventRefID returns the value of the "event_ref_id" field in the mutation. +func (m *NotifySendLogMutation) EventRefID() (r string, exists bool) { + v := m.event_ref_id if v == nil { return } return *v, true } -// OldEventTypes returns the old "event_types" field's value of the NotifySubscription entity. -// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. +// OldEventRefID returns the old "event_ref_id" field's value of the NotifySendLog entity. +// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySubscriptionMutation) OldEventTypes(ctx context.Context) (v []consts.NotifyEventType, err error) { +func (m *NotifySendLogMutation) OldEventRefID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEventTypes is only allowed on UpdateOne operations") + return v, errors.New("OldEventRefID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEventTypes requires an ID field in the mutation") + return v, errors.New("OldEventRefID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEventTypes: %w", err) - } - return oldValue.EventTypes, nil -} - -// AppendEventTypes adds cet to the "event_types" field. -func (m *NotifySubscriptionMutation) AppendEventTypes(cet []consts.NotifyEventType) { - m.appendevent_types = append(m.appendevent_types, cet...) -} - -// AppendedEventTypes returns the list of values that were appended to the "event_types" field in this mutation. -func (m *NotifySubscriptionMutation) AppendedEventTypes() ([]consts.NotifyEventType, bool) { - if len(m.appendevent_types) == 0 { - return nil, false + return v, fmt.Errorf("querying old value for OldEventRefID: %w", err) } - return m.appendevent_types, true + return oldValue.EventRefID, nil } -// ResetEventTypes resets all changes to the "event_types" field. -func (m *NotifySubscriptionMutation) ResetEventTypes() { - m.event_types = nil - m.appendevent_types = nil +// ResetEventRefID resets all changes to the "event_ref_id" field. +func (m *NotifySendLogMutation) ResetEventRefID() { + m.event_ref_id = nil } -// SetEnabled sets the "enabled" field. -func (m *NotifySubscriptionMutation) SetEnabled(b bool) { - m.enabled = &b +// SetStatus sets the "status" field. +func (m *NotifySendLogMutation) SetStatus(css consts.NotifySendStatus) { + m.status = &css } -// Enabled returns the value of the "enabled" field in the mutation. -func (m *NotifySubscriptionMutation) Enabled() (r bool, exists bool) { - v := m.enabled +// Status returns the value of the "status" field in the mutation. +func (m *NotifySendLogMutation) Status() (r consts.NotifySendStatus, exists bool) { + v := m.status if v == nil { return } return *v, true } -// OldEnabled returns the old "enabled" field's value of the NotifySubscription entity. -// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. +// OldStatus returns the old "status" field's value of the NotifySendLog entity. +// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySubscriptionMutation) OldEnabled(ctx context.Context) (v bool, err error) { +func (m *NotifySendLogMutation) OldStatus(ctx context.Context) (v consts.NotifySendStatus, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEnabled is only allowed on UpdateOne operations") + return v, errors.New("OldStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEnabled requires an ID field in the mutation") + return v, errors.New("OldStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEnabled: %w", err) + return v, fmt.Errorf("querying old value for OldStatus: %w", err) } - return oldValue.Enabled, nil + return oldValue.Status, nil } -// ResetEnabled resets all changes to the "enabled" field. -func (m *NotifySubscriptionMutation) ResetEnabled() { - m.enabled = nil +// ResetStatus resets all changes to the "status" field. +func (m *NotifySendLogMutation) ResetStatus() { + m.status = nil } -// SetCreatedAt sets the "created_at" field. -func (m *NotifySubscriptionMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// SetError sets the "error" field. +func (m *NotifySendLogMutation) SetError(s string) { + m.error = &s } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *NotifySubscriptionMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// Error returns the value of the "error" field in the mutation. +func (m *NotifySendLogMutation) Error() (r string, exists bool) { + v := m.error if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the NotifySubscription entity. -// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. +// OldError returns the old "error" field's value of the NotifySendLog entity. +// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySubscriptionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *NotifySendLogMutation) OldError(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldError is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + return v, errors.New("OldError requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldError: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.Error, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *NotifySubscriptionMutation) ResetCreatedAt() { - m.created_at = nil +// ClearError clears the value of the "error" field. +func (m *NotifySendLogMutation) ClearError() { + m.error = nil + m.clearedFields[notifysendlog.FieldError] = struct{}{} } -// SetUpdatedAt sets the "updated_at" field. -func (m *NotifySubscriptionMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t +// ErrorCleared returns if the "error" field was cleared in this mutation. +func (m *NotifySendLogMutation) ErrorCleared() bool { + _, ok := m.clearedFields[notifysendlog.FieldError] + return ok } -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *NotifySubscriptionMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at +// ResetError resets all changes to the "error" field. +func (m *NotifySendLogMutation) ResetError() { + m.error = nil + delete(m.clearedFields, notifysendlog.FieldError) +} + +// SetCreatedAt sets the "created_at" field. +func (m *NotifySendLogMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *NotifySendLogMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldUpdatedAt returns the old "updated_at" field's value of the NotifySubscription entity. -// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the NotifySendLog entity. +// If the NotifySendLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotifySubscriptionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { +func (m *NotifySendLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *NotifySubscriptionMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// ClearChannel clears the "channel" edge to the NotifyChannel entity. -func (m *NotifySubscriptionMutation) ClearChannel() { - m.clearedchannel = true - m.clearedFields[notifysubscription.FieldChannelID] = struct{}{} -} - -// ChannelCleared reports if the "channel" edge to the NotifyChannel entity was cleared. -func (m *NotifySubscriptionMutation) ChannelCleared() bool { - return m.clearedchannel -} - -// ChannelIDs returns the "channel" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ChannelID instead. It exists only for internal usage by the builders. -func (m *NotifySubscriptionMutation) ChannelIDs() (ids []uuid.UUID) { - if id := m.channel; id != nil { - ids = append(ids, *id) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return + return oldValue.CreatedAt, nil } -// ResetChannel resets all changes to the "channel" edge. -func (m *NotifySubscriptionMutation) ResetChannel() { - m.channel = nil - m.clearedchannel = false +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *NotifySendLogMutation) ResetCreatedAt() { + m.created_at = nil } -// Where appends a list predicates to the NotifySubscriptionMutation builder. -func (m *NotifySubscriptionMutation) Where(ps ...predicate.NotifySubscription) { +// Where appends a list predicates to the NotifySendLogMutation builder. +func (m *NotifySendLogMutation) Where(ps ...predicate.NotifySendLog) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the NotifySubscriptionMutation builder. Using this method, +// WhereP appends storage-level predicates to the NotifySendLogMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *NotifySubscriptionMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.NotifySubscription, len(ps)) +func (m *NotifySendLogMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.NotifySendLog, len(ps)) for i := range ps { p[i] = ps[i] } @@ -18742,45 +27688,45 @@ func (m *NotifySubscriptionMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *NotifySubscriptionMutation) Op() Op { +func (m *NotifySendLogMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *NotifySubscriptionMutation) SetOp(op Op) { +func (m *NotifySendLogMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (NotifySubscription). -func (m *NotifySubscriptionMutation) Type() string { +// Type returns the node type of this mutation (NotifySendLog). +func (m *NotifySendLogMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *NotifySubscriptionMutation) Fields() []string { +func (m *NotifySendLogMutation) Fields() []string { fields := make([]string, 0, 7) - if m.deleted_at != nil { - fields = append(fields, notifysubscription.FieldDeletedAt) + if m.subscription_id != nil { + fields = append(fields, notifysendlog.FieldSubscriptionID) } - if m.channel != nil { - fields = append(fields, notifysubscription.FieldChannelID) + if m.channel_id != nil { + fields = append(fields, notifysendlog.FieldChannelID) } - if m.scope != nil { - fields = append(fields, notifysubscription.FieldScope) + if m.event_type != nil { + fields = append(fields, notifysendlog.FieldEventType) } - if m.event_types != nil { - fields = append(fields, notifysubscription.FieldEventTypes) + if m.event_ref_id != nil { + fields = append(fields, notifysendlog.FieldEventRefID) } - if m.enabled != nil { - fields = append(fields, notifysubscription.FieldEnabled) + if m.status != nil { + fields = append(fields, notifysendlog.FieldStatus) } - if m.created_at != nil { - fields = append(fields, notifysubscription.FieldCreatedAt) + if m.error != nil { + fields = append(fields, notifysendlog.FieldError) } - if m.updated_at != nil { - fields = append(fields, notifysubscription.FieldUpdatedAt) + if m.created_at != nil { + fields = append(fields, notifysendlog.FieldCreatedAt) } return fields } @@ -18788,22 +27734,22 @@ func (m *NotifySubscriptionMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *NotifySubscriptionMutation) Field(name string) (ent.Value, bool) { +func (m *NotifySendLogMutation) Field(name string) (ent.Value, bool) { switch name { - case notifysubscription.FieldDeletedAt: - return m.DeletedAt() - case notifysubscription.FieldChannelID: + case notifysendlog.FieldSubscriptionID: + return m.SubscriptionID() + case notifysendlog.FieldChannelID: return m.ChannelID() - case notifysubscription.FieldScope: - return m.Scope() - case notifysubscription.FieldEventTypes: - return m.EventTypes() - case notifysubscription.FieldEnabled: - return m.Enabled() - case notifysubscription.FieldCreatedAt: + case notifysendlog.FieldEventType: + return m.EventType() + case notifysendlog.FieldEventRefID: + return m.EventRefID() + case notifysendlog.FieldStatus: + return m.Status() + case notifysendlog.FieldError: + return m.Error() + case notifysendlog.FieldCreatedAt: return m.CreatedAt() - case notifysubscription.FieldUpdatedAt: - return m.UpdatedAt() } return nil, false } @@ -18811,290 +27757,243 @@ func (m *NotifySubscriptionMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *NotifySubscriptionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *NotifySendLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case notifysubscription.FieldDeletedAt: - return m.OldDeletedAt(ctx) - case notifysubscription.FieldChannelID: + case notifysendlog.FieldSubscriptionID: + return m.OldSubscriptionID(ctx) + case notifysendlog.FieldChannelID: return m.OldChannelID(ctx) - case notifysubscription.FieldScope: - return m.OldScope(ctx) - case notifysubscription.FieldEventTypes: - return m.OldEventTypes(ctx) - case notifysubscription.FieldEnabled: - return m.OldEnabled(ctx) - case notifysubscription.FieldCreatedAt: + case notifysendlog.FieldEventType: + return m.OldEventType(ctx) + case notifysendlog.FieldEventRefID: + return m.OldEventRefID(ctx) + case notifysendlog.FieldStatus: + return m.OldStatus(ctx) + case notifysendlog.FieldError: + return m.OldError(ctx) + case notifysendlog.FieldCreatedAt: return m.OldCreatedAt(ctx) - case notifysubscription.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown NotifySubscription field %s", name) + return nil, fmt.Errorf("unknown NotifySendLog field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *NotifySubscriptionMutation) SetField(name string, value ent.Value) error { +func (m *NotifySendLogMutation) SetField(name string, value ent.Value) error { switch name { - case notifysubscription.FieldDeletedAt: - v, ok := value.(time.Time) + case notifysendlog.FieldSubscriptionID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDeletedAt(v) + m.SetSubscriptionID(v) return nil - case notifysubscription.FieldChannelID: + case notifysendlog.FieldChannelID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetChannelID(v) return nil - case notifysubscription.FieldScope: - v, ok := value.(string) + case notifysendlog.FieldEventType: + v, ok := value.(consts.NotifyEventType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetScope(v) + m.SetEventType(v) return nil - case notifysubscription.FieldEventTypes: - v, ok := value.([]consts.NotifyEventType) + case notifysendlog.FieldEventRefID: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetEventTypes(v) + m.SetEventRefID(v) return nil - case notifysubscription.FieldEnabled: - v, ok := value.(bool) + case notifysendlog.FieldStatus: + v, ok := value.(consts.NotifySendStatus) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetEnabled(v) + m.SetStatus(v) return nil - case notifysubscription.FieldCreatedAt: - v, ok := value.(time.Time) + case notifysendlog.FieldError: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreatedAt(v) + m.SetError(v) return nil - case notifysubscription.FieldUpdatedAt: + case notifysendlog.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUpdatedAt(v) + m.SetCreatedAt(v) return nil } - return fmt.Errorf("unknown NotifySubscription field %s", name) + return fmt.Errorf("unknown NotifySendLog field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *NotifySubscriptionMutation) AddedFields() []string { +func (m *NotifySendLogMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *NotifySubscriptionMutation) AddedField(name string) (ent.Value, bool) { +func (m *NotifySendLogMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *NotifySubscriptionMutation) AddField(name string, value ent.Value) error { +func (m *NotifySendLogMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown NotifySubscription numeric field %s", name) + return fmt.Errorf("unknown NotifySendLog numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *NotifySubscriptionMutation) ClearedFields() []string { +func (m *NotifySendLogMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(notifysubscription.FieldDeletedAt) { - fields = append(fields, notifysubscription.FieldDeletedAt) + if m.FieldCleared(notifysendlog.FieldError) { + fields = append(fields, notifysendlog.FieldError) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *NotifySubscriptionMutation) FieldCleared(name string) bool { +func (m *NotifySendLogMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *NotifySubscriptionMutation) ClearField(name string) error { +func (m *NotifySendLogMutation) ClearField(name string) error { switch name { - case notifysubscription.FieldDeletedAt: - m.ClearDeletedAt() + case notifysendlog.FieldError: + m.ClearError() return nil } - return fmt.Errorf("unknown NotifySubscription nullable field %s", name) + return fmt.Errorf("unknown NotifySendLog nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *NotifySubscriptionMutation) ResetField(name string) error { +func (m *NotifySendLogMutation) ResetField(name string) error { switch name { - case notifysubscription.FieldDeletedAt: - m.ResetDeletedAt() + case notifysendlog.FieldSubscriptionID: + m.ResetSubscriptionID() return nil - case notifysubscription.FieldChannelID: + case notifysendlog.FieldChannelID: m.ResetChannelID() return nil - case notifysubscription.FieldScope: - m.ResetScope() + case notifysendlog.FieldEventType: + m.ResetEventType() return nil - case notifysubscription.FieldEventTypes: - m.ResetEventTypes() + case notifysendlog.FieldEventRefID: + m.ResetEventRefID() return nil - case notifysubscription.FieldEnabled: - m.ResetEnabled() + case notifysendlog.FieldStatus: + m.ResetStatus() return nil - case notifysubscription.FieldCreatedAt: - m.ResetCreatedAt() + case notifysendlog.FieldError: + m.ResetError() return nil - case notifysubscription.FieldUpdatedAt: - m.ResetUpdatedAt() + case notifysendlog.FieldCreatedAt: + m.ResetCreatedAt() return nil } - return fmt.Errorf("unknown NotifySubscription field %s", name) + return fmt.Errorf("unknown NotifySendLog field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *NotifySubscriptionMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.channel != nil { - edges = append(edges, notifysubscription.EdgeChannel) - } +func (m *NotifySendLogMutation) AddedEdges() []string { + edges := make([]string, 0, 0) return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *NotifySubscriptionMutation) AddedIDs(name string) []ent.Value { - switch name { - case notifysubscription.EdgeChannel: - if id := m.channel; id != nil { - return []ent.Value{*id} - } - } +func (m *NotifySendLogMutation) AddedIDs(name string) []ent.Value { return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *NotifySubscriptionMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) +func (m *NotifySendLogMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *NotifySubscriptionMutation) RemovedIDs(name string) []ent.Value { +func (m *NotifySendLogMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *NotifySubscriptionMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedchannel { - edges = append(edges, notifysubscription.EdgeChannel) - } +func (m *NotifySendLogMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *NotifySubscriptionMutation) EdgeCleared(name string) bool { - switch name { - case notifysubscription.EdgeChannel: - return m.clearedchannel - } +func (m *NotifySendLogMutation) EdgeCleared(name string) bool { return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *NotifySubscriptionMutation) ClearEdge(name string) error { - switch name { - case notifysubscription.EdgeChannel: - m.ClearChannel() - return nil - } - return fmt.Errorf("unknown NotifySubscription unique edge %s", name) +func (m *NotifySendLogMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown NotifySendLog unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *NotifySubscriptionMutation) ResetEdge(name string) error { - switch name { - case notifysubscription.EdgeChannel: - m.ResetChannel() - return nil - } - return fmt.Errorf("unknown NotifySubscription edge %s", name) +func (m *NotifySendLogMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown NotifySendLog edge %s", name) } -// ProjectMutation represents an operation that mutates the Project nodes in the graph. -type ProjectMutation struct { +// NotifySubscriptionMutation represents an operation that mutates the NotifySubscription nodes in the graph. +type NotifySubscriptionMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - name *string - description *string - platform *consts.GitPlatform - repo_url *string - branch *string - env_variables *map[string]interface{} - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - user *uuid.UUID - cleareduser bool - git_identity *uuid.UUID - clearedgit_identity bool - image *uuid.UUID - clearedimage bool - issues map[uuid.UUID]struct{} - removedissues map[uuid.UUID]struct{} - clearedissues bool - collaborators map[uuid.UUID]struct{} - removedcollaborators map[uuid.UUID]struct{} - clearedcollaborators bool - project_tasks map[uuid.UUID]struct{} - removedproject_tasks map[uuid.UUID]struct{} - clearedproject_tasks bool - git_bots map[uuid.UUID]struct{} - removedgit_bots map[uuid.UUID]struct{} - clearedgit_bots bool - project_git_bots map[uuid.UUID]struct{} - removedproject_git_bots map[uuid.UUID]struct{} - clearedproject_git_bots bool - done bool - oldValue func(context.Context) (*Project, error) - predicates []predicate.Project + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + scope *string + event_types *[]consts.NotifyEventType + appendevent_types []consts.NotifyEventType + enabled *bool + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + channel *uuid.UUID + clearedchannel bool + done bool + oldValue func(context.Context) (*NotifySubscription, error) + predicates []predicate.NotifySubscription } -var _ ent.Mutation = (*ProjectMutation)(nil) +var _ ent.Mutation = (*NotifySubscriptionMutation)(nil) -// projectOption allows management of the mutation configuration using functional options. -type projectOption func(*ProjectMutation) +// notifysubscriptionOption allows management of the mutation configuration using functional options. +type notifysubscriptionOption func(*NotifySubscriptionMutation) -// newProjectMutation creates new mutation for the Project entity. -func newProjectMutation(c config, op Op, opts ...projectOption) *ProjectMutation { - m := &ProjectMutation{ +// newNotifySubscriptionMutation creates new mutation for the NotifySubscription entity. +func newNotifySubscriptionMutation(c config, op Op, opts ...notifysubscriptionOption) *NotifySubscriptionMutation { + m := &NotifySubscriptionMutation{ config: c, op: op, - typ: TypeProject, + typ: TypeNotifySubscription, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -19103,20 +28002,20 @@ func newProjectMutation(c config, op Op, opts ...projectOption) *ProjectMutation return m } -// withProjectID sets the ID field of the mutation. -func withProjectID(id uuid.UUID) projectOption { - return func(m *ProjectMutation) { +// withNotifySubscriptionID sets the ID field of the mutation. +func withNotifySubscriptionID(id uuid.UUID) notifysubscriptionOption { + return func(m *NotifySubscriptionMutation) { var ( err error once sync.Once - value *Project + value *NotifySubscription ) - m.oldValue = func(ctx context.Context) (*Project, error) { + m.oldValue = func(ctx context.Context) (*NotifySubscription, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Project.Get(ctx, id) + value, err = m.Client().NotifySubscription.Get(ctx, id) } }) return value, err @@ -19125,10 +28024,10 @@ func withProjectID(id uuid.UUID) projectOption { } } -// withProject sets the old Project of the mutation. -func withProject(node *Project) projectOption { - return func(m *ProjectMutation) { - m.oldValue = func(context.Context) (*Project, error) { +// withNotifySubscription sets the old NotifySubscription of the mutation. +func withNotifySubscription(node *NotifySubscription) notifysubscriptionOption { + return func(m *NotifySubscriptionMutation) { + m.oldValue = func(context.Context) (*NotifySubscription, error) { return node, nil } m.id = &node.ID @@ -19137,7 +28036,7 @@ func withProject(node *Project) projectOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ProjectMutation) Client() *Client { +func (m NotifySubscriptionMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -19145,7 +28044,7 @@ func (m ProjectMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ProjectMutation) Tx() (*Tx, error) { +func (m NotifySubscriptionMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -19155,14 +28054,14 @@ func (m ProjectMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Project entities. -func (m *ProjectMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of NotifySubscription entities. +func (m *NotifySubscriptionMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ProjectMutation) ID() (id uuid.UUID, exists bool) { +func (m *NotifySubscriptionMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -19173,7 +28072,7 @@ func (m *ProjectMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ProjectMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *NotifySubscriptionMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -19182,19 +28081,19 @@ func (m *ProjectMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Project.Query().Where(m.predicates...).IDs(ctx) + return m.Client().NotifySubscription.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetDeletedAt sets the "deleted_at" field. -func (m *ProjectMutation) SetDeletedAt(t time.Time) { +func (m *NotifySubscriptionMutation) SetDeletedAt(t time.Time) { m.deleted_at = &t } // DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *ProjectMutation) DeletedAt() (r time.Time, exists bool) { +func (m *NotifySubscriptionMutation) DeletedAt() (r time.Time, exists bool) { v := m.deleted_at if v == nil { return @@ -19202,10 +28101,10 @@ func (m *ProjectMutation) DeletedAt() (r time.Time, exists bool) { return *v, true } -// OldDeletedAt returns the old "deleted_at" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldDeletedAt returns the old "deleted_at" field's value of the NotifySubscription entity. +// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { +func (m *NotifySubscriptionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } @@ -19220,445 +28119,189 @@ func (m *ProjectMutation) OldDeletedAt(ctx context.Context) (v time.Time, err er } // ClearDeletedAt clears the value of the "deleted_at" field. -func (m *ProjectMutation) ClearDeletedAt() { +func (m *NotifySubscriptionMutation) ClearDeletedAt() { m.deleted_at = nil - m.clearedFields[project.FieldDeletedAt] = struct{}{} + m.clearedFields[notifysubscription.FieldDeletedAt] = struct{}{} } // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *ProjectMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[project.FieldDeletedAt] +func (m *NotifySubscriptionMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[notifysubscription.FieldDeletedAt] return ok } // ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *ProjectMutation) ResetDeletedAt() { +func (m *NotifySubscriptionMutation) ResetDeletedAt() { m.deleted_at = nil - delete(m.clearedFields, project.FieldDeletedAt) -} - -// SetUserID sets the "user_id" field. -func (m *ProjectMutation) SetUserID(u uuid.UUID) { - m.user = &u -} - -// UserID returns the value of the "user_id" field in the mutation. -func (m *ProjectMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user - if v == nil { - return - } - return *v, true -} - -// OldUserID returns the old "user_id" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) - } - return oldValue.UserID, nil -} - -// ResetUserID resets all changes to the "user_id" field. -func (m *ProjectMutation) ResetUserID() { - m.user = nil -} - -// SetName sets the "name" field. -func (m *ProjectMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *ProjectMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *ProjectMutation) ResetName() { - m.name = nil -} - -// SetDescription sets the "description" field. -func (m *ProjectMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *ProjectMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true -} - -// OldDescription returns the old "description" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ClearDescription clears the value of the "description" field. -func (m *ProjectMutation) ClearDescription() { - m.description = nil - m.clearedFields[project.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *ProjectMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[project.FieldDescription] - return ok -} - -// ResetDescription resets all changes to the "description" field. -func (m *ProjectMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, project.FieldDescription) -} - -// SetPlatform sets the "platform" field. -func (m *ProjectMutation) SetPlatform(cp consts.GitPlatform) { - m.platform = &cp -} - -// Platform returns the value of the "platform" field in the mutation. -func (m *ProjectMutation) Platform() (r consts.GitPlatform, exists bool) { - v := m.platform - if v == nil { - return - } - return *v, true -} - -// OldPlatform returns the old "platform" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldPlatform(ctx context.Context) (v consts.GitPlatform, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPlatform is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPlatform requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPlatform: %w", err) - } - return oldValue.Platform, nil -} - -// ClearPlatform clears the value of the "platform" field. -func (m *ProjectMutation) ClearPlatform() { - m.platform = nil - m.clearedFields[project.FieldPlatform] = struct{}{} -} - -// PlatformCleared returns if the "platform" field was cleared in this mutation. -func (m *ProjectMutation) PlatformCleared() bool { - _, ok := m.clearedFields[project.FieldPlatform] - return ok -} - -// ResetPlatform resets all changes to the "platform" field. -func (m *ProjectMutation) ResetPlatform() { - m.platform = nil - delete(m.clearedFields, project.FieldPlatform) -} - -// SetRepoURL sets the "repo_url" field. -func (m *ProjectMutation) SetRepoURL(s string) { - m.repo_url = &s -} - -// RepoURL returns the value of the "repo_url" field in the mutation. -func (m *ProjectMutation) RepoURL() (r string, exists bool) { - v := m.repo_url - if v == nil { - return - } - return *v, true -} - -// OldRepoURL returns the old "repo_url" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldRepoURL(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRepoURL is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRepoURL requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRepoURL: %w", err) - } - return oldValue.RepoURL, nil -} - -// ClearRepoURL clears the value of the "repo_url" field. -func (m *ProjectMutation) ClearRepoURL() { - m.repo_url = nil - m.clearedFields[project.FieldRepoURL] = struct{}{} -} - -// RepoURLCleared returns if the "repo_url" field was cleared in this mutation. -func (m *ProjectMutation) RepoURLCleared() bool { - _, ok := m.clearedFields[project.FieldRepoURL] - return ok -} - -// ResetRepoURL resets all changes to the "repo_url" field. -func (m *ProjectMutation) ResetRepoURL() { - m.repo_url = nil - delete(m.clearedFields, project.FieldRepoURL) + delete(m.clearedFields, notifysubscription.FieldDeletedAt) } -// SetBranch sets the "branch" field. -func (m *ProjectMutation) SetBranch(s string) { - m.branch = &s +// SetChannelID sets the "channel_id" field. +func (m *NotifySubscriptionMutation) SetChannelID(u uuid.UUID) { + m.channel = &u } -// Branch returns the value of the "branch" field in the mutation. -func (m *ProjectMutation) Branch() (r string, exists bool) { - v := m.branch +// ChannelID returns the value of the "channel_id" field in the mutation. +func (m *NotifySubscriptionMutation) ChannelID() (r uuid.UUID, exists bool) { + v := m.channel if v == nil { return } return *v, true } -// OldBranch returns the old "branch" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldChannelID returns the old "channel_id" field's value of the NotifySubscription entity. +// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldBranch(ctx context.Context) (v string, err error) { +func (m *NotifySubscriptionMutation) OldChannelID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBranch is only allowed on UpdateOne operations") + return v, errors.New("OldChannelID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBranch requires an ID field in the mutation") + return v, errors.New("OldChannelID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBranch: %w", err) + return v, fmt.Errorf("querying old value for OldChannelID: %w", err) } - return oldValue.Branch, nil -} - -// ClearBranch clears the value of the "branch" field. -func (m *ProjectMutation) ClearBranch() { - m.branch = nil - m.clearedFields[project.FieldBranch] = struct{}{} -} - -// BranchCleared returns if the "branch" field was cleared in this mutation. -func (m *ProjectMutation) BranchCleared() bool { - _, ok := m.clearedFields[project.FieldBranch] - return ok + return oldValue.ChannelID, nil } -// ResetBranch resets all changes to the "branch" field. -func (m *ProjectMutation) ResetBranch() { - m.branch = nil - delete(m.clearedFields, project.FieldBranch) +// ResetChannelID resets all changes to the "channel_id" field. +func (m *NotifySubscriptionMutation) ResetChannelID() { + m.channel = nil } -// SetGitIdentityID sets the "git_identity_id" field. -func (m *ProjectMutation) SetGitIdentityID(u uuid.UUID) { - m.git_identity = &u +// SetScope sets the "scope" field. +func (m *NotifySubscriptionMutation) SetScope(s string) { + m.scope = &s } -// GitIdentityID returns the value of the "git_identity_id" field in the mutation. -func (m *ProjectMutation) GitIdentityID() (r uuid.UUID, exists bool) { - v := m.git_identity +// Scope returns the value of the "scope" field in the mutation. +func (m *NotifySubscriptionMutation) Scope() (r string, exists bool) { + v := m.scope if v == nil { return } return *v, true } -// OldGitIdentityID returns the old "git_identity_id" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldScope returns the old "scope" field's value of the NotifySubscription entity. +// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldGitIdentityID(ctx context.Context) (v uuid.UUID, err error) { +func (m *NotifySubscriptionMutation) OldScope(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldGitIdentityID is only allowed on UpdateOne operations") + return v, errors.New("OldScope is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldGitIdentityID requires an ID field in the mutation") + return v, errors.New("OldScope requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldGitIdentityID: %w", err) + return v, fmt.Errorf("querying old value for OldScope: %w", err) } - return oldValue.GitIdentityID, nil -} - -// ClearGitIdentityID clears the value of the "git_identity_id" field. -func (m *ProjectMutation) ClearGitIdentityID() { - m.git_identity = nil - m.clearedFields[project.FieldGitIdentityID] = struct{}{} -} - -// GitIdentityIDCleared returns if the "git_identity_id" field was cleared in this mutation. -func (m *ProjectMutation) GitIdentityIDCleared() bool { - _, ok := m.clearedFields[project.FieldGitIdentityID] - return ok + return oldValue.Scope, nil } -// ResetGitIdentityID resets all changes to the "git_identity_id" field. -func (m *ProjectMutation) ResetGitIdentityID() { - m.git_identity = nil - delete(m.clearedFields, project.FieldGitIdentityID) +// ResetScope resets all changes to the "scope" field. +func (m *NotifySubscriptionMutation) ResetScope() { + m.scope = nil } -// SetImageID sets the "image_id" field. -func (m *ProjectMutation) SetImageID(u uuid.UUID) { - m.image = &u +// SetEventTypes sets the "event_types" field. +func (m *NotifySubscriptionMutation) SetEventTypes(cet []consts.NotifyEventType) { + m.event_types = &cet + m.appendevent_types = nil } -// ImageID returns the value of the "image_id" field in the mutation. -func (m *ProjectMutation) ImageID() (r uuid.UUID, exists bool) { - v := m.image +// EventTypes returns the value of the "event_types" field in the mutation. +func (m *NotifySubscriptionMutation) EventTypes() (r []consts.NotifyEventType, exists bool) { + v := m.event_types if v == nil { return } return *v, true } -// OldImageID returns the old "image_id" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldEventTypes returns the old "event_types" field's value of the NotifySubscription entity. +// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldImageID(ctx context.Context) (v uuid.UUID, err error) { +func (m *NotifySubscriptionMutation) OldEventTypes(ctx context.Context) (v []consts.NotifyEventType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldImageID is only allowed on UpdateOne operations") + return v, errors.New("OldEventTypes is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldImageID requires an ID field in the mutation") + return v, errors.New("OldEventTypes requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldImageID: %w", err) + return v, fmt.Errorf("querying old value for OldEventTypes: %w", err) } - return oldValue.ImageID, nil + return oldValue.EventTypes, nil } -// ClearImageID clears the value of the "image_id" field. -func (m *ProjectMutation) ClearImageID() { - m.image = nil - m.clearedFields[project.FieldImageID] = struct{}{} +// AppendEventTypes adds cet to the "event_types" field. +func (m *NotifySubscriptionMutation) AppendEventTypes(cet []consts.NotifyEventType) { + m.appendevent_types = append(m.appendevent_types, cet...) } -// ImageIDCleared returns if the "image_id" field was cleared in this mutation. -func (m *ProjectMutation) ImageIDCleared() bool { - _, ok := m.clearedFields[project.FieldImageID] - return ok +// AppendedEventTypes returns the list of values that were appended to the "event_types" field in this mutation. +func (m *NotifySubscriptionMutation) AppendedEventTypes() ([]consts.NotifyEventType, bool) { + if len(m.appendevent_types) == 0 { + return nil, false + } + return m.appendevent_types, true } -// ResetImageID resets all changes to the "image_id" field. -func (m *ProjectMutation) ResetImageID() { - m.image = nil - delete(m.clearedFields, project.FieldImageID) +// ResetEventTypes resets all changes to the "event_types" field. +func (m *NotifySubscriptionMutation) ResetEventTypes() { + m.event_types = nil + m.appendevent_types = nil } -// SetEnvVariables sets the "env_variables" field. -func (m *ProjectMutation) SetEnvVariables(value map[string]interface{}) { - m.env_variables = &value +// SetEnabled sets the "enabled" field. +func (m *NotifySubscriptionMutation) SetEnabled(b bool) { + m.enabled = &b } -// EnvVariables returns the value of the "env_variables" field in the mutation. -func (m *ProjectMutation) EnvVariables() (r map[string]interface{}, exists bool) { - v := m.env_variables +// Enabled returns the value of the "enabled" field in the mutation. +func (m *NotifySubscriptionMutation) Enabled() (r bool, exists bool) { + v := m.enabled if v == nil { return } return *v, true } -// OldEnvVariables returns the old "env_variables" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldEnabled returns the old "enabled" field's value of the NotifySubscription entity. +// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldEnvVariables(ctx context.Context) (v map[string]interface{}, err error) { +func (m *NotifySubscriptionMutation) OldEnabled(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEnvVariables is only allowed on UpdateOne operations") + return v, errors.New("OldEnabled is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEnvVariables requires an ID field in the mutation") + return v, errors.New("OldEnabled requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEnvVariables: %w", err) + return v, fmt.Errorf("querying old value for OldEnabled: %w", err) } - return oldValue.EnvVariables, nil -} - -// ClearEnvVariables clears the value of the "env_variables" field. -func (m *ProjectMutation) ClearEnvVariables() { - m.env_variables = nil - m.clearedFields[project.FieldEnvVariables] = struct{}{} -} - -// EnvVariablesCleared returns if the "env_variables" field was cleared in this mutation. -func (m *ProjectMutation) EnvVariablesCleared() bool { - _, ok := m.clearedFields[project.FieldEnvVariables] - return ok + return oldValue.Enabled, nil } -// ResetEnvVariables resets all changes to the "env_variables" field. -func (m *ProjectMutation) ResetEnvVariables() { - m.env_variables = nil - delete(m.clearedFields, project.FieldEnvVariables) +// ResetEnabled resets all changes to the "enabled" field. +func (m *NotifySubscriptionMutation) ResetEnabled() { + m.enabled = nil } // SetCreatedAt sets the "created_at" field. -func (m *ProjectMutation) SetCreatedAt(t time.Time) { +func (m *NotifySubscriptionMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ProjectMutation) CreatedAt() (r time.Time, exists bool) { +func (m *NotifySubscriptionMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -19666,10 +28309,10 @@ func (m *ProjectMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the NotifySubscription entity. +// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *NotifySubscriptionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -19684,17 +28327,17 @@ func (m *ProjectMutation) OldCreatedAt(ctx context.Context) (v time.Time, err er } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *ProjectMutation) ResetCreatedAt() { +func (m *NotifySubscriptionMutation) ResetCreatedAt() { m.created_at = nil } // SetUpdatedAt sets the "updated_at" field. -func (m *ProjectMutation) SetUpdatedAt(t time.Time) { +func (m *NotifySubscriptionMutation) SetUpdatedAt(t time.Time) { m.updated_at = &t } // UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *ProjectMutation) UpdatedAt() (r time.Time, exists bool) { +func (m *NotifySubscriptionMutation) UpdatedAt() (r time.Time, exists bool) { v := m.updated_at if v == nil { return @@ -19702,10 +28345,10 @@ func (m *ProjectMutation) UpdatedAt() (r time.Time, exists bool) { return *v, true } -// OldUpdatedAt returns the old "updated_at" field's value of the Project entity. -// If the Project object wasn't provided to the builder, the object is fetched from the database. +// OldUpdatedAt returns the old "updated_at" field's value of the NotifySubscription entity. +// If the NotifySubscription object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { +func (m *NotifySubscriptionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } @@ -19713,377 +28356,53 @@ func (m *ProjectMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err er return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *ProjectMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// ClearUser clears the "user" edge to the User entity. -func (m *ProjectMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[project.FieldUserID] = struct{}{} -} - -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *ProjectMutation) UserCleared() bool { - return m.cleareduser -} - -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *ProjectMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetUser resets all changes to the "user" edge. -func (m *ProjectMutation) ResetUser() { - m.user = nil - m.cleareduser = false -} - -// ClearGitIdentity clears the "git_identity" edge to the GitIdentity entity. -func (m *ProjectMutation) ClearGitIdentity() { - m.clearedgit_identity = true - m.clearedFields[project.FieldGitIdentityID] = struct{}{} -} - -// GitIdentityCleared reports if the "git_identity" edge to the GitIdentity entity was cleared. -func (m *ProjectMutation) GitIdentityCleared() bool { - return m.GitIdentityIDCleared() || m.clearedgit_identity -} - -// GitIdentityIDs returns the "git_identity" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// GitIdentityID instead. It exists only for internal usage by the builders. -func (m *ProjectMutation) GitIdentityIDs() (ids []uuid.UUID) { - if id := m.git_identity; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetGitIdentity resets all changes to the "git_identity" edge. -func (m *ProjectMutation) ResetGitIdentity() { - m.git_identity = nil - m.clearedgit_identity = false -} - -// ClearImage clears the "image" edge to the Image entity. -func (m *ProjectMutation) ClearImage() { - m.clearedimage = true - m.clearedFields[project.FieldImageID] = struct{}{} -} - -// ImageCleared reports if the "image" edge to the Image entity was cleared. -func (m *ProjectMutation) ImageCleared() bool { - return m.ImageIDCleared() || m.clearedimage -} - -// ImageIDs returns the "image" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ImageID instead. It exists only for internal usage by the builders. -func (m *ProjectMutation) ImageIDs() (ids []uuid.UUID) { - if id := m.image; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetImage resets all changes to the "image" edge. -func (m *ProjectMutation) ResetImage() { - m.image = nil - m.clearedimage = false -} - -// AddIssueIDs adds the "issues" edge to the ProjectIssue entity by ids. -func (m *ProjectMutation) AddIssueIDs(ids ...uuid.UUID) { - if m.issues == nil { - m.issues = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.issues[ids[i]] = struct{}{} - } -} - -// ClearIssues clears the "issues" edge to the ProjectIssue entity. -func (m *ProjectMutation) ClearIssues() { - m.clearedissues = true -} - -// IssuesCleared reports if the "issues" edge to the ProjectIssue entity was cleared. -func (m *ProjectMutation) IssuesCleared() bool { - return m.clearedissues -} - -// RemoveIssueIDs removes the "issues" edge to the ProjectIssue entity by IDs. -func (m *ProjectMutation) RemoveIssueIDs(ids ...uuid.UUID) { - if m.removedissues == nil { - m.removedissues = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.issues, ids[i]) - m.removedissues[ids[i]] = struct{}{} - } -} - -// RemovedIssues returns the removed IDs of the "issues" edge to the ProjectIssue entity. -func (m *ProjectMutation) RemovedIssuesIDs() (ids []uuid.UUID) { - for id := range m.removedissues { - ids = append(ids, id) - } - return -} - -// IssuesIDs returns the "issues" edge IDs in the mutation. -func (m *ProjectMutation) IssuesIDs() (ids []uuid.UUID) { - for id := range m.issues { - ids = append(ids, id) - } - return -} - -// ResetIssues resets all changes to the "issues" edge. -func (m *ProjectMutation) ResetIssues() { - m.issues = nil - m.clearedissues = false - m.removedissues = nil -} - -// AddCollaboratorIDs adds the "collaborators" edge to the ProjectCollaborator entity by ids. -func (m *ProjectMutation) AddCollaboratorIDs(ids ...uuid.UUID) { - if m.collaborators == nil { - m.collaborators = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.collaborators[ids[i]] = struct{}{} - } -} - -// ClearCollaborators clears the "collaborators" edge to the ProjectCollaborator entity. -func (m *ProjectMutation) ClearCollaborators() { - m.clearedcollaborators = true -} - -// CollaboratorsCleared reports if the "collaborators" edge to the ProjectCollaborator entity was cleared. -func (m *ProjectMutation) CollaboratorsCleared() bool { - return m.clearedcollaborators -} - -// RemoveCollaboratorIDs removes the "collaborators" edge to the ProjectCollaborator entity by IDs. -func (m *ProjectMutation) RemoveCollaboratorIDs(ids ...uuid.UUID) { - if m.removedcollaborators == nil { - m.removedcollaborators = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.collaborators, ids[i]) - m.removedcollaborators[ids[i]] = struct{}{} - } -} - -// RemovedCollaborators returns the removed IDs of the "collaborators" edge to the ProjectCollaborator entity. -func (m *ProjectMutation) RemovedCollaboratorsIDs() (ids []uuid.UUID) { - for id := range m.removedcollaborators { - ids = append(ids, id) - } - return -} - -// CollaboratorsIDs returns the "collaborators" edge IDs in the mutation. -func (m *ProjectMutation) CollaboratorsIDs() (ids []uuid.UUID) { - for id := range m.collaborators { - ids = append(ids, id) - } - return -} - -// ResetCollaborators resets all changes to the "collaborators" edge. -func (m *ProjectMutation) ResetCollaborators() { - m.collaborators = nil - m.clearedcollaborators = false - m.removedcollaborators = nil -} - -// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids. -func (m *ProjectMutation) AddProjectTaskIDs(ids ...uuid.UUID) { - if m.project_tasks == nil { - m.project_tasks = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.project_tasks[ids[i]] = struct{}{} - } -} - -// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity. -func (m *ProjectMutation) ClearProjectTasks() { - m.clearedproject_tasks = true -} - -// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared. -func (m *ProjectMutation) ProjectTasksCleared() bool { - return m.clearedproject_tasks -} - -// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs. -func (m *ProjectMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) { - if m.removedproject_tasks == nil { - m.removedproject_tasks = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.project_tasks, ids[i]) - m.removedproject_tasks[ids[i]] = struct{}{} - } -} - -// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity. -func (m *ProjectMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) { - for id := range m.removedproject_tasks { - ids = append(ids, id) - } - return -} - -// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation. -func (m *ProjectMutation) ProjectTasksIDs() (ids []uuid.UUID) { - for id := range m.project_tasks { - ids = append(ids, id) - } - return -} - -// ResetProjectTasks resets all changes to the "project_tasks" edge. -func (m *ProjectMutation) ResetProjectTasks() { - m.project_tasks = nil - m.clearedproject_tasks = false - m.removedproject_tasks = nil -} - -// AddGitBotIDs adds the "git_bots" edge to the GitBot entity by ids. -func (m *ProjectMutation) AddGitBotIDs(ids ...uuid.UUID) { - if m.git_bots == nil { - m.git_bots = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.git_bots[ids[i]] = struct{}{} - } -} - -// ClearGitBots clears the "git_bots" edge to the GitBot entity. -func (m *ProjectMutation) ClearGitBots() { - m.clearedgit_bots = true -} - -// GitBotsCleared reports if the "git_bots" edge to the GitBot entity was cleared. -func (m *ProjectMutation) GitBotsCleared() bool { - return m.clearedgit_bots -} - -// RemoveGitBotIDs removes the "git_bots" edge to the GitBot entity by IDs. -func (m *ProjectMutation) RemoveGitBotIDs(ids ...uuid.UUID) { - if m.removedgit_bots == nil { - m.removedgit_bots = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.git_bots, ids[i]) - m.removedgit_bots[ids[i]] = struct{}{} - } -} - -// RemovedGitBots returns the removed IDs of the "git_bots" edge to the GitBot entity. -func (m *ProjectMutation) RemovedGitBotsIDs() (ids []uuid.UUID) { - for id := range m.removedgit_bots { - ids = append(ids, id) - } - return -} - -// GitBotsIDs returns the "git_bots" edge IDs in the mutation. -func (m *ProjectMutation) GitBotsIDs() (ids []uuid.UUID) { - for id := range m.git_bots { - ids = append(ids, id) - } - return -} - -// ResetGitBots resets all changes to the "git_bots" edge. -func (m *ProjectMutation) ResetGitBots() { - m.git_bots = nil - m.clearedgit_bots = false - m.removedgit_bots = nil -} - -// AddProjectGitBotIDs adds the "project_git_bots" edge to the ProjectGitBot entity by ids. -func (m *ProjectMutation) AddProjectGitBotIDs(ids ...uuid.UUID) { - if m.project_git_bots == nil { - m.project_git_bots = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.project_git_bots[ids[i]] = struct{}{} + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } + return oldValue.UpdatedAt, nil } -// ClearProjectGitBots clears the "project_git_bots" edge to the ProjectGitBot entity. -func (m *ProjectMutation) ClearProjectGitBots() { - m.clearedproject_git_bots = true -} - -// ProjectGitBotsCleared reports if the "project_git_bots" edge to the ProjectGitBot entity was cleared. -func (m *ProjectMutation) ProjectGitBotsCleared() bool { - return m.clearedproject_git_bots +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *NotifySubscriptionMutation) ResetUpdatedAt() { + m.updated_at = nil } -// RemoveProjectGitBotIDs removes the "project_git_bots" edge to the ProjectGitBot entity by IDs. -func (m *ProjectMutation) RemoveProjectGitBotIDs(ids ...uuid.UUID) { - if m.removedproject_git_bots == nil { - m.removedproject_git_bots = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.project_git_bots, ids[i]) - m.removedproject_git_bots[ids[i]] = struct{}{} - } +// ClearChannel clears the "channel" edge to the NotifyChannel entity. +func (m *NotifySubscriptionMutation) ClearChannel() { + m.clearedchannel = true + m.clearedFields[notifysubscription.FieldChannelID] = struct{}{} } -// RemovedProjectGitBots returns the removed IDs of the "project_git_bots" edge to the ProjectGitBot entity. -func (m *ProjectMutation) RemovedProjectGitBotsIDs() (ids []uuid.UUID) { - for id := range m.removedproject_git_bots { - ids = append(ids, id) - } - return +// ChannelCleared reports if the "channel" edge to the NotifyChannel entity was cleared. +func (m *NotifySubscriptionMutation) ChannelCleared() bool { + return m.clearedchannel } -// ProjectGitBotsIDs returns the "project_git_bots" edge IDs in the mutation. -func (m *ProjectMutation) ProjectGitBotsIDs() (ids []uuid.UUID) { - for id := range m.project_git_bots { - ids = append(ids, id) +// ChannelIDs returns the "channel" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ChannelID instead. It exists only for internal usage by the builders. +func (m *NotifySubscriptionMutation) ChannelIDs() (ids []uuid.UUID) { + if id := m.channel; id != nil { + ids = append(ids, *id) } return } -// ResetProjectGitBots resets all changes to the "project_git_bots" edge. -func (m *ProjectMutation) ResetProjectGitBots() { - m.project_git_bots = nil - m.clearedproject_git_bots = false - m.removedproject_git_bots = nil +// ResetChannel resets all changes to the "channel" edge. +func (m *NotifySubscriptionMutation) ResetChannel() { + m.channel = nil + m.clearedchannel = false } -// Where appends a list predicates to the ProjectMutation builder. -func (m *ProjectMutation) Where(ps ...predicate.Project) { +// Where appends a list predicates to the NotifySubscriptionMutation builder. +func (m *NotifySubscriptionMutation) Where(ps ...predicate.NotifySubscription) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ProjectMutation builder. Using this method, +// WhereP appends storage-level predicates to the NotifySubscriptionMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ProjectMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Project, len(ps)) +func (m *NotifySubscriptionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.NotifySubscription, len(ps)) for i := range ps { p[i] = ps[i] } @@ -20091,60 +28410,45 @@ func (m *ProjectMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ProjectMutation) Op() Op { +func (m *NotifySubscriptionMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ProjectMutation) SetOp(op Op) { +func (m *NotifySubscriptionMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Project). -func (m *ProjectMutation) Type() string { +// Type returns the node type of this mutation (NotifySubscription). +func (m *NotifySubscriptionMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ProjectMutation) Fields() []string { - fields := make([]string, 0, 12) +func (m *NotifySubscriptionMutation) Fields() []string { + fields := make([]string, 0, 7) if m.deleted_at != nil { - fields = append(fields, project.FieldDeletedAt) - } - if m.user != nil { - fields = append(fields, project.FieldUserID) - } - if m.name != nil { - fields = append(fields, project.FieldName) - } - if m.description != nil { - fields = append(fields, project.FieldDescription) - } - if m.platform != nil { - fields = append(fields, project.FieldPlatform) - } - if m.repo_url != nil { - fields = append(fields, project.FieldRepoURL) + fields = append(fields, notifysubscription.FieldDeletedAt) } - if m.branch != nil { - fields = append(fields, project.FieldBranch) + if m.channel != nil { + fields = append(fields, notifysubscription.FieldChannelID) } - if m.git_identity != nil { - fields = append(fields, project.FieldGitIdentityID) + if m.scope != nil { + fields = append(fields, notifysubscription.FieldScope) } - if m.image != nil { - fields = append(fields, project.FieldImageID) + if m.event_types != nil { + fields = append(fields, notifysubscription.FieldEventTypes) } - if m.env_variables != nil { - fields = append(fields, project.FieldEnvVariables) + if m.enabled != nil { + fields = append(fields, notifysubscription.FieldEnabled) } if m.created_at != nil { - fields = append(fields, project.FieldCreatedAt) + fields = append(fields, notifysubscription.FieldCreatedAt) } if m.updated_at != nil { - fields = append(fields, project.FieldUpdatedAt) + fields = append(fields, notifysubscription.FieldUpdatedAt) } return fields } @@ -20152,31 +28456,21 @@ func (m *ProjectMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ProjectMutation) Field(name string) (ent.Value, bool) { +func (m *NotifySubscriptionMutation) Field(name string) (ent.Value, bool) { switch name { - case project.FieldDeletedAt: + case notifysubscription.FieldDeletedAt: return m.DeletedAt() - case project.FieldUserID: - return m.UserID() - case project.FieldName: - return m.Name() - case project.FieldDescription: - return m.Description() - case project.FieldPlatform: - return m.Platform() - case project.FieldRepoURL: - return m.RepoURL() - case project.FieldBranch: - return m.Branch() - case project.FieldGitIdentityID: - return m.GitIdentityID() - case project.FieldImageID: - return m.ImageID() - case project.FieldEnvVariables: - return m.EnvVariables() - case project.FieldCreatedAt: + case notifysubscription.FieldChannelID: + return m.ChannelID() + case notifysubscription.FieldScope: + return m.Scope() + case notifysubscription.FieldEventTypes: + return m.EventTypes() + case notifysubscription.FieldEnabled: + return m.Enabled() + case notifysubscription.FieldCreatedAt: return m.CreatedAt() - case project.FieldUpdatedAt: + case notifysubscription.FieldUpdatedAt: return m.UpdatedAt() } return nil, false @@ -20185,119 +28479,74 @@ func (m *ProjectMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ProjectMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *NotifySubscriptionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case project.FieldDeletedAt: + case notifysubscription.FieldDeletedAt: return m.OldDeletedAt(ctx) - case project.FieldUserID: - return m.OldUserID(ctx) - case project.FieldName: - return m.OldName(ctx) - case project.FieldDescription: - return m.OldDescription(ctx) - case project.FieldPlatform: - return m.OldPlatform(ctx) - case project.FieldRepoURL: - return m.OldRepoURL(ctx) - case project.FieldBranch: - return m.OldBranch(ctx) - case project.FieldGitIdentityID: - return m.OldGitIdentityID(ctx) - case project.FieldImageID: - return m.OldImageID(ctx) - case project.FieldEnvVariables: - return m.OldEnvVariables(ctx) - case project.FieldCreatedAt: + case notifysubscription.FieldChannelID: + return m.OldChannelID(ctx) + case notifysubscription.FieldScope: + return m.OldScope(ctx) + case notifysubscription.FieldEventTypes: + return m.OldEventTypes(ctx) + case notifysubscription.FieldEnabled: + return m.OldEnabled(ctx) + case notifysubscription.FieldCreatedAt: return m.OldCreatedAt(ctx) - case project.FieldUpdatedAt: + case notifysubscription.FieldUpdatedAt: return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown Project field %s", name) + return nil, fmt.Errorf("unknown NotifySubscription field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectMutation) SetField(name string, value ent.Value) error { +func (m *NotifySubscriptionMutation) SetField(name string, value ent.Value) error { switch name { - case project.FieldDeletedAt: + case notifysubscription.FieldDeletedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDeletedAt(v) return nil - case project.FieldUserID: + case notifysubscription.FieldChannelID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) - return nil - case project.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case project.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case project.FieldPlatform: - v, ok := value.(consts.GitPlatform) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPlatform(v) - return nil - case project.FieldRepoURL: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRepoURL(v) + m.SetChannelID(v) return nil - case project.FieldBranch: + case notifysubscription.FieldScope: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetBranch(v) - return nil - case project.FieldGitIdentityID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetGitIdentityID(v) + m.SetScope(v) return nil - case project.FieldImageID: - v, ok := value.(uuid.UUID) + case notifysubscription.FieldEventTypes: + v, ok := value.([]consts.NotifyEventType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetImageID(v) + m.SetEventTypes(v) return nil - case project.FieldEnvVariables: - v, ok := value.(map[string]interface{}) + case notifysubscription.FieldEnabled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetEnvVariables(v) + m.SetEnabled(v) return nil - case project.FieldCreatedAt: + case notifysubscription.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case project.FieldUpdatedAt: + case notifysubscription.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) @@ -20305,418 +28554,215 @@ func (m *ProjectMutation) SetField(name string, value ent.Value) error { m.SetUpdatedAt(v) return nil } - return fmt.Errorf("unknown Project field %s", name) + return fmt.Errorf("unknown NotifySubscription field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ProjectMutation) AddedFields() []string { +func (m *NotifySubscriptionMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ProjectMutation) AddedField(name string) (ent.Value, bool) { +func (m *NotifySubscriptionMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectMutation) AddField(name string, value ent.Value) error { +func (m *NotifySubscriptionMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Project numeric field %s", name) + return fmt.Errorf("unknown NotifySubscription numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ProjectMutation) ClearedFields() []string { +func (m *NotifySubscriptionMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(project.FieldDeletedAt) { - fields = append(fields, project.FieldDeletedAt) - } - if m.FieldCleared(project.FieldDescription) { - fields = append(fields, project.FieldDescription) - } - if m.FieldCleared(project.FieldPlatform) { - fields = append(fields, project.FieldPlatform) - } - if m.FieldCleared(project.FieldRepoURL) { - fields = append(fields, project.FieldRepoURL) - } - if m.FieldCleared(project.FieldBranch) { - fields = append(fields, project.FieldBranch) - } - if m.FieldCleared(project.FieldGitIdentityID) { - fields = append(fields, project.FieldGitIdentityID) - } - if m.FieldCleared(project.FieldImageID) { - fields = append(fields, project.FieldImageID) - } - if m.FieldCleared(project.FieldEnvVariables) { - fields = append(fields, project.FieldEnvVariables) + if m.FieldCleared(notifysubscription.FieldDeletedAt) { + fields = append(fields, notifysubscription.FieldDeletedAt) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ProjectMutation) FieldCleared(name string) bool { +func (m *NotifySubscriptionMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ProjectMutation) ClearField(name string) error { +func (m *NotifySubscriptionMutation) ClearField(name string) error { switch name { - case project.FieldDeletedAt: + case notifysubscription.FieldDeletedAt: m.ClearDeletedAt() return nil - case project.FieldDescription: - m.ClearDescription() - return nil - case project.FieldPlatform: - m.ClearPlatform() - return nil - case project.FieldRepoURL: - m.ClearRepoURL() - return nil - case project.FieldBranch: - m.ClearBranch() - return nil - case project.FieldGitIdentityID: - m.ClearGitIdentityID() - return nil - case project.FieldImageID: - m.ClearImageID() - return nil - case project.FieldEnvVariables: - m.ClearEnvVariables() - return nil } - return fmt.Errorf("unknown Project nullable field %s", name) + return fmt.Errorf("unknown NotifySubscription nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ProjectMutation) ResetField(name string) error { +func (m *NotifySubscriptionMutation) ResetField(name string) error { switch name { - case project.FieldDeletedAt: + case notifysubscription.FieldDeletedAt: m.ResetDeletedAt() return nil - case project.FieldUserID: - m.ResetUserID() - return nil - case project.FieldName: - m.ResetName() - return nil - case project.FieldDescription: - m.ResetDescription() - return nil - case project.FieldPlatform: - m.ResetPlatform() - return nil - case project.FieldRepoURL: - m.ResetRepoURL() - return nil - case project.FieldBranch: - m.ResetBranch() + case notifysubscription.FieldChannelID: + m.ResetChannelID() return nil - case project.FieldGitIdentityID: - m.ResetGitIdentityID() + case notifysubscription.FieldScope: + m.ResetScope() return nil - case project.FieldImageID: - m.ResetImageID() + case notifysubscription.FieldEventTypes: + m.ResetEventTypes() return nil - case project.FieldEnvVariables: - m.ResetEnvVariables() + case notifysubscription.FieldEnabled: + m.ResetEnabled() return nil - case project.FieldCreatedAt: + case notifysubscription.FieldCreatedAt: m.ResetCreatedAt() return nil - case project.FieldUpdatedAt: + case notifysubscription.FieldUpdatedAt: m.ResetUpdatedAt() return nil } - return fmt.Errorf("unknown Project field %s", name) + return fmt.Errorf("unknown NotifySubscription field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ProjectMutation) AddedEdges() []string { - edges := make([]string, 0, 8) - if m.user != nil { - edges = append(edges, project.EdgeUser) - } - if m.git_identity != nil { - edges = append(edges, project.EdgeGitIdentity) - } - if m.image != nil { - edges = append(edges, project.EdgeImage) - } - if m.issues != nil { - edges = append(edges, project.EdgeIssues) - } - if m.collaborators != nil { - edges = append(edges, project.EdgeCollaborators) - } - if m.project_tasks != nil { - edges = append(edges, project.EdgeProjectTasks) - } - if m.git_bots != nil { - edges = append(edges, project.EdgeGitBots) - } - if m.project_git_bots != nil { - edges = append(edges, project.EdgeProjectGitBots) +func (m *NotifySubscriptionMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.channel != nil { + edges = append(edges, notifysubscription.EdgeChannel) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ProjectMutation) AddedIDs(name string) []ent.Value { +func (m *NotifySubscriptionMutation) AddedIDs(name string) []ent.Value { switch name { - case project.EdgeUser: - if id := m.user; id != nil { - return []ent.Value{*id} - } - case project.EdgeGitIdentity: - if id := m.git_identity; id != nil { - return []ent.Value{*id} - } - case project.EdgeImage: - if id := m.image; id != nil { + case notifysubscription.EdgeChannel: + if id := m.channel; id != nil { return []ent.Value{*id} } - case project.EdgeIssues: - ids := make([]ent.Value, 0, len(m.issues)) - for id := range m.issues { - ids = append(ids, id) - } - return ids - case project.EdgeCollaborators: - ids := make([]ent.Value, 0, len(m.collaborators)) - for id := range m.collaborators { - ids = append(ids, id) - } - return ids - case project.EdgeProjectTasks: - ids := make([]ent.Value, 0, len(m.project_tasks)) - for id := range m.project_tasks { - ids = append(ids, id) - } - return ids - case project.EdgeGitBots: - ids := make([]ent.Value, 0, len(m.git_bots)) - for id := range m.git_bots { - ids = append(ids, id) - } - return ids - case project.EdgeProjectGitBots: - ids := make([]ent.Value, 0, len(m.project_git_bots)) - for id := range m.project_git_bots { - ids = append(ids, id) - } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ProjectMutation) RemovedEdges() []string { - edges := make([]string, 0, 8) - if m.removedissues != nil { - edges = append(edges, project.EdgeIssues) - } - if m.removedcollaborators != nil { - edges = append(edges, project.EdgeCollaborators) - } - if m.removedproject_tasks != nil { - edges = append(edges, project.EdgeProjectTasks) - } - if m.removedgit_bots != nil { - edges = append(edges, project.EdgeGitBots) - } - if m.removedproject_git_bots != nil { - edges = append(edges, project.EdgeProjectGitBots) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *ProjectMutation) RemovedIDs(name string) []ent.Value { - switch name { - case project.EdgeIssues: - ids := make([]ent.Value, 0, len(m.removedissues)) - for id := range m.removedissues { - ids = append(ids, id) - } - return ids - case project.EdgeCollaborators: - ids := make([]ent.Value, 0, len(m.removedcollaborators)) - for id := range m.removedcollaborators { - ids = append(ids, id) - } - return ids - case project.EdgeProjectTasks: - ids := make([]ent.Value, 0, len(m.removedproject_tasks)) - for id := range m.removedproject_tasks { - ids = append(ids, id) - } - return ids - case project.EdgeGitBots: - ids := make([]ent.Value, 0, len(m.removedgit_bots)) - for id := range m.removedgit_bots { - ids = append(ids, id) - } - return ids - case project.EdgeProjectGitBots: - ids := make([]ent.Value, 0, len(m.removedproject_git_bots)) - for id := range m.removedproject_git_bots { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ProjectMutation) ClearedEdges() []string { - edges := make([]string, 0, 8) - if m.cleareduser { - edges = append(edges, project.EdgeUser) - } - if m.clearedgit_identity { - edges = append(edges, project.EdgeGitIdentity) - } - if m.clearedimage { - edges = append(edges, project.EdgeImage) - } - if m.clearedissues { - edges = append(edges, project.EdgeIssues) - } - if m.clearedcollaborators { - edges = append(edges, project.EdgeCollaborators) - } - if m.clearedproject_tasks { - edges = append(edges, project.EdgeProjectTasks) - } - if m.clearedgit_bots { - edges = append(edges, project.EdgeGitBots) - } - if m.clearedproject_git_bots { - edges = append(edges, project.EdgeProjectGitBots) +func (m *NotifySubscriptionMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *NotifySubscriptionMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *NotifySubscriptionMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedchannel { + edges = append(edges, notifysubscription.EdgeChannel) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ProjectMutation) EdgeCleared(name string) bool { +func (m *NotifySubscriptionMutation) EdgeCleared(name string) bool { switch name { - case project.EdgeUser: - return m.cleareduser - case project.EdgeGitIdentity: - return m.clearedgit_identity - case project.EdgeImage: - return m.clearedimage - case project.EdgeIssues: - return m.clearedissues - case project.EdgeCollaborators: - return m.clearedcollaborators - case project.EdgeProjectTasks: - return m.clearedproject_tasks - case project.EdgeGitBots: - return m.clearedgit_bots - case project.EdgeProjectGitBots: - return m.clearedproject_git_bots + case notifysubscription.EdgeChannel: + return m.clearedchannel } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ProjectMutation) ClearEdge(name string) error { +func (m *NotifySubscriptionMutation) ClearEdge(name string) error { switch name { - case project.EdgeUser: - m.ClearUser() - return nil - case project.EdgeGitIdentity: - m.ClearGitIdentity() - return nil - case project.EdgeImage: - m.ClearImage() + case notifysubscription.EdgeChannel: + m.ClearChannel() return nil } - return fmt.Errorf("unknown Project unique edge %s", name) + return fmt.Errorf("unknown NotifySubscription unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ProjectMutation) ResetEdge(name string) error { +func (m *NotifySubscriptionMutation) ResetEdge(name string) error { switch name { - case project.EdgeUser: - m.ResetUser() - return nil - case project.EdgeGitIdentity: - m.ResetGitIdentity() - return nil - case project.EdgeImage: - m.ResetImage() - return nil - case project.EdgeIssues: - m.ResetIssues() - return nil - case project.EdgeCollaborators: - m.ResetCollaborators() - return nil - case project.EdgeProjectTasks: - m.ResetProjectTasks() - return nil - case project.EdgeGitBots: - m.ResetGitBots() - return nil - case project.EdgeProjectGitBots: - m.ResetProjectGitBots() + case notifysubscription.EdgeChannel: + m.ResetChannel() return nil } - return fmt.Errorf("unknown Project edge %s", name) + return fmt.Errorf("unknown NotifySubscription edge %s", name) } -// ProjectCollaboratorMutation represents an operation that mutates the ProjectCollaborator nodes in the graph. -type ProjectCollaboratorMutation struct { +// ProjectMutation represents an operation that mutates the Project nodes in the graph. +type ProjectMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - role *consts.ProjectCollaboratorRole - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - user *uuid.UUID - cleareduser bool - project *uuid.UUID - clearedproject bool - done bool - oldValue func(context.Context) (*ProjectCollaborator, error) - predicates []predicate.ProjectCollaborator + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + name *string + description *string + platform *consts.GitPlatform + repo_url *string + branch *string + env_variables *map[string]interface{} + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + user *uuid.UUID + cleareduser bool + git_identity *uuid.UUID + clearedgit_identity bool + image *uuid.UUID + clearedimage bool + issues map[uuid.UUID]struct{} + removedissues map[uuid.UUID]struct{} + clearedissues bool + collaborators map[uuid.UUID]struct{} + removedcollaborators map[uuid.UUID]struct{} + clearedcollaborators bool + project_tasks map[uuid.UUID]struct{} + removedproject_tasks map[uuid.UUID]struct{} + clearedproject_tasks bool + git_bots map[uuid.UUID]struct{} + removedgit_bots map[uuid.UUID]struct{} + clearedgit_bots bool + project_git_bots map[uuid.UUID]struct{} + removedproject_git_bots map[uuid.UUID]struct{} + clearedproject_git_bots bool + done bool + oldValue func(context.Context) (*Project, error) + predicates []predicate.Project } -var _ ent.Mutation = (*ProjectCollaboratorMutation)(nil) +var _ ent.Mutation = (*ProjectMutation)(nil) -// projectcollaboratorOption allows management of the mutation configuration using functional options. -type projectcollaboratorOption func(*ProjectCollaboratorMutation) +// projectOption allows management of the mutation configuration using functional options. +type projectOption func(*ProjectMutation) -// newProjectCollaboratorMutation creates new mutation for the ProjectCollaborator entity. -func newProjectCollaboratorMutation(c config, op Op, opts ...projectcollaboratorOption) *ProjectCollaboratorMutation { - m := &ProjectCollaboratorMutation{ +// newProjectMutation creates new mutation for the Project entity. +func newProjectMutation(c config, op Op, opts ...projectOption) *ProjectMutation { + m := &ProjectMutation{ config: c, op: op, - typ: TypeProjectCollaborator, + typ: TypeProject, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -20725,20 +28771,20 @@ func newProjectCollaboratorMutation(c config, op Op, opts ...projectcollaborator return m } -// withProjectCollaboratorID sets the ID field of the mutation. -func withProjectCollaboratorID(id uuid.UUID) projectcollaboratorOption { - return func(m *ProjectCollaboratorMutation) { +// withProjectID sets the ID field of the mutation. +func withProjectID(id uuid.UUID) projectOption { + return func(m *ProjectMutation) { var ( err error once sync.Once - value *ProjectCollaborator + value *Project ) - m.oldValue = func(ctx context.Context) (*ProjectCollaborator, error) { + m.oldValue = func(ctx context.Context) (*Project, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().ProjectCollaborator.Get(ctx, id) + value, err = m.Client().Project.Get(ctx, id) } }) return value, err @@ -20747,361 +28793,965 @@ func withProjectCollaboratorID(id uuid.UUID) projectcollaboratorOption { } } -// withProjectCollaborator sets the old ProjectCollaborator of the mutation. -func withProjectCollaborator(node *ProjectCollaborator) projectcollaboratorOption { - return func(m *ProjectCollaboratorMutation) { - m.oldValue = func(context.Context) (*ProjectCollaborator, error) { - return node, nil - } - m.id = &node.ID - } +// withProject sets the old Project of the mutation. +func withProject(node *Project) projectOption { + return func(m *ProjectMutation) { + m.oldValue = func(context.Context) (*Project, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ProjectMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ProjectMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Project entities. +func (m *ProjectMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ProjectMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ProjectMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Project.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *ProjectMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *ProjectMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *ProjectMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[project.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *ProjectMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[project.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *ProjectMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, project.FieldDeletedAt) +} + +// SetUserID sets the "user_id" field. +func (m *ProjectMutation) SetUserID(u uuid.UUID) { + m.user = &u +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *ProjectMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *ProjectMutation) ResetUserID() { + m.user = nil +} + +// SetName sets the "name" field. +func (m *ProjectMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ProjectMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *ProjectMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *ProjectMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *ProjectMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *ProjectMutation) ClearDescription() { + m.description = nil + m.clearedFields[project.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *ProjectMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[project.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *ProjectMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, project.FieldDescription) +} + +// SetPlatform sets the "platform" field. +func (m *ProjectMutation) SetPlatform(cp consts.GitPlatform) { + m.platform = &cp +} + +// Platform returns the value of the "platform" field in the mutation. +func (m *ProjectMutation) Platform() (r consts.GitPlatform, exists bool) { + v := m.platform + if v == nil { + return + } + return *v, true +} + +// OldPlatform returns the old "platform" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectMutation) OldPlatform(ctx context.Context) (v consts.GitPlatform, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPlatform is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPlatform requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPlatform: %w", err) + } + return oldValue.Platform, nil +} + +// ClearPlatform clears the value of the "platform" field. +func (m *ProjectMutation) ClearPlatform() { + m.platform = nil + m.clearedFields[project.FieldPlatform] = struct{}{} +} + +// PlatformCleared returns if the "platform" field was cleared in this mutation. +func (m *ProjectMutation) PlatformCleared() bool { + _, ok := m.clearedFields[project.FieldPlatform] + return ok +} + +// ResetPlatform resets all changes to the "platform" field. +func (m *ProjectMutation) ResetPlatform() { + m.platform = nil + delete(m.clearedFields, project.FieldPlatform) +} + +// SetRepoURL sets the "repo_url" field. +func (m *ProjectMutation) SetRepoURL(s string) { + m.repo_url = &s +} + +// RepoURL returns the value of the "repo_url" field in the mutation. +func (m *ProjectMutation) RepoURL() (r string, exists bool) { + v := m.repo_url + if v == nil { + return + } + return *v, true +} + +// OldRepoURL returns the old "repo_url" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectMutation) OldRepoURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRepoURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRepoURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRepoURL: %w", err) + } + return oldValue.RepoURL, nil +} + +// ClearRepoURL clears the value of the "repo_url" field. +func (m *ProjectMutation) ClearRepoURL() { + m.repo_url = nil + m.clearedFields[project.FieldRepoURL] = struct{}{} +} + +// RepoURLCleared returns if the "repo_url" field was cleared in this mutation. +func (m *ProjectMutation) RepoURLCleared() bool { + _, ok := m.clearedFields[project.FieldRepoURL] + return ok +} + +// ResetRepoURL resets all changes to the "repo_url" field. +func (m *ProjectMutation) ResetRepoURL() { + m.repo_url = nil + delete(m.clearedFields, project.FieldRepoURL) +} + +// SetBranch sets the "branch" field. +func (m *ProjectMutation) SetBranch(s string) { + m.branch = &s +} + +// Branch returns the value of the "branch" field in the mutation. +func (m *ProjectMutation) Branch() (r string, exists bool) { + v := m.branch + if v == nil { + return + } + return *v, true +} + +// OldBranch returns the old "branch" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectMutation) OldBranch(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBranch is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBranch requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBranch: %w", err) + } + return oldValue.Branch, nil +} + +// ClearBranch clears the value of the "branch" field. +func (m *ProjectMutation) ClearBranch() { + m.branch = nil + m.clearedFields[project.FieldBranch] = struct{}{} } -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m ProjectCollaboratorMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client +// BranchCleared returns if the "branch" field was cleared in this mutation. +func (m *ProjectMutation) BranchCleared() bool { + _, ok := m.clearedFields[project.FieldBranch] + return ok } -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m ProjectCollaboratorMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("db: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil +// ResetBranch resets all changes to the "branch" field. +func (m *ProjectMutation) ResetBranch() { + m.branch = nil + delete(m.clearedFields, project.FieldBranch) } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of ProjectCollaborator entities. -func (m *ProjectCollaboratorMutation) SetID(id uuid.UUID) { - m.id = &id +// SetGitIdentityID sets the "git_identity_id" field. +func (m *ProjectMutation) SetGitIdentityID(u uuid.UUID) { + m.git_identity = &u } -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *ProjectCollaboratorMutation) ID() (id uuid.UUID, exists bool) { - if m.id == nil { +// GitIdentityID returns the value of the "git_identity_id" field in the mutation. +func (m *ProjectMutation) GitIdentityID() (r uuid.UUID, exists bool) { + v := m.git_identity + if v == nil { return } - return *m.id, true + return *v, true } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *ProjectCollaboratorMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []uuid.UUID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().ProjectCollaborator.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) +// OldGitIdentityID returns the old "git_identity_id" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectMutation) OldGitIdentityID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGitIdentityID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGitIdentityID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGitIdentityID: %w", err) } + return oldValue.GitIdentityID, nil } -// SetDeletedAt sets the "deleted_at" field. -func (m *ProjectCollaboratorMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t +// ClearGitIdentityID clears the value of the "git_identity_id" field. +func (m *ProjectMutation) ClearGitIdentityID() { + m.git_identity = nil + m.clearedFields[project.FieldGitIdentityID] = struct{}{} } -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *ProjectCollaboratorMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at +// GitIdentityIDCleared returns if the "git_identity_id" field was cleared in this mutation. +func (m *ProjectMutation) GitIdentityIDCleared() bool { + _, ok := m.clearedFields[project.FieldGitIdentityID] + return ok +} + +// ResetGitIdentityID resets all changes to the "git_identity_id" field. +func (m *ProjectMutation) ResetGitIdentityID() { + m.git_identity = nil + delete(m.clearedFields, project.FieldGitIdentityID) +} + +// SetImageID sets the "image_id" field. +func (m *ProjectMutation) SetImageID(u uuid.UUID) { + m.image = &u +} + +// ImageID returns the value of the "image_id" field in the mutation. +func (m *ProjectMutation) ImageID() (r uuid.UUID, exists bool) { + v := m.image if v == nil { return } return *v, true } -// OldDeletedAt returns the old "deleted_at" field's value of the ProjectCollaborator entity. -// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. +// OldImageID returns the old "image_id" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectCollaboratorMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectMutation) OldImageID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + return v, errors.New("OldImageID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") + return v, errors.New("OldImageID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + return v, fmt.Errorf("querying old value for OldImageID: %w", err) } - return oldValue.DeletedAt, nil + return oldValue.ImageID, nil } -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *ProjectCollaboratorMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[projectcollaborator.FieldDeletedAt] = struct{}{} +// ClearImageID clears the value of the "image_id" field. +func (m *ProjectMutation) ClearImageID() { + m.image = nil + m.clearedFields[project.FieldImageID] = struct{}{} } -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *ProjectCollaboratorMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[projectcollaborator.FieldDeletedAt] +// ImageIDCleared returns if the "image_id" field was cleared in this mutation. +func (m *ProjectMutation) ImageIDCleared() bool { + _, ok := m.clearedFields[project.FieldImageID] return ok } -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *ProjectCollaboratorMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, projectcollaborator.FieldDeletedAt) +// ResetImageID resets all changes to the "image_id" field. +func (m *ProjectMutation) ResetImageID() { + m.image = nil + delete(m.clearedFields, project.FieldImageID) } -// SetProjectID sets the "project_id" field. -func (m *ProjectCollaboratorMutation) SetProjectID(u uuid.UUID) { - m.project = &u +// SetEnvVariables sets the "env_variables" field. +func (m *ProjectMutation) SetEnvVariables(value map[string]interface{}) { + m.env_variables = &value } -// ProjectID returns the value of the "project_id" field in the mutation. -func (m *ProjectCollaboratorMutation) ProjectID() (r uuid.UUID, exists bool) { - v := m.project +// EnvVariables returns the value of the "env_variables" field in the mutation. +func (m *ProjectMutation) EnvVariables() (r map[string]interface{}, exists bool) { + v := m.env_variables if v == nil { return } return *v, true } -// OldProjectID returns the old "project_id" field's value of the ProjectCollaborator entity. -// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. +// OldEnvVariables returns the old "env_variables" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectCollaboratorMutation) OldProjectID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ProjectMutation) OldEnvVariables(ctx context.Context) (v map[string]interface{}, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProjectID is only allowed on UpdateOne operations") + return v, errors.New("OldEnvVariables is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProjectID requires an ID field in the mutation") + return v, errors.New("OldEnvVariables requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProjectID: %w", err) + return v, fmt.Errorf("querying old value for OldEnvVariables: %w", err) } - return oldValue.ProjectID, nil + return oldValue.EnvVariables, nil } -// ResetProjectID resets all changes to the "project_id" field. -func (m *ProjectCollaboratorMutation) ResetProjectID() { - m.project = nil +// ClearEnvVariables clears the value of the "env_variables" field. +func (m *ProjectMutation) ClearEnvVariables() { + m.env_variables = nil + m.clearedFields[project.FieldEnvVariables] = struct{}{} } -// SetUserID sets the "user_id" field. -func (m *ProjectCollaboratorMutation) SetUserID(u uuid.UUID) { - m.user = &u +// EnvVariablesCleared returns if the "env_variables" field was cleared in this mutation. +func (m *ProjectMutation) EnvVariablesCleared() bool { + _, ok := m.clearedFields[project.FieldEnvVariables] + return ok } -// UserID returns the value of the "user_id" field in the mutation. -func (m *ProjectCollaboratorMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user +// ResetEnvVariables resets all changes to the "env_variables" field. +func (m *ProjectMutation) ResetEnvVariables() { + m.env_variables = nil + delete(m.clearedFields, project.FieldEnvVariables) +} + +// SetCreatedAt sets the "created_at" field. +func (m *ProjectMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ProjectMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldUserID returns the old "user_id" field's value of the ProjectCollaborator entity. -// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectCollaboratorMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ProjectMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.UserID, nil + return oldValue.CreatedAt, nil } -// ResetUserID resets all changes to the "user_id" field. -func (m *ProjectCollaboratorMutation) ResetUserID() { - m.user = nil +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ProjectMutation) ResetCreatedAt() { + m.created_at = nil } -// SetRole sets the "role" field. -func (m *ProjectCollaboratorMutation) SetRole(ccr consts.ProjectCollaboratorRole) { - m.role = &ccr +// SetUpdatedAt sets the "updated_at" field. +func (m *ProjectMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t } -// Role returns the value of the "role" field in the mutation. -func (m *ProjectCollaboratorMutation) Role() (r consts.ProjectCollaboratorRole, exists bool) { - v := m.role +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ProjectMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at if v == nil { return } return *v, true } -// OldRole returns the old "role" field's value of the ProjectCollaborator entity. -// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. +// OldUpdatedAt returns the old "updated_at" field's value of the Project entity. +// If the Project object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectCollaboratorMutation) OldRole(ctx context.Context) (v consts.ProjectCollaboratorRole, err error) { +func (m *ProjectMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRole is only allowed on UpdateOne operations") + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRole requires an ID field in the mutation") + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRole: %w", err) + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } - return oldValue.Role, nil + return oldValue.UpdatedAt, nil } -// ResetRole resets all changes to the "role" field. -func (m *ProjectCollaboratorMutation) ResetRole() { - m.role = nil +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ProjectMutation) ResetUpdatedAt() { + m.updated_at = nil } -// SetCreatedAt sets the "created_at" field. -func (m *ProjectCollaboratorMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// ClearUser clears the "user" edge to the User entity. +func (m *ProjectMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[project.FieldUserID] = struct{}{} } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ProjectCollaboratorMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *ProjectMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *ProjectMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { + ids = append(ids, *id) } - return *v, true + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *ProjectMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// ClearGitIdentity clears the "git_identity" edge to the GitIdentity entity. +func (m *ProjectMutation) ClearGitIdentity() { + m.clearedgit_identity = true + m.clearedFields[project.FieldGitIdentityID] = struct{}{} +} + +// GitIdentityCleared reports if the "git_identity" edge to the GitIdentity entity was cleared. +func (m *ProjectMutation) GitIdentityCleared() bool { + return m.GitIdentityIDCleared() || m.clearedgit_identity +} + +// GitIdentityIDs returns the "git_identity" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// GitIdentityID instead. It exists only for internal usage by the builders. +func (m *ProjectMutation) GitIdentityIDs() (ids []uuid.UUID) { + if id := m.git_identity; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetGitIdentity resets all changes to the "git_identity" edge. +func (m *ProjectMutation) ResetGitIdentity() { + m.git_identity = nil + m.clearedgit_identity = false +} + +// ClearImage clears the "image" edge to the Image entity. +func (m *ProjectMutation) ClearImage() { + m.clearedimage = true + m.clearedFields[project.FieldImageID] = struct{}{} +} + +// ImageCleared reports if the "image" edge to the Image entity was cleared. +func (m *ProjectMutation) ImageCleared() bool { + return m.ImageIDCleared() || m.clearedimage +} + +// ImageIDs returns the "image" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ImageID instead. It exists only for internal usage by the builders. +func (m *ProjectMutation) ImageIDs() (ids []uuid.UUID) { + if id := m.image; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetImage resets all changes to the "image" edge. +func (m *ProjectMutation) ResetImage() { + m.image = nil + m.clearedimage = false +} + +// AddIssueIDs adds the "issues" edge to the ProjectIssue entity by ids. +func (m *ProjectMutation) AddIssueIDs(ids ...uuid.UUID) { + if m.issues == nil { + m.issues = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.issues[ids[i]] = struct{}{} + } +} + +// ClearIssues clears the "issues" edge to the ProjectIssue entity. +func (m *ProjectMutation) ClearIssues() { + m.clearedissues = true +} + +// IssuesCleared reports if the "issues" edge to the ProjectIssue entity was cleared. +func (m *ProjectMutation) IssuesCleared() bool { + return m.clearedissues +} + +// RemoveIssueIDs removes the "issues" edge to the ProjectIssue entity by IDs. +func (m *ProjectMutation) RemoveIssueIDs(ids ...uuid.UUID) { + if m.removedissues == nil { + m.removedissues = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.issues, ids[i]) + m.removedissues[ids[i]] = struct{}{} + } +} + +// RemovedIssues returns the removed IDs of the "issues" edge to the ProjectIssue entity. +func (m *ProjectMutation) RemovedIssuesIDs() (ids []uuid.UUID) { + for id := range m.removedissues { + ids = append(ids, id) + } + return +} + +// IssuesIDs returns the "issues" edge IDs in the mutation. +func (m *ProjectMutation) IssuesIDs() (ids []uuid.UUID) { + for id := range m.issues { + ids = append(ids, id) + } + return +} + +// ResetIssues resets all changes to the "issues" edge. +func (m *ProjectMutation) ResetIssues() { + m.issues = nil + m.clearedissues = false + m.removedissues = nil +} + +// AddCollaboratorIDs adds the "collaborators" edge to the ProjectCollaborator entity by ids. +func (m *ProjectMutation) AddCollaboratorIDs(ids ...uuid.UUID) { + if m.collaborators == nil { + m.collaborators = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.collaborators[ids[i]] = struct{}{} + } +} + +// ClearCollaborators clears the "collaborators" edge to the ProjectCollaborator entity. +func (m *ProjectMutation) ClearCollaborators() { + m.clearedcollaborators = true +} + +// CollaboratorsCleared reports if the "collaborators" edge to the ProjectCollaborator entity was cleared. +func (m *ProjectMutation) CollaboratorsCleared() bool { + return m.clearedcollaborators +} + +// RemoveCollaboratorIDs removes the "collaborators" edge to the ProjectCollaborator entity by IDs. +func (m *ProjectMutation) RemoveCollaboratorIDs(ids ...uuid.UUID) { + if m.removedcollaborators == nil { + m.removedcollaborators = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.collaborators, ids[i]) + m.removedcollaborators[ids[i]] = struct{}{} + } +} + +// RemovedCollaborators returns the removed IDs of the "collaborators" edge to the ProjectCollaborator entity. +func (m *ProjectMutation) RemovedCollaboratorsIDs() (ids []uuid.UUID) { + for id := range m.removedcollaborators { + ids = append(ids, id) + } + return +} + +// CollaboratorsIDs returns the "collaborators" edge IDs in the mutation. +func (m *ProjectMutation) CollaboratorsIDs() (ids []uuid.UUID) { + for id := range m.collaborators { + ids = append(ids, id) + } + return +} + +// ResetCollaborators resets all changes to the "collaborators" edge. +func (m *ProjectMutation) ResetCollaborators() { + m.collaborators = nil + m.clearedcollaborators = false + m.removedcollaborators = nil +} + +// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids. +func (m *ProjectMutation) AddProjectTaskIDs(ids ...uuid.UUID) { + if m.project_tasks == nil { + m.project_tasks = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.project_tasks[ids[i]] = struct{}{} + } +} + +// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity. +func (m *ProjectMutation) ClearProjectTasks() { + m.clearedproject_tasks = true +} + +// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared. +func (m *ProjectMutation) ProjectTasksCleared() bool { + return m.clearedproject_tasks +} + +// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs. +func (m *ProjectMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) { + if m.removedproject_tasks == nil { + m.removedproject_tasks = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.project_tasks, ids[i]) + m.removedproject_tasks[ids[i]] = struct{}{} + } +} + +// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity. +func (m *ProjectMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) { + for id := range m.removedproject_tasks { + ids = append(ids, id) + } + return +} + +// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation. +func (m *ProjectMutation) ProjectTasksIDs() (ids []uuid.UUID) { + for id := range m.project_tasks { + ids = append(ids, id) + } + return +} + +// ResetProjectTasks resets all changes to the "project_tasks" edge. +func (m *ProjectMutation) ResetProjectTasks() { + m.project_tasks = nil + m.clearedproject_tasks = false + m.removedproject_tasks = nil } -// OldCreatedAt returns the old "created_at" field's value of the ProjectCollaborator entity. -// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectCollaboratorMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") +// AddGitBotIDs adds the "git_bots" edge to the GitBot entity by ids. +func (m *ProjectMutation) AddGitBotIDs(ids ...uuid.UUID) { + if m.git_bots == nil { + m.git_bots = make(map[uuid.UUID]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + for i := range ids { + m.git_bots[ids[i]] = struct{}{} } - return oldValue.CreatedAt, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *ProjectCollaboratorMutation) ResetCreatedAt() { - m.created_at = nil +// ClearGitBots clears the "git_bots" edge to the GitBot entity. +func (m *ProjectMutation) ClearGitBots() { + m.clearedgit_bots = true } -// SetUpdatedAt sets the "updated_at" field. -func (m *ProjectCollaboratorMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t +// GitBotsCleared reports if the "git_bots" edge to the GitBot entity was cleared. +func (m *ProjectMutation) GitBotsCleared() bool { + return m.clearedgit_bots } -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *ProjectCollaboratorMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return +// RemoveGitBotIDs removes the "git_bots" edge to the GitBot entity by IDs. +func (m *ProjectMutation) RemoveGitBotIDs(ids ...uuid.UUID) { + if m.removedgit_bots == nil { + m.removedgit_bots = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.git_bots, ids[i]) + m.removedgit_bots[ids[i]] = struct{}{} } - return *v, true } -// OldUpdatedAt returns the old "updated_at" field's value of the ProjectCollaborator entity. -// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectCollaboratorMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) +// RemovedGitBots returns the removed IDs of the "git_bots" edge to the GitBot entity. +func (m *ProjectMutation) RemovedGitBotsIDs() (ids []uuid.UUID) { + for id := range m.removedgit_bots { + ids = append(ids, id) } - return oldValue.UpdatedAt, nil + return } -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *ProjectCollaboratorMutation) ResetUpdatedAt() { - m.updated_at = nil +// GitBotsIDs returns the "git_bots" edge IDs in the mutation. +func (m *ProjectMutation) GitBotsIDs() (ids []uuid.UUID) { + for id := range m.git_bots { + ids = append(ids, id) + } + return } -// ClearUser clears the "user" edge to the User entity. -func (m *ProjectCollaboratorMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[projectcollaborator.FieldUserID] = struct{}{} +// ResetGitBots resets all changes to the "git_bots" edge. +func (m *ProjectMutation) ResetGitBots() { + m.git_bots = nil + m.clearedgit_bots = false + m.removedgit_bots = nil } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *ProjectCollaboratorMutation) UserCleared() bool { - return m.cleareduser +// AddProjectGitBotIDs adds the "project_git_bots" edge to the ProjectGitBot entity by ids. +func (m *ProjectMutation) AddProjectGitBotIDs(ids ...uuid.UUID) { + if m.project_git_bots == nil { + m.project_git_bots = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.project_git_bots[ids[i]] = struct{}{} + } } -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *ProjectCollaboratorMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { - ids = append(ids, *id) - } - return +// ClearProjectGitBots clears the "project_git_bots" edge to the ProjectGitBot entity. +func (m *ProjectMutation) ClearProjectGitBots() { + m.clearedproject_git_bots = true } -// ResetUser resets all changes to the "user" edge. -func (m *ProjectCollaboratorMutation) ResetUser() { - m.user = nil - m.cleareduser = false +// ProjectGitBotsCleared reports if the "project_git_bots" edge to the ProjectGitBot entity was cleared. +func (m *ProjectMutation) ProjectGitBotsCleared() bool { + return m.clearedproject_git_bots } -// ClearProject clears the "project" edge to the Project entity. -func (m *ProjectCollaboratorMutation) ClearProject() { - m.clearedproject = true - m.clearedFields[projectcollaborator.FieldProjectID] = struct{}{} +// RemoveProjectGitBotIDs removes the "project_git_bots" edge to the ProjectGitBot entity by IDs. +func (m *ProjectMutation) RemoveProjectGitBotIDs(ids ...uuid.UUID) { + if m.removedproject_git_bots == nil { + m.removedproject_git_bots = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.project_git_bots, ids[i]) + m.removedproject_git_bots[ids[i]] = struct{}{} + } } -// ProjectCleared reports if the "project" edge to the Project entity was cleared. -func (m *ProjectCollaboratorMutation) ProjectCleared() bool { - return m.clearedproject +// RemovedProjectGitBots returns the removed IDs of the "project_git_bots" edge to the ProjectGitBot entity. +func (m *ProjectMutation) RemovedProjectGitBotsIDs() (ids []uuid.UUID) { + for id := range m.removedproject_git_bots { + ids = append(ids, id) + } + return } -// ProjectIDs returns the "project" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ProjectID instead. It exists only for internal usage by the builders. -func (m *ProjectCollaboratorMutation) ProjectIDs() (ids []uuid.UUID) { - if id := m.project; id != nil { - ids = append(ids, *id) +// ProjectGitBotsIDs returns the "project_git_bots" edge IDs in the mutation. +func (m *ProjectMutation) ProjectGitBotsIDs() (ids []uuid.UUID) { + for id := range m.project_git_bots { + ids = append(ids, id) } return } -// ResetProject resets all changes to the "project" edge. -func (m *ProjectCollaboratorMutation) ResetProject() { - m.project = nil - m.clearedproject = false +// ResetProjectGitBots resets all changes to the "project_git_bots" edge. +func (m *ProjectMutation) ResetProjectGitBots() { + m.project_git_bots = nil + m.clearedproject_git_bots = false + m.removedproject_git_bots = nil } -// Where appends a list predicates to the ProjectCollaboratorMutation builder. -func (m *ProjectCollaboratorMutation) Where(ps ...predicate.ProjectCollaborator) { +// Where appends a list predicates to the ProjectMutation builder. +func (m *ProjectMutation) Where(ps ...predicate.Project) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ProjectCollaboratorMutation builder. Using this method, +// WhereP appends storage-level predicates to the ProjectMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ProjectCollaboratorMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.ProjectCollaborator, len(ps)) +func (m *ProjectMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Project, len(ps)) for i := range ps { p[i] = ps[i] } @@ -21109,42 +29759,60 @@ func (m *ProjectCollaboratorMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ProjectCollaboratorMutation) Op() Op { +func (m *ProjectMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ProjectCollaboratorMutation) SetOp(op Op) { +func (m *ProjectMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (ProjectCollaborator). -func (m *ProjectCollaboratorMutation) Type() string { +// Type returns the node type of this mutation (Project). +func (m *ProjectMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ProjectCollaboratorMutation) Fields() []string { - fields := make([]string, 0, 6) +func (m *ProjectMutation) Fields() []string { + fields := make([]string, 0, 12) if m.deleted_at != nil { - fields = append(fields, projectcollaborator.FieldDeletedAt) - } - if m.project != nil { - fields = append(fields, projectcollaborator.FieldProjectID) + fields = append(fields, project.FieldDeletedAt) } if m.user != nil { - fields = append(fields, projectcollaborator.FieldUserID) + fields = append(fields, project.FieldUserID) } - if m.role != nil { - fields = append(fields, projectcollaborator.FieldRole) + if m.name != nil { + fields = append(fields, project.FieldName) + } + if m.description != nil { + fields = append(fields, project.FieldDescription) + } + if m.platform != nil { + fields = append(fields, project.FieldPlatform) + } + if m.repo_url != nil { + fields = append(fields, project.FieldRepoURL) + } + if m.branch != nil { + fields = append(fields, project.FieldBranch) + } + if m.git_identity != nil { + fields = append(fields, project.FieldGitIdentityID) + } + if m.image != nil { + fields = append(fields, project.FieldImageID) + } + if m.env_variables != nil { + fields = append(fields, project.FieldEnvVariables) } if m.created_at != nil { - fields = append(fields, projectcollaborator.FieldCreatedAt) + fields = append(fields, project.FieldCreatedAt) } if m.updated_at != nil { - fields = append(fields, projectcollaborator.FieldUpdatedAt) + fields = append(fields, project.FieldUpdatedAt) } return fields } @@ -21152,19 +29820,31 @@ func (m *ProjectCollaboratorMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ProjectCollaboratorMutation) Field(name string) (ent.Value, bool) { +func (m *ProjectMutation) Field(name string) (ent.Value, bool) { switch name { - case projectcollaborator.FieldDeletedAt: + case project.FieldDeletedAt: return m.DeletedAt() - case projectcollaborator.FieldProjectID: - return m.ProjectID() - case projectcollaborator.FieldUserID: + case project.FieldUserID: return m.UserID() - case projectcollaborator.FieldRole: - return m.Role() - case projectcollaborator.FieldCreatedAt: + case project.FieldName: + return m.Name() + case project.FieldDescription: + return m.Description() + case project.FieldPlatform: + return m.Platform() + case project.FieldRepoURL: + return m.RepoURL() + case project.FieldBranch: + return m.Branch() + case project.FieldGitIdentityID: + return m.GitIdentityID() + case project.FieldImageID: + return m.ImageID() + case project.FieldEnvVariables: + return m.EnvVariables() + case project.FieldCreatedAt: return m.CreatedAt() - case projectcollaborator.FieldUpdatedAt: + case project.FieldUpdatedAt: return m.UpdatedAt() } return nil, false @@ -21173,65 +29853,119 @@ func (m *ProjectCollaboratorMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ProjectCollaboratorMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ProjectMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case projectcollaborator.FieldDeletedAt: + case project.FieldDeletedAt: return m.OldDeletedAt(ctx) - case projectcollaborator.FieldProjectID: - return m.OldProjectID(ctx) - case projectcollaborator.FieldUserID: + case project.FieldUserID: return m.OldUserID(ctx) - case projectcollaborator.FieldRole: - return m.OldRole(ctx) - case projectcollaborator.FieldCreatedAt: + case project.FieldName: + return m.OldName(ctx) + case project.FieldDescription: + return m.OldDescription(ctx) + case project.FieldPlatform: + return m.OldPlatform(ctx) + case project.FieldRepoURL: + return m.OldRepoURL(ctx) + case project.FieldBranch: + return m.OldBranch(ctx) + case project.FieldGitIdentityID: + return m.OldGitIdentityID(ctx) + case project.FieldImageID: + return m.OldImageID(ctx) + case project.FieldEnvVariables: + return m.OldEnvVariables(ctx) + case project.FieldCreatedAt: return m.OldCreatedAt(ctx) - case projectcollaborator.FieldUpdatedAt: + case project.FieldUpdatedAt: return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown ProjectCollaborator field %s", name) + return nil, fmt.Errorf("unknown Project field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectCollaboratorMutation) SetField(name string, value ent.Value) error { +func (m *ProjectMutation) SetField(name string, value ent.Value) error { switch name { - case projectcollaborator.FieldDeletedAt: + case project.FieldDeletedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDeletedAt(v) return nil - case projectcollaborator.FieldProjectID: + case project.FieldUserID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetProjectID(v) + m.SetUserID(v) return nil - case projectcollaborator.FieldUserID: + case project.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case project.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case project.FieldPlatform: + v, ok := value.(consts.GitPlatform) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPlatform(v) + return nil + case project.FieldRepoURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRepoURL(v) + return nil + case project.FieldBranch: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBranch(v) + return nil + case project.FieldGitIdentityID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) + m.SetGitIdentityID(v) return nil - case projectcollaborator.FieldRole: - v, ok := value.(consts.ProjectCollaboratorRole) + case project.FieldImageID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRole(v) + m.SetImageID(v) return nil - case projectcollaborator.FieldCreatedAt: + case project.FieldEnvVariables: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEnvVariables(v) + return nil + case project.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case projectcollaborator.FieldUpdatedAt: + case project.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) @@ -21239,205 +29973,418 @@ func (m *ProjectCollaboratorMutation) SetField(name string, value ent.Value) err m.SetUpdatedAt(v) return nil } - return fmt.Errorf("unknown ProjectCollaborator field %s", name) + return fmt.Errorf("unknown Project field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ProjectCollaboratorMutation) AddedFields() []string { +func (m *ProjectMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ProjectCollaboratorMutation) AddedField(name string) (ent.Value, bool) { +func (m *ProjectMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectCollaboratorMutation) AddField(name string, value ent.Value) error { +func (m *ProjectMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown ProjectCollaborator numeric field %s", name) + return fmt.Errorf("unknown Project numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ProjectCollaboratorMutation) ClearedFields() []string { +func (m *ProjectMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(projectcollaborator.FieldDeletedAt) { - fields = append(fields, projectcollaborator.FieldDeletedAt) + if m.FieldCleared(project.FieldDeletedAt) { + fields = append(fields, project.FieldDeletedAt) + } + if m.FieldCleared(project.FieldDescription) { + fields = append(fields, project.FieldDescription) + } + if m.FieldCleared(project.FieldPlatform) { + fields = append(fields, project.FieldPlatform) + } + if m.FieldCleared(project.FieldRepoURL) { + fields = append(fields, project.FieldRepoURL) + } + if m.FieldCleared(project.FieldBranch) { + fields = append(fields, project.FieldBranch) + } + if m.FieldCleared(project.FieldGitIdentityID) { + fields = append(fields, project.FieldGitIdentityID) + } + if m.FieldCleared(project.FieldImageID) { + fields = append(fields, project.FieldImageID) + } + if m.FieldCleared(project.FieldEnvVariables) { + fields = append(fields, project.FieldEnvVariables) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ProjectCollaboratorMutation) FieldCleared(name string) bool { +func (m *ProjectMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ProjectCollaboratorMutation) ClearField(name string) error { +func (m *ProjectMutation) ClearField(name string) error { switch name { - case projectcollaborator.FieldDeletedAt: + case project.FieldDeletedAt: m.ClearDeletedAt() return nil + case project.FieldDescription: + m.ClearDescription() + return nil + case project.FieldPlatform: + m.ClearPlatform() + return nil + case project.FieldRepoURL: + m.ClearRepoURL() + return nil + case project.FieldBranch: + m.ClearBranch() + return nil + case project.FieldGitIdentityID: + m.ClearGitIdentityID() + return nil + case project.FieldImageID: + m.ClearImageID() + return nil + case project.FieldEnvVariables: + m.ClearEnvVariables() + return nil } - return fmt.Errorf("unknown ProjectCollaborator nullable field %s", name) + return fmt.Errorf("unknown Project nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ProjectCollaboratorMutation) ResetField(name string) error { +func (m *ProjectMutation) ResetField(name string) error { switch name { - case projectcollaborator.FieldDeletedAt: + case project.FieldDeletedAt: m.ResetDeletedAt() return nil - case projectcollaborator.FieldProjectID: - m.ResetProjectID() - return nil - case projectcollaborator.FieldUserID: + case project.FieldUserID: m.ResetUserID() return nil - case projectcollaborator.FieldRole: - m.ResetRole() + case project.FieldName: + m.ResetName() return nil - case projectcollaborator.FieldCreatedAt: + case project.FieldDescription: + m.ResetDescription() + return nil + case project.FieldPlatform: + m.ResetPlatform() + return nil + case project.FieldRepoURL: + m.ResetRepoURL() + return nil + case project.FieldBranch: + m.ResetBranch() + return nil + case project.FieldGitIdentityID: + m.ResetGitIdentityID() + return nil + case project.FieldImageID: + m.ResetImageID() + return nil + case project.FieldEnvVariables: + m.ResetEnvVariables() + return nil + case project.FieldCreatedAt: m.ResetCreatedAt() return nil - case projectcollaborator.FieldUpdatedAt: + case project.FieldUpdatedAt: m.ResetUpdatedAt() return nil } - return fmt.Errorf("unknown ProjectCollaborator field %s", name) + return fmt.Errorf("unknown Project field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ProjectCollaboratorMutation) AddedEdges() []string { - edges := make([]string, 0, 2) +func (m *ProjectMutation) AddedEdges() []string { + edges := make([]string, 0, 8) if m.user != nil { - edges = append(edges, projectcollaborator.EdgeUser) + edges = append(edges, project.EdgeUser) } - if m.project != nil { - edges = append(edges, projectcollaborator.EdgeProject) + if m.git_identity != nil { + edges = append(edges, project.EdgeGitIdentity) + } + if m.image != nil { + edges = append(edges, project.EdgeImage) + } + if m.issues != nil { + edges = append(edges, project.EdgeIssues) + } + if m.collaborators != nil { + edges = append(edges, project.EdgeCollaborators) + } + if m.project_tasks != nil { + edges = append(edges, project.EdgeProjectTasks) + } + if m.git_bots != nil { + edges = append(edges, project.EdgeGitBots) + } + if m.project_git_bots != nil { + edges = append(edges, project.EdgeProjectGitBots) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ProjectCollaboratorMutation) AddedIDs(name string) []ent.Value { +func (m *ProjectMutation) AddedIDs(name string) []ent.Value { switch name { - case projectcollaborator.EdgeUser: + case project.EdgeUser: if id := m.user; id != nil { return []ent.Value{*id} } - case projectcollaborator.EdgeProject: - if id := m.project; id != nil { + case project.EdgeGitIdentity: + if id := m.git_identity; id != nil { return []ent.Value{*id} } + case project.EdgeImage: + if id := m.image; id != nil { + return []ent.Value{*id} + } + case project.EdgeIssues: + ids := make([]ent.Value, 0, len(m.issues)) + for id := range m.issues { + ids = append(ids, id) + } + return ids + case project.EdgeCollaborators: + ids := make([]ent.Value, 0, len(m.collaborators)) + for id := range m.collaborators { + ids = append(ids, id) + } + return ids + case project.EdgeProjectTasks: + ids := make([]ent.Value, 0, len(m.project_tasks)) + for id := range m.project_tasks { + ids = append(ids, id) + } + return ids + case project.EdgeGitBots: + ids := make([]ent.Value, 0, len(m.git_bots)) + for id := range m.git_bots { + ids = append(ids, id) + } + return ids + case project.EdgeProjectGitBots: + ids := make([]ent.Value, 0, len(m.project_git_bots)) + for id := range m.project_git_bots { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ProjectCollaboratorMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) +func (m *ProjectMutation) RemovedEdges() []string { + edges := make([]string, 0, 8) + if m.removedissues != nil { + edges = append(edges, project.EdgeIssues) + } + if m.removedcollaborators != nil { + edges = append(edges, project.EdgeCollaborators) + } + if m.removedproject_tasks != nil { + edges = append(edges, project.EdgeProjectTasks) + } + if m.removedgit_bots != nil { + edges = append(edges, project.EdgeGitBots) + } + if m.removedproject_git_bots != nil { + edges = append(edges, project.EdgeProjectGitBots) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ProjectCollaboratorMutation) RemovedIDs(name string) []ent.Value { +func (m *ProjectMutation) RemovedIDs(name string) []ent.Value { + switch name { + case project.EdgeIssues: + ids := make([]ent.Value, 0, len(m.removedissues)) + for id := range m.removedissues { + ids = append(ids, id) + } + return ids + case project.EdgeCollaborators: + ids := make([]ent.Value, 0, len(m.removedcollaborators)) + for id := range m.removedcollaborators { + ids = append(ids, id) + } + return ids + case project.EdgeProjectTasks: + ids := make([]ent.Value, 0, len(m.removedproject_tasks)) + for id := range m.removedproject_tasks { + ids = append(ids, id) + } + return ids + case project.EdgeGitBots: + ids := make([]ent.Value, 0, len(m.removedgit_bots)) + for id := range m.removedgit_bots { + ids = append(ids, id) + } + return ids + case project.EdgeProjectGitBots: + ids := make([]ent.Value, 0, len(m.removedproject_git_bots)) + for id := range m.removedproject_git_bots { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ProjectCollaboratorMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) +func (m *ProjectMutation) ClearedEdges() []string { + edges := make([]string, 0, 8) if m.cleareduser { - edges = append(edges, projectcollaborator.EdgeUser) + edges = append(edges, project.EdgeUser) } - if m.clearedproject { - edges = append(edges, projectcollaborator.EdgeProject) + if m.clearedgit_identity { + edges = append(edges, project.EdgeGitIdentity) + } + if m.clearedimage { + edges = append(edges, project.EdgeImage) + } + if m.clearedissues { + edges = append(edges, project.EdgeIssues) + } + if m.clearedcollaborators { + edges = append(edges, project.EdgeCollaborators) + } + if m.clearedproject_tasks { + edges = append(edges, project.EdgeProjectTasks) + } + if m.clearedgit_bots { + edges = append(edges, project.EdgeGitBots) + } + if m.clearedproject_git_bots { + edges = append(edges, project.EdgeProjectGitBots) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ProjectCollaboratorMutation) EdgeCleared(name string) bool { +func (m *ProjectMutation) EdgeCleared(name string) bool { switch name { - case projectcollaborator.EdgeUser: + case project.EdgeUser: return m.cleareduser - case projectcollaborator.EdgeProject: - return m.clearedproject + case project.EdgeGitIdentity: + return m.clearedgit_identity + case project.EdgeImage: + return m.clearedimage + case project.EdgeIssues: + return m.clearedissues + case project.EdgeCollaborators: + return m.clearedcollaborators + case project.EdgeProjectTasks: + return m.clearedproject_tasks + case project.EdgeGitBots: + return m.clearedgit_bots + case project.EdgeProjectGitBots: + return m.clearedproject_git_bots } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ProjectCollaboratorMutation) ClearEdge(name string) error { +func (m *ProjectMutation) ClearEdge(name string) error { switch name { - case projectcollaborator.EdgeUser: + case project.EdgeUser: m.ClearUser() return nil - case projectcollaborator.EdgeProject: - m.ClearProject() + case project.EdgeGitIdentity: + m.ClearGitIdentity() + return nil + case project.EdgeImage: + m.ClearImage() return nil } - return fmt.Errorf("unknown ProjectCollaborator unique edge %s", name) + return fmt.Errorf("unknown Project unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ProjectCollaboratorMutation) ResetEdge(name string) error { +func (m *ProjectMutation) ResetEdge(name string) error { switch name { - case projectcollaborator.EdgeUser: + case project.EdgeUser: m.ResetUser() return nil - case projectcollaborator.EdgeProject: - m.ResetProject() + case project.EdgeGitIdentity: + m.ResetGitIdentity() + return nil + case project.EdgeImage: + m.ResetImage() + return nil + case project.EdgeIssues: + m.ResetIssues() + return nil + case project.EdgeCollaborators: + m.ResetCollaborators() + return nil + case project.EdgeProjectTasks: + m.ResetProjectTasks() + return nil + case project.EdgeGitBots: + m.ResetGitBots() + return nil + case project.EdgeProjectGitBots: + m.ResetProjectGitBots() return nil } - return fmt.Errorf("unknown ProjectCollaborator edge %s", name) + return fmt.Errorf("unknown Project edge %s", name) } -// ProjectGitBotMutation represents an operation that mutates the ProjectGitBot nodes in the graph. -type ProjectGitBotMutation struct { +// ProjectCollaboratorMutation represents an operation that mutates the ProjectCollaborator nodes in the graph. +type ProjectCollaboratorMutation struct { config op Op typ string id *uuid.UUID + deleted_at *time.Time + role *consts.ProjectCollaboratorRole created_at *time.Time + updated_at *time.Time clearedFields map[string]struct{} + user *uuid.UUID + cleareduser bool project *uuid.UUID clearedproject bool - git_bot *uuid.UUID - clearedgit_bot bool done bool - oldValue func(context.Context) (*ProjectGitBot, error) - predicates []predicate.ProjectGitBot + oldValue func(context.Context) (*ProjectCollaborator, error) + predicates []predicate.ProjectCollaborator } -var _ ent.Mutation = (*ProjectGitBotMutation)(nil) +var _ ent.Mutation = (*ProjectCollaboratorMutation)(nil) -// projectgitbotOption allows management of the mutation configuration using functional options. -type projectgitbotOption func(*ProjectGitBotMutation) +// projectcollaboratorOption allows management of the mutation configuration using functional options. +type projectcollaboratorOption func(*ProjectCollaboratorMutation) -// newProjectGitBotMutation creates new mutation for the ProjectGitBot entity. -func newProjectGitBotMutation(c config, op Op, opts ...projectgitbotOption) *ProjectGitBotMutation { - m := &ProjectGitBotMutation{ +// newProjectCollaboratorMutation creates new mutation for the ProjectCollaborator entity. +func newProjectCollaboratorMutation(c config, op Op, opts ...projectcollaboratorOption) *ProjectCollaboratorMutation { + m := &ProjectCollaboratorMutation{ config: c, op: op, - typ: TypeProjectGitBot, + typ: TypeProjectCollaborator, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -21446,20 +30393,20 @@ func newProjectGitBotMutation(c config, op Op, opts ...projectgitbotOption) *Pro return m } -// withProjectGitBotID sets the ID field of the mutation. -func withProjectGitBotID(id uuid.UUID) projectgitbotOption { - return func(m *ProjectGitBotMutation) { +// withProjectCollaboratorID sets the ID field of the mutation. +func withProjectCollaboratorID(id uuid.UUID) projectcollaboratorOption { + return func(m *ProjectCollaboratorMutation) { var ( err error once sync.Once - value *ProjectGitBot + value *ProjectCollaborator ) - m.oldValue = func(ctx context.Context) (*ProjectGitBot, error) { + m.oldValue = func(ctx context.Context) (*ProjectCollaborator, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().ProjectGitBot.Get(ctx, id) + value, err = m.Client().ProjectCollaborator.Get(ctx, id) } }) return value, err @@ -21468,10 +30415,10 @@ func withProjectGitBotID(id uuid.UUID) projectgitbotOption { } } -// withProjectGitBot sets the old ProjectGitBot of the mutation. -func withProjectGitBot(node *ProjectGitBot) projectgitbotOption { - return func(m *ProjectGitBotMutation) { - m.oldValue = func(context.Context) (*ProjectGitBot, error) { +// withProjectCollaborator sets the old ProjectCollaborator of the mutation. +func withProjectCollaborator(node *ProjectCollaborator) projectcollaboratorOption { + return func(m *ProjectCollaboratorMutation) { + m.oldValue = func(context.Context) (*ProjectCollaborator, error) { return node, nil } m.id = &node.ID @@ -21480,7 +30427,7 @@ func withProjectGitBot(node *ProjectGitBot) projectgitbotOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ProjectGitBotMutation) Client() *Client { +func (m ProjectCollaboratorMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -21488,7 +30435,7 @@ func (m ProjectGitBotMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ProjectGitBotMutation) Tx() (*Tx, error) { +func (m ProjectCollaboratorMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -21498,14 +30445,14 @@ func (m ProjectGitBotMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of ProjectGitBot entities. -func (m *ProjectGitBotMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of ProjectCollaborator entities. +func (m *ProjectCollaboratorMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ProjectGitBotMutation) ID() (id uuid.UUID, exists bool) { +func (m *ProjectCollaboratorMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -21516,7 +30463,7 @@ func (m *ProjectGitBotMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ProjectGitBotMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *ProjectCollaboratorMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -21525,19 +30472,68 @@ func (m *ProjectGitBotMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().ProjectGitBot.Query().Where(m.predicates...).IDs(ctx) + return m.Client().ProjectCollaborator.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } +// SetDeletedAt sets the "deleted_at" field. +func (m *ProjectCollaboratorMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *ProjectCollaboratorMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the ProjectCollaborator entity. +// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectCollaboratorMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *ProjectCollaboratorMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[projectcollaborator.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *ProjectCollaboratorMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[projectcollaborator.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *ProjectCollaboratorMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, projectcollaborator.FieldDeletedAt) +} + // SetProjectID sets the "project_id" field. -func (m *ProjectGitBotMutation) SetProjectID(u uuid.UUID) { +func (m *ProjectCollaboratorMutation) SetProjectID(u uuid.UUID) { m.project = &u } // ProjectID returns the value of the "project_id" field in the mutation. -func (m *ProjectGitBotMutation) ProjectID() (r uuid.UUID, exists bool) { +func (m *ProjectCollaboratorMutation) ProjectID() (r uuid.UUID, exists bool) { v := m.project if v == nil { return @@ -21545,10 +30541,10 @@ func (m *ProjectGitBotMutation) ProjectID() (r uuid.UUID, exists bool) { return *v, true } -// OldProjectID returns the old "project_id" field's value of the ProjectGitBot entity. -// If the ProjectGitBot object wasn't provided to the builder, the object is fetched from the database. +// OldProjectID returns the old "project_id" field's value of the ProjectCollaborator entity. +// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectGitBotMutation) OldProjectID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ProjectCollaboratorMutation) OldProjectID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldProjectID is only allowed on UpdateOne operations") } @@ -21563,53 +30559,89 @@ func (m *ProjectGitBotMutation) OldProjectID(ctx context.Context) (v uuid.UUID, } // ResetProjectID resets all changes to the "project_id" field. -func (m *ProjectGitBotMutation) ResetProjectID() { +func (m *ProjectCollaboratorMutation) ResetProjectID() { m.project = nil } -// SetGitBotID sets the "git_bot_id" field. -func (m *ProjectGitBotMutation) SetGitBotID(u uuid.UUID) { - m.git_bot = &u +// SetUserID sets the "user_id" field. +func (m *ProjectCollaboratorMutation) SetUserID(u uuid.UUID) { + m.user = &u } -// GitBotID returns the value of the "git_bot_id" field in the mutation. -func (m *ProjectGitBotMutation) GitBotID() (r uuid.UUID, exists bool) { - v := m.git_bot +// UserID returns the value of the "user_id" field in the mutation. +func (m *ProjectCollaboratorMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user if v == nil { return } return *v, true } -// OldGitBotID returns the old "git_bot_id" field's value of the ProjectGitBot entity. -// If the ProjectGitBot object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the ProjectCollaborator entity. +// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectGitBotMutation) OldGitBotID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ProjectCollaboratorMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldGitBotID is only allowed on UpdateOne operations") + return v, errors.New("OldUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldGitBotID requires an ID field in the mutation") + return v, errors.New("OldUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldGitBotID: %w", err) + return v, fmt.Errorf("querying old value for OldUserID: %w", err) } - return oldValue.GitBotID, nil + return oldValue.UserID, nil } -// ResetGitBotID resets all changes to the "git_bot_id" field. -func (m *ProjectGitBotMutation) ResetGitBotID() { - m.git_bot = nil +// ResetUserID resets all changes to the "user_id" field. +func (m *ProjectCollaboratorMutation) ResetUserID() { + m.user = nil +} + +// SetRole sets the "role" field. +func (m *ProjectCollaboratorMutation) SetRole(ccr consts.ProjectCollaboratorRole) { + m.role = &ccr +} + +// Role returns the value of the "role" field in the mutation. +func (m *ProjectCollaboratorMutation) Role() (r consts.ProjectCollaboratorRole, exists bool) { + v := m.role + if v == nil { + return + } + return *v, true +} + +// OldRole returns the old "role" field's value of the ProjectCollaborator entity. +// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectCollaboratorMutation) OldRole(ctx context.Context) (v consts.ProjectCollaboratorRole, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRole is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRole requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRole: %w", err) + } + return oldValue.Role, nil +} + +// ResetRole resets all changes to the "role" field. +func (m *ProjectCollaboratorMutation) ResetRole() { + m.role = nil } // SetCreatedAt sets the "created_at" field. -func (m *ProjectGitBotMutation) SetCreatedAt(t time.Time) { +func (m *ProjectCollaboratorMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ProjectGitBotMutation) CreatedAt() (r time.Time, exists bool) { +func (m *ProjectCollaboratorMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -21617,10 +30649,10 @@ func (m *ProjectGitBotMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the ProjectGitBot entity. -// If the ProjectGitBot object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the ProjectCollaborator entity. +// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectGitBotMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectCollaboratorMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -21635,73 +30667,109 @@ func (m *ProjectGitBotMutation) OldCreatedAt(ctx context.Context) (v time.Time, } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *ProjectGitBotMutation) ResetCreatedAt() { +func (m *ProjectCollaboratorMutation) ResetCreatedAt() { m.created_at = nil } -// ClearProject clears the "project" edge to the Project entity. -func (m *ProjectGitBotMutation) ClearProject() { - m.clearedproject = true - m.clearedFields[projectgitbot.FieldProjectID] = struct{}{} +// SetUpdatedAt sets the "updated_at" field. +func (m *ProjectCollaboratorMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t } -// ProjectCleared reports if the "project" edge to the Project entity was cleared. -func (m *ProjectGitBotMutation) ProjectCleared() bool { - return m.clearedproject +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ProjectCollaboratorMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true } -// ProjectIDs returns the "project" edge IDs in the mutation. +// OldUpdatedAt returns the old "updated_at" field's value of the ProjectCollaborator entity. +// If the ProjectCollaborator object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectCollaboratorMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ProjectCollaboratorMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// ClearUser clears the "user" edge to the User entity. +func (m *ProjectCollaboratorMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[projectcollaborator.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *ProjectCollaboratorMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ProjectID instead. It exists only for internal usage by the builders. -func (m *ProjectGitBotMutation) ProjectIDs() (ids []uuid.UUID) { - if id := m.project; id != nil { +// UserID instead. It exists only for internal usage by the builders. +func (m *ProjectCollaboratorMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { ids = append(ids, *id) } return } -// ResetProject resets all changes to the "project" edge. -func (m *ProjectGitBotMutation) ResetProject() { - m.project = nil - m.clearedproject = false +// ResetUser resets all changes to the "user" edge. +func (m *ProjectCollaboratorMutation) ResetUser() { + m.user = nil + m.cleareduser = false } -// ClearGitBot clears the "git_bot" edge to the GitBot entity. -func (m *ProjectGitBotMutation) ClearGitBot() { - m.clearedgit_bot = true - m.clearedFields[projectgitbot.FieldGitBotID] = struct{}{} +// ClearProject clears the "project" edge to the Project entity. +func (m *ProjectCollaboratorMutation) ClearProject() { + m.clearedproject = true + m.clearedFields[projectcollaborator.FieldProjectID] = struct{}{} } -// GitBotCleared reports if the "git_bot" edge to the GitBot entity was cleared. -func (m *ProjectGitBotMutation) GitBotCleared() bool { - return m.clearedgit_bot +// ProjectCleared reports if the "project" edge to the Project entity was cleared. +func (m *ProjectCollaboratorMutation) ProjectCleared() bool { + return m.clearedproject } -// GitBotIDs returns the "git_bot" edge IDs in the mutation. +// ProjectIDs returns the "project" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// GitBotID instead. It exists only for internal usage by the builders. -func (m *ProjectGitBotMutation) GitBotIDs() (ids []uuid.UUID) { - if id := m.git_bot; id != nil { +// ProjectID instead. It exists only for internal usage by the builders. +func (m *ProjectCollaboratorMutation) ProjectIDs() (ids []uuid.UUID) { + if id := m.project; id != nil { ids = append(ids, *id) } return } -// ResetGitBot resets all changes to the "git_bot" edge. -func (m *ProjectGitBotMutation) ResetGitBot() { - m.git_bot = nil - m.clearedgit_bot = false +// ResetProject resets all changes to the "project" edge. +func (m *ProjectCollaboratorMutation) ResetProject() { + m.project = nil + m.clearedproject = false } -// Where appends a list predicates to the ProjectGitBotMutation builder. -func (m *ProjectGitBotMutation) Where(ps ...predicate.ProjectGitBot) { +// Where appends a list predicates to the ProjectCollaboratorMutation builder. +func (m *ProjectCollaboratorMutation) Where(ps ...predicate.ProjectCollaborator) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ProjectGitBotMutation builder. Using this method, +// WhereP appends storage-level predicates to the ProjectCollaboratorMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ProjectGitBotMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.ProjectGitBot, len(ps)) +func (m *ProjectCollaboratorMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ProjectCollaborator, len(ps)) for i := range ps { p[i] = ps[i] } @@ -21709,33 +30777,42 @@ func (m *ProjectGitBotMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ProjectGitBotMutation) Op() Op { +func (m *ProjectCollaboratorMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ProjectGitBotMutation) SetOp(op Op) { +func (m *ProjectCollaboratorMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (ProjectGitBot). -func (m *ProjectGitBotMutation) Type() string { +// Type returns the node type of this mutation (ProjectCollaborator). +func (m *ProjectCollaboratorMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ProjectGitBotMutation) Fields() []string { - fields := make([]string, 0, 3) +func (m *ProjectCollaboratorMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.deleted_at != nil { + fields = append(fields, projectcollaborator.FieldDeletedAt) + } if m.project != nil { - fields = append(fields, projectgitbot.FieldProjectID) + fields = append(fields, projectcollaborator.FieldProjectID) } - if m.git_bot != nil { - fields = append(fields, projectgitbot.FieldGitBotID) + if m.user != nil { + fields = append(fields, projectcollaborator.FieldUserID) + } + if m.role != nil { + fields = append(fields, projectcollaborator.FieldRole) } if m.created_at != nil { - fields = append(fields, projectgitbot.FieldCreatedAt) + fields = append(fields, projectcollaborator.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, projectcollaborator.FieldUpdatedAt) } return fields } @@ -21743,14 +30820,20 @@ func (m *ProjectGitBotMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ProjectGitBotMutation) Field(name string) (ent.Value, bool) { +func (m *ProjectCollaboratorMutation) Field(name string) (ent.Value, bool) { switch name { - case projectgitbot.FieldProjectID: + case projectcollaborator.FieldDeletedAt: + return m.DeletedAt() + case projectcollaborator.FieldProjectID: return m.ProjectID() - case projectgitbot.FieldGitBotID: - return m.GitBotID() - case projectgitbot.FieldCreatedAt: + case projectcollaborator.FieldUserID: + return m.UserID() + case projectcollaborator.FieldRole: + return m.Role() + case projectcollaborator.FieldCreatedAt: return m.CreatedAt() + case projectcollaborator.FieldUpdatedAt: + return m.UpdatedAt() } return nil, false } @@ -21758,128 +30841,173 @@ func (m *ProjectGitBotMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ProjectGitBotMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ProjectCollaboratorMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case projectgitbot.FieldProjectID: + case projectcollaborator.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case projectcollaborator.FieldProjectID: return m.OldProjectID(ctx) - case projectgitbot.FieldGitBotID: - return m.OldGitBotID(ctx) - case projectgitbot.FieldCreatedAt: + case projectcollaborator.FieldUserID: + return m.OldUserID(ctx) + case projectcollaborator.FieldRole: + return m.OldRole(ctx) + case projectcollaborator.FieldCreatedAt: return m.OldCreatedAt(ctx) + case projectcollaborator.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown ProjectGitBot field %s", name) + return nil, fmt.Errorf("unknown ProjectCollaborator field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectGitBotMutation) SetField(name string, value ent.Value) error { +func (m *ProjectCollaboratorMutation) SetField(name string, value ent.Value) error { switch name { - case projectgitbot.FieldProjectID: + case projectcollaborator.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case projectcollaborator.FieldProjectID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetProjectID(v) return nil - case projectgitbot.FieldGitBotID: + case projectcollaborator.FieldUserID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetGitBotID(v) + m.SetUserID(v) return nil - case projectgitbot.FieldCreatedAt: + case projectcollaborator.FieldRole: + v, ok := value.(consts.ProjectCollaboratorRole) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRole(v) + return nil + case projectcollaborator.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil + case projectcollaborator.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil } - return fmt.Errorf("unknown ProjectGitBot field %s", name) + return fmt.Errorf("unknown ProjectCollaborator field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ProjectGitBotMutation) AddedFields() []string { +func (m *ProjectCollaboratorMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ProjectGitBotMutation) AddedField(name string) (ent.Value, bool) { +func (m *ProjectCollaboratorMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectGitBotMutation) AddField(name string, value ent.Value) error { +func (m *ProjectCollaboratorMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown ProjectGitBot numeric field %s", name) + return fmt.Errorf("unknown ProjectCollaborator numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ProjectGitBotMutation) ClearedFields() []string { - return nil +func (m *ProjectCollaboratorMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(projectcollaborator.FieldDeletedAt) { + fields = append(fields, projectcollaborator.FieldDeletedAt) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ProjectGitBotMutation) FieldCleared(name string) bool { +func (m *ProjectCollaboratorMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ProjectGitBotMutation) ClearField(name string) error { - return fmt.Errorf("unknown ProjectGitBot nullable field %s", name) +func (m *ProjectCollaboratorMutation) ClearField(name string) error { + switch name { + case projectcollaborator.FieldDeletedAt: + m.ClearDeletedAt() + return nil + } + return fmt.Errorf("unknown ProjectCollaborator nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ProjectGitBotMutation) ResetField(name string) error { +func (m *ProjectCollaboratorMutation) ResetField(name string) error { switch name { - case projectgitbot.FieldProjectID: + case projectcollaborator.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case projectcollaborator.FieldProjectID: m.ResetProjectID() return nil - case projectgitbot.FieldGitBotID: - m.ResetGitBotID() + case projectcollaborator.FieldUserID: + m.ResetUserID() return nil - case projectgitbot.FieldCreatedAt: + case projectcollaborator.FieldRole: + m.ResetRole() + return nil + case projectcollaborator.FieldCreatedAt: m.ResetCreatedAt() return nil + case projectcollaborator.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil } - return fmt.Errorf("unknown ProjectGitBot field %s", name) + return fmt.Errorf("unknown ProjectCollaborator field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ProjectGitBotMutation) AddedEdges() []string { +func (m *ProjectCollaboratorMutation) AddedEdges() []string { edges := make([]string, 0, 2) - if m.project != nil { - edges = append(edges, projectgitbot.EdgeProject) + if m.user != nil { + edges = append(edges, projectcollaborator.EdgeUser) } - if m.git_bot != nil { - edges = append(edges, projectgitbot.EdgeGitBot) + if m.project != nil { + edges = append(edges, projectcollaborator.EdgeProject) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ProjectGitBotMutation) AddedIDs(name string) []ent.Value { +func (m *ProjectCollaboratorMutation) AddedIDs(name string) []ent.Value { switch name { - case projectgitbot.EdgeProject: - if id := m.project; id != nil { + case projectcollaborator.EdgeUser: + if id := m.user; id != nil { return []ent.Value{*id} } - case projectgitbot.EdgeGitBot: - if id := m.git_bot; id != nil { + case projectcollaborator.EdgeProject: + if id := m.project; id != nil { return []ent.Value{*id} } } @@ -21887,659 +31015,269 @@ func (m *ProjectGitBotMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ProjectGitBotMutation) RemovedEdges() []string { +func (m *ProjectCollaboratorMutation) RemovedEdges() []string { edges := make([]string, 0, 2) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ProjectGitBotMutation) RemovedIDs(name string) []ent.Value { +func (m *ProjectCollaboratorMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ProjectGitBotMutation) ClearedEdges() []string { +func (m *ProjectCollaboratorMutation) ClearedEdges() []string { edges := make([]string, 0, 2) - if m.clearedproject { - edges = append(edges, projectgitbot.EdgeProject) + if m.cleareduser { + edges = append(edges, projectcollaborator.EdgeUser) } - if m.clearedgit_bot { - edges = append(edges, projectgitbot.EdgeGitBot) + if m.clearedproject { + edges = append(edges, projectcollaborator.EdgeProject) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ProjectGitBotMutation) EdgeCleared(name string) bool { +func (m *ProjectCollaboratorMutation) EdgeCleared(name string) bool { switch name { - case projectgitbot.EdgeProject: + case projectcollaborator.EdgeUser: + return m.cleareduser + case projectcollaborator.EdgeProject: return m.clearedproject - case projectgitbot.EdgeGitBot: - return m.clearedgit_bot } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ProjectGitBotMutation) ClearEdge(name string) error { +func (m *ProjectCollaboratorMutation) ClearEdge(name string) error { switch name { - case projectgitbot.EdgeProject: - m.ClearProject() + case projectcollaborator.EdgeUser: + m.ClearUser() return nil - case projectgitbot.EdgeGitBot: - m.ClearGitBot() + case projectcollaborator.EdgeProject: + m.ClearProject() return nil } - return fmt.Errorf("unknown ProjectGitBot unique edge %s", name) + return fmt.Errorf("unknown ProjectCollaborator unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ProjectGitBotMutation) ResetEdge(name string) error { +func (m *ProjectCollaboratorMutation) ResetEdge(name string) error { switch name { - case projectgitbot.EdgeProject: - m.ResetProject() - return nil - case projectgitbot.EdgeGitBot: - m.ResetGitBot() + case projectcollaborator.EdgeUser: + m.ResetUser() + return nil + case projectcollaborator.EdgeProject: + m.ResetProject() return nil } - return fmt.Errorf("unknown ProjectGitBot edge %s", name) -} - -// ProjectIssueMutation represents an operation that mutates the ProjectIssue nodes in the graph. -type ProjectIssueMutation struct { - config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - status *consts.ProjectIssueStatus - title *string - requirement_document *string - design_document *string - summary *string - priority *consts.ProjectIssuePriority - addpriority *consts.ProjectIssuePriority - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - user *uuid.UUID - cleareduser bool - assignee *uuid.UUID - clearedassignee bool - project *uuid.UUID - clearedproject bool - comments map[uuid.UUID]struct{} - removedcomments map[uuid.UUID]struct{} - clearedcomments bool - project_tasks map[uuid.UUID]struct{} - removedproject_tasks map[uuid.UUID]struct{} - clearedproject_tasks bool - done bool - oldValue func(context.Context) (*ProjectIssue, error) - predicates []predicate.ProjectIssue -} - -var _ ent.Mutation = (*ProjectIssueMutation)(nil) - -// projectissueOption allows management of the mutation configuration using functional options. -type projectissueOption func(*ProjectIssueMutation) - -// newProjectIssueMutation creates new mutation for the ProjectIssue entity. -func newProjectIssueMutation(c config, op Op, opts ...projectissueOption) *ProjectIssueMutation { - m := &ProjectIssueMutation{ - config: c, - op: op, - typ: TypeProjectIssue, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withProjectIssueID sets the ID field of the mutation. -func withProjectIssueID(id uuid.UUID) projectissueOption { - return func(m *ProjectIssueMutation) { - var ( - err error - once sync.Once - value *ProjectIssue - ) - m.oldValue = func(ctx context.Context) (*ProjectIssue, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().ProjectIssue.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withProjectIssue sets the old ProjectIssue of the mutation. -func withProjectIssue(node *ProjectIssue) projectissueOption { - return func(m *ProjectIssueMutation) { - m.oldValue = func(context.Context) (*ProjectIssue, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m ProjectIssueMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m ProjectIssueMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("db: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of ProjectIssue entities. -func (m *ProjectIssueMutation) SetID(id uuid.UUID) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *ProjectIssueMutation) ID() (id uuid.UUID, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *ProjectIssueMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []uuid.UUID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().ProjectIssue.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetDeletedAt sets the "deleted_at" field. -func (m *ProjectIssueMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t -} - -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *ProjectIssueMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at - if v == nil { - return - } - return *v, true -} - -// OldDeletedAt returns the old "deleted_at" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) - } - return oldValue.DeletedAt, nil -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *ProjectIssueMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[projectissue.FieldDeletedAt] = struct{}{} -} - -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *ProjectIssueMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[projectissue.FieldDeletedAt] - return ok -} - -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *ProjectIssueMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, projectissue.FieldDeletedAt) -} - -// SetUserID sets the "user_id" field. -func (m *ProjectIssueMutation) SetUserID(u uuid.UUID) { - m.user = &u -} - -// UserID returns the value of the "user_id" field in the mutation. -func (m *ProjectIssueMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user - if v == nil { - return - } - return *v, true -} - -// OldUserID returns the old "user_id" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) - } - return oldValue.UserID, nil -} - -// ResetUserID resets all changes to the "user_id" field. -func (m *ProjectIssueMutation) ResetUserID() { - m.user = nil -} - -// SetProjectID sets the "project_id" field. -func (m *ProjectIssueMutation) SetProjectID(u uuid.UUID) { - m.project = &u -} - -// ProjectID returns the value of the "project_id" field in the mutation. -func (m *ProjectIssueMutation) ProjectID() (r uuid.UUID, exists bool) { - v := m.project - if v == nil { - return - } - return *v, true -} - -// OldProjectID returns the old "project_id" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldProjectID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProjectID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProjectID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldProjectID: %w", err) - } - return oldValue.ProjectID, nil -} - -// ResetProjectID resets all changes to the "project_id" field. -func (m *ProjectIssueMutation) ResetProjectID() { - m.project = nil -} - -// SetStatus sets the "status" field. -func (m *ProjectIssueMutation) SetStatus(cis consts.ProjectIssueStatus) { - m.status = &cis -} - -// Status returns the value of the "status" field in the mutation. -func (m *ProjectIssueMutation) Status() (r consts.ProjectIssueStatus, exists bool) { - v := m.status - if v == nil { - return - } - return *v, true -} - -// OldStatus returns the old "status" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldStatus(ctx context.Context) (v consts.ProjectIssueStatus, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) - } - return oldValue.Status, nil -} - -// ResetStatus resets all changes to the "status" field. -func (m *ProjectIssueMutation) ResetStatus() { - m.status = nil -} - -// SetTitle sets the "title" field. -func (m *ProjectIssueMutation) SetTitle(s string) { - m.title = &s -} - -// Title returns the value of the "title" field in the mutation. -func (m *ProjectIssueMutation) Title() (r string, exists bool) { - v := m.title - if v == nil { - return - } - return *v, true -} - -// OldTitle returns the old "title" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldTitle(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTitle is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTitle requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTitle: %w", err) - } - return oldValue.Title, nil -} - -// ResetTitle resets all changes to the "title" field. -func (m *ProjectIssueMutation) ResetTitle() { - m.title = nil -} - -// SetRequirementDocument sets the "requirement_document" field. -func (m *ProjectIssueMutation) SetRequirementDocument(s string) { - m.requirement_document = &s -} - -// RequirementDocument returns the value of the "requirement_document" field in the mutation. -func (m *ProjectIssueMutation) RequirementDocument() (r string, exists bool) { - v := m.requirement_document - if v == nil { - return - } - return *v, true -} - -// OldRequirementDocument returns the old "requirement_document" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldRequirementDocument(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRequirementDocument is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRequirementDocument requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRequirementDocument: %w", err) - } - return oldValue.RequirementDocument, nil -} - -// ClearRequirementDocument clears the value of the "requirement_document" field. -func (m *ProjectIssueMutation) ClearRequirementDocument() { - m.requirement_document = nil - m.clearedFields[projectissue.FieldRequirementDocument] = struct{}{} + return fmt.Errorf("unknown ProjectCollaborator edge %s", name) } -// RequirementDocumentCleared returns if the "requirement_document" field was cleared in this mutation. -func (m *ProjectIssueMutation) RequirementDocumentCleared() bool { - _, ok := m.clearedFields[projectissue.FieldRequirementDocument] - return ok +// ProjectGitBotMutation represents an operation that mutates the ProjectGitBot nodes in the graph. +type ProjectGitBotMutation struct { + config + op Op + typ string + id *uuid.UUID + created_at *time.Time + clearedFields map[string]struct{} + project *uuid.UUID + clearedproject bool + git_bot *uuid.UUID + clearedgit_bot bool + done bool + oldValue func(context.Context) (*ProjectGitBot, error) + predicates []predicate.ProjectGitBot } -// ResetRequirementDocument resets all changes to the "requirement_document" field. -func (m *ProjectIssueMutation) ResetRequirementDocument() { - m.requirement_document = nil - delete(m.clearedFields, projectissue.FieldRequirementDocument) -} +var _ ent.Mutation = (*ProjectGitBotMutation)(nil) -// SetDesignDocument sets the "design_document" field. -func (m *ProjectIssueMutation) SetDesignDocument(s string) { - m.design_document = &s -} +// projectgitbotOption allows management of the mutation configuration using functional options. +type projectgitbotOption func(*ProjectGitBotMutation) -// DesignDocument returns the value of the "design_document" field in the mutation. -func (m *ProjectIssueMutation) DesignDocument() (r string, exists bool) { - v := m.design_document - if v == nil { - return +// newProjectGitBotMutation creates new mutation for the ProjectGitBot entity. +func newProjectGitBotMutation(c config, op Op, opts ...projectgitbotOption) *ProjectGitBotMutation { + m := &ProjectGitBotMutation{ + config: c, + op: op, + typ: TypeProjectGitBot, + clearedFields: make(map[string]struct{}), } - return *v, true + for _, opt := range opts { + opt(m) + } + return m } -// OldDesignDocument returns the old "design_document" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldDesignDocument(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDesignDocument is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDesignDocument requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDesignDocument: %w", err) +// withProjectGitBotID sets the ID field of the mutation. +func withProjectGitBotID(id uuid.UUID) projectgitbotOption { + return func(m *ProjectGitBotMutation) { + var ( + err error + once sync.Once + value *ProjectGitBot + ) + m.oldValue = func(ctx context.Context) (*ProjectGitBot, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ProjectGitBot.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } - return oldValue.DesignDocument, nil } -// ClearDesignDocument clears the value of the "design_document" field. -func (m *ProjectIssueMutation) ClearDesignDocument() { - m.design_document = nil - m.clearedFields[projectissue.FieldDesignDocument] = struct{}{} +// withProjectGitBot sets the old ProjectGitBot of the mutation. +func withProjectGitBot(node *ProjectGitBot) projectgitbotOption { + return func(m *ProjectGitBotMutation) { + m.oldValue = func(context.Context) (*ProjectGitBot, error) { + return node, nil + } + m.id = &node.ID + } } -// DesignDocumentCleared returns if the "design_document" field was cleared in this mutation. -func (m *ProjectIssueMutation) DesignDocumentCleared() bool { - _, ok := m.clearedFields[projectissue.FieldDesignDocument] - return ok +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ProjectGitBotMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// ResetDesignDocument resets all changes to the "design_document" field. -func (m *ProjectIssueMutation) ResetDesignDocument() { - m.design_document = nil - delete(m.clearedFields, projectissue.FieldDesignDocument) +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ProjectGitBotMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// SetSummary sets the "summary" field. -func (m *ProjectIssueMutation) SetSummary(s string) { - m.summary = &s +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of ProjectGitBot entities. +func (m *ProjectGitBotMutation) SetID(id uuid.UUID) { + m.id = &id } -// Summary returns the value of the "summary" field in the mutation. -func (m *ProjectIssueMutation) Summary() (r string, exists bool) { - v := m.summary - if v == nil { +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ProjectGitBotMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { return } - return *v, true + return *m.id, true } -// OldSummary returns the old "summary" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldSummary(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSummary is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSummary requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSummary: %w", err) +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ProjectGitBotMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().ProjectGitBot.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } - return oldValue.Summary, nil -} - -// ClearSummary clears the value of the "summary" field. -func (m *ProjectIssueMutation) ClearSummary() { - m.summary = nil - m.clearedFields[projectissue.FieldSummary] = struct{}{} -} - -// SummaryCleared returns if the "summary" field was cleared in this mutation. -func (m *ProjectIssueMutation) SummaryCleared() bool { - _, ok := m.clearedFields[projectissue.FieldSummary] - return ok -} - -// ResetSummary resets all changes to the "summary" field. -func (m *ProjectIssueMutation) ResetSummary() { - m.summary = nil - delete(m.clearedFields, projectissue.FieldSummary) } -// SetAssigneeID sets the "assignee_id" field. -func (m *ProjectIssueMutation) SetAssigneeID(u uuid.UUID) { - m.assignee = &u +// SetProjectID sets the "project_id" field. +func (m *ProjectGitBotMutation) SetProjectID(u uuid.UUID) { + m.project = &u } -// AssigneeID returns the value of the "assignee_id" field in the mutation. -func (m *ProjectIssueMutation) AssigneeID() (r uuid.UUID, exists bool) { - v := m.assignee +// ProjectID returns the value of the "project_id" field in the mutation. +func (m *ProjectGitBotMutation) ProjectID() (r uuid.UUID, exists bool) { + v := m.project if v == nil { return } return *v, true } -// OldAssigneeID returns the old "assignee_id" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. +// OldProjectID returns the old "project_id" field's value of the ProjectGitBot entity. +// If the ProjectGitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldAssigneeID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ProjectGitBotMutation) OldProjectID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAssigneeID is only allowed on UpdateOne operations") + return v, errors.New("OldProjectID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAssigneeID requires an ID field in the mutation") + return v, errors.New("OldProjectID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAssigneeID: %w", err) + return v, fmt.Errorf("querying old value for OldProjectID: %w", err) } - return oldValue.AssigneeID, nil -} - -// ClearAssigneeID clears the value of the "assignee_id" field. -func (m *ProjectIssueMutation) ClearAssigneeID() { - m.assignee = nil - m.clearedFields[projectissue.FieldAssigneeID] = struct{}{} -} - -// AssigneeIDCleared returns if the "assignee_id" field was cleared in this mutation. -func (m *ProjectIssueMutation) AssigneeIDCleared() bool { - _, ok := m.clearedFields[projectissue.FieldAssigneeID] - return ok + return oldValue.ProjectID, nil } -// ResetAssigneeID resets all changes to the "assignee_id" field. -func (m *ProjectIssueMutation) ResetAssigneeID() { - m.assignee = nil - delete(m.clearedFields, projectissue.FieldAssigneeID) +// ResetProjectID resets all changes to the "project_id" field. +func (m *ProjectGitBotMutation) ResetProjectID() { + m.project = nil } -// SetPriority sets the "priority" field. -func (m *ProjectIssueMutation) SetPriority(cip consts.ProjectIssuePriority) { - m.priority = &cip - m.addpriority = nil +// SetGitBotID sets the "git_bot_id" field. +func (m *ProjectGitBotMutation) SetGitBotID(u uuid.UUID) { + m.git_bot = &u } -// Priority returns the value of the "priority" field in the mutation. -func (m *ProjectIssueMutation) Priority() (r consts.ProjectIssuePriority, exists bool) { - v := m.priority +// GitBotID returns the value of the "git_bot_id" field in the mutation. +func (m *ProjectGitBotMutation) GitBotID() (r uuid.UUID, exists bool) { + v := m.git_bot if v == nil { return } return *v, true } -// OldPriority returns the old "priority" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. +// OldGitBotID returns the old "git_bot_id" field's value of the ProjectGitBot entity. +// If the ProjectGitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldPriority(ctx context.Context) (v consts.ProjectIssuePriority, err error) { +func (m *ProjectGitBotMutation) OldGitBotID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPriority is only allowed on UpdateOne operations") + return v, errors.New("OldGitBotID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPriority requires an ID field in the mutation") + return v, errors.New("OldGitBotID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPriority: %w", err) - } - return oldValue.Priority, nil -} - -// AddPriority adds cip to the "priority" field. -func (m *ProjectIssueMutation) AddPriority(cip consts.ProjectIssuePriority) { - if m.addpriority != nil { - *m.addpriority += cip - } else { - m.addpriority = &cip - } -} - -// AddedPriority returns the value that was added to the "priority" field in this mutation. -func (m *ProjectIssueMutation) AddedPriority() (r consts.ProjectIssuePriority, exists bool) { - v := m.addpriority - if v == nil { - return + return v, fmt.Errorf("querying old value for OldGitBotID: %w", err) } - return *v, true + return oldValue.GitBotID, nil } -// ResetPriority resets all changes to the "priority" field. -func (m *ProjectIssueMutation) ResetPriority() { - m.priority = nil - m.addpriority = nil +// ResetGitBotID resets all changes to the "git_bot_id" field. +func (m *ProjectGitBotMutation) ResetGitBotID() { + m.git_bot = nil } // SetCreatedAt sets the "created_at" field. -func (m *ProjectIssueMutation) SetCreatedAt(t time.Time) { +func (m *ProjectGitBotMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ProjectIssueMutation) CreatedAt() (r time.Time, exists bool) { +func (m *ProjectGitBotMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -22547,10 +31285,10 @@ func (m *ProjectIssueMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the ProjectGitBot entity. +// If the ProjectGitBot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectGitBotMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -22565,115 +31303,25 @@ func (m *ProjectIssueMutation) OldCreatedAt(ctx context.Context) (v time.Time, e } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *ProjectIssueMutation) ResetCreatedAt() { +func (m *ProjectGitBotMutation) ResetCreatedAt() { m.created_at = nil } -// SetUpdatedAt sets the "updated_at" field. -func (m *ProjectIssueMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *ProjectIssueMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the ProjectIssue entity. -// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *ProjectIssueMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// ClearUser clears the "user" edge to the User entity. -func (m *ProjectIssueMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[projectissue.FieldUserID] = struct{}{} -} - -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *ProjectIssueMutation) UserCleared() bool { - return m.cleareduser -} - -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *ProjectIssueMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetUser resets all changes to the "user" edge. -func (m *ProjectIssueMutation) ResetUser() { - m.user = nil - m.cleareduser = false -} - -// ClearAssignee clears the "assignee" edge to the User entity. -func (m *ProjectIssueMutation) ClearAssignee() { - m.clearedassignee = true - m.clearedFields[projectissue.FieldAssigneeID] = struct{}{} -} - -// AssigneeCleared reports if the "assignee" edge to the User entity was cleared. -func (m *ProjectIssueMutation) AssigneeCleared() bool { - return m.AssigneeIDCleared() || m.clearedassignee -} - -// AssigneeIDs returns the "assignee" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// AssigneeID instead. It exists only for internal usage by the builders. -func (m *ProjectIssueMutation) AssigneeIDs() (ids []uuid.UUID) { - if id := m.assignee; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetAssignee resets all changes to the "assignee" edge. -func (m *ProjectIssueMutation) ResetAssignee() { - m.assignee = nil - m.clearedassignee = false -} - // ClearProject clears the "project" edge to the Project entity. -func (m *ProjectIssueMutation) ClearProject() { +func (m *ProjectGitBotMutation) ClearProject() { m.clearedproject = true - m.clearedFields[projectissue.FieldProjectID] = struct{}{} + m.clearedFields[projectgitbot.FieldProjectID] = struct{}{} } // ProjectCleared reports if the "project" edge to the Project entity was cleared. -func (m *ProjectIssueMutation) ProjectCleared() bool { +func (m *ProjectGitBotMutation) ProjectCleared() bool { return m.clearedproject } // ProjectIDs returns the "project" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // ProjectID instead. It exists only for internal usage by the builders. -func (m *ProjectIssueMutation) ProjectIDs() (ids []uuid.UUID) { +func (m *ProjectGitBotMutation) ProjectIDs() (ids []uuid.UUID) { if id := m.project; id != nil { ids = append(ids, *id) } @@ -22681,128 +31329,47 @@ func (m *ProjectIssueMutation) ProjectIDs() (ids []uuid.UUID) { } // ResetProject resets all changes to the "project" edge. -func (m *ProjectIssueMutation) ResetProject() { +func (m *ProjectGitBotMutation) ResetProject() { m.project = nil m.clearedproject = false } -// AddCommentIDs adds the "comments" edge to the ProjectIssueComment entity by ids. -func (m *ProjectIssueMutation) AddCommentIDs(ids ...uuid.UUID) { - if m.comments == nil { - m.comments = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.comments[ids[i]] = struct{}{} - } -} - -// ClearComments clears the "comments" edge to the ProjectIssueComment entity. -func (m *ProjectIssueMutation) ClearComments() { - m.clearedcomments = true -} - -// CommentsCleared reports if the "comments" edge to the ProjectIssueComment entity was cleared. -func (m *ProjectIssueMutation) CommentsCleared() bool { - return m.clearedcomments -} - -// RemoveCommentIDs removes the "comments" edge to the ProjectIssueComment entity by IDs. -func (m *ProjectIssueMutation) RemoveCommentIDs(ids ...uuid.UUID) { - if m.removedcomments == nil { - m.removedcomments = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.comments, ids[i]) - m.removedcomments[ids[i]] = struct{}{} - } -} - -// RemovedComments returns the removed IDs of the "comments" edge to the ProjectIssueComment entity. -func (m *ProjectIssueMutation) RemovedCommentsIDs() (ids []uuid.UUID) { - for id := range m.removedcomments { - ids = append(ids, id) - } - return -} - -// CommentsIDs returns the "comments" edge IDs in the mutation. -func (m *ProjectIssueMutation) CommentsIDs() (ids []uuid.UUID) { - for id := range m.comments { - ids = append(ids, id) - } - return -} - -// ResetComments resets all changes to the "comments" edge. -func (m *ProjectIssueMutation) ResetComments() { - m.comments = nil - m.clearedcomments = false - m.removedcomments = nil -} - -// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids. -func (m *ProjectIssueMutation) AddProjectTaskIDs(ids ...uuid.UUID) { - if m.project_tasks == nil { - m.project_tasks = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.project_tasks[ids[i]] = struct{}{} - } -} - -// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity. -func (m *ProjectIssueMutation) ClearProjectTasks() { - m.clearedproject_tasks = true -} - -// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared. -func (m *ProjectIssueMutation) ProjectTasksCleared() bool { - return m.clearedproject_tasks -} - -// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs. -func (m *ProjectIssueMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) { - if m.removedproject_tasks == nil { - m.removedproject_tasks = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.project_tasks, ids[i]) - m.removedproject_tasks[ids[i]] = struct{}{} - } +// ClearGitBot clears the "git_bot" edge to the GitBot entity. +func (m *ProjectGitBotMutation) ClearGitBot() { + m.clearedgit_bot = true + m.clearedFields[projectgitbot.FieldGitBotID] = struct{}{} } -// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity. -func (m *ProjectIssueMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) { - for id := range m.removedproject_tasks { - ids = append(ids, id) - } - return +// GitBotCleared reports if the "git_bot" edge to the GitBot entity was cleared. +func (m *ProjectGitBotMutation) GitBotCleared() bool { + return m.clearedgit_bot } -// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation. -func (m *ProjectIssueMutation) ProjectTasksIDs() (ids []uuid.UUID) { - for id := range m.project_tasks { - ids = append(ids, id) +// GitBotIDs returns the "git_bot" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// GitBotID instead. It exists only for internal usage by the builders. +func (m *ProjectGitBotMutation) GitBotIDs() (ids []uuid.UUID) { + if id := m.git_bot; id != nil { + ids = append(ids, *id) } return } - -// ResetProjectTasks resets all changes to the "project_tasks" edge. -func (m *ProjectIssueMutation) ResetProjectTasks() { - m.project_tasks = nil - m.clearedproject_tasks = false - m.removedproject_tasks = nil + +// ResetGitBot resets all changes to the "git_bot" edge. +func (m *ProjectGitBotMutation) ResetGitBot() { + m.git_bot = nil + m.clearedgit_bot = false } -// Where appends a list predicates to the ProjectIssueMutation builder. -func (m *ProjectIssueMutation) Where(ps ...predicate.ProjectIssue) { +// Where appends a list predicates to the ProjectGitBotMutation builder. +func (m *ProjectGitBotMutation) Where(ps ...predicate.ProjectGitBot) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ProjectIssueMutation builder. Using this method, +// WhereP appends storage-level predicates to the ProjectGitBotMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ProjectIssueMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.ProjectIssue, len(ps)) +func (m *ProjectGitBotMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ProjectGitBot, len(ps)) for i := range ps { p[i] = ps[i] } @@ -22810,60 +31377,33 @@ func (m *ProjectIssueMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ProjectIssueMutation) Op() Op { +func (m *ProjectGitBotMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ProjectIssueMutation) SetOp(op Op) { +func (m *ProjectGitBotMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (ProjectIssue). -func (m *ProjectIssueMutation) Type() string { +// Type returns the node type of this mutation (ProjectGitBot). +func (m *ProjectGitBotMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ProjectIssueMutation) Fields() []string { - fields := make([]string, 0, 12) - if m.deleted_at != nil { - fields = append(fields, projectissue.FieldDeletedAt) - } - if m.user != nil { - fields = append(fields, projectissue.FieldUserID) - } +func (m *ProjectGitBotMutation) Fields() []string { + fields := make([]string, 0, 3) if m.project != nil { - fields = append(fields, projectissue.FieldProjectID) - } - if m.status != nil { - fields = append(fields, projectissue.FieldStatus) - } - if m.title != nil { - fields = append(fields, projectissue.FieldTitle) - } - if m.requirement_document != nil { - fields = append(fields, projectissue.FieldRequirementDocument) - } - if m.design_document != nil { - fields = append(fields, projectissue.FieldDesignDocument) - } - if m.summary != nil { - fields = append(fields, projectissue.FieldSummary) - } - if m.assignee != nil { - fields = append(fields, projectissue.FieldAssigneeID) + fields = append(fields, projectgitbot.FieldProjectID) } - if m.priority != nil { - fields = append(fields, projectissue.FieldPriority) + if m.git_bot != nil { + fields = append(fields, projectgitbot.FieldGitBotID) } if m.created_at != nil { - fields = append(fields, projectissue.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, projectissue.FieldUpdatedAt) + fields = append(fields, projectgitbot.FieldCreatedAt) } return fields } @@ -22871,32 +31411,14 @@ func (m *ProjectIssueMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ProjectIssueMutation) Field(name string) (ent.Value, bool) { +func (m *ProjectGitBotMutation) Field(name string) (ent.Value, bool) { switch name { - case projectissue.FieldDeletedAt: - return m.DeletedAt() - case projectissue.FieldUserID: - return m.UserID() - case projectissue.FieldProjectID: + case projectgitbot.FieldProjectID: return m.ProjectID() - case projectissue.FieldStatus: - return m.Status() - case projectissue.FieldTitle: - return m.Title() - case projectissue.FieldRequirementDocument: - return m.RequirementDocument() - case projectissue.FieldDesignDocument: - return m.DesignDocument() - case projectissue.FieldSummary: - return m.Summary() - case projectissue.FieldAssigneeID: - return m.AssigneeID() - case projectissue.FieldPriority: - return m.Priority() - case projectissue.FieldCreatedAt: + case projectgitbot.FieldGitBotID: + return m.GitBotID() + case projectgitbot.FieldCreatedAt: return m.CreatedAt() - case projectissue.FieldUpdatedAt: - return m.UpdatedAt() } return nil, false } @@ -22904,462 +31426,243 @@ func (m *ProjectIssueMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ProjectIssueMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ProjectGitBotMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case projectissue.FieldDeletedAt: - return m.OldDeletedAt(ctx) - case projectissue.FieldUserID: - return m.OldUserID(ctx) - case projectissue.FieldProjectID: + case projectgitbot.FieldProjectID: return m.OldProjectID(ctx) - case projectissue.FieldStatus: - return m.OldStatus(ctx) - case projectissue.FieldTitle: - return m.OldTitle(ctx) - case projectissue.FieldRequirementDocument: - return m.OldRequirementDocument(ctx) - case projectissue.FieldDesignDocument: - return m.OldDesignDocument(ctx) - case projectissue.FieldSummary: - return m.OldSummary(ctx) - case projectissue.FieldAssigneeID: - return m.OldAssigneeID(ctx) - case projectissue.FieldPriority: - return m.OldPriority(ctx) - case projectissue.FieldCreatedAt: + case projectgitbot.FieldGitBotID: + return m.OldGitBotID(ctx) + case projectgitbot.FieldCreatedAt: return m.OldCreatedAt(ctx) - case projectissue.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown ProjectIssue field %s", name) + return nil, fmt.Errorf("unknown ProjectGitBot field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectIssueMutation) SetField(name string, value ent.Value) error { +func (m *ProjectGitBotMutation) SetField(name string, value ent.Value) error { switch name { - case projectissue.FieldDeletedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDeletedAt(v) - return nil - case projectissue.FieldUserID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUserID(v) - return nil - case projectissue.FieldProjectID: + case projectgitbot.FieldProjectID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetProjectID(v) return nil - case projectissue.FieldStatus: - v, ok := value.(consts.ProjectIssueStatus) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetStatus(v) - return nil - case projectissue.FieldTitle: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTitle(v) - return nil - case projectissue.FieldRequirementDocument: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRequirementDocument(v) - return nil - case projectissue.FieldDesignDocument: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDesignDocument(v) - return nil - case projectissue.FieldSummary: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSummary(v) - return nil - case projectissue.FieldAssigneeID: + case projectgitbot.FieldGitBotID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetAssigneeID(v) - return nil - case projectissue.FieldPriority: - v, ok := value.(consts.ProjectIssuePriority) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPriority(v) + m.SetGitBotID(v) return nil - case projectissue.FieldCreatedAt: + case projectgitbot.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case projectissue.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil } - return fmt.Errorf("unknown ProjectIssue field %s", name) + return fmt.Errorf("unknown ProjectGitBot field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ProjectIssueMutation) AddedFields() []string { - var fields []string - if m.addpriority != nil { - fields = append(fields, projectissue.FieldPriority) - } - return fields +func (m *ProjectGitBotMutation) AddedFields() []string { + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ProjectIssueMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case projectissue.FieldPriority: - return m.AddedPriority() - } +func (m *ProjectGitBotMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectIssueMutation) AddField(name string, value ent.Value) error { +func (m *ProjectGitBotMutation) AddField(name string, value ent.Value) error { switch name { - case projectissue.FieldPriority: - v, ok := value.(consts.ProjectIssuePriority) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddPriority(v) - return nil } - return fmt.Errorf("unknown ProjectIssue numeric field %s", name) + return fmt.Errorf("unknown ProjectGitBot numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ProjectIssueMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(projectissue.FieldDeletedAt) { - fields = append(fields, projectissue.FieldDeletedAt) - } - if m.FieldCleared(projectissue.FieldRequirementDocument) { - fields = append(fields, projectissue.FieldRequirementDocument) - } - if m.FieldCleared(projectissue.FieldDesignDocument) { - fields = append(fields, projectissue.FieldDesignDocument) - } - if m.FieldCleared(projectissue.FieldSummary) { - fields = append(fields, projectissue.FieldSummary) - } - if m.FieldCleared(projectissue.FieldAssigneeID) { - fields = append(fields, projectissue.FieldAssigneeID) - } - return fields +func (m *ProjectGitBotMutation) ClearedFields() []string { + return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ProjectIssueMutation) FieldCleared(name string) bool { +func (m *ProjectGitBotMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ProjectIssueMutation) ClearField(name string) error { - switch name { - case projectissue.FieldDeletedAt: - m.ClearDeletedAt() - return nil - case projectissue.FieldRequirementDocument: - m.ClearRequirementDocument() - return nil - case projectissue.FieldDesignDocument: - m.ClearDesignDocument() - return nil - case projectissue.FieldSummary: - m.ClearSummary() - return nil - case projectissue.FieldAssigneeID: - m.ClearAssigneeID() - return nil - } - return fmt.Errorf("unknown ProjectIssue nullable field %s", name) +func (m *ProjectGitBotMutation) ClearField(name string) error { + return fmt.Errorf("unknown ProjectGitBot nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ProjectIssueMutation) ResetField(name string) error { +func (m *ProjectGitBotMutation) ResetField(name string) error { switch name { - case projectissue.FieldDeletedAt: - m.ResetDeletedAt() - return nil - case projectissue.FieldUserID: - m.ResetUserID() - return nil - case projectissue.FieldProjectID: + case projectgitbot.FieldProjectID: m.ResetProjectID() return nil - case projectissue.FieldStatus: - m.ResetStatus() - return nil - case projectissue.FieldTitle: - m.ResetTitle() - return nil - case projectissue.FieldRequirementDocument: - m.ResetRequirementDocument() - return nil - case projectissue.FieldDesignDocument: - m.ResetDesignDocument() - return nil - case projectissue.FieldSummary: - m.ResetSummary() - return nil - case projectissue.FieldAssigneeID: - m.ResetAssigneeID() - return nil - case projectissue.FieldPriority: - m.ResetPriority() + case projectgitbot.FieldGitBotID: + m.ResetGitBotID() return nil - case projectissue.FieldCreatedAt: + case projectgitbot.FieldCreatedAt: m.ResetCreatedAt() return nil - case projectissue.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil } - return fmt.Errorf("unknown ProjectIssue field %s", name) + return fmt.Errorf("unknown ProjectGitBot field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ProjectIssueMutation) AddedEdges() []string { - edges := make([]string, 0, 5) - if m.user != nil { - edges = append(edges, projectissue.EdgeUser) - } - if m.assignee != nil { - edges = append(edges, projectissue.EdgeAssignee) - } +func (m *ProjectGitBotMutation) AddedEdges() []string { + edges := make([]string, 0, 2) if m.project != nil { - edges = append(edges, projectissue.EdgeProject) - } - if m.comments != nil { - edges = append(edges, projectissue.EdgeComments) + edges = append(edges, projectgitbot.EdgeProject) } - if m.project_tasks != nil { - edges = append(edges, projectissue.EdgeProjectTasks) + if m.git_bot != nil { + edges = append(edges, projectgitbot.EdgeGitBot) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ProjectIssueMutation) AddedIDs(name string) []ent.Value { +func (m *ProjectGitBotMutation) AddedIDs(name string) []ent.Value { switch name { - case projectissue.EdgeUser: - if id := m.user; id != nil { - return []ent.Value{*id} - } - case projectissue.EdgeAssignee: - if id := m.assignee; id != nil { - return []ent.Value{*id} - } - case projectissue.EdgeProject: + case projectgitbot.EdgeProject: if id := m.project; id != nil { return []ent.Value{*id} } - case projectissue.EdgeComments: - ids := make([]ent.Value, 0, len(m.comments)) - for id := range m.comments { - ids = append(ids, id) - } - return ids - case projectissue.EdgeProjectTasks: - ids := make([]ent.Value, 0, len(m.project_tasks)) - for id := range m.project_tasks { - ids = append(ids, id) + case projectgitbot.EdgeGitBot: + if id := m.git_bot; id != nil { + return []ent.Value{*id} } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ProjectIssueMutation) RemovedEdges() []string { - edges := make([]string, 0, 5) - if m.removedcomments != nil { - edges = append(edges, projectissue.EdgeComments) - } - if m.removedproject_tasks != nil { - edges = append(edges, projectissue.EdgeProjectTasks) - } +func (m *ProjectGitBotMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ProjectIssueMutation) RemovedIDs(name string) []ent.Value { - switch name { - case projectissue.EdgeComments: - ids := make([]ent.Value, 0, len(m.removedcomments)) - for id := range m.removedcomments { - ids = append(ids, id) - } - return ids - case projectissue.EdgeProjectTasks: - ids := make([]ent.Value, 0, len(m.removedproject_tasks)) - for id := range m.removedproject_tasks { - ids = append(ids, id) - } - return ids - } +func (m *ProjectGitBotMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ProjectIssueMutation) ClearedEdges() []string { - edges := make([]string, 0, 5) - if m.cleareduser { - edges = append(edges, projectissue.EdgeUser) - } - if m.clearedassignee { - edges = append(edges, projectissue.EdgeAssignee) - } +func (m *ProjectGitBotMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) if m.clearedproject { - edges = append(edges, projectissue.EdgeProject) - } - if m.clearedcomments { - edges = append(edges, projectissue.EdgeComments) + edges = append(edges, projectgitbot.EdgeProject) } - if m.clearedproject_tasks { - edges = append(edges, projectissue.EdgeProjectTasks) + if m.clearedgit_bot { + edges = append(edges, projectgitbot.EdgeGitBot) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ProjectIssueMutation) EdgeCleared(name string) bool { +func (m *ProjectGitBotMutation) EdgeCleared(name string) bool { switch name { - case projectissue.EdgeUser: - return m.cleareduser - case projectissue.EdgeAssignee: - return m.clearedassignee - case projectissue.EdgeProject: + case projectgitbot.EdgeProject: return m.clearedproject - case projectissue.EdgeComments: - return m.clearedcomments - case projectissue.EdgeProjectTasks: - return m.clearedproject_tasks + case projectgitbot.EdgeGitBot: + return m.clearedgit_bot } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ProjectIssueMutation) ClearEdge(name string) error { +func (m *ProjectGitBotMutation) ClearEdge(name string) error { switch name { - case projectissue.EdgeUser: - m.ClearUser() - return nil - case projectissue.EdgeAssignee: - m.ClearAssignee() - return nil - case projectissue.EdgeProject: + case projectgitbot.EdgeProject: m.ClearProject() return nil + case projectgitbot.EdgeGitBot: + m.ClearGitBot() + return nil } - return fmt.Errorf("unknown ProjectIssue unique edge %s", name) + return fmt.Errorf("unknown ProjectGitBot unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ProjectIssueMutation) ResetEdge(name string) error { +func (m *ProjectGitBotMutation) ResetEdge(name string) error { switch name { - case projectissue.EdgeUser: - m.ResetUser() - return nil - case projectissue.EdgeAssignee: - m.ResetAssignee() - return nil - case projectissue.EdgeProject: + case projectgitbot.EdgeProject: m.ResetProject() return nil - case projectissue.EdgeComments: - m.ResetComments() - return nil - case projectissue.EdgeProjectTasks: - m.ResetProjectTasks() + case projectgitbot.EdgeGitBot: + m.ResetGitBot() return nil } - return fmt.Errorf("unknown ProjectIssue edge %s", name) + return fmt.Errorf("unknown ProjectGitBot edge %s", name) } -// ProjectIssueCommentMutation represents an operation that mutates the ProjectIssueComment nodes in the graph. -type ProjectIssueCommentMutation struct { +// ProjectIssueMutation represents an operation that mutates the ProjectIssue nodes in the graph. +type ProjectIssueMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - comment *string - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - user *uuid.UUID - cleareduser bool - issue *uuid.UUID - clearedissue bool - parent *uuid.UUID - clearedparent bool - replies map[uuid.UUID]struct{} - removedreplies map[uuid.UUID]struct{} - clearedreplies bool - done bool - oldValue func(context.Context) (*ProjectIssueComment, error) - predicates []predicate.ProjectIssueComment + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + status *consts.ProjectIssueStatus + title *string + requirement_document *string + design_document *string + summary *string + priority *consts.ProjectIssuePriority + addpriority *consts.ProjectIssuePriority + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + user *uuid.UUID + cleareduser bool + assignee *uuid.UUID + clearedassignee bool + project *uuid.UUID + clearedproject bool + comments map[uuid.UUID]struct{} + removedcomments map[uuid.UUID]struct{} + clearedcomments bool + project_tasks map[uuid.UUID]struct{} + removedproject_tasks map[uuid.UUID]struct{} + clearedproject_tasks bool + done bool + oldValue func(context.Context) (*ProjectIssue, error) + predicates []predicate.ProjectIssue } -var _ ent.Mutation = (*ProjectIssueCommentMutation)(nil) +var _ ent.Mutation = (*ProjectIssueMutation)(nil) -// projectissuecommentOption allows management of the mutation configuration using functional options. -type projectissuecommentOption func(*ProjectIssueCommentMutation) +// projectissueOption allows management of the mutation configuration using functional options. +type projectissueOption func(*ProjectIssueMutation) -// newProjectIssueCommentMutation creates new mutation for the ProjectIssueComment entity. -func newProjectIssueCommentMutation(c config, op Op, opts ...projectissuecommentOption) *ProjectIssueCommentMutation { - m := &ProjectIssueCommentMutation{ +// newProjectIssueMutation creates new mutation for the ProjectIssue entity. +func newProjectIssueMutation(c config, op Op, opts ...projectissueOption) *ProjectIssueMutation { + m := &ProjectIssueMutation{ config: c, op: op, - typ: TypeProjectIssueComment, + typ: TypeProjectIssue, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -23368,20 +31671,20 @@ func newProjectIssueCommentMutation(c config, op Op, opts ...projectissuecomment return m } -// withProjectIssueCommentID sets the ID field of the mutation. -func withProjectIssueCommentID(id uuid.UUID) projectissuecommentOption { - return func(m *ProjectIssueCommentMutation) { +// withProjectIssueID sets the ID field of the mutation. +func withProjectIssueID(id uuid.UUID) projectissueOption { + return func(m *ProjectIssueMutation) { var ( err error once sync.Once - value *ProjectIssueComment + value *ProjectIssue ) - m.oldValue = func(ctx context.Context) (*ProjectIssueComment, error) { + m.oldValue = func(ctx context.Context) (*ProjectIssue, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().ProjectIssueComment.Get(ctx, id) + value, err = m.Client().ProjectIssue.Get(ctx, id) } }) return value, err @@ -23390,10 +31693,10 @@ func withProjectIssueCommentID(id uuid.UUID) projectissuecommentOption { } } -// withProjectIssueComment sets the old ProjectIssueComment of the mutation. -func withProjectIssueComment(node *ProjectIssueComment) projectissuecommentOption { - return func(m *ProjectIssueCommentMutation) { - m.oldValue = func(context.Context) (*ProjectIssueComment, error) { +// withProjectIssue sets the old ProjectIssue of the mutation. +func withProjectIssue(node *ProjectIssue) projectissueOption { + return func(m *ProjectIssueMutation) { + m.oldValue = func(context.Context) (*ProjectIssue, error) { return node, nil } m.id = &node.ID @@ -23402,7 +31705,7 @@ func withProjectIssueComment(node *ProjectIssueComment) projectissuecommentOptio // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ProjectIssueCommentMutation) Client() *Client { +func (m ProjectIssueMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -23410,7 +31713,7 @@ func (m ProjectIssueCommentMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ProjectIssueCommentMutation) Tx() (*Tx, error) { +func (m ProjectIssueMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -23420,14 +31723,14 @@ func (m ProjectIssueCommentMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of ProjectIssueComment entities. -func (m *ProjectIssueCommentMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of ProjectIssue entities. +func (m *ProjectIssueMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ProjectIssueCommentMutation) ID() (id uuid.UUID, exists bool) { +func (m *ProjectIssueMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -23438,7 +31741,7 @@ func (m *ProjectIssueCommentMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ProjectIssueCommentMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *ProjectIssueMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -23447,19 +31750,19 @@ func (m *ProjectIssueCommentMutation) IDs(ctx context.Context) ([]uuid.UUID, err } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().ProjectIssueComment.Query().Where(m.predicates...).IDs(ctx) + return m.Client().ProjectIssue.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetDeletedAt sets the "deleted_at" field. -func (m *ProjectIssueCommentMutation) SetDeletedAt(t time.Time) { +func (m *ProjectIssueMutation) SetDeletedAt(t time.Time) { m.deleted_at = &t } // DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *ProjectIssueCommentMutation) DeletedAt() (r time.Time, exists bool) { +func (m *ProjectIssueMutation) DeletedAt() (r time.Time, exists bool) { v := m.deleted_at if v == nil { return @@ -23467,10 +31770,10 @@ func (m *ProjectIssueCommentMutation) DeletedAt() (r time.Time, exists bool) { return *v, true } -// OldDeletedAt returns the old "deleted_at" field's value of the ProjectIssueComment entity. -// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. +// OldDeletedAt returns the old "deleted_at" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueCommentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectIssueMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } @@ -23485,30 +31788,30 @@ func (m *ProjectIssueCommentMutation) OldDeletedAt(ctx context.Context) (v time. } // ClearDeletedAt clears the value of the "deleted_at" field. -func (m *ProjectIssueCommentMutation) ClearDeletedAt() { +func (m *ProjectIssueMutation) ClearDeletedAt() { m.deleted_at = nil - m.clearedFields[projectissuecomment.FieldDeletedAt] = struct{}{} + m.clearedFields[projectissue.FieldDeletedAt] = struct{}{} } // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *ProjectIssueCommentMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[projectissuecomment.FieldDeletedAt] +func (m *ProjectIssueMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[projectissue.FieldDeletedAt] return ok } // ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *ProjectIssueCommentMutation) ResetDeletedAt() { +func (m *ProjectIssueMutation) ResetDeletedAt() { m.deleted_at = nil - delete(m.clearedFields, projectissuecomment.FieldDeletedAt) + delete(m.clearedFields, projectissue.FieldDeletedAt) } // SetUserID sets the "user_id" field. -func (m *ProjectIssueCommentMutation) SetUserID(u uuid.UUID) { +func (m *ProjectIssueMutation) SetUserID(u uuid.UUID) { m.user = &u } // UserID returns the value of the "user_id" field in the mutation. -func (m *ProjectIssueCommentMutation) UserID() (r uuid.UUID, exists bool) { +func (m *ProjectIssueMutation) UserID() (r uuid.UUID, exists bool) { v := m.user if v == nil { return @@ -23516,10 +31819,10 @@ func (m *ProjectIssueCommentMutation) UserID() (r uuid.UUID, exists bool) { return *v, true } -// OldUserID returns the old "user_id" field's value of the ProjectIssueComment entity. -// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueCommentMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ProjectIssueMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUserID is only allowed on UpdateOne operations") } @@ -23534,138 +31837,377 @@ func (m *ProjectIssueCommentMutation) OldUserID(ctx context.Context) (v uuid.UUI } // ResetUserID resets all changes to the "user_id" field. -func (m *ProjectIssueCommentMutation) ResetUserID() { +func (m *ProjectIssueMutation) ResetUserID() { m.user = nil } -// SetIssueID sets the "issue_id" field. -func (m *ProjectIssueCommentMutation) SetIssueID(u uuid.UUID) { - m.issue = &u +// SetProjectID sets the "project_id" field. +func (m *ProjectIssueMutation) SetProjectID(u uuid.UUID) { + m.project = &u } -// IssueID returns the value of the "issue_id" field in the mutation. -func (m *ProjectIssueCommentMutation) IssueID() (r uuid.UUID, exists bool) { - v := m.issue +// ProjectID returns the value of the "project_id" field in the mutation. +func (m *ProjectIssueMutation) ProjectID() (r uuid.UUID, exists bool) { + v := m.project if v == nil { return } return *v, true } -// OldIssueID returns the old "issue_id" field's value of the ProjectIssueComment entity. -// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. +// OldProjectID returns the old "project_id" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueCommentMutation) OldIssueID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ProjectIssueMutation) OldProjectID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIssueID is only allowed on UpdateOne operations") + return v, errors.New("OldProjectID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIssueID requires an ID field in the mutation") + return v, errors.New("OldProjectID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldIssueID: %w", err) + return v, fmt.Errorf("querying old value for OldProjectID: %w", err) } - return oldValue.IssueID, nil + return oldValue.ProjectID, nil } -// ResetIssueID resets all changes to the "issue_id" field. -func (m *ProjectIssueCommentMutation) ResetIssueID() { - m.issue = nil +// ResetProjectID resets all changes to the "project_id" field. +func (m *ProjectIssueMutation) ResetProjectID() { + m.project = nil } -// SetParentID sets the "parent_id" field. -func (m *ProjectIssueCommentMutation) SetParentID(u uuid.UUID) { - m.parent = &u +// SetStatus sets the "status" field. +func (m *ProjectIssueMutation) SetStatus(cis consts.ProjectIssueStatus) { + m.status = &cis } -// ParentID returns the value of the "parent_id" field in the mutation. -func (m *ProjectIssueCommentMutation) ParentID() (r uuid.UUID, exists bool) { - v := m.parent +// Status returns the value of the "status" field in the mutation. +func (m *ProjectIssueMutation) Status() (r consts.ProjectIssueStatus, exists bool) { + v := m.status if v == nil { return } return *v, true } -// OldParentID returns the old "parent_id" field's value of the ProjectIssueComment entity. -// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. +// OldStatus returns the old "status" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueCommentMutation) OldParentID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ProjectIssueMutation) OldStatus(ctx context.Context) (v consts.ProjectIssueStatus, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldParentID is only allowed on UpdateOne operations") + return v, errors.New("OldStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldParentID requires an ID field in the mutation") + return v, errors.New("OldStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldParentID: %w", err) + return v, fmt.Errorf("querying old value for OldStatus: %w", err) } - return oldValue.ParentID, nil + return oldValue.Status, nil } -// ClearParentID clears the value of the "parent_id" field. -func (m *ProjectIssueCommentMutation) ClearParentID() { - m.parent = nil - m.clearedFields[projectissuecomment.FieldParentID] = struct{}{} +// ResetStatus resets all changes to the "status" field. +func (m *ProjectIssueMutation) ResetStatus() { + m.status = nil } -// ParentIDCleared returns if the "parent_id" field was cleared in this mutation. -func (m *ProjectIssueCommentMutation) ParentIDCleared() bool { - _, ok := m.clearedFields[projectissuecomment.FieldParentID] +// SetTitle sets the "title" field. +func (m *ProjectIssueMutation) SetTitle(s string) { + m.title = &s +} + +// Title returns the value of the "title" field in the mutation. +func (m *ProjectIssueMutation) Title() (r string, exists bool) { + v := m.title + if v == nil { + return + } + return *v, true +} + +// OldTitle returns the old "title" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectIssueMutation) OldTitle(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTitle is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTitle requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTitle: %w", err) + } + return oldValue.Title, nil +} + +// ResetTitle resets all changes to the "title" field. +func (m *ProjectIssueMutation) ResetTitle() { + m.title = nil +} + +// SetRequirementDocument sets the "requirement_document" field. +func (m *ProjectIssueMutation) SetRequirementDocument(s string) { + m.requirement_document = &s +} + +// RequirementDocument returns the value of the "requirement_document" field in the mutation. +func (m *ProjectIssueMutation) RequirementDocument() (r string, exists bool) { + v := m.requirement_document + if v == nil { + return + } + return *v, true +} + +// OldRequirementDocument returns the old "requirement_document" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectIssueMutation) OldRequirementDocument(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRequirementDocument is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRequirementDocument requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRequirementDocument: %w", err) + } + return oldValue.RequirementDocument, nil +} + +// ClearRequirementDocument clears the value of the "requirement_document" field. +func (m *ProjectIssueMutation) ClearRequirementDocument() { + m.requirement_document = nil + m.clearedFields[projectissue.FieldRequirementDocument] = struct{}{} +} + +// RequirementDocumentCleared returns if the "requirement_document" field was cleared in this mutation. +func (m *ProjectIssueMutation) RequirementDocumentCleared() bool { + _, ok := m.clearedFields[projectissue.FieldRequirementDocument] return ok } -// ResetParentID resets all changes to the "parent_id" field. -func (m *ProjectIssueCommentMutation) ResetParentID() { - m.parent = nil - delete(m.clearedFields, projectissuecomment.FieldParentID) +// ResetRequirementDocument resets all changes to the "requirement_document" field. +func (m *ProjectIssueMutation) ResetRequirementDocument() { + m.requirement_document = nil + delete(m.clearedFields, projectissue.FieldRequirementDocument) } -// SetComment sets the "comment" field. -func (m *ProjectIssueCommentMutation) SetComment(s string) { - m.comment = &s +// SetDesignDocument sets the "design_document" field. +func (m *ProjectIssueMutation) SetDesignDocument(s string) { + m.design_document = &s } -// Comment returns the value of the "comment" field in the mutation. -func (m *ProjectIssueCommentMutation) Comment() (r string, exists bool) { - v := m.comment +// DesignDocument returns the value of the "design_document" field in the mutation. +func (m *ProjectIssueMutation) DesignDocument() (r string, exists bool) { + v := m.design_document if v == nil { return } return *v, true } -// OldComment returns the old "comment" field's value of the ProjectIssueComment entity. -// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. +// OldDesignDocument returns the old "design_document" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueCommentMutation) OldComment(ctx context.Context) (v string, err error) { +func (m *ProjectIssueMutation) OldDesignDocument(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldComment is only allowed on UpdateOne operations") + return v, errors.New("OldDesignDocument is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldComment requires an ID field in the mutation") + return v, errors.New("OldDesignDocument requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldComment: %w", err) + return v, fmt.Errorf("querying old value for OldDesignDocument: %w", err) } - return oldValue.Comment, nil + return oldValue.DesignDocument, nil } -// ResetComment resets all changes to the "comment" field. -func (m *ProjectIssueCommentMutation) ResetComment() { - m.comment = nil +// ClearDesignDocument clears the value of the "design_document" field. +func (m *ProjectIssueMutation) ClearDesignDocument() { + m.design_document = nil + m.clearedFields[projectissue.FieldDesignDocument] = struct{}{} +} + +// DesignDocumentCleared returns if the "design_document" field was cleared in this mutation. +func (m *ProjectIssueMutation) DesignDocumentCleared() bool { + _, ok := m.clearedFields[projectissue.FieldDesignDocument] + return ok +} + +// ResetDesignDocument resets all changes to the "design_document" field. +func (m *ProjectIssueMutation) ResetDesignDocument() { + m.design_document = nil + delete(m.clearedFields, projectissue.FieldDesignDocument) +} + +// SetSummary sets the "summary" field. +func (m *ProjectIssueMutation) SetSummary(s string) { + m.summary = &s +} + +// Summary returns the value of the "summary" field in the mutation. +func (m *ProjectIssueMutation) Summary() (r string, exists bool) { + v := m.summary + if v == nil { + return + } + return *v, true +} + +// OldSummary returns the old "summary" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectIssueMutation) OldSummary(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSummary is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSummary requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSummary: %w", err) + } + return oldValue.Summary, nil +} + +// ClearSummary clears the value of the "summary" field. +func (m *ProjectIssueMutation) ClearSummary() { + m.summary = nil + m.clearedFields[projectissue.FieldSummary] = struct{}{} +} + +// SummaryCleared returns if the "summary" field was cleared in this mutation. +func (m *ProjectIssueMutation) SummaryCleared() bool { + _, ok := m.clearedFields[projectissue.FieldSummary] + return ok +} + +// ResetSummary resets all changes to the "summary" field. +func (m *ProjectIssueMutation) ResetSummary() { + m.summary = nil + delete(m.clearedFields, projectissue.FieldSummary) +} + +// SetAssigneeID sets the "assignee_id" field. +func (m *ProjectIssueMutation) SetAssigneeID(u uuid.UUID) { + m.assignee = &u +} + +// AssigneeID returns the value of the "assignee_id" field in the mutation. +func (m *ProjectIssueMutation) AssigneeID() (r uuid.UUID, exists bool) { + v := m.assignee + if v == nil { + return + } + return *v, true +} + +// OldAssigneeID returns the old "assignee_id" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectIssueMutation) OldAssigneeID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAssigneeID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAssigneeID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAssigneeID: %w", err) + } + return oldValue.AssigneeID, nil +} + +// ClearAssigneeID clears the value of the "assignee_id" field. +func (m *ProjectIssueMutation) ClearAssigneeID() { + m.assignee = nil + m.clearedFields[projectissue.FieldAssigneeID] = struct{}{} +} + +// AssigneeIDCleared returns if the "assignee_id" field was cleared in this mutation. +func (m *ProjectIssueMutation) AssigneeIDCleared() bool { + _, ok := m.clearedFields[projectissue.FieldAssigneeID] + return ok +} + +// ResetAssigneeID resets all changes to the "assignee_id" field. +func (m *ProjectIssueMutation) ResetAssigneeID() { + m.assignee = nil + delete(m.clearedFields, projectissue.FieldAssigneeID) +} + +// SetPriority sets the "priority" field. +func (m *ProjectIssueMutation) SetPriority(cip consts.ProjectIssuePriority) { + m.priority = &cip + m.addpriority = nil +} + +// Priority returns the value of the "priority" field in the mutation. +func (m *ProjectIssueMutation) Priority() (r consts.ProjectIssuePriority, exists bool) { + v := m.priority + if v == nil { + return + } + return *v, true +} + +// OldPriority returns the old "priority" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectIssueMutation) OldPriority(ctx context.Context) (v consts.ProjectIssuePriority, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPriority is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPriority requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPriority: %w", err) + } + return oldValue.Priority, nil +} + +// AddPriority adds cip to the "priority" field. +func (m *ProjectIssueMutation) AddPriority(cip consts.ProjectIssuePriority) { + if m.addpriority != nil { + *m.addpriority += cip + } else { + m.addpriority = &cip + } +} + +// AddedPriority returns the value that was added to the "priority" field in this mutation. +func (m *ProjectIssueMutation) AddedPriority() (r consts.ProjectIssuePriority, exists bool) { + v := m.addpriority + if v == nil { + return + } + return *v, true +} + +// ResetPriority resets all changes to the "priority" field. +func (m *ProjectIssueMutation) ResetPriority() { + m.priority = nil + m.addpriority = nil } // SetCreatedAt sets the "created_at" field. -func (m *ProjectIssueCommentMutation) SetCreatedAt(t time.Time) { +func (m *ProjectIssueMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ProjectIssueCommentMutation) CreatedAt() (r time.Time, exists bool) { +func (m *ProjectIssueMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -23673,10 +32215,10 @@ func (m *ProjectIssueCommentMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the ProjectIssueComment entity. -// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueCommentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectIssueMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -23691,17 +32233,17 @@ func (m *ProjectIssueCommentMutation) OldCreatedAt(ctx context.Context) (v time. } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *ProjectIssueCommentMutation) ResetCreatedAt() { +func (m *ProjectIssueMutation) ResetCreatedAt() { m.created_at = nil } // SetUpdatedAt sets the "updated_at" field. -func (m *ProjectIssueCommentMutation) SetUpdatedAt(t time.Time) { +func (m *ProjectIssueMutation) SetUpdatedAt(t time.Time) { m.updated_at = &t } // UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *ProjectIssueCommentMutation) UpdatedAt() (r time.Time, exists bool) { +func (m *ProjectIssueMutation) UpdatedAt() (r time.Time, exists bool) { v := m.updated_at if v == nil { return @@ -23709,10 +32251,10 @@ func (m *ProjectIssueCommentMutation) UpdatedAt() (r time.Time, exists bool) { return *v, true } -// OldUpdatedAt returns the old "updated_at" field's value of the ProjectIssueComment entity. -// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. +// OldUpdatedAt returns the old "updated_at" field's value of the ProjectIssue entity. +// If the ProjectIssue object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectIssueCommentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectIssueMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } @@ -23727,25 +32269,25 @@ func (m *ProjectIssueCommentMutation) OldUpdatedAt(ctx context.Context) (v time. } // ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *ProjectIssueCommentMutation) ResetUpdatedAt() { +func (m *ProjectIssueMutation) ResetUpdatedAt() { m.updated_at = nil } // ClearUser clears the "user" edge to the User entity. -func (m *ProjectIssueCommentMutation) ClearUser() { +func (m *ProjectIssueMutation) ClearUser() { m.cleareduser = true - m.clearedFields[projectissuecomment.FieldUserID] = struct{}{} + m.clearedFields[projectissue.FieldUserID] = struct{}{} } // UserCleared reports if the "user" edge to the User entity was cleared. -func (m *ProjectIssueCommentMutation) UserCleared() bool { +func (m *ProjectIssueMutation) UserCleared() bool { return m.cleareduser } // UserIDs returns the "user" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // UserID instead. It exists only for internal usage by the builders. -func (m *ProjectIssueCommentMutation) UserIDs() (ids []uuid.UUID) { +func (m *ProjectIssueMutation) UserIDs() (ids []uuid.UUID) { if id := m.user; id != nil { ids = append(ids, *id) } @@ -23753,128 +32295,182 @@ func (m *ProjectIssueCommentMutation) UserIDs() (ids []uuid.UUID) { } // ResetUser resets all changes to the "user" edge. -func (m *ProjectIssueCommentMutation) ResetUser() { +func (m *ProjectIssueMutation) ResetUser() { m.user = nil m.cleareduser = false } -// ClearIssue clears the "issue" edge to the ProjectIssue entity. -func (m *ProjectIssueCommentMutation) ClearIssue() { - m.clearedissue = true - m.clearedFields[projectissuecomment.FieldIssueID] = struct{}{} +// ClearAssignee clears the "assignee" edge to the User entity. +func (m *ProjectIssueMutation) ClearAssignee() { + m.clearedassignee = true + m.clearedFields[projectissue.FieldAssigneeID] = struct{}{} } -// IssueCleared reports if the "issue" edge to the ProjectIssue entity was cleared. -func (m *ProjectIssueCommentMutation) IssueCleared() bool { - return m.clearedissue +// AssigneeCleared reports if the "assignee" edge to the User entity was cleared. +func (m *ProjectIssueMutation) AssigneeCleared() bool { + return m.AssigneeIDCleared() || m.clearedassignee } -// IssueIDs returns the "issue" edge IDs in the mutation. +// AssigneeIDs returns the "assignee" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// IssueID instead. It exists only for internal usage by the builders. -func (m *ProjectIssueCommentMutation) IssueIDs() (ids []uuid.UUID) { - if id := m.issue; id != nil { +// AssigneeID instead. It exists only for internal usage by the builders. +func (m *ProjectIssueMutation) AssigneeIDs() (ids []uuid.UUID) { + if id := m.assignee; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetAssignee resets all changes to the "assignee" edge. +func (m *ProjectIssueMutation) ResetAssignee() { + m.assignee = nil + m.clearedassignee = false +} + +// ClearProject clears the "project" edge to the Project entity. +func (m *ProjectIssueMutation) ClearProject() { + m.clearedproject = true + m.clearedFields[projectissue.FieldProjectID] = struct{}{} +} + +// ProjectCleared reports if the "project" edge to the Project entity was cleared. +func (m *ProjectIssueMutation) ProjectCleared() bool { + return m.clearedproject +} + +// ProjectIDs returns the "project" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ProjectID instead. It exists only for internal usage by the builders. +func (m *ProjectIssueMutation) ProjectIDs() (ids []uuid.UUID) { + if id := m.project; id != nil { ids = append(ids, *id) } - return + return +} + +// ResetProject resets all changes to the "project" edge. +func (m *ProjectIssueMutation) ResetProject() { + m.project = nil + m.clearedproject = false +} + +// AddCommentIDs adds the "comments" edge to the ProjectIssueComment entity by ids. +func (m *ProjectIssueMutation) AddCommentIDs(ids ...uuid.UUID) { + if m.comments == nil { + m.comments = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.comments[ids[i]] = struct{}{} + } } -// ResetIssue resets all changes to the "issue" edge. -func (m *ProjectIssueCommentMutation) ResetIssue() { - m.issue = nil - m.clearedissue = false +// ClearComments clears the "comments" edge to the ProjectIssueComment entity. +func (m *ProjectIssueMutation) ClearComments() { + m.clearedcomments = true } -// ClearParent clears the "parent" edge to the ProjectIssueComment entity. -func (m *ProjectIssueCommentMutation) ClearParent() { - m.clearedparent = true - m.clearedFields[projectissuecomment.FieldParentID] = struct{}{} +// CommentsCleared reports if the "comments" edge to the ProjectIssueComment entity was cleared. +func (m *ProjectIssueMutation) CommentsCleared() bool { + return m.clearedcomments } -// ParentCleared reports if the "parent" edge to the ProjectIssueComment entity was cleared. -func (m *ProjectIssueCommentMutation) ParentCleared() bool { - return m.ParentIDCleared() || m.clearedparent +// RemoveCommentIDs removes the "comments" edge to the ProjectIssueComment entity by IDs. +func (m *ProjectIssueMutation) RemoveCommentIDs(ids ...uuid.UUID) { + if m.removedcomments == nil { + m.removedcomments = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.comments, ids[i]) + m.removedcomments[ids[i]] = struct{}{} + } } -// ParentIDs returns the "parent" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ParentID instead. It exists only for internal usage by the builders. -func (m *ProjectIssueCommentMutation) ParentIDs() (ids []uuid.UUID) { - if id := m.parent; id != nil { - ids = append(ids, *id) +// RemovedComments returns the removed IDs of the "comments" edge to the ProjectIssueComment entity. +func (m *ProjectIssueMutation) RemovedCommentsIDs() (ids []uuid.UUID) { + for id := range m.removedcomments { + ids = append(ids, id) } return } -// ResetParent resets all changes to the "parent" edge. -func (m *ProjectIssueCommentMutation) ResetParent() { - m.parent = nil - m.clearedparent = false +// CommentsIDs returns the "comments" edge IDs in the mutation. +func (m *ProjectIssueMutation) CommentsIDs() (ids []uuid.UUID) { + for id := range m.comments { + ids = append(ids, id) + } + return } -// AddReplyIDs adds the "replies" edge to the ProjectIssueComment entity by ids. -func (m *ProjectIssueCommentMutation) AddReplyIDs(ids ...uuid.UUID) { - if m.replies == nil { - m.replies = make(map[uuid.UUID]struct{}) +// ResetComments resets all changes to the "comments" edge. +func (m *ProjectIssueMutation) ResetComments() { + m.comments = nil + m.clearedcomments = false + m.removedcomments = nil +} + +// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by ids. +func (m *ProjectIssueMutation) AddProjectTaskIDs(ids ...uuid.UUID) { + if m.project_tasks == nil { + m.project_tasks = make(map[uuid.UUID]struct{}) } for i := range ids { - m.replies[ids[i]] = struct{}{} + m.project_tasks[ids[i]] = struct{}{} } } -// ClearReplies clears the "replies" edge to the ProjectIssueComment entity. -func (m *ProjectIssueCommentMutation) ClearReplies() { - m.clearedreplies = true +// ClearProjectTasks clears the "project_tasks" edge to the ProjectTask entity. +func (m *ProjectIssueMutation) ClearProjectTasks() { + m.clearedproject_tasks = true } -// RepliesCleared reports if the "replies" edge to the ProjectIssueComment entity was cleared. -func (m *ProjectIssueCommentMutation) RepliesCleared() bool { - return m.clearedreplies +// ProjectTasksCleared reports if the "project_tasks" edge to the ProjectTask entity was cleared. +func (m *ProjectIssueMutation) ProjectTasksCleared() bool { + return m.clearedproject_tasks } -// RemoveReplyIDs removes the "replies" edge to the ProjectIssueComment entity by IDs. -func (m *ProjectIssueCommentMutation) RemoveReplyIDs(ids ...uuid.UUID) { - if m.removedreplies == nil { - m.removedreplies = make(map[uuid.UUID]struct{}) +// RemoveProjectTaskIDs removes the "project_tasks" edge to the ProjectTask entity by IDs. +func (m *ProjectIssueMutation) RemoveProjectTaskIDs(ids ...uuid.UUID) { + if m.removedproject_tasks == nil { + m.removedproject_tasks = make(map[uuid.UUID]struct{}) } for i := range ids { - delete(m.replies, ids[i]) - m.removedreplies[ids[i]] = struct{}{} + delete(m.project_tasks, ids[i]) + m.removedproject_tasks[ids[i]] = struct{}{} } } -// RemovedReplies returns the removed IDs of the "replies" edge to the ProjectIssueComment entity. -func (m *ProjectIssueCommentMutation) RemovedRepliesIDs() (ids []uuid.UUID) { - for id := range m.removedreplies { +// RemovedProjectTasks returns the removed IDs of the "project_tasks" edge to the ProjectTask entity. +func (m *ProjectIssueMutation) RemovedProjectTasksIDs() (ids []uuid.UUID) { + for id := range m.removedproject_tasks { ids = append(ids, id) } return } -// RepliesIDs returns the "replies" edge IDs in the mutation. -func (m *ProjectIssueCommentMutation) RepliesIDs() (ids []uuid.UUID) { - for id := range m.replies { +// ProjectTasksIDs returns the "project_tasks" edge IDs in the mutation. +func (m *ProjectIssueMutation) ProjectTasksIDs() (ids []uuid.UUID) { + for id := range m.project_tasks { ids = append(ids, id) } return } -// ResetReplies resets all changes to the "replies" edge. -func (m *ProjectIssueCommentMutation) ResetReplies() { - m.replies = nil - m.clearedreplies = false - m.removedreplies = nil +// ResetProjectTasks resets all changes to the "project_tasks" edge. +func (m *ProjectIssueMutation) ResetProjectTasks() { + m.project_tasks = nil + m.clearedproject_tasks = false + m.removedproject_tasks = nil } -// Where appends a list predicates to the ProjectIssueCommentMutation builder. -func (m *ProjectIssueCommentMutation) Where(ps ...predicate.ProjectIssueComment) { +// Where appends a list predicates to the ProjectIssueMutation builder. +func (m *ProjectIssueMutation) Where(ps ...predicate.ProjectIssue) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ProjectIssueCommentMutation builder. Using this method, +// WhereP appends storage-level predicates to the ProjectIssueMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ProjectIssueCommentMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.ProjectIssueComment, len(ps)) +func (m *ProjectIssueMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ProjectIssue, len(ps)) for i := range ps { p[i] = ps[i] } @@ -23882,45 +32478,60 @@ func (m *ProjectIssueCommentMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ProjectIssueCommentMutation) Op() Op { +func (m *ProjectIssueMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ProjectIssueCommentMutation) SetOp(op Op) { +func (m *ProjectIssueMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (ProjectIssueComment). -func (m *ProjectIssueCommentMutation) Type() string { +// Type returns the node type of this mutation (ProjectIssue). +func (m *ProjectIssueMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ProjectIssueCommentMutation) Fields() []string { - fields := make([]string, 0, 7) +func (m *ProjectIssueMutation) Fields() []string { + fields := make([]string, 0, 12) if m.deleted_at != nil { - fields = append(fields, projectissuecomment.FieldDeletedAt) + fields = append(fields, projectissue.FieldDeletedAt) } if m.user != nil { - fields = append(fields, projectissuecomment.FieldUserID) + fields = append(fields, projectissue.FieldUserID) } - if m.issue != nil { - fields = append(fields, projectissuecomment.FieldIssueID) + if m.project != nil { + fields = append(fields, projectissue.FieldProjectID) } - if m.parent != nil { - fields = append(fields, projectissuecomment.FieldParentID) + if m.status != nil { + fields = append(fields, projectissue.FieldStatus) } - if m.comment != nil { - fields = append(fields, projectissuecomment.FieldComment) + if m.title != nil { + fields = append(fields, projectissue.FieldTitle) + } + if m.requirement_document != nil { + fields = append(fields, projectissue.FieldRequirementDocument) + } + if m.design_document != nil { + fields = append(fields, projectissue.FieldDesignDocument) + } + if m.summary != nil { + fields = append(fields, projectissue.FieldSummary) + } + if m.assignee != nil { + fields = append(fields, projectissue.FieldAssigneeID) + } + if m.priority != nil { + fields = append(fields, projectissue.FieldPriority) } if m.created_at != nil { - fields = append(fields, projectissuecomment.FieldCreatedAt) + fields = append(fields, projectissue.FieldCreatedAt) } if m.updated_at != nil { - fields = append(fields, projectissuecomment.FieldUpdatedAt) + fields = append(fields, projectissue.FieldUpdatedAt) } return fields } @@ -23928,21 +32539,31 @@ func (m *ProjectIssueCommentMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ProjectIssueCommentMutation) Field(name string) (ent.Value, bool) { +func (m *ProjectIssueMutation) Field(name string) (ent.Value, bool) { switch name { - case projectissuecomment.FieldDeletedAt: + case projectissue.FieldDeletedAt: return m.DeletedAt() - case projectissuecomment.FieldUserID: + case projectissue.FieldUserID: return m.UserID() - case projectissuecomment.FieldIssueID: - return m.IssueID() - case projectissuecomment.FieldParentID: - return m.ParentID() - case projectissuecomment.FieldComment: - return m.Comment() - case projectissuecomment.FieldCreatedAt: + case projectissue.FieldProjectID: + return m.ProjectID() + case projectissue.FieldStatus: + return m.Status() + case projectissue.FieldTitle: + return m.Title() + case projectissue.FieldRequirementDocument: + return m.RequirementDocument() + case projectissue.FieldDesignDocument: + return m.DesignDocument() + case projectissue.FieldSummary: + return m.Summary() + case projectissue.FieldAssigneeID: + return m.AssigneeID() + case projectissue.FieldPriority: + return m.Priority() + case projectissue.FieldCreatedAt: return m.CreatedAt() - case projectissuecomment.FieldUpdatedAt: + case projectissue.FieldUpdatedAt: return m.UpdatedAt() } return nil, false @@ -23951,74 +32572,119 @@ func (m *ProjectIssueCommentMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ProjectIssueCommentMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ProjectIssueMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case projectissuecomment.FieldDeletedAt: + case projectissue.FieldDeletedAt: return m.OldDeletedAt(ctx) - case projectissuecomment.FieldUserID: + case projectissue.FieldUserID: return m.OldUserID(ctx) - case projectissuecomment.FieldIssueID: - return m.OldIssueID(ctx) - case projectissuecomment.FieldParentID: - return m.OldParentID(ctx) - case projectissuecomment.FieldComment: - return m.OldComment(ctx) - case projectissuecomment.FieldCreatedAt: + case projectissue.FieldProjectID: + return m.OldProjectID(ctx) + case projectissue.FieldStatus: + return m.OldStatus(ctx) + case projectissue.FieldTitle: + return m.OldTitle(ctx) + case projectissue.FieldRequirementDocument: + return m.OldRequirementDocument(ctx) + case projectissue.FieldDesignDocument: + return m.OldDesignDocument(ctx) + case projectissue.FieldSummary: + return m.OldSummary(ctx) + case projectissue.FieldAssigneeID: + return m.OldAssigneeID(ctx) + case projectissue.FieldPriority: + return m.OldPriority(ctx) + case projectissue.FieldCreatedAt: return m.OldCreatedAt(ctx) - case projectissuecomment.FieldUpdatedAt: + case projectissue.FieldUpdatedAt: return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown ProjectIssueComment field %s", name) + return nil, fmt.Errorf("unknown ProjectIssue field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectIssueCommentMutation) SetField(name string, value ent.Value) error { +func (m *ProjectIssueMutation) SetField(name string, value ent.Value) error { switch name { - case projectissuecomment.FieldDeletedAt: + case projectissue.FieldDeletedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDeletedAt(v) return nil - case projectissuecomment.FieldUserID: + case projectissue.FieldUserID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUserID(v) return nil - case projectissuecomment.FieldIssueID: + case projectissue.FieldProjectID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetIssueID(v) + m.SetProjectID(v) return nil - case projectissuecomment.FieldParentID: - v, ok := value.(uuid.UUID) + case projectissue.FieldStatus: + v, ok := value.(consts.ProjectIssueStatus) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetParentID(v) + m.SetStatus(v) return nil - case projectissuecomment.FieldComment: + case projectissue.FieldTitle: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetComment(v) + m.SetTitle(v) return nil - case projectissuecomment.FieldCreatedAt: + case projectissue.FieldRequirementDocument: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRequirementDocument(v) + return nil + case projectissue.FieldDesignDocument: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDesignDocument(v) + return nil + case projectissue.FieldSummary: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSummary(v) + return nil + case projectissue.FieldAssigneeID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAssigneeID(v) + return nil + case projectissue.FieldPriority: + v, ok := value.(consts.ProjectIssuePriority) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPriority(v) + return nil + case projectissue.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case projectissuecomment.FieldUpdatedAt: + case projectissue.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) @@ -24026,131 +32692,188 @@ func (m *ProjectIssueCommentMutation) SetField(name string, value ent.Value) err m.SetUpdatedAt(v) return nil } - return fmt.Errorf("unknown ProjectIssueComment field %s", name) + return fmt.Errorf("unknown ProjectIssue field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ProjectIssueCommentMutation) AddedFields() []string { - return nil +func (m *ProjectIssueMutation) AddedFields() []string { + var fields []string + if m.addpriority != nil { + fields = append(fields, projectissue.FieldPriority) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ProjectIssueCommentMutation) AddedField(name string) (ent.Value, bool) { +func (m *ProjectIssueMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case projectissue.FieldPriority: + return m.AddedPriority() + } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectIssueCommentMutation) AddField(name string, value ent.Value) error { +func (m *ProjectIssueMutation) AddField(name string, value ent.Value) error { switch name { + case projectissue.FieldPriority: + v, ok := value.(consts.ProjectIssuePriority) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPriority(v) + return nil } - return fmt.Errorf("unknown ProjectIssueComment numeric field %s", name) + return fmt.Errorf("unknown ProjectIssue numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ProjectIssueCommentMutation) ClearedFields() []string { +func (m *ProjectIssueMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(projectissuecomment.FieldDeletedAt) { - fields = append(fields, projectissuecomment.FieldDeletedAt) + if m.FieldCleared(projectissue.FieldDeletedAt) { + fields = append(fields, projectissue.FieldDeletedAt) } - if m.FieldCleared(projectissuecomment.FieldParentID) { - fields = append(fields, projectissuecomment.FieldParentID) + if m.FieldCleared(projectissue.FieldRequirementDocument) { + fields = append(fields, projectissue.FieldRequirementDocument) + } + if m.FieldCleared(projectissue.FieldDesignDocument) { + fields = append(fields, projectissue.FieldDesignDocument) + } + if m.FieldCleared(projectissue.FieldSummary) { + fields = append(fields, projectissue.FieldSummary) + } + if m.FieldCleared(projectissue.FieldAssigneeID) { + fields = append(fields, projectissue.FieldAssigneeID) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ProjectIssueCommentMutation) FieldCleared(name string) bool { +func (m *ProjectIssueMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ProjectIssueCommentMutation) ClearField(name string) error { +func (m *ProjectIssueMutation) ClearField(name string) error { switch name { - case projectissuecomment.FieldDeletedAt: + case projectissue.FieldDeletedAt: m.ClearDeletedAt() return nil - case projectissuecomment.FieldParentID: - m.ClearParentID() + case projectissue.FieldRequirementDocument: + m.ClearRequirementDocument() + return nil + case projectissue.FieldDesignDocument: + m.ClearDesignDocument() + return nil + case projectissue.FieldSummary: + m.ClearSummary() + return nil + case projectissue.FieldAssigneeID: + m.ClearAssigneeID() return nil } - return fmt.Errorf("unknown ProjectIssueComment nullable field %s", name) + return fmt.Errorf("unknown ProjectIssue nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ProjectIssueCommentMutation) ResetField(name string) error { +func (m *ProjectIssueMutation) ResetField(name string) error { switch name { - case projectissuecomment.FieldDeletedAt: + case projectissue.FieldDeletedAt: m.ResetDeletedAt() return nil - case projectissuecomment.FieldUserID: + case projectissue.FieldUserID: m.ResetUserID() return nil - case projectissuecomment.FieldIssueID: - m.ResetIssueID() + case projectissue.FieldProjectID: + m.ResetProjectID() return nil - case projectissuecomment.FieldParentID: - m.ResetParentID() + case projectissue.FieldStatus: + m.ResetStatus() return nil - case projectissuecomment.FieldComment: - m.ResetComment() + case projectissue.FieldTitle: + m.ResetTitle() return nil - case projectissuecomment.FieldCreatedAt: + case projectissue.FieldRequirementDocument: + m.ResetRequirementDocument() + return nil + case projectissue.FieldDesignDocument: + m.ResetDesignDocument() + return nil + case projectissue.FieldSummary: + m.ResetSummary() + return nil + case projectissue.FieldAssigneeID: + m.ResetAssigneeID() + return nil + case projectissue.FieldPriority: + m.ResetPriority() + return nil + case projectissue.FieldCreatedAt: m.ResetCreatedAt() return nil - case projectissuecomment.FieldUpdatedAt: + case projectissue.FieldUpdatedAt: m.ResetUpdatedAt() return nil } - return fmt.Errorf("unknown ProjectIssueComment field %s", name) + return fmt.Errorf("unknown ProjectIssue field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ProjectIssueCommentMutation) AddedEdges() []string { - edges := make([]string, 0, 4) +func (m *ProjectIssueMutation) AddedEdges() []string { + edges := make([]string, 0, 5) if m.user != nil { - edges = append(edges, projectissuecomment.EdgeUser) + edges = append(edges, projectissue.EdgeUser) } - if m.issue != nil { - edges = append(edges, projectissuecomment.EdgeIssue) + if m.assignee != nil { + edges = append(edges, projectissue.EdgeAssignee) } - if m.parent != nil { - edges = append(edges, projectissuecomment.EdgeParent) + if m.project != nil { + edges = append(edges, projectissue.EdgeProject) } - if m.replies != nil { - edges = append(edges, projectissuecomment.EdgeReplies) + if m.comments != nil { + edges = append(edges, projectissue.EdgeComments) + } + if m.project_tasks != nil { + edges = append(edges, projectissue.EdgeProjectTasks) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ProjectIssueCommentMutation) AddedIDs(name string) []ent.Value { +func (m *ProjectIssueMutation) AddedIDs(name string) []ent.Value { switch name { - case projectissuecomment.EdgeUser: + case projectissue.EdgeUser: if id := m.user; id != nil { return []ent.Value{*id} } - case projectissuecomment.EdgeIssue: - if id := m.issue; id != nil { + case projectissue.EdgeAssignee: + if id := m.assignee; id != nil { return []ent.Value{*id} } - case projectissuecomment.EdgeParent: - if id := m.parent; id != nil { + case projectissue.EdgeProject: + if id := m.project; id != nil { return []ent.Value{*id} } - case projectissuecomment.EdgeReplies: - ids := make([]ent.Value, 0, len(m.replies)) - for id := range m.replies { + case projectissue.EdgeComments: + ids := make([]ent.Value, 0, len(m.comments)) + for id := range m.comments { + ids = append(ids, id) + } + return ids + case projectissue.EdgeProjectTasks: + ids := make([]ent.Value, 0, len(m.project_tasks)) + for id := range m.project_tasks { ids = append(ids, id) } return ids @@ -24159,21 +32882,30 @@ func (m *ProjectIssueCommentMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ProjectIssueCommentMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - if m.removedreplies != nil { - edges = append(edges, projectissuecomment.EdgeReplies) +func (m *ProjectIssueMutation) RemovedEdges() []string { + edges := make([]string, 0, 5) + if m.removedcomments != nil { + edges = append(edges, projectissue.EdgeComments) + } + if m.removedproject_tasks != nil { + edges = append(edges, projectissue.EdgeProjectTasks) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ProjectIssueCommentMutation) RemovedIDs(name string) []ent.Value { +func (m *ProjectIssueMutation) RemovedIDs(name string) []ent.Value { switch name { - case projectissuecomment.EdgeReplies: - ids := make([]ent.Value, 0, len(m.removedreplies)) - for id := range m.removedreplies { + case projectissue.EdgeComments: + ids := make([]ent.Value, 0, len(m.removedcomments)) + for id := range m.removedcomments { + ids = append(ids, id) + } + return ids + case projectissue.EdgeProjectTasks: + ids := make([]ent.Value, 0, len(m.removedproject_tasks)) + for id := range m.removedproject_tasks { ids = append(ids, id) } return ids @@ -24182,116 +32914,120 @@ func (m *ProjectIssueCommentMutation) RemovedIDs(name string) []ent.Value { } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ProjectIssueCommentMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) +func (m *ProjectIssueMutation) ClearedEdges() []string { + edges := make([]string, 0, 5) if m.cleareduser { - edges = append(edges, projectissuecomment.EdgeUser) + edges = append(edges, projectissue.EdgeUser) } - if m.clearedissue { - edges = append(edges, projectissuecomment.EdgeIssue) + if m.clearedassignee { + edges = append(edges, projectissue.EdgeAssignee) } - if m.clearedparent { - edges = append(edges, projectissuecomment.EdgeParent) + if m.clearedproject { + edges = append(edges, projectissue.EdgeProject) } - if m.clearedreplies { - edges = append(edges, projectissuecomment.EdgeReplies) + if m.clearedcomments { + edges = append(edges, projectissue.EdgeComments) + } + if m.clearedproject_tasks { + edges = append(edges, projectissue.EdgeProjectTasks) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ProjectIssueCommentMutation) EdgeCleared(name string) bool { +func (m *ProjectIssueMutation) EdgeCleared(name string) bool { switch name { - case projectissuecomment.EdgeUser: + case projectissue.EdgeUser: return m.cleareduser - case projectissuecomment.EdgeIssue: - return m.clearedissue - case projectissuecomment.EdgeParent: - return m.clearedparent - case projectissuecomment.EdgeReplies: - return m.clearedreplies + case projectissue.EdgeAssignee: + return m.clearedassignee + case projectissue.EdgeProject: + return m.clearedproject + case projectissue.EdgeComments: + return m.clearedcomments + case projectissue.EdgeProjectTasks: + return m.clearedproject_tasks } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ProjectIssueCommentMutation) ClearEdge(name string) error { +func (m *ProjectIssueMutation) ClearEdge(name string) error { switch name { - case projectissuecomment.EdgeUser: + case projectissue.EdgeUser: m.ClearUser() return nil - case projectissuecomment.EdgeIssue: - m.ClearIssue() + case projectissue.EdgeAssignee: + m.ClearAssignee() return nil - case projectissuecomment.EdgeParent: - m.ClearParent() + case projectissue.EdgeProject: + m.ClearProject() return nil } - return fmt.Errorf("unknown ProjectIssueComment unique edge %s", name) + return fmt.Errorf("unknown ProjectIssue unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ProjectIssueCommentMutation) ResetEdge(name string) error { +func (m *ProjectIssueMutation) ResetEdge(name string) error { switch name { - case projectissuecomment.EdgeUser: + case projectissue.EdgeUser: m.ResetUser() return nil - case projectissuecomment.EdgeIssue: - m.ResetIssue() + case projectissue.EdgeAssignee: + m.ResetAssignee() return nil - case projectissuecomment.EdgeParent: - m.ResetParent() + case projectissue.EdgeProject: + m.ResetProject() return nil - case projectissuecomment.EdgeReplies: - m.ResetReplies() + case projectissue.EdgeComments: + m.ResetComments() + return nil + case projectissue.EdgeProjectTasks: + m.ResetProjectTasks() return nil } - return fmt.Errorf("unknown ProjectIssueComment edge %s", name) + return fmt.Errorf("unknown ProjectIssue edge %s", name) } -// ProjectTaskMutation represents an operation that mutates the ProjectTask nodes in the graph. -type ProjectTaskMutation struct { +// ProjectIssueCommentMutation represents an operation that mutates the ProjectIssueComment nodes in the graph. +type ProjectIssueCommentMutation struct { config - op Op - typ string - id *uuid.UUID - repo_url *string - repo_filename *string - branch *string - cli_name *consts.CliName - created_at *time.Time - clearedFields map[string]struct{} - task *uuid.UUID - clearedtask bool - model *uuid.UUID - clearedmodel bool - image *uuid.UUID - clearedimage bool - git_identity *uuid.UUID - clearedgit_identity bool - project *uuid.UUID - clearedproject bool - issue *uuid.UUID - clearedissue bool - done bool - oldValue func(context.Context) (*ProjectTask, error) - predicates []predicate.ProjectTask + op Op + typ string + id *uuid.UUID + deleted_at *time.Time + comment *string + created_at *time.Time + updated_at *time.Time + clearedFields map[string]struct{} + user *uuid.UUID + cleareduser bool + issue *uuid.UUID + clearedissue bool + parent *uuid.UUID + clearedparent bool + replies map[uuid.UUID]struct{} + removedreplies map[uuid.UUID]struct{} + clearedreplies bool + done bool + oldValue func(context.Context) (*ProjectIssueComment, error) + predicates []predicate.ProjectIssueComment } -var _ ent.Mutation = (*ProjectTaskMutation)(nil) +var _ ent.Mutation = (*ProjectIssueCommentMutation)(nil) -// projecttaskOption allows management of the mutation configuration using functional options. -type projecttaskOption func(*ProjectTaskMutation) +// projectissuecommentOption allows management of the mutation configuration using functional options. +type projectissuecommentOption func(*ProjectIssueCommentMutation) -// newProjectTaskMutation creates new mutation for the ProjectTask entity. -func newProjectTaskMutation(c config, op Op, opts ...projecttaskOption) *ProjectTaskMutation { - m := &ProjectTaskMutation{ +// newProjectIssueCommentMutation creates new mutation for the ProjectIssueComment entity. +func newProjectIssueCommentMutation(c config, op Op, opts ...projectissuecommentOption) *ProjectIssueCommentMutation { + m := &ProjectIssueCommentMutation{ config: c, op: op, - typ: TypeProjectTask, + typ: TypeProjectIssueComment, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -24300,20 +33036,20 @@ func newProjectTaskMutation(c config, op Op, opts ...projecttaskOption) *Project return m } -// withProjectTaskID sets the ID field of the mutation. -func withProjectTaskID(id uuid.UUID) projecttaskOption { - return func(m *ProjectTaskMutation) { +// withProjectIssueCommentID sets the ID field of the mutation. +func withProjectIssueCommentID(id uuid.UUID) projectissuecommentOption { + return func(m *ProjectIssueCommentMutation) { var ( err error once sync.Once - value *ProjectTask + value *ProjectIssueComment ) - m.oldValue = func(ctx context.Context) (*ProjectTask, error) { + m.oldValue = func(ctx context.Context) (*ProjectIssueComment, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().ProjectTask.Get(ctx, id) + value, err = m.Client().ProjectIssueComment.Get(ctx, id) } }) return value, err @@ -24322,10 +33058,10 @@ func withProjectTaskID(id uuid.UUID) projecttaskOption { } } -// withProjectTask sets the old ProjectTask of the mutation. -func withProjectTask(node *ProjectTask) projecttaskOption { - return func(m *ProjectTaskMutation) { - m.oldValue = func(context.Context) (*ProjectTask, error) { +// withProjectIssueComment sets the old ProjectIssueComment of the mutation. +func withProjectIssueComment(node *ProjectIssueComment) projectissuecommentOption { + return func(m *ProjectIssueCommentMutation) { + m.oldValue = func(context.Context) (*ProjectIssueComment, error) { return node, nil } m.id = &node.ID @@ -24334,7 +33070,7 @@ func withProjectTask(node *ProjectTask) projecttaskOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ProjectTaskMutation) Client() *Client { +func (m ProjectIssueCommentMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -24342,7 +33078,7 @@ func (m ProjectTaskMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ProjectTaskMutation) Tx() (*Tx, error) { +func (m ProjectIssueCommentMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -24352,14 +33088,14 @@ func (m ProjectTaskMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of ProjectTask entities. -func (m *ProjectTaskMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of ProjectIssueComment entities. +func (m *ProjectIssueCommentMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ProjectTaskMutation) ID() (id uuid.UUID, exists bool) { +func (m *ProjectIssueCommentMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -24370,7 +33106,7 @@ func (m *ProjectTaskMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ProjectTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *ProjectIssueCommentMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -24379,225 +33115,104 @@ func (m *ProjectTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().ProjectTask.Query().Where(m.predicates...).IDs(ctx) + return m.Client().ProjectIssueComment.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetTaskID sets the "task_id" field. -func (m *ProjectTaskMutation) SetTaskID(u uuid.UUID) { - m.task = &u -} - -// TaskID returns the value of the "task_id" field in the mutation. -func (m *ProjectTaskMutation) TaskID() (r uuid.UUID, exists bool) { - v := m.task - if v == nil { - return - } - return *v, true -} - -// OldTaskID returns the old "task_id" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTaskID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTaskID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTaskID: %w", err) - } - return oldValue.TaskID, nil -} - -// ResetTaskID resets all changes to the "task_id" field. -func (m *ProjectTaskMutation) ResetTaskID() { - m.task = nil -} - -// SetModelID sets the "model_id" field. -func (m *ProjectTaskMutation) SetModelID(u uuid.UUID) { - m.model = &u -} - -// ModelID returns the value of the "model_id" field in the mutation. -func (m *ProjectTaskMutation) ModelID() (r uuid.UUID, exists bool) { - v := m.model - if v == nil { - return - } - return *v, true -} - -// OldModelID returns the old "model_id" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModelID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModelID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModelID: %w", err) - } - return oldValue.ModelID, nil -} - -// ResetModelID resets all changes to the "model_id" field. -func (m *ProjectTaskMutation) ResetModelID() { - m.model = nil -} - -// SetImageID sets the "image_id" field. -func (m *ProjectTaskMutation) SetImageID(u uuid.UUID) { - m.image = &u -} - -// ImageID returns the value of the "image_id" field in the mutation. -func (m *ProjectTaskMutation) ImageID() (r uuid.UUID, exists bool) { - v := m.image - if v == nil { - return - } - return *v, true -} - -// OldImageID returns the old "image_id" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldImageID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldImageID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldImageID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldImageID: %w", err) - } - return oldValue.ImageID, nil -} - -// ResetImageID resets all changes to the "image_id" field. -func (m *ProjectTaskMutation) ResetImageID() { - m.image = nil -} - -// SetGitIdentityID sets the "git_identity_id" field. -func (m *ProjectTaskMutation) SetGitIdentityID(u uuid.UUID) { - m.git_identity = &u +// SetDeletedAt sets the "deleted_at" field. +func (m *ProjectIssueCommentMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t } -// GitIdentityID returns the value of the "git_identity_id" field in the mutation. -func (m *ProjectTaskMutation) GitIdentityID() (r uuid.UUID, exists bool) { - v := m.git_identity +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *ProjectIssueCommentMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at if v == nil { return } return *v, true } -// OldGitIdentityID returns the old "git_identity_id" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. +// OldDeletedAt returns the old "deleted_at" field's value of the ProjectIssueComment entity. +// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldGitIdentityID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ProjectIssueCommentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldGitIdentityID is only allowed on UpdateOne operations") + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldGitIdentityID requires an ID field in the mutation") + return v, errors.New("OldDeletedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldGitIdentityID: %w", err) + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) } - return oldValue.GitIdentityID, nil + return oldValue.DeletedAt, nil } -// ClearGitIdentityID clears the value of the "git_identity_id" field. -func (m *ProjectTaskMutation) ClearGitIdentityID() { - m.git_identity = nil - m.clearedFields[projecttask.FieldGitIdentityID] = struct{}{} +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *ProjectIssueCommentMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[projectissuecomment.FieldDeletedAt] = struct{}{} } -// GitIdentityIDCleared returns if the "git_identity_id" field was cleared in this mutation. -func (m *ProjectTaskMutation) GitIdentityIDCleared() bool { - _, ok := m.clearedFields[projecttask.FieldGitIdentityID] +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *ProjectIssueCommentMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[projectissuecomment.FieldDeletedAt] return ok } -// ResetGitIdentityID resets all changes to the "git_identity_id" field. -func (m *ProjectTaskMutation) ResetGitIdentityID() { - m.git_identity = nil - delete(m.clearedFields, projecttask.FieldGitIdentityID) +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *ProjectIssueCommentMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, projectissuecomment.FieldDeletedAt) } -// SetProjectID sets the "project_id" field. -func (m *ProjectTaskMutation) SetProjectID(u uuid.UUID) { - m.project = &u +// SetUserID sets the "user_id" field. +func (m *ProjectIssueCommentMutation) SetUserID(u uuid.UUID) { + m.user = &u } -// ProjectID returns the value of the "project_id" field in the mutation. -func (m *ProjectTaskMutation) ProjectID() (r uuid.UUID, exists bool) { - v := m.project +// UserID returns the value of the "user_id" field in the mutation. +func (m *ProjectIssueCommentMutation) UserID() (r uuid.UUID, exists bool) { + v := m.user if v == nil { return } return *v, true } -// OldProjectID returns the old "project_id" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the ProjectIssueComment entity. +// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldProjectID(ctx context.Context) (v *uuid.UUID, err error) { +func (m *ProjectIssueCommentMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProjectID is only allowed on UpdateOne operations") + return v, errors.New("OldUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProjectID requires an ID field in the mutation") + return v, errors.New("OldUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProjectID: %w", err) + return v, fmt.Errorf("querying old value for OldUserID: %w", err) } - return oldValue.ProjectID, nil -} - -// ClearProjectID clears the value of the "project_id" field. -func (m *ProjectTaskMutation) ClearProjectID() { - m.project = nil - m.clearedFields[projecttask.FieldProjectID] = struct{}{} -} - -// ProjectIDCleared returns if the "project_id" field was cleared in this mutation. -func (m *ProjectTaskMutation) ProjectIDCleared() bool { - _, ok := m.clearedFields[projecttask.FieldProjectID] - return ok + return oldValue.UserID, nil } -// ResetProjectID resets all changes to the "project_id" field. -func (m *ProjectTaskMutation) ResetProjectID() { - m.project = nil - delete(m.clearedFields, projecttask.FieldProjectID) +// ResetUserID resets all changes to the "user_id" field. +func (m *ProjectIssueCommentMutation) ResetUserID() { + m.user = nil } // SetIssueID sets the "issue_id" field. -func (m *ProjectTaskMutation) SetIssueID(u uuid.UUID) { +func (m *ProjectIssueCommentMutation) SetIssueID(u uuid.UUID) { m.issue = &u } // IssueID returns the value of the "issue_id" field in the mutation. -func (m *ProjectTaskMutation) IssueID() (r uuid.UUID, exists bool) { +func (m *ProjectIssueCommentMutation) IssueID() (r uuid.UUID, exists bool) { v := m.issue if v == nil { return @@ -24605,10 +33220,10 @@ func (m *ProjectTaskMutation) IssueID() (r uuid.UUID, exists bool) { return *v, true } -// OldIssueID returns the old "issue_id" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. +// OldIssueID returns the old "issue_id" field's value of the ProjectIssueComment entity. +// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldIssueID(ctx context.Context) (v uuid.UUID, err error) { +func (m *ProjectIssueCommentMutation) OldIssueID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldIssueID is only allowed on UpdateOne operations") } @@ -24622,214 +33237,103 @@ func (m *ProjectTaskMutation) OldIssueID(ctx context.Context) (v uuid.UUID, err return oldValue.IssueID, nil } -// ClearIssueID clears the value of the "issue_id" field. -func (m *ProjectTaskMutation) ClearIssueID() { - m.issue = nil - m.clearedFields[projecttask.FieldIssueID] = struct{}{} -} - -// IssueIDCleared returns if the "issue_id" field was cleared in this mutation. -func (m *ProjectTaskMutation) IssueIDCleared() bool { - _, ok := m.clearedFields[projecttask.FieldIssueID] - return ok -} - // ResetIssueID resets all changes to the "issue_id" field. -func (m *ProjectTaskMutation) ResetIssueID() { +func (m *ProjectIssueCommentMutation) ResetIssueID() { m.issue = nil - delete(m.clearedFields, projecttask.FieldIssueID) -} - -// SetRepoURL sets the "repo_url" field. -func (m *ProjectTaskMutation) SetRepoURL(s string) { - m.repo_url = &s -} - -// RepoURL returns the value of the "repo_url" field in the mutation. -func (m *ProjectTaskMutation) RepoURL() (r string, exists bool) { - v := m.repo_url - if v == nil { - return - } - return *v, true -} - -// OldRepoURL returns the old "repo_url" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldRepoURL(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRepoURL is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRepoURL requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRepoURL: %w", err) - } - return oldValue.RepoURL, nil -} - -// ClearRepoURL clears the value of the "repo_url" field. -func (m *ProjectTaskMutation) ClearRepoURL() { - m.repo_url = nil - m.clearedFields[projecttask.FieldRepoURL] = struct{}{} -} - -// RepoURLCleared returns if the "repo_url" field was cleared in this mutation. -func (m *ProjectTaskMutation) RepoURLCleared() bool { - _, ok := m.clearedFields[projecttask.FieldRepoURL] - return ok -} - -// ResetRepoURL resets all changes to the "repo_url" field. -func (m *ProjectTaskMutation) ResetRepoURL() { - m.repo_url = nil - delete(m.clearedFields, projecttask.FieldRepoURL) -} - -// SetRepoFilename sets the "repo_filename" field. -func (m *ProjectTaskMutation) SetRepoFilename(s string) { - m.repo_filename = &s -} - -// RepoFilename returns the value of the "repo_filename" field in the mutation. -func (m *ProjectTaskMutation) RepoFilename() (r string, exists bool) { - v := m.repo_filename - if v == nil { - return - } - return *v, true -} - -// OldRepoFilename returns the old "repo_filename" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldRepoFilename(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRepoFilename is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRepoFilename requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRepoFilename: %w", err) - } - return oldValue.RepoFilename, nil -} - -// ClearRepoFilename clears the value of the "repo_filename" field. -func (m *ProjectTaskMutation) ClearRepoFilename() { - m.repo_filename = nil - m.clearedFields[projecttask.FieldRepoFilename] = struct{}{} -} - -// RepoFilenameCleared returns if the "repo_filename" field was cleared in this mutation. -func (m *ProjectTaskMutation) RepoFilenameCleared() bool { - _, ok := m.clearedFields[projecttask.FieldRepoFilename] - return ok -} - -// ResetRepoFilename resets all changes to the "repo_filename" field. -func (m *ProjectTaskMutation) ResetRepoFilename() { - m.repo_filename = nil - delete(m.clearedFields, projecttask.FieldRepoFilename) } -// SetBranch sets the "branch" field. -func (m *ProjectTaskMutation) SetBranch(s string) { - m.branch = &s +// SetParentID sets the "parent_id" field. +func (m *ProjectIssueCommentMutation) SetParentID(u uuid.UUID) { + m.parent = &u } -// Branch returns the value of the "branch" field in the mutation. -func (m *ProjectTaskMutation) Branch() (r string, exists bool) { - v := m.branch +// ParentID returns the value of the "parent_id" field in the mutation. +func (m *ProjectIssueCommentMutation) ParentID() (r uuid.UUID, exists bool) { + v := m.parent if v == nil { return } return *v, true } -// OldBranch returns the old "branch" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. +// OldParentID returns the old "parent_id" field's value of the ProjectIssueComment entity. +// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldBranch(ctx context.Context) (v string, err error) { +func (m *ProjectIssueCommentMutation) OldParentID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBranch is only allowed on UpdateOne operations") + return v, errors.New("OldParentID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBranch requires an ID field in the mutation") + return v, errors.New("OldParentID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBranch: %w", err) + return v, fmt.Errorf("querying old value for OldParentID: %w", err) } - return oldValue.Branch, nil + return oldValue.ParentID, nil } -// ClearBranch clears the value of the "branch" field. -func (m *ProjectTaskMutation) ClearBranch() { - m.branch = nil - m.clearedFields[projecttask.FieldBranch] = struct{}{} +// ClearParentID clears the value of the "parent_id" field. +func (m *ProjectIssueCommentMutation) ClearParentID() { + m.parent = nil + m.clearedFields[projectissuecomment.FieldParentID] = struct{}{} } -// BranchCleared returns if the "branch" field was cleared in this mutation. -func (m *ProjectTaskMutation) BranchCleared() bool { - _, ok := m.clearedFields[projecttask.FieldBranch] +// ParentIDCleared returns if the "parent_id" field was cleared in this mutation. +func (m *ProjectIssueCommentMutation) ParentIDCleared() bool { + _, ok := m.clearedFields[projectissuecomment.FieldParentID] return ok } -// ResetBranch resets all changes to the "branch" field. -func (m *ProjectTaskMutation) ResetBranch() { - m.branch = nil - delete(m.clearedFields, projecttask.FieldBranch) +// ResetParentID resets all changes to the "parent_id" field. +func (m *ProjectIssueCommentMutation) ResetParentID() { + m.parent = nil + delete(m.clearedFields, projectissuecomment.FieldParentID) } -// SetCliName sets the "cli_name" field. -func (m *ProjectTaskMutation) SetCliName(cn consts.CliName) { - m.cli_name = &cn +// SetComment sets the "comment" field. +func (m *ProjectIssueCommentMutation) SetComment(s string) { + m.comment = &s } -// CliName returns the value of the "cli_name" field in the mutation. -func (m *ProjectTaskMutation) CliName() (r consts.CliName, exists bool) { - v := m.cli_name +// Comment returns the value of the "comment" field in the mutation. +func (m *ProjectIssueCommentMutation) Comment() (r string, exists bool) { + v := m.comment if v == nil { return } return *v, true } -// OldCliName returns the old "cli_name" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. +// OldComment returns the old "comment" field's value of the ProjectIssueComment entity. +// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldCliName(ctx context.Context) (v consts.CliName, err error) { +func (m *ProjectIssueCommentMutation) OldComment(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCliName is only allowed on UpdateOne operations") + return v, errors.New("OldComment is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCliName requires an ID field in the mutation") + return v, errors.New("OldComment requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCliName: %w", err) + return v, fmt.Errorf("querying old value for OldComment: %w", err) } - return oldValue.CliName, nil + return oldValue.Comment, nil } -// ResetCliName resets all changes to the "cli_name" field. -func (m *ProjectTaskMutation) ResetCliName() { - m.cli_name = nil +// ResetComment resets all changes to the "comment" field. +func (m *ProjectIssueCommentMutation) ResetComment() { + m.comment = nil } // SetCreatedAt sets the "created_at" field. -func (m *ProjectTaskMutation) SetCreatedAt(t time.Time) { +func (m *ProjectIssueCommentMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ProjectTaskMutation) CreatedAt() (r time.Time, exists bool) { +func (m *ProjectIssueCommentMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -24837,10 +33341,10 @@ func (m *ProjectTaskMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the ProjectTask entity. -// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the ProjectIssueComment entity. +// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProjectTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectIssueCommentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -24855,181 +33359,190 @@ func (m *ProjectTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, er } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *ProjectTaskMutation) ResetCreatedAt() { +func (m *ProjectIssueCommentMutation) ResetCreatedAt() { m.created_at = nil } -// ClearTask clears the "task" edge to the Task entity. -func (m *ProjectTaskMutation) ClearTask() { - m.clearedtask = true - m.clearedFields[projecttask.FieldTaskID] = struct{}{} +// SetUpdatedAt sets the "updated_at" field. +func (m *ProjectIssueCommentMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t } -// TaskCleared reports if the "task" edge to the Task entity was cleared. -func (m *ProjectTaskMutation) TaskCleared() bool { - return m.clearedtask +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ProjectIssueCommentMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true } -// TaskIDs returns the "task" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TaskID instead. It exists only for internal usage by the builders. -func (m *ProjectTaskMutation) TaskIDs() (ids []uuid.UUID) { - if id := m.task; id != nil { - ids = append(ids, *id) +// OldUpdatedAt returns the old "updated_at" field's value of the ProjectIssueComment entity. +// If the ProjectIssueComment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ProjectIssueCommentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil } -// ResetTask resets all changes to the "task" edge. -func (m *ProjectTaskMutation) ResetTask() { - m.task = nil - m.clearedtask = false +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ProjectIssueCommentMutation) ResetUpdatedAt() { + m.updated_at = nil } -// ClearModel clears the "model" edge to the Model entity. -func (m *ProjectTaskMutation) ClearModel() { - m.clearedmodel = true - m.clearedFields[projecttask.FieldModelID] = struct{}{} +// ClearUser clears the "user" edge to the User entity. +func (m *ProjectIssueCommentMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[projectissuecomment.FieldUserID] = struct{}{} } -// ModelCleared reports if the "model" edge to the Model entity was cleared. -func (m *ProjectTaskMutation) ModelCleared() bool { - return m.clearedmodel +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *ProjectIssueCommentMutation) UserCleared() bool { + return m.cleareduser } -// ModelIDs returns the "model" edge IDs in the mutation. +// UserIDs returns the "user" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ModelID instead. It exists only for internal usage by the builders. -func (m *ProjectTaskMutation) ModelIDs() (ids []uuid.UUID) { - if id := m.model; id != nil { +// UserID instead. It exists only for internal usage by the builders. +func (m *ProjectIssueCommentMutation) UserIDs() (ids []uuid.UUID) { + if id := m.user; id != nil { ids = append(ids, *id) } return } -// ResetModel resets all changes to the "model" edge. -func (m *ProjectTaskMutation) ResetModel() { - m.model = nil - m.clearedmodel = false +// ResetUser resets all changes to the "user" edge. +func (m *ProjectIssueCommentMutation) ResetUser() { + m.user = nil + m.cleareduser = false } -// ClearImage clears the "image" edge to the Image entity. -func (m *ProjectTaskMutation) ClearImage() { - m.clearedimage = true - m.clearedFields[projecttask.FieldImageID] = struct{}{} +// ClearIssue clears the "issue" edge to the ProjectIssue entity. +func (m *ProjectIssueCommentMutation) ClearIssue() { + m.clearedissue = true + m.clearedFields[projectissuecomment.FieldIssueID] = struct{}{} } -// ImageCleared reports if the "image" edge to the Image entity was cleared. -func (m *ProjectTaskMutation) ImageCleared() bool { - return m.clearedimage +// IssueCleared reports if the "issue" edge to the ProjectIssue entity was cleared. +func (m *ProjectIssueCommentMutation) IssueCleared() bool { + return m.clearedissue } -// ImageIDs returns the "image" edge IDs in the mutation. +// IssueIDs returns the "issue" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ImageID instead. It exists only for internal usage by the builders. -func (m *ProjectTaskMutation) ImageIDs() (ids []uuid.UUID) { - if id := m.image; id != nil { +// IssueID instead. It exists only for internal usage by the builders. +func (m *ProjectIssueCommentMutation) IssueIDs() (ids []uuid.UUID) { + if id := m.issue; id != nil { ids = append(ids, *id) } return } -// ResetImage resets all changes to the "image" edge. -func (m *ProjectTaskMutation) ResetImage() { - m.image = nil - m.clearedimage = false +// ResetIssue resets all changes to the "issue" edge. +func (m *ProjectIssueCommentMutation) ResetIssue() { + m.issue = nil + m.clearedissue = false } -// ClearGitIdentity clears the "git_identity" edge to the GitIdentity entity. -func (m *ProjectTaskMutation) ClearGitIdentity() { - m.clearedgit_identity = true - m.clearedFields[projecttask.FieldGitIdentityID] = struct{}{} +// ClearParent clears the "parent" edge to the ProjectIssueComment entity. +func (m *ProjectIssueCommentMutation) ClearParent() { + m.clearedparent = true + m.clearedFields[projectissuecomment.FieldParentID] = struct{}{} } -// GitIdentityCleared reports if the "git_identity" edge to the GitIdentity entity was cleared. -func (m *ProjectTaskMutation) GitIdentityCleared() bool { - return m.GitIdentityIDCleared() || m.clearedgit_identity +// ParentCleared reports if the "parent" edge to the ProjectIssueComment entity was cleared. +func (m *ProjectIssueCommentMutation) ParentCleared() bool { + return m.ParentIDCleared() || m.clearedparent } -// GitIdentityIDs returns the "git_identity" edge IDs in the mutation. +// ParentIDs returns the "parent" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// GitIdentityID instead. It exists only for internal usage by the builders. -func (m *ProjectTaskMutation) GitIdentityIDs() (ids []uuid.UUID) { - if id := m.git_identity; id != nil { +// ParentID instead. It exists only for internal usage by the builders. +func (m *ProjectIssueCommentMutation) ParentIDs() (ids []uuid.UUID) { + if id := m.parent; id != nil { ids = append(ids, *id) } return } -// ResetGitIdentity resets all changes to the "git_identity" edge. -func (m *ProjectTaskMutation) ResetGitIdentity() { - m.git_identity = nil - m.clearedgit_identity = false -} - -// ClearProject clears the "project" edge to the Project entity. -func (m *ProjectTaskMutation) ClearProject() { - m.clearedproject = true - m.clearedFields[projecttask.FieldProjectID] = struct{}{} +// ResetParent resets all changes to the "parent" edge. +func (m *ProjectIssueCommentMutation) ResetParent() { + m.parent = nil + m.clearedparent = false } -// ProjectCleared reports if the "project" edge to the Project entity was cleared. -func (m *ProjectTaskMutation) ProjectCleared() bool { - return m.ProjectIDCleared() || m.clearedproject +// AddReplyIDs adds the "replies" edge to the ProjectIssueComment entity by ids. +func (m *ProjectIssueCommentMutation) AddReplyIDs(ids ...uuid.UUID) { + if m.replies == nil { + m.replies = make(map[uuid.UUID]struct{}) + } + for i := range ids { + m.replies[ids[i]] = struct{}{} + } } -// ProjectIDs returns the "project" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ProjectID instead. It exists only for internal usage by the builders. -func (m *ProjectTaskMutation) ProjectIDs() (ids []uuid.UUID) { - if id := m.project; id != nil { - ids = append(ids, *id) - } - return +// ClearReplies clears the "replies" edge to the ProjectIssueComment entity. +func (m *ProjectIssueCommentMutation) ClearReplies() { + m.clearedreplies = true } -// ResetProject resets all changes to the "project" edge. -func (m *ProjectTaskMutation) ResetProject() { - m.project = nil - m.clearedproject = false +// RepliesCleared reports if the "replies" edge to the ProjectIssueComment entity was cleared. +func (m *ProjectIssueCommentMutation) RepliesCleared() bool { + return m.clearedreplies } -// ClearIssue clears the "issue" edge to the ProjectIssue entity. -func (m *ProjectTaskMutation) ClearIssue() { - m.clearedissue = true - m.clearedFields[projecttask.FieldIssueID] = struct{}{} +// RemoveReplyIDs removes the "replies" edge to the ProjectIssueComment entity by IDs. +func (m *ProjectIssueCommentMutation) RemoveReplyIDs(ids ...uuid.UUID) { + if m.removedreplies == nil { + m.removedreplies = make(map[uuid.UUID]struct{}) + } + for i := range ids { + delete(m.replies, ids[i]) + m.removedreplies[ids[i]] = struct{}{} + } } -// IssueCleared reports if the "issue" edge to the ProjectIssue entity was cleared. -func (m *ProjectTaskMutation) IssueCleared() bool { - return m.IssueIDCleared() || m.clearedissue +// RemovedReplies returns the removed IDs of the "replies" edge to the ProjectIssueComment entity. +func (m *ProjectIssueCommentMutation) RemovedRepliesIDs() (ids []uuid.UUID) { + for id := range m.removedreplies { + ids = append(ids, id) + } + return } -// IssueIDs returns the "issue" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// IssueID instead. It exists only for internal usage by the builders. -func (m *ProjectTaskMutation) IssueIDs() (ids []uuid.UUID) { - if id := m.issue; id != nil { - ids = append(ids, *id) +// RepliesIDs returns the "replies" edge IDs in the mutation. +func (m *ProjectIssueCommentMutation) RepliesIDs() (ids []uuid.UUID) { + for id := range m.replies { + ids = append(ids, id) } return } -// ResetIssue resets all changes to the "issue" edge. -func (m *ProjectTaskMutation) ResetIssue() { - m.issue = nil - m.clearedissue = false +// ResetReplies resets all changes to the "replies" edge. +func (m *ProjectIssueCommentMutation) ResetReplies() { + m.replies = nil + m.clearedreplies = false + m.removedreplies = nil } -// Where appends a list predicates to the ProjectTaskMutation builder. -func (m *ProjectTaskMutation) Where(ps ...predicate.ProjectTask) { +// Where appends a list predicates to the ProjectIssueCommentMutation builder. +func (m *ProjectIssueCommentMutation) Where(ps ...predicate.ProjectIssueComment) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ProjectTaskMutation builder. Using this method, +// WhereP appends storage-level predicates to the ProjectIssueCommentMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ProjectTaskMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.ProjectTask, len(ps)) +func (m *ProjectIssueCommentMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ProjectIssueComment, len(ps)) for i := range ps { p[i] = ps[i] } @@ -25037,57 +33550,45 @@ func (m *ProjectTaskMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ProjectTaskMutation) Op() Op { +func (m *ProjectIssueCommentMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ProjectTaskMutation) SetOp(op Op) { +func (m *ProjectIssueCommentMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (ProjectTask). -func (m *ProjectTaskMutation) Type() string { +// Type returns the node type of this mutation (ProjectIssueComment). +func (m *ProjectIssueCommentMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ProjectTaskMutation) Fields() []string { - fields := make([]string, 0, 11) - if m.task != nil { - fields = append(fields, projecttask.FieldTaskID) - } - if m.model != nil { - fields = append(fields, projecttask.FieldModelID) - } - if m.image != nil { - fields = append(fields, projecttask.FieldImageID) - } - if m.git_identity != nil { - fields = append(fields, projecttask.FieldGitIdentityID) +func (m *ProjectIssueCommentMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.deleted_at != nil { + fields = append(fields, projectissuecomment.FieldDeletedAt) } - if m.project != nil { - fields = append(fields, projecttask.FieldProjectID) + if m.user != nil { + fields = append(fields, projectissuecomment.FieldUserID) } if m.issue != nil { - fields = append(fields, projecttask.FieldIssueID) - } - if m.repo_url != nil { - fields = append(fields, projecttask.FieldRepoURL) - } - if m.repo_filename != nil { - fields = append(fields, projecttask.FieldRepoFilename) + fields = append(fields, projectissuecomment.FieldIssueID) } - if m.branch != nil { - fields = append(fields, projecttask.FieldBranch) + if m.parent != nil { + fields = append(fields, projectissuecomment.FieldParentID) } - if m.cli_name != nil { - fields = append(fields, projecttask.FieldCliName) + if m.comment != nil { + fields = append(fields, projectissuecomment.FieldComment) } if m.created_at != nil { - fields = append(fields, projecttask.FieldCreatedAt) + fields = append(fields, projectissuecomment.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, projectissuecomment.FieldUpdatedAt) } return fields } @@ -25095,30 +33596,22 @@ func (m *ProjectTaskMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ProjectTaskMutation) Field(name string) (ent.Value, bool) { +func (m *ProjectIssueCommentMutation) Field(name string) (ent.Value, bool) { switch name { - case projecttask.FieldTaskID: - return m.TaskID() - case projecttask.FieldModelID: - return m.ModelID() - case projecttask.FieldImageID: - return m.ImageID() - case projecttask.FieldGitIdentityID: - return m.GitIdentityID() - case projecttask.FieldProjectID: - return m.ProjectID() - case projecttask.FieldIssueID: + case projectissuecomment.FieldDeletedAt: + return m.DeletedAt() + case projectissuecomment.FieldUserID: + return m.UserID() + case projectissuecomment.FieldIssueID: return m.IssueID() - case projecttask.FieldRepoURL: - return m.RepoURL() - case projecttask.FieldRepoFilename: - return m.RepoFilename() - case projecttask.FieldBranch: - return m.Branch() - case projecttask.FieldCliName: - return m.CliName() - case projecttask.FieldCreatedAt: + case projectissuecomment.FieldParentID: + return m.ParentID() + case projectissuecomment.FieldComment: + return m.Comment() + case projectissuecomment.FieldCreatedAt: return m.CreatedAt() + case projectissuecomment.FieldUpdatedAt: + return m.UpdatedAt() } return nil, false } @@ -25126,458 +33619,347 @@ func (m *ProjectTaskMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ProjectTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ProjectIssueCommentMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case projecttask.FieldTaskID: - return m.OldTaskID(ctx) - case projecttask.FieldModelID: - return m.OldModelID(ctx) - case projecttask.FieldImageID: - return m.OldImageID(ctx) - case projecttask.FieldGitIdentityID: - return m.OldGitIdentityID(ctx) - case projecttask.FieldProjectID: - return m.OldProjectID(ctx) - case projecttask.FieldIssueID: + case projectissuecomment.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case projectissuecomment.FieldUserID: + return m.OldUserID(ctx) + case projectissuecomment.FieldIssueID: return m.OldIssueID(ctx) - case projecttask.FieldRepoURL: - return m.OldRepoURL(ctx) - case projecttask.FieldRepoFilename: - return m.OldRepoFilename(ctx) - case projecttask.FieldBranch: - return m.OldBranch(ctx) - case projecttask.FieldCliName: - return m.OldCliName(ctx) - case projecttask.FieldCreatedAt: + case projectissuecomment.FieldParentID: + return m.OldParentID(ctx) + case projectissuecomment.FieldComment: + return m.OldComment(ctx) + case projectissuecomment.FieldCreatedAt: return m.OldCreatedAt(ctx) + case projectissuecomment.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown ProjectTask field %s", name) + return nil, fmt.Errorf("unknown ProjectIssueComment field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectTaskMutation) SetField(name string, value ent.Value) error { +func (m *ProjectIssueCommentMutation) SetField(name string, value ent.Value) error { switch name { - case projecttask.FieldTaskID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTaskID(v) - return nil - case projecttask.FieldModelID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetModelID(v) - return nil - case projecttask.FieldImageID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetImageID(v) - return nil - case projecttask.FieldGitIdentityID: - v, ok := value.(uuid.UUID) + case projectissuecomment.FieldDeletedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetGitIdentityID(v) + m.SetDeletedAt(v) return nil - case projecttask.FieldProjectID: + case projectissuecomment.FieldUserID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetProjectID(v) + m.SetUserID(v) return nil - case projecttask.FieldIssueID: + case projectissuecomment.FieldIssueID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetIssueID(v) return nil - case projecttask.FieldRepoURL: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRepoURL(v) - return nil - case projecttask.FieldRepoFilename: - v, ok := value.(string) + case projectissuecomment.FieldParentID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRepoFilename(v) + m.SetParentID(v) return nil - case projecttask.FieldBranch: + case projectissuecomment.FieldComment: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetBranch(v) + m.SetComment(v) return nil - case projecttask.FieldCliName: - v, ok := value.(consts.CliName) + case projectissuecomment.FieldCreatedAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCliName(v) + m.SetCreatedAt(v) return nil - case projecttask.FieldCreatedAt: + case projectissuecomment.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreatedAt(v) + m.SetUpdatedAt(v) return nil } - return fmt.Errorf("unknown ProjectTask field %s", name) + return fmt.Errorf("unknown ProjectIssueComment field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ProjectTaskMutation) AddedFields() []string { +func (m *ProjectIssueCommentMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ProjectTaskMutation) AddedField(name string) (ent.Value, bool) { +func (m *ProjectIssueCommentMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProjectTaskMutation) AddField(name string, value ent.Value) error { +func (m *ProjectIssueCommentMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown ProjectTask numeric field %s", name) + return fmt.Errorf("unknown ProjectIssueComment numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ProjectTaskMutation) ClearedFields() []string { +func (m *ProjectIssueCommentMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(projecttask.FieldGitIdentityID) { - fields = append(fields, projecttask.FieldGitIdentityID) - } - if m.FieldCleared(projecttask.FieldProjectID) { - fields = append(fields, projecttask.FieldProjectID) - } - if m.FieldCleared(projecttask.FieldIssueID) { - fields = append(fields, projecttask.FieldIssueID) - } - if m.FieldCleared(projecttask.FieldRepoURL) { - fields = append(fields, projecttask.FieldRepoURL) - } - if m.FieldCleared(projecttask.FieldRepoFilename) { - fields = append(fields, projecttask.FieldRepoFilename) + if m.FieldCleared(projectissuecomment.FieldDeletedAt) { + fields = append(fields, projectissuecomment.FieldDeletedAt) } - if m.FieldCleared(projecttask.FieldBranch) { - fields = append(fields, projecttask.FieldBranch) + if m.FieldCleared(projectissuecomment.FieldParentID) { + fields = append(fields, projectissuecomment.FieldParentID) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ProjectTaskMutation) FieldCleared(name string) bool { +func (m *ProjectIssueCommentMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ProjectTaskMutation) ClearField(name string) error { +func (m *ProjectIssueCommentMutation) ClearField(name string) error { switch name { - case projecttask.FieldGitIdentityID: - m.ClearGitIdentityID() - return nil - case projecttask.FieldProjectID: - m.ClearProjectID() - return nil - case projecttask.FieldIssueID: - m.ClearIssueID() - return nil - case projecttask.FieldRepoURL: - m.ClearRepoURL() - return nil - case projecttask.FieldRepoFilename: - m.ClearRepoFilename() + case projectissuecomment.FieldDeletedAt: + m.ClearDeletedAt() return nil - case projecttask.FieldBranch: - m.ClearBranch() + case projectissuecomment.FieldParentID: + m.ClearParentID() return nil } - return fmt.Errorf("unknown ProjectTask nullable field %s", name) + return fmt.Errorf("unknown ProjectIssueComment nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ProjectTaskMutation) ResetField(name string) error { +func (m *ProjectIssueCommentMutation) ResetField(name string) error { switch name { - case projecttask.FieldTaskID: - m.ResetTaskID() - return nil - case projecttask.FieldModelID: - m.ResetModelID() - return nil - case projecttask.FieldImageID: - m.ResetImageID() - return nil - case projecttask.FieldGitIdentityID: - m.ResetGitIdentityID() - return nil - case projecttask.FieldProjectID: - m.ResetProjectID() - return nil - case projecttask.FieldIssueID: - m.ResetIssueID() + case projectissuecomment.FieldDeletedAt: + m.ResetDeletedAt() return nil - case projecttask.FieldRepoURL: - m.ResetRepoURL() + case projectissuecomment.FieldUserID: + m.ResetUserID() return nil - case projecttask.FieldRepoFilename: - m.ResetRepoFilename() + case projectissuecomment.FieldIssueID: + m.ResetIssueID() return nil - case projecttask.FieldBranch: - m.ResetBranch() + case projectissuecomment.FieldParentID: + m.ResetParentID() return nil - case projecttask.FieldCliName: - m.ResetCliName() + case projectissuecomment.FieldComment: + m.ResetComment() return nil - case projecttask.FieldCreatedAt: + case projectissuecomment.FieldCreatedAt: m.ResetCreatedAt() return nil + case projectissuecomment.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil } - return fmt.Errorf("unknown ProjectTask field %s", name) + return fmt.Errorf("unknown ProjectIssueComment field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ProjectTaskMutation) AddedEdges() []string { - edges := make([]string, 0, 6) - if m.task != nil { - edges = append(edges, projecttask.EdgeTask) - } - if m.model != nil { - edges = append(edges, projecttask.EdgeModel) - } - if m.image != nil { - edges = append(edges, projecttask.EdgeImage) +func (m *ProjectIssueCommentMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.user != nil { + edges = append(edges, projectissuecomment.EdgeUser) } - if m.git_identity != nil { - edges = append(edges, projecttask.EdgeGitIdentity) + if m.issue != nil { + edges = append(edges, projectissuecomment.EdgeIssue) } - if m.project != nil { - edges = append(edges, projecttask.EdgeProject) + if m.parent != nil { + edges = append(edges, projectissuecomment.EdgeParent) } - if m.issue != nil { - edges = append(edges, projecttask.EdgeIssue) + if m.replies != nil { + edges = append(edges, projectissuecomment.EdgeReplies) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ProjectTaskMutation) AddedIDs(name string) []ent.Value { +func (m *ProjectIssueCommentMutation) AddedIDs(name string) []ent.Value { switch name { - case projecttask.EdgeTask: - if id := m.task; id != nil { - return []ent.Value{*id} - } - case projecttask.EdgeModel: - if id := m.model; id != nil { - return []ent.Value{*id} - } - case projecttask.EdgeImage: - if id := m.image; id != nil { + case projectissuecomment.EdgeUser: + if id := m.user; id != nil { return []ent.Value{*id} } - case projecttask.EdgeGitIdentity: - if id := m.git_identity; id != nil { + case projectissuecomment.EdgeIssue: + if id := m.issue; id != nil { return []ent.Value{*id} } - case projecttask.EdgeProject: - if id := m.project; id != nil { + case projectissuecomment.EdgeParent: + if id := m.parent; id != nil { return []ent.Value{*id} } - case projecttask.EdgeIssue: - if id := m.issue; id != nil { - return []ent.Value{*id} + case projectissuecomment.EdgeReplies: + ids := make([]ent.Value, 0, len(m.replies)) + for id := range m.replies { + ids = append(ids, id) } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ProjectTaskMutation) RemovedEdges() []string { - edges := make([]string, 0, 6) +func (m *ProjectIssueCommentMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedreplies != nil { + edges = append(edges, projectissuecomment.EdgeReplies) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ProjectTaskMutation) RemovedIDs(name string) []ent.Value { +func (m *ProjectIssueCommentMutation) RemovedIDs(name string) []ent.Value { + switch name { + case projectissuecomment.EdgeReplies: + ids := make([]ent.Value, 0, len(m.removedreplies)) + for id := range m.removedreplies { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ProjectTaskMutation) ClearedEdges() []string { - edges := make([]string, 0, 6) - if m.clearedtask { - edges = append(edges, projecttask.EdgeTask) - } - if m.clearedmodel { - edges = append(edges, projecttask.EdgeModel) - } - if m.clearedimage { - edges = append(edges, projecttask.EdgeImage) +func (m *ProjectIssueCommentMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.cleareduser { + edges = append(edges, projectissuecomment.EdgeUser) } - if m.clearedgit_identity { - edges = append(edges, projecttask.EdgeGitIdentity) + if m.clearedissue { + edges = append(edges, projectissuecomment.EdgeIssue) } - if m.clearedproject { - edges = append(edges, projecttask.EdgeProject) + if m.clearedparent { + edges = append(edges, projectissuecomment.EdgeParent) } - if m.clearedissue { - edges = append(edges, projecttask.EdgeIssue) + if m.clearedreplies { + edges = append(edges, projectissuecomment.EdgeReplies) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ProjectTaskMutation) EdgeCleared(name string) bool { +func (m *ProjectIssueCommentMutation) EdgeCleared(name string) bool { switch name { - case projecttask.EdgeTask: - return m.clearedtask - case projecttask.EdgeModel: - return m.clearedmodel - case projecttask.EdgeImage: - return m.clearedimage - case projecttask.EdgeGitIdentity: - return m.clearedgit_identity - case projecttask.EdgeProject: - return m.clearedproject - case projecttask.EdgeIssue: + case projectissuecomment.EdgeUser: + return m.cleareduser + case projectissuecomment.EdgeIssue: return m.clearedissue + case projectissuecomment.EdgeParent: + return m.clearedparent + case projectissuecomment.EdgeReplies: + return m.clearedreplies } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ProjectTaskMutation) ClearEdge(name string) error { +func (m *ProjectIssueCommentMutation) ClearEdge(name string) error { switch name { - case projecttask.EdgeTask: - m.ClearTask() - return nil - case projecttask.EdgeModel: - m.ClearModel() - return nil - case projecttask.EdgeImage: - m.ClearImage() - return nil - case projecttask.EdgeGitIdentity: - m.ClearGitIdentity() - return nil - case projecttask.EdgeProject: - m.ClearProject() + case projectissuecomment.EdgeUser: + m.ClearUser() return nil - case projecttask.EdgeIssue: + case projectissuecomment.EdgeIssue: m.ClearIssue() return nil + case projectissuecomment.EdgeParent: + m.ClearParent() + return nil } - return fmt.Errorf("unknown ProjectTask unique edge %s", name) + return fmt.Errorf("unknown ProjectIssueComment unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ProjectTaskMutation) ResetEdge(name string) error { +func (m *ProjectIssueCommentMutation) ResetEdge(name string) error { switch name { - case projecttask.EdgeTask: - m.ResetTask() - return nil - case projecttask.EdgeModel: - m.ResetModel() - return nil - case projecttask.EdgeImage: - m.ResetImage() + case projectissuecomment.EdgeUser: + m.ResetUser() return nil - case projecttask.EdgeGitIdentity: - m.ResetGitIdentity() + case projectissuecomment.EdgeIssue: + m.ResetIssue() return nil - case projecttask.EdgeProject: - m.ResetProject() + case projectissuecomment.EdgeParent: + m.ResetParent() return nil - case projecttask.EdgeIssue: - m.ResetIssue() + case projectissuecomment.EdgeReplies: + m.ResetReplies() return nil } - return fmt.Errorf("unknown ProjectTask edge %s", name) + return fmt.Errorf("unknown ProjectIssueComment edge %s", name) } -// SkillMutation represents an operation that mutates the Skill nodes in the graph. -type SkillMutation struct { +// ProjectTaskMutation represents an operation that mutates the ProjectTask nodes in the graph. +type ProjectTaskMutation struct { config - op Op - typ string - id *uuid.UUID - deleted_at *time.Time - name *string - description *string - tags *[]string - appendtags []string - content *string - package_object_key *string - package_url *string - source_type *string - source_label *string - skill_md_path *string - extension_package_id *string - extension_skill_id *string - extension_version *string - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - user *uuid.UUID - cleareduser bool - teams map[uuid.UUID]struct{} - removedteams map[uuid.UUID]struct{} - clearedteams bool - groups map[uuid.UUID]struct{} - removedgroups map[uuid.UUID]struct{} - clearedgroups bool - team_skills map[uuid.UUID]struct{} - removedteam_skills map[uuid.UUID]struct{} - clearedteam_skills bool - team_group_skills map[uuid.UUID]struct{} - removedteam_group_skills map[uuid.UUID]struct{} - clearedteam_group_skills bool - done bool - oldValue func(context.Context) (*Skill, error) - predicates []predicate.Skill + op Op + typ string + id *uuid.UUID + repo_url *string + repo_filename *string + branch *string + cli_name *consts.CliName + created_at *time.Time + clearedFields map[string]struct{} + task *uuid.UUID + clearedtask bool + model *uuid.UUID + clearedmodel bool + image *uuid.UUID + clearedimage bool + git_identity *uuid.UUID + clearedgit_identity bool + project *uuid.UUID + clearedproject bool + issue *uuid.UUID + clearedissue bool + done bool + oldValue func(context.Context) (*ProjectTask, error) + predicates []predicate.ProjectTask } -var _ ent.Mutation = (*SkillMutation)(nil) +var _ ent.Mutation = (*ProjectTaskMutation)(nil) -// skillOption allows management of the mutation configuration using functional options. -type skillOption func(*SkillMutation) +// projecttaskOption allows management of the mutation configuration using functional options. +type projecttaskOption func(*ProjectTaskMutation) -// newSkillMutation creates new mutation for the Skill entity. -func newSkillMutation(c config, op Op, opts ...skillOption) *SkillMutation { - m := &SkillMutation{ +// newProjectTaskMutation creates new mutation for the ProjectTask entity. +func newProjectTaskMutation(c config, op Op, opts ...projecttaskOption) *ProjectTaskMutation { + m := &ProjectTaskMutation{ config: c, op: op, - typ: TypeSkill, + typ: TypeProjectTask, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -25586,20 +33968,20 @@ func newSkillMutation(c config, op Op, opts ...skillOption) *SkillMutation { return m } -// withSkillID sets the ID field of the mutation. -func withSkillID(id uuid.UUID) skillOption { - return func(m *SkillMutation) { +// withProjectTaskID sets the ID field of the mutation. +func withProjectTaskID(id uuid.UUID) projecttaskOption { + return func(m *ProjectTaskMutation) { var ( err error once sync.Once - value *Skill + value *ProjectTask ) - m.oldValue = func(ctx context.Context) (*Skill, error) { + m.oldValue = func(ctx context.Context) (*ProjectTask, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Skill.Get(ctx, id) + value, err = m.Client().ProjectTask.Get(ctx, id) } }) return value, err @@ -25608,10 +33990,10 @@ func withSkillID(id uuid.UUID) skillOption { } } -// withSkill sets the old Skill of the mutation. -func withSkill(node *Skill) skillOption { - return func(m *SkillMutation) { - m.oldValue = func(context.Context) (*Skill, error) { +// withProjectTask sets the old ProjectTask of the mutation. +func withProjectTask(node *ProjectTask) projecttaskOption { + return func(m *ProjectTaskMutation) { + m.oldValue = func(context.Context) (*ProjectTask, error) { return node, nil } m.id = &node.ID @@ -25620,7 +34002,7 @@ func withSkill(node *Skill) skillOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m SkillMutation) Client() *Client { +func (m ProjectTaskMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -25628,7 +34010,7 @@ func (m SkillMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m SkillMutation) Tx() (*Tx, error) { +func (m ProjectTaskMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("db: mutation is not running in a transaction") } @@ -25638,14 +34020,14 @@ func (m SkillMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Skill entities. -func (m *SkillMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of ProjectTask entities. +func (m *ProjectTaskMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *SkillMutation) ID() (id uuid.UUID, exists bool) { +func (m *ProjectTaskMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -25656,7 +34038,7 @@ func (m *SkillMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *SkillMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *ProjectTaskMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -25665,960 +34047,657 @@ func (m *SkillMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Skill.Query().Where(m.predicates...).IDs(ctx) + return m.Client().ProjectTask.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetDeletedAt sets the "deleted_at" field. -func (m *SkillMutation) SetDeletedAt(t time.Time) { - m.deleted_at = &t -} - -// DeletedAt returns the value of the "deleted_at" field in the mutation. -func (m *SkillMutation) DeletedAt() (r time.Time, exists bool) { - v := m.deleted_at - if v == nil { - return - } - return *v, true -} - -// OldDeletedAt returns the old "deleted_at" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeletedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) - } - return oldValue.DeletedAt, nil -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (m *SkillMutation) ClearDeletedAt() { - m.deleted_at = nil - m.clearedFields[skill.FieldDeletedAt] = struct{}{} -} - -// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. -func (m *SkillMutation) DeletedAtCleared() bool { - _, ok := m.clearedFields[skill.FieldDeletedAt] - return ok -} - -// ResetDeletedAt resets all changes to the "deleted_at" field. -func (m *SkillMutation) ResetDeletedAt() { - m.deleted_at = nil - delete(m.clearedFields, skill.FieldDeletedAt) -} - -// SetUserID sets the "user_id" field. -func (m *SkillMutation) SetUserID(u uuid.UUID) { - m.user = &u -} - -// UserID returns the value of the "user_id" field in the mutation. -func (m *SkillMutation) UserID() (r uuid.UUID, exists bool) { - v := m.user - if v == nil { - return - } - return *v, true -} - -// OldUserID returns the old "user_id" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) - } - return oldValue.UserID, nil -} - -// ResetUserID resets all changes to the "user_id" field. -func (m *SkillMutation) ResetUserID() { - m.user = nil -} - -// SetName sets the "name" field. -func (m *SkillMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *SkillMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *SkillMutation) ResetName() { - m.name = nil -} - -// SetDescription sets the "description" field. -func (m *SkillMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *SkillMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true -} - -// OldDescription returns the old "description" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ResetDescription resets all changes to the "description" field. -func (m *SkillMutation) ResetDescription() { - m.description = nil -} - -// SetTags sets the "tags" field. -func (m *SkillMutation) SetTags(s []string) { - m.tags = &s - m.appendtags = nil +// SetTaskID sets the "task_id" field. +func (m *ProjectTaskMutation) SetTaskID(u uuid.UUID) { + m.task = &u } -// Tags returns the value of the "tags" field in the mutation. -func (m *SkillMutation) Tags() (r []string, exists bool) { - v := m.tags +// TaskID returns the value of the "task_id" field in the mutation. +func (m *ProjectTaskMutation) TaskID() (r uuid.UUID, exists bool) { + v := m.task if v == nil { return } return *v, true } -// OldTags returns the old "tags" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldTaskID returns the old "task_id" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldTags(ctx context.Context) (v []string, err error) { +func (m *ProjectTaskMutation) OldTaskID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTags is only allowed on UpdateOne operations") + return v, errors.New("OldTaskID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTags requires an ID field in the mutation") + return v, errors.New("OldTaskID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTags: %w", err) - } - return oldValue.Tags, nil -} - -// AppendTags adds s to the "tags" field. -func (m *SkillMutation) AppendTags(s []string) { - m.appendtags = append(m.appendtags, s...) -} - -// AppendedTags returns the list of values that were appended to the "tags" field in this mutation. -func (m *SkillMutation) AppendedTags() ([]string, bool) { - if len(m.appendtags) == 0 { - return nil, false + return v, fmt.Errorf("querying old value for OldTaskID: %w", err) } - return m.appendtags, true -} - -// ClearTags clears the value of the "tags" field. -func (m *SkillMutation) ClearTags() { - m.tags = nil - m.appendtags = nil - m.clearedFields[skill.FieldTags] = struct{}{} -} - -// TagsCleared returns if the "tags" field was cleared in this mutation. -func (m *SkillMutation) TagsCleared() bool { - _, ok := m.clearedFields[skill.FieldTags] - return ok + return oldValue.TaskID, nil } -// ResetTags resets all changes to the "tags" field. -func (m *SkillMutation) ResetTags() { - m.tags = nil - m.appendtags = nil - delete(m.clearedFields, skill.FieldTags) +// ResetTaskID resets all changes to the "task_id" field. +func (m *ProjectTaskMutation) ResetTaskID() { + m.task = nil } -// SetContent sets the "content" field. -func (m *SkillMutation) SetContent(s string) { - m.content = &s +// SetModelID sets the "model_id" field. +func (m *ProjectTaskMutation) SetModelID(u uuid.UUID) { + m.model = &u } -// Content returns the value of the "content" field in the mutation. -func (m *SkillMutation) Content() (r string, exists bool) { - v := m.content +// ModelID returns the value of the "model_id" field in the mutation. +func (m *ProjectTaskMutation) ModelID() (r uuid.UUID, exists bool) { + v := m.model if v == nil { return } return *v, true } -// OldContent returns the old "content" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldModelID returns the old "model_id" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldContent(ctx context.Context) (v string, err error) { +func (m *ProjectTaskMutation) OldModelID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldContent is only allowed on UpdateOne operations") + return v, errors.New("OldModelID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldContent requires an ID field in the mutation") + return v, errors.New("OldModelID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldContent: %w", err) + return v, fmt.Errorf("querying old value for OldModelID: %w", err) } - return oldValue.Content, nil + return oldValue.ModelID, nil } -// ResetContent resets all changes to the "content" field. -func (m *SkillMutation) ResetContent() { - m.content = nil +// ResetModelID resets all changes to the "model_id" field. +func (m *ProjectTaskMutation) ResetModelID() { + m.model = nil } -// SetPackageObjectKey sets the "package_object_key" field. -func (m *SkillMutation) SetPackageObjectKey(s string) { - m.package_object_key = &s +// SetImageID sets the "image_id" field. +func (m *ProjectTaskMutation) SetImageID(u uuid.UUID) { + m.image = &u } -// PackageObjectKey returns the value of the "package_object_key" field in the mutation. -func (m *SkillMutation) PackageObjectKey() (r string, exists bool) { - v := m.package_object_key +// ImageID returns the value of the "image_id" field in the mutation. +func (m *ProjectTaskMutation) ImageID() (r uuid.UUID, exists bool) { + v := m.image if v == nil { return } return *v, true } -// OldPackageObjectKey returns the old "package_object_key" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldImageID returns the old "image_id" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldPackageObjectKey(ctx context.Context) (v string, err error) { +func (m *ProjectTaskMutation) OldImageID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPackageObjectKey is only allowed on UpdateOne operations") + return v, errors.New("OldImageID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPackageObjectKey requires an ID field in the mutation") + return v, errors.New("OldImageID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPackageObjectKey: %w", err) + return v, fmt.Errorf("querying old value for OldImageID: %w", err) } - return oldValue.PackageObjectKey, nil -} - -// ClearPackageObjectKey clears the value of the "package_object_key" field. -func (m *SkillMutation) ClearPackageObjectKey() { - m.package_object_key = nil - m.clearedFields[skill.FieldPackageObjectKey] = struct{}{} -} - -// PackageObjectKeyCleared returns if the "package_object_key" field was cleared in this mutation. -func (m *SkillMutation) PackageObjectKeyCleared() bool { - _, ok := m.clearedFields[skill.FieldPackageObjectKey] - return ok + return oldValue.ImageID, nil } -// ResetPackageObjectKey resets all changes to the "package_object_key" field. -func (m *SkillMutation) ResetPackageObjectKey() { - m.package_object_key = nil - delete(m.clearedFields, skill.FieldPackageObjectKey) +// ResetImageID resets all changes to the "image_id" field. +func (m *ProjectTaskMutation) ResetImageID() { + m.image = nil } -// SetPackageURL sets the "package_url" field. -func (m *SkillMutation) SetPackageURL(s string) { - m.package_url = &s +// SetGitIdentityID sets the "git_identity_id" field. +func (m *ProjectTaskMutation) SetGitIdentityID(u uuid.UUID) { + m.git_identity = &u } -// PackageURL returns the value of the "package_url" field in the mutation. -func (m *SkillMutation) PackageURL() (r string, exists bool) { - v := m.package_url +// GitIdentityID returns the value of the "git_identity_id" field in the mutation. +func (m *ProjectTaskMutation) GitIdentityID() (r uuid.UUID, exists bool) { + v := m.git_identity if v == nil { return } return *v, true } -// OldPackageURL returns the old "package_url" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldGitIdentityID returns the old "git_identity_id" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldPackageURL(ctx context.Context) (v string, err error) { +func (m *ProjectTaskMutation) OldGitIdentityID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPackageURL is only allowed on UpdateOne operations") + return v, errors.New("OldGitIdentityID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPackageURL requires an ID field in the mutation") + return v, errors.New("OldGitIdentityID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPackageURL: %w", err) + return v, fmt.Errorf("querying old value for OldGitIdentityID: %w", err) } - return oldValue.PackageURL, nil + return oldValue.GitIdentityID, nil } -// ClearPackageURL clears the value of the "package_url" field. -func (m *SkillMutation) ClearPackageURL() { - m.package_url = nil - m.clearedFields[skill.FieldPackageURL] = struct{}{} +// ClearGitIdentityID clears the value of the "git_identity_id" field. +func (m *ProjectTaskMutation) ClearGitIdentityID() { + m.git_identity = nil + m.clearedFields[projecttask.FieldGitIdentityID] = struct{}{} } -// PackageURLCleared returns if the "package_url" field was cleared in this mutation. -func (m *SkillMutation) PackageURLCleared() bool { - _, ok := m.clearedFields[skill.FieldPackageURL] +// GitIdentityIDCleared returns if the "git_identity_id" field was cleared in this mutation. +func (m *ProjectTaskMutation) GitIdentityIDCleared() bool { + _, ok := m.clearedFields[projecttask.FieldGitIdentityID] return ok } -// ResetPackageURL resets all changes to the "package_url" field. -func (m *SkillMutation) ResetPackageURL() { - m.package_url = nil - delete(m.clearedFields, skill.FieldPackageURL) -} - -// SetSourceType sets the "source_type" field. -func (m *SkillMutation) SetSourceType(s string) { - m.source_type = &s -} - -// SourceType returns the value of the "source_type" field in the mutation. -func (m *SkillMutation) SourceType() (r string, exists bool) { - v := m.source_type - if v == nil { - return - } - return *v, true -} - -// OldSourceType returns the old "source_type" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldSourceType(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSourceType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSourceType requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSourceType: %w", err) - } - return oldValue.SourceType, nil -} - -// ResetSourceType resets all changes to the "source_type" field. -func (m *SkillMutation) ResetSourceType() { - m.source_type = nil +// ResetGitIdentityID resets all changes to the "git_identity_id" field. +func (m *ProjectTaskMutation) ResetGitIdentityID() { + m.git_identity = nil + delete(m.clearedFields, projecttask.FieldGitIdentityID) } -// SetSourceLabel sets the "source_label" field. -func (m *SkillMutation) SetSourceLabel(s string) { - m.source_label = &s +// SetProjectID sets the "project_id" field. +func (m *ProjectTaskMutation) SetProjectID(u uuid.UUID) { + m.project = &u } -// SourceLabel returns the value of the "source_label" field in the mutation. -func (m *SkillMutation) SourceLabel() (r string, exists bool) { - v := m.source_label +// ProjectID returns the value of the "project_id" field in the mutation. +func (m *ProjectTaskMutation) ProjectID() (r uuid.UUID, exists bool) { + v := m.project if v == nil { return } return *v, true } -// OldSourceLabel returns the old "source_label" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldProjectID returns the old "project_id" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldSourceLabel(ctx context.Context) (v string, err error) { +func (m *ProjectTaskMutation) OldProjectID(ctx context.Context) (v *uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSourceLabel is only allowed on UpdateOne operations") + return v, errors.New("OldProjectID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSourceLabel requires an ID field in the mutation") + return v, errors.New("OldProjectID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSourceLabel: %w", err) + return v, fmt.Errorf("querying old value for OldProjectID: %w", err) } - return oldValue.SourceLabel, nil + return oldValue.ProjectID, nil +} + +// ClearProjectID clears the value of the "project_id" field. +func (m *ProjectTaskMutation) ClearProjectID() { + m.project = nil + m.clearedFields[projecttask.FieldProjectID] = struct{}{} +} + +// ProjectIDCleared returns if the "project_id" field was cleared in this mutation. +func (m *ProjectTaskMutation) ProjectIDCleared() bool { + _, ok := m.clearedFields[projecttask.FieldProjectID] + return ok } -// ResetSourceLabel resets all changes to the "source_label" field. -func (m *SkillMutation) ResetSourceLabel() { - m.source_label = nil +// ResetProjectID resets all changes to the "project_id" field. +func (m *ProjectTaskMutation) ResetProjectID() { + m.project = nil + delete(m.clearedFields, projecttask.FieldProjectID) } -// SetSkillMdPath sets the "skill_md_path" field. -func (m *SkillMutation) SetSkillMdPath(s string) { - m.skill_md_path = &s +// SetIssueID sets the "issue_id" field. +func (m *ProjectTaskMutation) SetIssueID(u uuid.UUID) { + m.issue = &u } -// SkillMdPath returns the value of the "skill_md_path" field in the mutation. -func (m *SkillMutation) SkillMdPath() (r string, exists bool) { - v := m.skill_md_path +// IssueID returns the value of the "issue_id" field in the mutation. +func (m *ProjectTaskMutation) IssueID() (r uuid.UUID, exists bool) { + v := m.issue if v == nil { return } return *v, true } -// OldSkillMdPath returns the old "skill_md_path" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldIssueID returns the old "issue_id" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldSkillMdPath(ctx context.Context) (v string, err error) { +func (m *ProjectTaskMutation) OldIssueID(ctx context.Context) (v uuid.UUID, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSkillMdPath is only allowed on UpdateOne operations") + return v, errors.New("OldIssueID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSkillMdPath requires an ID field in the mutation") + return v, errors.New("OldIssueID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSkillMdPath: %w", err) + return v, fmt.Errorf("querying old value for OldIssueID: %w", err) } - return oldValue.SkillMdPath, nil + return oldValue.IssueID, nil } -// ClearSkillMdPath clears the value of the "skill_md_path" field. -func (m *SkillMutation) ClearSkillMdPath() { - m.skill_md_path = nil - m.clearedFields[skill.FieldSkillMdPath] = struct{}{} +// ClearIssueID clears the value of the "issue_id" field. +func (m *ProjectTaskMutation) ClearIssueID() { + m.issue = nil + m.clearedFields[projecttask.FieldIssueID] = struct{}{} } -// SkillMdPathCleared returns if the "skill_md_path" field was cleared in this mutation. -func (m *SkillMutation) SkillMdPathCleared() bool { - _, ok := m.clearedFields[skill.FieldSkillMdPath] +// IssueIDCleared returns if the "issue_id" field was cleared in this mutation. +func (m *ProjectTaskMutation) IssueIDCleared() bool { + _, ok := m.clearedFields[projecttask.FieldIssueID] return ok } -// ResetSkillMdPath resets all changes to the "skill_md_path" field. -func (m *SkillMutation) ResetSkillMdPath() { - m.skill_md_path = nil - delete(m.clearedFields, skill.FieldSkillMdPath) +// ResetIssueID resets all changes to the "issue_id" field. +func (m *ProjectTaskMutation) ResetIssueID() { + m.issue = nil + delete(m.clearedFields, projecttask.FieldIssueID) } -// SetExtensionPackageID sets the "extension_package_id" field. -func (m *SkillMutation) SetExtensionPackageID(s string) { - m.extension_package_id = &s +// SetRepoURL sets the "repo_url" field. +func (m *ProjectTaskMutation) SetRepoURL(s string) { + m.repo_url = &s } -// ExtensionPackageID returns the value of the "extension_package_id" field in the mutation. -func (m *SkillMutation) ExtensionPackageID() (r string, exists bool) { - v := m.extension_package_id +// RepoURL returns the value of the "repo_url" field in the mutation. +func (m *ProjectTaskMutation) RepoURL() (r string, exists bool) { + v := m.repo_url if v == nil { return } return *v, true } -// OldExtensionPackageID returns the old "extension_package_id" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldRepoURL returns the old "repo_url" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldExtensionPackageID(ctx context.Context) (v string, err error) { +func (m *ProjectTaskMutation) OldRepoURL(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExtensionPackageID is only allowed on UpdateOne operations") + return v, errors.New("OldRepoURL is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExtensionPackageID requires an ID field in the mutation") + return v, errors.New("OldRepoURL requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExtensionPackageID: %w", err) + return v, fmt.Errorf("querying old value for OldRepoURL: %w", err) } - return oldValue.ExtensionPackageID, nil + return oldValue.RepoURL, nil } -// ClearExtensionPackageID clears the value of the "extension_package_id" field. -func (m *SkillMutation) ClearExtensionPackageID() { - m.extension_package_id = nil - m.clearedFields[skill.FieldExtensionPackageID] = struct{}{} +// ClearRepoURL clears the value of the "repo_url" field. +func (m *ProjectTaskMutation) ClearRepoURL() { + m.repo_url = nil + m.clearedFields[projecttask.FieldRepoURL] = struct{}{} } -// ExtensionPackageIDCleared returns if the "extension_package_id" field was cleared in this mutation. -func (m *SkillMutation) ExtensionPackageIDCleared() bool { - _, ok := m.clearedFields[skill.FieldExtensionPackageID] +// RepoURLCleared returns if the "repo_url" field was cleared in this mutation. +func (m *ProjectTaskMutation) RepoURLCleared() bool { + _, ok := m.clearedFields[projecttask.FieldRepoURL] return ok } -// ResetExtensionPackageID resets all changes to the "extension_package_id" field. -func (m *SkillMutation) ResetExtensionPackageID() { - m.extension_package_id = nil - delete(m.clearedFields, skill.FieldExtensionPackageID) +// ResetRepoURL resets all changes to the "repo_url" field. +func (m *ProjectTaskMutation) ResetRepoURL() { + m.repo_url = nil + delete(m.clearedFields, projecttask.FieldRepoURL) } -// SetExtensionSkillID sets the "extension_skill_id" field. -func (m *SkillMutation) SetExtensionSkillID(s string) { - m.extension_skill_id = &s +// SetRepoFilename sets the "repo_filename" field. +func (m *ProjectTaskMutation) SetRepoFilename(s string) { + m.repo_filename = &s } -// ExtensionSkillID returns the value of the "extension_skill_id" field in the mutation. -func (m *SkillMutation) ExtensionSkillID() (r string, exists bool) { - v := m.extension_skill_id +// RepoFilename returns the value of the "repo_filename" field in the mutation. +func (m *ProjectTaskMutation) RepoFilename() (r string, exists bool) { + v := m.repo_filename if v == nil { return } return *v, true } -// OldExtensionSkillID returns the old "extension_skill_id" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldRepoFilename returns the old "repo_filename" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldExtensionSkillID(ctx context.Context) (v string, err error) { +func (m *ProjectTaskMutation) OldRepoFilename(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExtensionSkillID is only allowed on UpdateOne operations") + return v, errors.New("OldRepoFilename is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExtensionSkillID requires an ID field in the mutation") + return v, errors.New("OldRepoFilename requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExtensionSkillID: %w", err) + return v, fmt.Errorf("querying old value for OldRepoFilename: %w", err) } - return oldValue.ExtensionSkillID, nil + return oldValue.RepoFilename, nil } -// ClearExtensionSkillID clears the value of the "extension_skill_id" field. -func (m *SkillMutation) ClearExtensionSkillID() { - m.extension_skill_id = nil - m.clearedFields[skill.FieldExtensionSkillID] = struct{}{} +// ClearRepoFilename clears the value of the "repo_filename" field. +func (m *ProjectTaskMutation) ClearRepoFilename() { + m.repo_filename = nil + m.clearedFields[projecttask.FieldRepoFilename] = struct{}{} } -// ExtensionSkillIDCleared returns if the "extension_skill_id" field was cleared in this mutation. -func (m *SkillMutation) ExtensionSkillIDCleared() bool { - _, ok := m.clearedFields[skill.FieldExtensionSkillID] +// RepoFilenameCleared returns if the "repo_filename" field was cleared in this mutation. +func (m *ProjectTaskMutation) RepoFilenameCleared() bool { + _, ok := m.clearedFields[projecttask.FieldRepoFilename] return ok } -// ResetExtensionSkillID resets all changes to the "extension_skill_id" field. -func (m *SkillMutation) ResetExtensionSkillID() { - m.extension_skill_id = nil - delete(m.clearedFields, skill.FieldExtensionSkillID) +// ResetRepoFilename resets all changes to the "repo_filename" field. +func (m *ProjectTaskMutation) ResetRepoFilename() { + m.repo_filename = nil + delete(m.clearedFields, projecttask.FieldRepoFilename) } -// SetExtensionVersion sets the "extension_version" field. -func (m *SkillMutation) SetExtensionVersion(s string) { - m.extension_version = &s +// SetBranch sets the "branch" field. +func (m *ProjectTaskMutation) SetBranch(s string) { + m.branch = &s } -// ExtensionVersion returns the value of the "extension_version" field in the mutation. -func (m *SkillMutation) ExtensionVersion() (r string, exists bool) { - v := m.extension_version +// Branch returns the value of the "branch" field in the mutation. +func (m *ProjectTaskMutation) Branch() (r string, exists bool) { + v := m.branch if v == nil { return } return *v, true } -// OldExtensionVersion returns the old "extension_version" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldBranch returns the old "branch" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldExtensionVersion(ctx context.Context) (v string, err error) { +func (m *ProjectTaskMutation) OldBranch(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExtensionVersion is only allowed on UpdateOne operations") + return v, errors.New("OldBranch is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExtensionVersion requires an ID field in the mutation") + return v, errors.New("OldBranch requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExtensionVersion: %w", err) + return v, fmt.Errorf("querying old value for OldBranch: %w", err) } - return oldValue.ExtensionVersion, nil + return oldValue.Branch, nil } -// ClearExtensionVersion clears the value of the "extension_version" field. -func (m *SkillMutation) ClearExtensionVersion() { - m.extension_version = nil - m.clearedFields[skill.FieldExtensionVersion] = struct{}{} +// ClearBranch clears the value of the "branch" field. +func (m *ProjectTaskMutation) ClearBranch() { + m.branch = nil + m.clearedFields[projecttask.FieldBranch] = struct{}{} } -// ExtensionVersionCleared returns if the "extension_version" field was cleared in this mutation. -func (m *SkillMutation) ExtensionVersionCleared() bool { - _, ok := m.clearedFields[skill.FieldExtensionVersion] +// BranchCleared returns if the "branch" field was cleared in this mutation. +func (m *ProjectTaskMutation) BranchCleared() bool { + _, ok := m.clearedFields[projecttask.FieldBranch] return ok } -// ResetExtensionVersion resets all changes to the "extension_version" field. -func (m *SkillMutation) ResetExtensionVersion() { - m.extension_version = nil - delete(m.clearedFields, skill.FieldExtensionVersion) +// ResetBranch resets all changes to the "branch" field. +func (m *ProjectTaskMutation) ResetBranch() { + m.branch = nil + delete(m.clearedFields, projecttask.FieldBranch) } -// SetCreatedAt sets the "created_at" field. -func (m *SkillMutation) SetCreatedAt(t time.Time) { - m.created_at = &t +// SetCliName sets the "cli_name" field. +func (m *ProjectTaskMutation) SetCliName(cn consts.CliName) { + m.cli_name = &cn } -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *SkillMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at +// CliName returns the value of the "cli_name" field in the mutation. +func (m *ProjectTaskMutation) CliName() (r consts.CliName, exists bool) { + v := m.cli_name if v == nil { return } return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldCliName returns the old "cli_name" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectTaskMutation) OldCliName(ctx context.Context) (v consts.CliName, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldCliName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") + return v, errors.New("OldCliName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldCliName: %w", err) } - return oldValue.CreatedAt, nil + return oldValue.CliName, nil } -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *SkillMutation) ResetCreatedAt() { - m.created_at = nil +// ResetCliName resets all changes to the "cli_name" field. +func (m *ProjectTaskMutation) ResetCliName() { + m.cli_name = nil } -// SetUpdatedAt sets the "updated_at" field. -func (m *SkillMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t +// SetCreatedAt sets the "created_at" field. +func (m *ProjectTaskMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *SkillMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *ProjectTaskMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldUpdatedAt returns the old "updated_at" field's value of the Skill entity. -// If the Skill object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the ProjectTask entity. +// If the ProjectTask object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SkillMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { +func (m *ProjectTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.UpdatedAt, nil + return oldValue.CreatedAt, nil } -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *SkillMutation) ResetUpdatedAt() { - m.updated_at = nil +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *ProjectTaskMutation) ResetCreatedAt() { + m.created_at = nil } -// ClearUser clears the "user" edge to the User entity. -func (m *SkillMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[skill.FieldUserID] = struct{}{} +// ClearTask clears the "task" edge to the Task entity. +func (m *ProjectTaskMutation) ClearTask() { + m.clearedtask = true + m.clearedFields[projecttask.FieldTaskID] = struct{}{} } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *SkillMutation) UserCleared() bool { - return m.cleareduser +// TaskCleared reports if the "task" edge to the Task entity was cleared. +func (m *ProjectTaskMutation) TaskCleared() bool { + return m.clearedtask } -// UserIDs returns the "user" edge IDs in the mutation. +// TaskIDs returns the "task" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *SkillMutation) UserIDs() (ids []uuid.UUID) { - if id := m.user; id != nil { +// TaskID instead. It exists only for internal usage by the builders. +func (m *ProjectTaskMutation) TaskIDs() (ids []uuid.UUID) { + if id := m.task; id != nil { ids = append(ids, *id) } return } -// ResetUser resets all changes to the "user" edge. -func (m *SkillMutation) ResetUser() { - m.user = nil - m.cleareduser = false -} - -// AddTeamIDs adds the "teams" edge to the Team entity by ids. -func (m *SkillMutation) AddTeamIDs(ids ...uuid.UUID) { - if m.teams == nil { - m.teams = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.teams[ids[i]] = struct{}{} - } -} - -// ClearTeams clears the "teams" edge to the Team entity. -func (m *SkillMutation) ClearTeams() { - m.clearedteams = true -} - -// TeamsCleared reports if the "teams" edge to the Team entity was cleared. -func (m *SkillMutation) TeamsCleared() bool { - return m.clearedteams +// ResetTask resets all changes to the "task" edge. +func (m *ProjectTaskMutation) ResetTask() { + m.task = nil + m.clearedtask = false } -// RemoveTeamIDs removes the "teams" edge to the Team entity by IDs. -func (m *SkillMutation) RemoveTeamIDs(ids ...uuid.UUID) { - if m.removedteams == nil { - m.removedteams = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.teams, ids[i]) - m.removedteams[ids[i]] = struct{}{} - } +// ClearModel clears the "model" edge to the Model entity. +func (m *ProjectTaskMutation) ClearModel() { + m.clearedmodel = true + m.clearedFields[projecttask.FieldModelID] = struct{}{} } -// RemovedTeams returns the removed IDs of the "teams" edge to the Team entity. -func (m *SkillMutation) RemovedTeamsIDs() (ids []uuid.UUID) { - for id := range m.removedteams { - ids = append(ids, id) - } - return +// ModelCleared reports if the "model" edge to the Model entity was cleared. +func (m *ProjectTaskMutation) ModelCleared() bool { + return m.clearedmodel } -// TeamsIDs returns the "teams" edge IDs in the mutation. -func (m *SkillMutation) TeamsIDs() (ids []uuid.UUID) { - for id := range m.teams { - ids = append(ids, id) +// ModelIDs returns the "model" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ModelID instead. It exists only for internal usage by the builders. +func (m *ProjectTaskMutation) ModelIDs() (ids []uuid.UUID) { + if id := m.model; id != nil { + ids = append(ids, *id) } return } -// ResetTeams resets all changes to the "teams" edge. -func (m *SkillMutation) ResetTeams() { - m.teams = nil - m.clearedteams = false - m.removedteams = nil -} - -// AddGroupIDs adds the "groups" edge to the TeamGroup entity by ids. -func (m *SkillMutation) AddGroupIDs(ids ...uuid.UUID) { - if m.groups == nil { - m.groups = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.groups[ids[i]] = struct{}{} - } -} - -// ClearGroups clears the "groups" edge to the TeamGroup entity. -func (m *SkillMutation) ClearGroups() { - m.clearedgroups = true -} - -// GroupsCleared reports if the "groups" edge to the TeamGroup entity was cleared. -func (m *SkillMutation) GroupsCleared() bool { - return m.clearedgroups +// ResetModel resets all changes to the "model" edge. +func (m *ProjectTaskMutation) ResetModel() { + m.model = nil + m.clearedmodel = false } -// RemoveGroupIDs removes the "groups" edge to the TeamGroup entity by IDs. -func (m *SkillMutation) RemoveGroupIDs(ids ...uuid.UUID) { - if m.removedgroups == nil { - m.removedgroups = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.groups, ids[i]) - m.removedgroups[ids[i]] = struct{}{} - } +// ClearImage clears the "image" edge to the Image entity. +func (m *ProjectTaskMutation) ClearImage() { + m.clearedimage = true + m.clearedFields[projecttask.FieldImageID] = struct{}{} } -// RemovedGroups returns the removed IDs of the "groups" edge to the TeamGroup entity. -func (m *SkillMutation) RemovedGroupsIDs() (ids []uuid.UUID) { - for id := range m.removedgroups { - ids = append(ids, id) - } - return +// ImageCleared reports if the "image" edge to the Image entity was cleared. +func (m *ProjectTaskMutation) ImageCleared() bool { + return m.clearedimage } -// GroupsIDs returns the "groups" edge IDs in the mutation. -func (m *SkillMutation) GroupsIDs() (ids []uuid.UUID) { - for id := range m.groups { - ids = append(ids, id) +// ImageIDs returns the "image" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ImageID instead. It exists only for internal usage by the builders. +func (m *ProjectTaskMutation) ImageIDs() (ids []uuid.UUID) { + if id := m.image; id != nil { + ids = append(ids, *id) } return } -// ResetGroups resets all changes to the "groups" edge. -func (m *SkillMutation) ResetGroups() { - m.groups = nil - m.clearedgroups = false - m.removedgroups = nil -} - -// AddTeamSkillIDs adds the "team_skills" edge to the TeamSkill entity by ids. -func (m *SkillMutation) AddTeamSkillIDs(ids ...uuid.UUID) { - if m.team_skills == nil { - m.team_skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.team_skills[ids[i]] = struct{}{} - } -} - -// ClearTeamSkills clears the "team_skills" edge to the TeamSkill entity. -func (m *SkillMutation) ClearTeamSkills() { - m.clearedteam_skills = true +// ResetImage resets all changes to the "image" edge. +func (m *ProjectTaskMutation) ResetImage() { + m.image = nil + m.clearedimage = false } -// TeamSkillsCleared reports if the "team_skills" edge to the TeamSkill entity was cleared. -func (m *SkillMutation) TeamSkillsCleared() bool { - return m.clearedteam_skills +// ClearGitIdentity clears the "git_identity" edge to the GitIdentity entity. +func (m *ProjectTaskMutation) ClearGitIdentity() { + m.clearedgit_identity = true + m.clearedFields[projecttask.FieldGitIdentityID] = struct{}{} } -// RemoveTeamSkillIDs removes the "team_skills" edge to the TeamSkill entity by IDs. -func (m *SkillMutation) RemoveTeamSkillIDs(ids ...uuid.UUID) { - if m.removedteam_skills == nil { - m.removedteam_skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.team_skills, ids[i]) - m.removedteam_skills[ids[i]] = struct{}{} - } +// GitIdentityCleared reports if the "git_identity" edge to the GitIdentity entity was cleared. +func (m *ProjectTaskMutation) GitIdentityCleared() bool { + return m.GitIdentityIDCleared() || m.clearedgit_identity } -// RemovedTeamSkills returns the removed IDs of the "team_skills" edge to the TeamSkill entity. -func (m *SkillMutation) RemovedTeamSkillsIDs() (ids []uuid.UUID) { - for id := range m.removedteam_skills { - ids = append(ids, id) +// GitIdentityIDs returns the "git_identity" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// GitIdentityID instead. It exists only for internal usage by the builders. +func (m *ProjectTaskMutation) GitIdentityIDs() (ids []uuid.UUID) { + if id := m.git_identity; id != nil { + ids = append(ids, *id) } return } -// TeamSkillsIDs returns the "team_skills" edge IDs in the mutation. -func (m *SkillMutation) TeamSkillsIDs() (ids []uuid.UUID) { - for id := range m.team_skills { - ids = append(ids, id) - } - return +// ResetGitIdentity resets all changes to the "git_identity" edge. +func (m *ProjectTaskMutation) ResetGitIdentity() { + m.git_identity = nil + m.clearedgit_identity = false } -// ResetTeamSkills resets all changes to the "team_skills" edge. -func (m *SkillMutation) ResetTeamSkills() { - m.team_skills = nil - m.clearedteam_skills = false - m.removedteam_skills = nil +// ClearProject clears the "project" edge to the Project entity. +func (m *ProjectTaskMutation) ClearProject() { + m.clearedproject = true + m.clearedFields[projecttask.FieldProjectID] = struct{}{} } -// AddTeamGroupSkillIDs adds the "team_group_skills" edge to the TeamGroupSkill entity by ids. -func (m *SkillMutation) AddTeamGroupSkillIDs(ids ...uuid.UUID) { - if m.team_group_skills == nil { - m.team_group_skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.team_group_skills[ids[i]] = struct{}{} - } +// ProjectCleared reports if the "project" edge to the Project entity was cleared. +func (m *ProjectTaskMutation) ProjectCleared() bool { + return m.ProjectIDCleared() || m.clearedproject } -// ClearTeamGroupSkills clears the "team_group_skills" edge to the TeamGroupSkill entity. -func (m *SkillMutation) ClearTeamGroupSkills() { - m.clearedteam_group_skills = true +// ProjectIDs returns the "project" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ProjectID instead. It exists only for internal usage by the builders. +func (m *ProjectTaskMutation) ProjectIDs() (ids []uuid.UUID) { + if id := m.project; id != nil { + ids = append(ids, *id) + } + return } -// TeamGroupSkillsCleared reports if the "team_group_skills" edge to the TeamGroupSkill entity was cleared. -func (m *SkillMutation) TeamGroupSkillsCleared() bool { - return m.clearedteam_group_skills +// ResetProject resets all changes to the "project" edge. +func (m *ProjectTaskMutation) ResetProject() { + m.project = nil + m.clearedproject = false } -// RemoveTeamGroupSkillIDs removes the "team_group_skills" edge to the TeamGroupSkill entity by IDs. -func (m *SkillMutation) RemoveTeamGroupSkillIDs(ids ...uuid.UUID) { - if m.removedteam_group_skills == nil { - m.removedteam_group_skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.team_group_skills, ids[i]) - m.removedteam_group_skills[ids[i]] = struct{}{} - } +// ClearIssue clears the "issue" edge to the ProjectIssue entity. +func (m *ProjectTaskMutation) ClearIssue() { + m.clearedissue = true + m.clearedFields[projecttask.FieldIssueID] = struct{}{} } -// RemovedTeamGroupSkills returns the removed IDs of the "team_group_skills" edge to the TeamGroupSkill entity. -func (m *SkillMutation) RemovedTeamGroupSkillsIDs() (ids []uuid.UUID) { - for id := range m.removedteam_group_skills { - ids = append(ids, id) - } - return +// IssueCleared reports if the "issue" edge to the ProjectIssue entity was cleared. +func (m *ProjectTaskMutation) IssueCleared() bool { + return m.IssueIDCleared() || m.clearedissue } -// TeamGroupSkillsIDs returns the "team_group_skills" edge IDs in the mutation. -func (m *SkillMutation) TeamGroupSkillsIDs() (ids []uuid.UUID) { - for id := range m.team_group_skills { - ids = append(ids, id) +// IssueIDs returns the "issue" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// IssueID instead. It exists only for internal usage by the builders. +func (m *ProjectTaskMutation) IssueIDs() (ids []uuid.UUID) { + if id := m.issue; id != nil { + ids = append(ids, *id) } return } -// ResetTeamGroupSkills resets all changes to the "team_group_skills" edge. -func (m *SkillMutation) ResetTeamGroupSkills() { - m.team_group_skills = nil - m.clearedteam_group_skills = false - m.removedteam_group_skills = nil +// ResetIssue resets all changes to the "issue" edge. +func (m *ProjectTaskMutation) ResetIssue() { + m.issue = nil + m.clearedissue = false } -// Where appends a list predicates to the SkillMutation builder. -func (m *SkillMutation) Where(ps ...predicate.Skill) { +// Where appends a list predicates to the ProjectTaskMutation builder. +func (m *ProjectTaskMutation) Where(ps ...predicate.ProjectTask) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the SkillMutation builder. Using this method, +// WhereP appends storage-level predicates to the ProjectTaskMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *SkillMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Skill, len(ps)) +func (m *ProjectTaskMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ProjectTask, len(ps)) for i := range ps { p[i] = ps[i] } @@ -26626,72 +34705,57 @@ func (m *SkillMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *SkillMutation) Op() Op { +func (m *ProjectTaskMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *SkillMutation) SetOp(op Op) { +func (m *ProjectTaskMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Skill). -func (m *SkillMutation) Type() string { +// Type returns the node type of this mutation (ProjectTask). +func (m *ProjectTaskMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *SkillMutation) Fields() []string { - fields := make([]string, 0, 16) - if m.deleted_at != nil { - fields = append(fields, skill.FieldDeletedAt) - } - if m.user != nil { - fields = append(fields, skill.FieldUserID) - } - if m.name != nil { - fields = append(fields, skill.FieldName) - } - if m.description != nil { - fields = append(fields, skill.FieldDescription) - } - if m.tags != nil { - fields = append(fields, skill.FieldTags) +func (m *ProjectTaskMutation) Fields() []string { + fields := make([]string, 0, 11) + if m.task != nil { + fields = append(fields, projecttask.FieldTaskID) } - if m.content != nil { - fields = append(fields, skill.FieldContent) + if m.model != nil { + fields = append(fields, projecttask.FieldModelID) } - if m.package_object_key != nil { - fields = append(fields, skill.FieldPackageObjectKey) + if m.image != nil { + fields = append(fields, projecttask.FieldImageID) } - if m.package_url != nil { - fields = append(fields, skill.FieldPackageURL) + if m.git_identity != nil { + fields = append(fields, projecttask.FieldGitIdentityID) } - if m.source_type != nil { - fields = append(fields, skill.FieldSourceType) + if m.project != nil { + fields = append(fields, projecttask.FieldProjectID) } - if m.source_label != nil { - fields = append(fields, skill.FieldSourceLabel) + if m.issue != nil { + fields = append(fields, projecttask.FieldIssueID) } - if m.skill_md_path != nil { - fields = append(fields, skill.FieldSkillMdPath) + if m.repo_url != nil { + fields = append(fields, projecttask.FieldRepoURL) } - if m.extension_package_id != nil { - fields = append(fields, skill.FieldExtensionPackageID) + if m.repo_filename != nil { + fields = append(fields, projecttask.FieldRepoFilename) } - if m.extension_skill_id != nil { - fields = append(fields, skill.FieldExtensionSkillID) + if m.branch != nil { + fields = append(fields, projecttask.FieldBranch) } - if m.extension_version != nil { - fields = append(fields, skill.FieldExtensionVersion) + if m.cli_name != nil { + fields = append(fields, projecttask.FieldCliName) } if m.created_at != nil { - fields = append(fields, skill.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, skill.FieldUpdatedAt) + fields = append(fields, projecttask.FieldCreatedAt) } return fields } @@ -26699,40 +34763,30 @@ func (m *SkillMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *SkillMutation) Field(name string) (ent.Value, bool) { +func (m *ProjectTaskMutation) Field(name string) (ent.Value, bool) { switch name { - case skill.FieldDeletedAt: - return m.DeletedAt() - case skill.FieldUserID: - return m.UserID() - case skill.FieldName: - return m.Name() - case skill.FieldDescription: - return m.Description() - case skill.FieldTags: - return m.Tags() - case skill.FieldContent: - return m.Content() - case skill.FieldPackageObjectKey: - return m.PackageObjectKey() - case skill.FieldPackageURL: - return m.PackageURL() - case skill.FieldSourceType: - return m.SourceType() - case skill.FieldSourceLabel: - return m.SourceLabel() - case skill.FieldSkillMdPath: - return m.SkillMdPath() - case skill.FieldExtensionPackageID: - return m.ExtensionPackageID() - case skill.FieldExtensionSkillID: - return m.ExtensionSkillID() - case skill.FieldExtensionVersion: - return m.ExtensionVersion() - case skill.FieldCreatedAt: + case projecttask.FieldTaskID: + return m.TaskID() + case projecttask.FieldModelID: + return m.ModelID() + case projecttask.FieldImageID: + return m.ImageID() + case projecttask.FieldGitIdentityID: + return m.GitIdentityID() + case projecttask.FieldProjectID: + return m.ProjectID() + case projecttask.FieldIssueID: + return m.IssueID() + case projecttask.FieldRepoURL: + return m.RepoURL() + case projecttask.FieldRepoFilename: + return m.RepoFilename() + case projecttask.FieldBranch: + return m.Branch() + case projecttask.FieldCliName: + return m.CliName() + case projecttask.FieldCreatedAt: return m.CreatedAt() - case skill.FieldUpdatedAt: - return m.UpdatedAt() } return nil, false } @@ -26740,491 +34794,403 @@ func (m *SkillMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *SkillMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ProjectTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case skill.FieldDeletedAt: - return m.OldDeletedAt(ctx) - case skill.FieldUserID: - return m.OldUserID(ctx) - case skill.FieldName: - return m.OldName(ctx) - case skill.FieldDescription: - return m.OldDescription(ctx) - case skill.FieldTags: - return m.OldTags(ctx) - case skill.FieldContent: - return m.OldContent(ctx) - case skill.FieldPackageObjectKey: - return m.OldPackageObjectKey(ctx) - case skill.FieldPackageURL: - return m.OldPackageURL(ctx) - case skill.FieldSourceType: - return m.OldSourceType(ctx) - case skill.FieldSourceLabel: - return m.OldSourceLabel(ctx) - case skill.FieldSkillMdPath: - return m.OldSkillMdPath(ctx) - case skill.FieldExtensionPackageID: - return m.OldExtensionPackageID(ctx) - case skill.FieldExtensionSkillID: - return m.OldExtensionSkillID(ctx) - case skill.FieldExtensionVersion: - return m.OldExtensionVersion(ctx) - case skill.FieldCreatedAt: + case projecttask.FieldTaskID: + return m.OldTaskID(ctx) + case projecttask.FieldModelID: + return m.OldModelID(ctx) + case projecttask.FieldImageID: + return m.OldImageID(ctx) + case projecttask.FieldGitIdentityID: + return m.OldGitIdentityID(ctx) + case projecttask.FieldProjectID: + return m.OldProjectID(ctx) + case projecttask.FieldIssueID: + return m.OldIssueID(ctx) + case projecttask.FieldRepoURL: + return m.OldRepoURL(ctx) + case projecttask.FieldRepoFilename: + return m.OldRepoFilename(ctx) + case projecttask.FieldBranch: + return m.OldBranch(ctx) + case projecttask.FieldCliName: + return m.OldCliName(ctx) + case projecttask.FieldCreatedAt: return m.OldCreatedAt(ctx) - case skill.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) } - return nil, fmt.Errorf("unknown Skill field %s", name) + return nil, fmt.Errorf("unknown ProjectTask field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *SkillMutation) SetField(name string, value ent.Value) error { +func (m *ProjectTaskMutation) SetField(name string, value ent.Value) error { switch name { - case skill.FieldDeletedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDeletedAt(v) - return nil - case skill.FieldUserID: + case projecttask.FieldTaskID: v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) - return nil - case skill.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case skill.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case skill.FieldTags: - v, ok := value.([]string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTags(v) + m.SetTaskID(v) return nil - case skill.FieldContent: - v, ok := value.(string) + case projecttask.FieldModelID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetContent(v) + m.SetModelID(v) return nil - case skill.FieldPackageObjectKey: - v, ok := value.(string) + case projecttask.FieldImageID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPackageObjectKey(v) + m.SetImageID(v) return nil - case skill.FieldPackageURL: - v, ok := value.(string) + case projecttask.FieldGitIdentityID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPackageURL(v) + m.SetGitIdentityID(v) return nil - case skill.FieldSourceType: - v, ok := value.(string) + case projecttask.FieldProjectID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSourceType(v) + m.SetProjectID(v) return nil - case skill.FieldSourceLabel: - v, ok := value.(string) + case projecttask.FieldIssueID: + v, ok := value.(uuid.UUID) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSourceLabel(v) + m.SetIssueID(v) return nil - case skill.FieldSkillMdPath: + case projecttask.FieldRepoURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSkillMdPath(v) + m.SetRepoURL(v) return nil - case skill.FieldExtensionPackageID: + case projecttask.FieldRepoFilename: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetExtensionPackageID(v) + m.SetRepoFilename(v) return nil - case skill.FieldExtensionSkillID: + case projecttask.FieldBranch: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetExtensionSkillID(v) + m.SetBranch(v) return nil - case skill.FieldExtensionVersion: - v, ok := value.(string) + case projecttask.FieldCliName: + v, ok := value.(consts.CliName) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetExtensionVersion(v) + m.SetCliName(v) return nil - case skill.FieldCreatedAt: + case projecttask.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case skill.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil } - return fmt.Errorf("unknown Skill field %s", name) + return fmt.Errorf("unknown ProjectTask field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *SkillMutation) AddedFields() []string { +func (m *ProjectTaskMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *SkillMutation) AddedField(name string) (ent.Value, bool) { +func (m *ProjectTaskMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *SkillMutation) AddField(name string, value ent.Value) error { +func (m *ProjectTaskMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Skill numeric field %s", name) + return fmt.Errorf("unknown ProjectTask numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *SkillMutation) ClearedFields() []string { +func (m *ProjectTaskMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(skill.FieldDeletedAt) { - fields = append(fields, skill.FieldDeletedAt) - } - if m.FieldCleared(skill.FieldTags) { - fields = append(fields, skill.FieldTags) - } - if m.FieldCleared(skill.FieldPackageObjectKey) { - fields = append(fields, skill.FieldPackageObjectKey) + if m.FieldCleared(projecttask.FieldGitIdentityID) { + fields = append(fields, projecttask.FieldGitIdentityID) } - if m.FieldCleared(skill.FieldPackageURL) { - fields = append(fields, skill.FieldPackageURL) + if m.FieldCleared(projecttask.FieldProjectID) { + fields = append(fields, projecttask.FieldProjectID) } - if m.FieldCleared(skill.FieldSkillMdPath) { - fields = append(fields, skill.FieldSkillMdPath) + if m.FieldCleared(projecttask.FieldIssueID) { + fields = append(fields, projecttask.FieldIssueID) } - if m.FieldCleared(skill.FieldExtensionPackageID) { - fields = append(fields, skill.FieldExtensionPackageID) + if m.FieldCleared(projecttask.FieldRepoURL) { + fields = append(fields, projecttask.FieldRepoURL) } - if m.FieldCleared(skill.FieldExtensionSkillID) { - fields = append(fields, skill.FieldExtensionSkillID) + if m.FieldCleared(projecttask.FieldRepoFilename) { + fields = append(fields, projecttask.FieldRepoFilename) } - if m.FieldCleared(skill.FieldExtensionVersion) { - fields = append(fields, skill.FieldExtensionVersion) + if m.FieldCleared(projecttask.FieldBranch) { + fields = append(fields, projecttask.FieldBranch) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *SkillMutation) FieldCleared(name string) bool { +func (m *ProjectTaskMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *SkillMutation) ClearField(name string) error { +func (m *ProjectTaskMutation) ClearField(name string) error { switch name { - case skill.FieldDeletedAt: - m.ClearDeletedAt() - return nil - case skill.FieldTags: - m.ClearTags() - return nil - case skill.FieldPackageObjectKey: - m.ClearPackageObjectKey() + case projecttask.FieldGitIdentityID: + m.ClearGitIdentityID() return nil - case skill.FieldPackageURL: - m.ClearPackageURL() + case projecttask.FieldProjectID: + m.ClearProjectID() return nil - case skill.FieldSkillMdPath: - m.ClearSkillMdPath() + case projecttask.FieldIssueID: + m.ClearIssueID() return nil - case skill.FieldExtensionPackageID: - m.ClearExtensionPackageID() + case projecttask.FieldRepoURL: + m.ClearRepoURL() return nil - case skill.FieldExtensionSkillID: - m.ClearExtensionSkillID() + case projecttask.FieldRepoFilename: + m.ClearRepoFilename() return nil - case skill.FieldExtensionVersion: - m.ClearExtensionVersion() + case projecttask.FieldBranch: + m.ClearBranch() return nil } - return fmt.Errorf("unknown Skill nullable field %s", name) + return fmt.Errorf("unknown ProjectTask nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *SkillMutation) ResetField(name string) error { +func (m *ProjectTaskMutation) ResetField(name string) error { switch name { - case skill.FieldDeletedAt: - m.ResetDeletedAt() - return nil - case skill.FieldUserID: - m.ResetUserID() - return nil - case skill.FieldName: - m.ResetName() - return nil - case skill.FieldDescription: - m.ResetDescription() - return nil - case skill.FieldTags: - m.ResetTags() + case projecttask.FieldTaskID: + m.ResetTaskID() return nil - case skill.FieldContent: - m.ResetContent() + case projecttask.FieldModelID: + m.ResetModelID() return nil - case skill.FieldPackageObjectKey: - m.ResetPackageObjectKey() + case projecttask.FieldImageID: + m.ResetImageID() return nil - case skill.FieldPackageURL: - m.ResetPackageURL() + case projecttask.FieldGitIdentityID: + m.ResetGitIdentityID() return nil - case skill.FieldSourceType: - m.ResetSourceType() + case projecttask.FieldProjectID: + m.ResetProjectID() return nil - case skill.FieldSourceLabel: - m.ResetSourceLabel() + case projecttask.FieldIssueID: + m.ResetIssueID() return nil - case skill.FieldSkillMdPath: - m.ResetSkillMdPath() + case projecttask.FieldRepoURL: + m.ResetRepoURL() return nil - case skill.FieldExtensionPackageID: - m.ResetExtensionPackageID() + case projecttask.FieldRepoFilename: + m.ResetRepoFilename() return nil - case skill.FieldExtensionSkillID: - m.ResetExtensionSkillID() + case projecttask.FieldBranch: + m.ResetBranch() return nil - case skill.FieldExtensionVersion: - m.ResetExtensionVersion() + case projecttask.FieldCliName: + m.ResetCliName() return nil - case skill.FieldCreatedAt: + case projecttask.FieldCreatedAt: m.ResetCreatedAt() return nil - case skill.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil } - return fmt.Errorf("unknown Skill field %s", name) + return fmt.Errorf("unknown ProjectTask field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *SkillMutation) AddedEdges() []string { - edges := make([]string, 0, 5) - if m.user != nil { - edges = append(edges, skill.EdgeUser) +func (m *ProjectTaskMutation) AddedEdges() []string { + edges := make([]string, 0, 6) + if m.task != nil { + edges = append(edges, projecttask.EdgeTask) } - if m.teams != nil { - edges = append(edges, skill.EdgeTeams) + if m.model != nil { + edges = append(edges, projecttask.EdgeModel) } - if m.groups != nil { - edges = append(edges, skill.EdgeGroups) + if m.image != nil { + edges = append(edges, projecttask.EdgeImage) } - if m.team_skills != nil { - edges = append(edges, skill.EdgeTeamSkills) + if m.git_identity != nil { + edges = append(edges, projecttask.EdgeGitIdentity) + } + if m.project != nil { + edges = append(edges, projecttask.EdgeProject) } - if m.team_group_skills != nil { - edges = append(edges, skill.EdgeTeamGroupSkills) + if m.issue != nil { + edges = append(edges, projecttask.EdgeIssue) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *SkillMutation) AddedIDs(name string) []ent.Value { +func (m *ProjectTaskMutation) AddedIDs(name string) []ent.Value { switch name { - case skill.EdgeUser: - if id := m.user; id != nil { + case projecttask.EdgeTask: + if id := m.task; id != nil { return []ent.Value{*id} } - case skill.EdgeTeams: - ids := make([]ent.Value, 0, len(m.teams)) - for id := range m.teams { - ids = append(ids, id) + case projecttask.EdgeModel: + if id := m.model; id != nil { + return []ent.Value{*id} } - return ids - case skill.EdgeGroups: - ids := make([]ent.Value, 0, len(m.groups)) - for id := range m.groups { - ids = append(ids, id) + case projecttask.EdgeImage: + if id := m.image; id != nil { + return []ent.Value{*id} } - return ids - case skill.EdgeTeamSkills: - ids := make([]ent.Value, 0, len(m.team_skills)) - for id := range m.team_skills { - ids = append(ids, id) + case projecttask.EdgeGitIdentity: + if id := m.git_identity; id != nil { + return []ent.Value{*id} } - return ids - case skill.EdgeTeamGroupSkills: - ids := make([]ent.Value, 0, len(m.team_group_skills)) - for id := range m.team_group_skills { - ids = append(ids, id) + case projecttask.EdgeProject: + if id := m.project; id != nil { + return []ent.Value{*id} + } + case projecttask.EdgeIssue: + if id := m.issue; id != nil { + return []ent.Value{*id} } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *SkillMutation) RemovedEdges() []string { - edges := make([]string, 0, 5) - if m.removedteams != nil { - edges = append(edges, skill.EdgeTeams) - } - if m.removedgroups != nil { - edges = append(edges, skill.EdgeGroups) - } - if m.removedteam_skills != nil { - edges = append(edges, skill.EdgeTeamSkills) - } - if m.removedteam_group_skills != nil { - edges = append(edges, skill.EdgeTeamGroupSkills) - } +func (m *ProjectTaskMutation) RemovedEdges() []string { + edges := make([]string, 0, 6) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *SkillMutation) RemovedIDs(name string) []ent.Value { - switch name { - case skill.EdgeTeams: - ids := make([]ent.Value, 0, len(m.removedteams)) - for id := range m.removedteams { - ids = append(ids, id) - } - return ids - case skill.EdgeGroups: - ids := make([]ent.Value, 0, len(m.removedgroups)) - for id := range m.removedgroups { - ids = append(ids, id) - } - return ids - case skill.EdgeTeamSkills: - ids := make([]ent.Value, 0, len(m.removedteam_skills)) - for id := range m.removedteam_skills { - ids = append(ids, id) - } - return ids - case skill.EdgeTeamGroupSkills: - ids := make([]ent.Value, 0, len(m.removedteam_group_skills)) - for id := range m.removedteam_group_skills { - ids = append(ids, id) - } - return ids - } +func (m *ProjectTaskMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *SkillMutation) ClearedEdges() []string { - edges := make([]string, 0, 5) - if m.cleareduser { - edges = append(edges, skill.EdgeUser) +func (m *ProjectTaskMutation) ClearedEdges() []string { + edges := make([]string, 0, 6) + if m.clearedtask { + edges = append(edges, projecttask.EdgeTask) } - if m.clearedteams { - edges = append(edges, skill.EdgeTeams) + if m.clearedmodel { + edges = append(edges, projecttask.EdgeModel) } - if m.clearedgroups { - edges = append(edges, skill.EdgeGroups) + if m.clearedimage { + edges = append(edges, projecttask.EdgeImage) + } + if m.clearedgit_identity { + edges = append(edges, projecttask.EdgeGitIdentity) } - if m.clearedteam_skills { - edges = append(edges, skill.EdgeTeamSkills) + if m.clearedproject { + edges = append(edges, projecttask.EdgeProject) } - if m.clearedteam_group_skills { - edges = append(edges, skill.EdgeTeamGroupSkills) + if m.clearedissue { + edges = append(edges, projecttask.EdgeIssue) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *SkillMutation) EdgeCleared(name string) bool { +func (m *ProjectTaskMutation) EdgeCleared(name string) bool { switch name { - case skill.EdgeUser: - return m.cleareduser - case skill.EdgeTeams: - return m.clearedteams - case skill.EdgeGroups: - return m.clearedgroups - case skill.EdgeTeamSkills: - return m.clearedteam_skills - case skill.EdgeTeamGroupSkills: - return m.clearedteam_group_skills + case projecttask.EdgeTask: + return m.clearedtask + case projecttask.EdgeModel: + return m.clearedmodel + case projecttask.EdgeImage: + return m.clearedimage + case projecttask.EdgeGitIdentity: + return m.clearedgit_identity + case projecttask.EdgeProject: + return m.clearedproject + case projecttask.EdgeIssue: + return m.clearedissue } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *SkillMutation) ClearEdge(name string) error { +func (m *ProjectTaskMutation) ClearEdge(name string) error { switch name { - case skill.EdgeUser: - m.ClearUser() + case projecttask.EdgeTask: + m.ClearTask() + return nil + case projecttask.EdgeModel: + m.ClearModel() + return nil + case projecttask.EdgeImage: + m.ClearImage() + return nil + case projecttask.EdgeGitIdentity: + m.ClearGitIdentity() + return nil + case projecttask.EdgeProject: + m.ClearProject() + return nil + case projecttask.EdgeIssue: + m.ClearIssue() return nil } - return fmt.Errorf("unknown Skill unique edge %s", name) + return fmt.Errorf("unknown ProjectTask unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *SkillMutation) ResetEdge(name string) error { +func (m *ProjectTaskMutation) ResetEdge(name string) error { switch name { - case skill.EdgeUser: - m.ResetUser() + case projecttask.EdgeTask: + m.ResetTask() return nil - case skill.EdgeTeams: - m.ResetTeams() + case projecttask.EdgeModel: + m.ResetModel() return nil - case skill.EdgeGroups: - m.ResetGroups() + case projecttask.EdgeImage: + m.ResetImage() return nil - case skill.EdgeTeamSkills: - m.ResetTeamSkills() + case projecttask.EdgeGitIdentity: + m.ResetGitIdentity() + return nil + case projecttask.EdgeProject: + m.ResetProject() return nil - case skill.EdgeTeamGroupSkills: - m.ResetTeamGroupSkills() + case projecttask.EdgeIssue: + m.ResetIssue() return nil } - return fmt.Errorf("unknown Skill edge %s", name) + return fmt.Errorf("unknown ProjectTask edge %s", name) } // TaskMutation represents an operation that mutates the Task nodes in the graph. @@ -31290,9 +39256,6 @@ type TeamMutation struct { images map[uuid.UUID]struct{} removedimages map[uuid.UUID]struct{} clearedimages bool - skills map[uuid.UUID]struct{} - removedskills map[uuid.UUID]struct{} - clearedskills bool extension_image_archives map[uuid.UUID]struct{} removedextension_image_archives map[uuid.UUID]struct{} clearedextension_image_archives bool @@ -31305,9 +39268,6 @@ type TeamMutation struct { team_images map[uuid.UUID]struct{} removedteam_images map[uuid.UUID]struct{} clearedteam_images bool - team_skills map[uuid.UUID]struct{} - removedteam_skills map[uuid.UUID]struct{} - clearedteam_skills bool done bool oldValue func(context.Context) (*Team, error) predicates []predicate.Team @@ -32086,60 +40046,6 @@ func (m *TeamMutation) ResetImages() { m.removedimages = nil } -// AddSkillIDs adds the "skills" edge to the Skill entity by ids. -func (m *TeamMutation) AddSkillIDs(ids ...uuid.UUID) { - if m.skills == nil { - m.skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.skills[ids[i]] = struct{}{} - } -} - -// ClearSkills clears the "skills" edge to the Skill entity. -func (m *TeamMutation) ClearSkills() { - m.clearedskills = true -} - -// SkillsCleared reports if the "skills" edge to the Skill entity was cleared. -func (m *TeamMutation) SkillsCleared() bool { - return m.clearedskills -} - -// RemoveSkillIDs removes the "skills" edge to the Skill entity by IDs. -func (m *TeamMutation) RemoveSkillIDs(ids ...uuid.UUID) { - if m.removedskills == nil { - m.removedskills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.skills, ids[i]) - m.removedskills[ids[i]] = struct{}{} - } -} - -// RemovedSkills returns the removed IDs of the "skills" edge to the Skill entity. -func (m *TeamMutation) RemovedSkillsIDs() (ids []uuid.UUID) { - for id := range m.removedskills { - ids = append(ids, id) - } - return -} - -// SkillsIDs returns the "skills" edge IDs in the mutation. -func (m *TeamMutation) SkillsIDs() (ids []uuid.UUID) { - for id := range m.skills { - ids = append(ids, id) - } - return -} - -// ResetSkills resets all changes to the "skills" edge. -func (m *TeamMutation) ResetSkills() { - m.skills = nil - m.clearedskills = false - m.removedskills = nil -} - // AddExtensionImageArchiveIDs adds the "extension_image_archives" edge to the TeamExtensionImageArchive entity by ids. func (m *TeamMutation) AddExtensionImageArchiveIDs(ids ...uuid.UUID) { if m.extension_image_archives == nil { @@ -32356,60 +40262,6 @@ func (m *TeamMutation) ResetTeamImages() { m.removedteam_images = nil } -// AddTeamSkillIDs adds the "team_skills" edge to the TeamSkill entity by ids. -func (m *TeamMutation) AddTeamSkillIDs(ids ...uuid.UUID) { - if m.team_skills == nil { - m.team_skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.team_skills[ids[i]] = struct{}{} - } -} - -// ClearTeamSkills clears the "team_skills" edge to the TeamSkill entity. -func (m *TeamMutation) ClearTeamSkills() { - m.clearedteam_skills = true -} - -// TeamSkillsCleared reports if the "team_skills" edge to the TeamSkill entity was cleared. -func (m *TeamMutation) TeamSkillsCleared() bool { - return m.clearedteam_skills -} - -// RemoveTeamSkillIDs removes the "team_skills" edge to the TeamSkill entity by IDs. -func (m *TeamMutation) RemoveTeamSkillIDs(ids ...uuid.UUID) { - if m.removedteam_skills == nil { - m.removedteam_skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.team_skills, ids[i]) - m.removedteam_skills[ids[i]] = struct{}{} - } -} - -// RemovedTeamSkills returns the removed IDs of the "team_skills" edge to the TeamSkill entity. -func (m *TeamMutation) RemovedTeamSkillsIDs() (ids []uuid.UUID) { - for id := range m.removedteam_skills { - ids = append(ids, id) - } - return -} - -// TeamSkillsIDs returns the "team_skills" edge IDs in the mutation. -func (m *TeamMutation) TeamSkillsIDs() (ids []uuid.UUID) { - for id := range m.team_skills { - ids = append(ids, id) - } - return -} - -// ResetTeamSkills resets all changes to the "team_skills" edge. -func (m *TeamMutation) ResetTeamSkills() { - m.team_skills = nil - m.clearedteam_skills = false - m.removedteam_skills = nil -} - // Where appends a list predicates to the TeamMutation builder. func (m *TeamMutation) Where(ps ...predicate.Team) { m.predicates = append(m.predicates, ps...) @@ -32756,7 +40608,7 @@ func (m *TeamMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *TeamMutation) AddedEdges() []string { - edges := make([]string, 0, 10) + edges := make([]string, 0, 8) if m.groups != nil { edges = append(edges, team.EdgeGroups) } @@ -32769,9 +40621,6 @@ func (m *TeamMutation) AddedEdges() []string { if m.images != nil { edges = append(edges, team.EdgeImages) } - if m.skills != nil { - edges = append(edges, team.EdgeSkills) - } if m.extension_image_archives != nil { edges = append(edges, team.EdgeExtensionImageArchives) } @@ -32784,9 +40633,6 @@ func (m *TeamMutation) AddedEdges() []string { if m.team_images != nil { edges = append(edges, team.EdgeTeamImages) } - if m.team_skills != nil { - edges = append(edges, team.EdgeTeamSkills) - } return edges } @@ -32818,12 +40664,6 @@ func (m *TeamMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case team.EdgeSkills: - ids := make([]ent.Value, 0, len(m.skills)) - for id := range m.skills { - ids = append(ids, id) - } - return ids case team.EdgeExtensionImageArchives: ids := make([]ent.Value, 0, len(m.extension_image_archives)) for id := range m.extension_image_archives { @@ -32848,19 +40688,13 @@ func (m *TeamMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case team.EdgeTeamSkills: - ids := make([]ent.Value, 0, len(m.team_skills)) - for id := range m.team_skills { - ids = append(ids, id) - } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *TeamMutation) RemovedEdges() []string { - edges := make([]string, 0, 10) + edges := make([]string, 0, 8) if m.removedgroups != nil { edges = append(edges, team.EdgeGroups) } @@ -32873,9 +40707,6 @@ func (m *TeamMutation) RemovedEdges() []string { if m.removedimages != nil { edges = append(edges, team.EdgeImages) } - if m.removedskills != nil { - edges = append(edges, team.EdgeSkills) - } if m.removedextension_image_archives != nil { edges = append(edges, team.EdgeExtensionImageArchives) } @@ -32888,9 +40719,6 @@ func (m *TeamMutation) RemovedEdges() []string { if m.removedteam_images != nil { edges = append(edges, team.EdgeTeamImages) } - if m.removedteam_skills != nil { - edges = append(edges, team.EdgeTeamSkills) - } return edges } @@ -32922,12 +40750,6 @@ func (m *TeamMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case team.EdgeSkills: - ids := make([]ent.Value, 0, len(m.removedskills)) - for id := range m.removedskills { - ids = append(ids, id) - } - return ids case team.EdgeExtensionImageArchives: ids := make([]ent.Value, 0, len(m.removedextension_image_archives)) for id := range m.removedextension_image_archives { @@ -32952,19 +40774,13 @@ func (m *TeamMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case team.EdgeTeamSkills: - ids := make([]ent.Value, 0, len(m.removedteam_skills)) - for id := range m.removedteam_skills { - ids = append(ids, id) - } - return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *TeamMutation) ClearedEdges() []string { - edges := make([]string, 0, 10) + edges := make([]string, 0, 8) if m.clearedgroups { edges = append(edges, team.EdgeGroups) } @@ -32977,9 +40793,6 @@ func (m *TeamMutation) ClearedEdges() []string { if m.clearedimages { edges = append(edges, team.EdgeImages) } - if m.clearedskills { - edges = append(edges, team.EdgeSkills) - } if m.clearedextension_image_archives { edges = append(edges, team.EdgeExtensionImageArchives) } @@ -32992,9 +40805,6 @@ func (m *TeamMutation) ClearedEdges() []string { if m.clearedteam_images { edges = append(edges, team.EdgeTeamImages) } - if m.clearedteam_skills { - edges = append(edges, team.EdgeTeamSkills) - } return edges } @@ -33010,8 +40820,6 @@ func (m *TeamMutation) EdgeCleared(name string) bool { return m.clearedmodels case team.EdgeImages: return m.clearedimages - case team.EdgeSkills: - return m.clearedskills case team.EdgeExtensionImageArchives: return m.clearedextension_image_archives case team.EdgeTeamMembers: @@ -33020,8 +40828,6 @@ func (m *TeamMutation) EdgeCleared(name string) bool { return m.clearedteam_models case team.EdgeTeamImages: return m.clearedteam_images - case team.EdgeTeamSkills: - return m.clearedteam_skills } return false } @@ -33050,9 +40856,6 @@ func (m *TeamMutation) ResetEdge(name string) error { case team.EdgeImages: m.ResetImages() return nil - case team.EdgeSkills: - m.ResetSkills() - return nil case team.EdgeExtensionImageArchives: m.ResetExtensionImageArchives() return nil @@ -33065,9 +40868,6 @@ func (m *TeamMutation) ResetEdge(name string) error { case team.EdgeTeamImages: m.ResetTeamImages() return nil - case team.EdgeTeamSkills: - m.ResetTeamSkills() - return nil } return fmt.Errorf("unknown Team edge %s", name) } @@ -34145,9 +41945,6 @@ type TeamGroupMutation struct { hosts map[string]struct{} removedhosts map[string]struct{} clearedhosts bool - skills map[uuid.UUID]struct{} - removedskills map[uuid.UUID]struct{} - clearedskills bool team_group_members map[uuid.UUID]struct{} removedteam_group_members map[uuid.UUID]struct{} clearedteam_group_members bool @@ -34160,9 +41957,6 @@ type TeamGroupMutation struct { team_group_hosts map[uuid.UUID]struct{} removedteam_group_hosts map[uuid.UUID]struct{} clearedteam_group_hosts bool - team_group_skills map[uuid.UUID]struct{} - removedteam_group_skills map[uuid.UUID]struct{} - clearedteam_group_skills bool done bool oldValue func(context.Context) (*TeamGroup, error) predicates []predicate.TeamGroup @@ -34708,60 +42502,6 @@ func (m *TeamGroupMutation) ResetHosts() { m.removedhosts = nil } -// AddSkillIDs adds the "skills" edge to the Skill entity by ids. -func (m *TeamGroupMutation) AddSkillIDs(ids ...uuid.UUID) { - if m.skills == nil { - m.skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.skills[ids[i]] = struct{}{} - } -} - -// ClearSkills clears the "skills" edge to the Skill entity. -func (m *TeamGroupMutation) ClearSkills() { - m.clearedskills = true -} - -// SkillsCleared reports if the "skills" edge to the Skill entity was cleared. -func (m *TeamGroupMutation) SkillsCleared() bool { - return m.clearedskills -} - -// RemoveSkillIDs removes the "skills" edge to the Skill entity by IDs. -func (m *TeamGroupMutation) RemoveSkillIDs(ids ...uuid.UUID) { - if m.removedskills == nil { - m.removedskills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.skills, ids[i]) - m.removedskills[ids[i]] = struct{}{} - } -} - -// RemovedSkills returns the removed IDs of the "skills" edge to the Skill entity. -func (m *TeamGroupMutation) RemovedSkillsIDs() (ids []uuid.UUID) { - for id := range m.removedskills { - ids = append(ids, id) - } - return -} - -// SkillsIDs returns the "skills" edge IDs in the mutation. -func (m *TeamGroupMutation) SkillsIDs() (ids []uuid.UUID) { - for id := range m.skills { - ids = append(ids, id) - } - return -} - -// ResetSkills resets all changes to the "skills" edge. -func (m *TeamGroupMutation) ResetSkills() { - m.skills = nil - m.clearedskills = false - m.removedskills = nil -} - // AddTeamGroupMemberIDs adds the "team_group_members" edge to the TeamGroupMember entity by ids. func (m *TeamGroupMutation) AddTeamGroupMemberIDs(ids ...uuid.UUID) { if m.team_group_members == nil { @@ -34978,60 +42718,6 @@ func (m *TeamGroupMutation) ResetTeamGroupHosts() { m.removedteam_group_hosts = nil } -// AddTeamGroupSkillIDs adds the "team_group_skills" edge to the TeamGroupSkill entity by ids. -func (m *TeamGroupMutation) AddTeamGroupSkillIDs(ids ...uuid.UUID) { - if m.team_group_skills == nil { - m.team_group_skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.team_group_skills[ids[i]] = struct{}{} - } -} - -// ClearTeamGroupSkills clears the "team_group_skills" edge to the TeamGroupSkill entity. -func (m *TeamGroupMutation) ClearTeamGroupSkills() { - m.clearedteam_group_skills = true -} - -// TeamGroupSkillsCleared reports if the "team_group_skills" edge to the TeamGroupSkill entity was cleared. -func (m *TeamGroupMutation) TeamGroupSkillsCleared() bool { - return m.clearedteam_group_skills -} - -// RemoveTeamGroupSkillIDs removes the "team_group_skills" edge to the TeamGroupSkill entity by IDs. -func (m *TeamGroupMutation) RemoveTeamGroupSkillIDs(ids ...uuid.UUID) { - if m.removedteam_group_skills == nil { - m.removedteam_group_skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.team_group_skills, ids[i]) - m.removedteam_group_skills[ids[i]] = struct{}{} - } -} - -// RemovedTeamGroupSkills returns the removed IDs of the "team_group_skills" edge to the TeamGroupSkill entity. -func (m *TeamGroupMutation) RemovedTeamGroupSkillsIDs() (ids []uuid.UUID) { - for id := range m.removedteam_group_skills { - ids = append(ids, id) - } - return -} - -// TeamGroupSkillsIDs returns the "team_group_skills" edge IDs in the mutation. -func (m *TeamGroupMutation) TeamGroupSkillsIDs() (ids []uuid.UUID) { - for id := range m.team_group_skills { - ids = append(ids, id) - } - return -} - -// ResetTeamGroupSkills resets all changes to the "team_group_skills" edge. -func (m *TeamGroupMutation) ResetTeamGroupSkills() { - m.team_group_skills = nil - m.clearedteam_group_skills = false - m.removedteam_group_skills = nil -} - // Where appends a list predicates to the TeamGroupMutation builder. func (m *TeamGroupMutation) Where(ps ...predicate.TeamGroup) { m.predicates = append(m.predicates, ps...) @@ -35242,7 +42928,7 @@ func (m *TeamGroupMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *TeamGroupMutation) AddedEdges() []string { - edges := make([]string, 0, 11) + edges := make([]string, 0, 9) if m.members != nil { edges = append(edges, teamgroup.EdgeMembers) } @@ -35258,9 +42944,6 @@ func (m *TeamGroupMutation) AddedEdges() []string { if m.hosts != nil { edges = append(edges, teamgroup.EdgeHosts) } - if m.skills != nil { - edges = append(edges, teamgroup.EdgeSkills) - } if m.team_group_members != nil { edges = append(edges, teamgroup.EdgeTeamGroupMembers) } @@ -35273,9 +42956,6 @@ func (m *TeamGroupMutation) AddedEdges() []string { if m.team_group_hosts != nil { edges = append(edges, teamgroup.EdgeTeamGroupHosts) } - if m.team_group_skills != nil { - edges = append(edges, teamgroup.EdgeTeamGroupSkills) - } return edges } @@ -35311,12 +42991,6 @@ func (m *TeamGroupMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case teamgroup.EdgeSkills: - ids := make([]ent.Value, 0, len(m.skills)) - for id := range m.skills { - ids = append(ids, id) - } - return ids case teamgroup.EdgeTeamGroupMembers: ids := make([]ent.Value, 0, len(m.team_group_members)) for id := range m.team_group_members { @@ -35341,19 +43015,13 @@ func (m *TeamGroupMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case teamgroup.EdgeTeamGroupSkills: - ids := make([]ent.Value, 0, len(m.team_group_skills)) - for id := range m.team_group_skills { - ids = append(ids, id) - } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *TeamGroupMutation) RemovedEdges() []string { - edges := make([]string, 0, 11) + edges := make([]string, 0, 9) if m.removedmembers != nil { edges = append(edges, teamgroup.EdgeMembers) } @@ -35366,9 +43034,6 @@ func (m *TeamGroupMutation) RemovedEdges() []string { if m.removedhosts != nil { edges = append(edges, teamgroup.EdgeHosts) } - if m.removedskills != nil { - edges = append(edges, teamgroup.EdgeSkills) - } if m.removedteam_group_members != nil { edges = append(edges, teamgroup.EdgeTeamGroupMembers) } @@ -35381,9 +43046,6 @@ func (m *TeamGroupMutation) RemovedEdges() []string { if m.removedteam_group_hosts != nil { edges = append(edges, teamgroup.EdgeTeamGroupHosts) } - if m.removedteam_group_skills != nil { - edges = append(edges, teamgroup.EdgeTeamGroupSkills) - } return edges } @@ -35415,12 +43077,6 @@ func (m *TeamGroupMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case teamgroup.EdgeSkills: - ids := make([]ent.Value, 0, len(m.removedskills)) - for id := range m.removedskills { - ids = append(ids, id) - } - return ids case teamgroup.EdgeTeamGroupMembers: ids := make([]ent.Value, 0, len(m.removedteam_group_members)) for id := range m.removedteam_group_members { @@ -35445,19 +43101,13 @@ func (m *TeamGroupMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case teamgroup.EdgeTeamGroupSkills: - ids := make([]ent.Value, 0, len(m.removedteam_group_skills)) - for id := range m.removedteam_group_skills { - ids = append(ids, id) - } - return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *TeamGroupMutation) ClearedEdges() []string { - edges := make([]string, 0, 11) + edges := make([]string, 0, 9) if m.clearedmembers { edges = append(edges, teamgroup.EdgeMembers) } @@ -35473,9 +43123,6 @@ func (m *TeamGroupMutation) ClearedEdges() []string { if m.clearedhosts { edges = append(edges, teamgroup.EdgeHosts) } - if m.clearedskills { - edges = append(edges, teamgroup.EdgeSkills) - } if m.clearedteam_group_members { edges = append(edges, teamgroup.EdgeTeamGroupMembers) } @@ -35488,9 +43135,6 @@ func (m *TeamGroupMutation) ClearedEdges() []string { if m.clearedteam_group_hosts { edges = append(edges, teamgroup.EdgeTeamGroupHosts) } - if m.clearedteam_group_skills { - edges = append(edges, teamgroup.EdgeTeamGroupSkills) - } return edges } @@ -35508,8 +43152,6 @@ func (m *TeamGroupMutation) EdgeCleared(name string) bool { return m.clearedimages case teamgroup.EdgeHosts: return m.clearedhosts - case teamgroup.EdgeSkills: - return m.clearedskills case teamgroup.EdgeTeamGroupMembers: return m.clearedteam_group_members case teamgroup.EdgeTeamGroupModels: @@ -35518,8 +43160,6 @@ func (m *TeamGroupMutation) EdgeCleared(name string) bool { return m.clearedteam_group_images case teamgroup.EdgeTeamGroupHosts: return m.clearedteam_group_hosts - case teamgroup.EdgeTeamGroupSkills: - return m.clearedteam_group_skills } return false } @@ -35554,9 +43194,6 @@ func (m *TeamGroupMutation) ResetEdge(name string) error { case teamgroup.EdgeHosts: m.ResetHosts() return nil - case teamgroup.EdgeSkills: - m.ResetSkills() - return nil case teamgroup.EdgeTeamGroupMembers: m.ResetTeamGroupMembers() return nil @@ -35569,9 +43206,6 @@ func (m *TeamGroupMutation) ResetEdge(name string) error { case teamgroup.EdgeTeamGroupHosts: m.ResetTeamGroupHosts() return nil - case teamgroup.EdgeTeamGroupSkills: - m.ResetTeamGroupSkills() - return nil } return fmt.Errorf("unknown TeamGroup edge %s", name) } @@ -37736,546 +45370,6 @@ func (m *TeamGroupModelMutation) ResetEdge(name string) error { return fmt.Errorf("unknown TeamGroupModel edge %s", name) } -// TeamGroupSkillMutation represents an operation that mutates the TeamGroupSkill nodes in the graph. -type TeamGroupSkillMutation struct { - config - op Op - typ string - id *uuid.UUID - created_at *time.Time - clearedFields map[string]struct{} - group *uuid.UUID - clearedgroup bool - skill *uuid.UUID - clearedskill bool - done bool - oldValue func(context.Context) (*TeamGroupSkill, error) - predicates []predicate.TeamGroupSkill -} - -var _ ent.Mutation = (*TeamGroupSkillMutation)(nil) - -// teamgroupskillOption allows management of the mutation configuration using functional options. -type teamgroupskillOption func(*TeamGroupSkillMutation) - -// newTeamGroupSkillMutation creates new mutation for the TeamGroupSkill entity. -func newTeamGroupSkillMutation(c config, op Op, opts ...teamgroupskillOption) *TeamGroupSkillMutation { - m := &TeamGroupSkillMutation{ - config: c, - op: op, - typ: TypeTeamGroupSkill, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withTeamGroupSkillID sets the ID field of the mutation. -func withTeamGroupSkillID(id uuid.UUID) teamgroupskillOption { - return func(m *TeamGroupSkillMutation) { - var ( - err error - once sync.Once - value *TeamGroupSkill - ) - m.oldValue = func(ctx context.Context) (*TeamGroupSkill, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().TeamGroupSkill.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withTeamGroupSkill sets the old TeamGroupSkill of the mutation. -func withTeamGroupSkill(node *TeamGroupSkill) teamgroupskillOption { - return func(m *TeamGroupSkillMutation) { - m.oldValue = func(context.Context) (*TeamGroupSkill, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m TeamGroupSkillMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m TeamGroupSkillMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("db: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of TeamGroupSkill entities. -func (m *TeamGroupSkillMutation) SetID(id uuid.UUID) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *TeamGroupSkillMutation) ID() (id uuid.UUID, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *TeamGroupSkillMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []uuid.UUID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().TeamGroupSkill.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetGroupID sets the "group_id" field. -func (m *TeamGroupSkillMutation) SetGroupID(u uuid.UUID) { - m.group = &u -} - -// GroupID returns the value of the "group_id" field in the mutation. -func (m *TeamGroupSkillMutation) GroupID() (r uuid.UUID, exists bool) { - v := m.group - if v == nil { - return - } - return *v, true -} - -// OldGroupID returns the old "group_id" field's value of the TeamGroupSkill entity. -// If the TeamGroupSkill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TeamGroupSkillMutation) OldGroupID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldGroupID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldGroupID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldGroupID: %w", err) - } - return oldValue.GroupID, nil -} - -// ResetGroupID resets all changes to the "group_id" field. -func (m *TeamGroupSkillMutation) ResetGroupID() { - m.group = nil -} - -// SetSkillID sets the "skill_id" field. -func (m *TeamGroupSkillMutation) SetSkillID(u uuid.UUID) { - m.skill = &u -} - -// SkillID returns the value of the "skill_id" field in the mutation. -func (m *TeamGroupSkillMutation) SkillID() (r uuid.UUID, exists bool) { - v := m.skill - if v == nil { - return - } - return *v, true -} - -// OldSkillID returns the old "skill_id" field's value of the TeamGroupSkill entity. -// If the TeamGroupSkill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TeamGroupSkillMutation) OldSkillID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSkillID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSkillID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSkillID: %w", err) - } - return oldValue.SkillID, nil -} - -// ResetSkillID resets all changes to the "skill_id" field. -func (m *TeamGroupSkillMutation) ResetSkillID() { - m.skill = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *TeamGroupSkillMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *TeamGroupSkillMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the TeamGroupSkill entity. -// If the TeamGroupSkill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TeamGroupSkillMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *TeamGroupSkillMutation) ResetCreatedAt() { - m.created_at = nil -} - -// ClearGroup clears the "group" edge to the TeamGroup entity. -func (m *TeamGroupSkillMutation) ClearGroup() { - m.clearedgroup = true - m.clearedFields[teamgroupskill.FieldGroupID] = struct{}{} -} - -// GroupCleared reports if the "group" edge to the TeamGroup entity was cleared. -func (m *TeamGroupSkillMutation) GroupCleared() bool { - return m.clearedgroup -} - -// GroupIDs returns the "group" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// GroupID instead. It exists only for internal usage by the builders. -func (m *TeamGroupSkillMutation) GroupIDs() (ids []uuid.UUID) { - if id := m.group; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetGroup resets all changes to the "group" edge. -func (m *TeamGroupSkillMutation) ResetGroup() { - m.group = nil - m.clearedgroup = false -} - -// ClearSkill clears the "skill" edge to the Skill entity. -func (m *TeamGroupSkillMutation) ClearSkill() { - m.clearedskill = true - m.clearedFields[teamgroupskill.FieldSkillID] = struct{}{} -} - -// SkillCleared reports if the "skill" edge to the Skill entity was cleared. -func (m *TeamGroupSkillMutation) SkillCleared() bool { - return m.clearedskill -} - -// SkillIDs returns the "skill" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// SkillID instead. It exists only for internal usage by the builders. -func (m *TeamGroupSkillMutation) SkillIDs() (ids []uuid.UUID) { - if id := m.skill; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetSkill resets all changes to the "skill" edge. -func (m *TeamGroupSkillMutation) ResetSkill() { - m.skill = nil - m.clearedskill = false -} - -// Where appends a list predicates to the TeamGroupSkillMutation builder. -func (m *TeamGroupSkillMutation) Where(ps ...predicate.TeamGroupSkill) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the TeamGroupSkillMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *TeamGroupSkillMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.TeamGroupSkill, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *TeamGroupSkillMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *TeamGroupSkillMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (TeamGroupSkill). -func (m *TeamGroupSkillMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *TeamGroupSkillMutation) Fields() []string { - fields := make([]string, 0, 3) - if m.group != nil { - fields = append(fields, teamgroupskill.FieldGroupID) - } - if m.skill != nil { - fields = append(fields, teamgroupskill.FieldSkillID) - } - if m.created_at != nil { - fields = append(fields, teamgroupskill.FieldCreatedAt) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *TeamGroupSkillMutation) Field(name string) (ent.Value, bool) { - switch name { - case teamgroupskill.FieldGroupID: - return m.GroupID() - case teamgroupskill.FieldSkillID: - return m.SkillID() - case teamgroupskill.FieldCreatedAt: - return m.CreatedAt() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *TeamGroupSkillMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case teamgroupskill.FieldGroupID: - return m.OldGroupID(ctx) - case teamgroupskill.FieldSkillID: - return m.OldSkillID(ctx) - case teamgroupskill.FieldCreatedAt: - return m.OldCreatedAt(ctx) - } - return nil, fmt.Errorf("unknown TeamGroupSkill field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *TeamGroupSkillMutation) SetField(name string, value ent.Value) error { - switch name { - case teamgroupskill.FieldGroupID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetGroupID(v) - return nil - case teamgroupskill.FieldSkillID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSkillID(v) - return nil - case teamgroupskill.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - } - return fmt.Errorf("unknown TeamGroupSkill field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *TeamGroupSkillMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *TeamGroupSkillMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *TeamGroupSkillMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown TeamGroupSkill numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *TeamGroupSkillMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *TeamGroupSkillMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *TeamGroupSkillMutation) ClearField(name string) error { - return fmt.Errorf("unknown TeamGroupSkill nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *TeamGroupSkillMutation) ResetField(name string) error { - switch name { - case teamgroupskill.FieldGroupID: - m.ResetGroupID() - return nil - case teamgroupskill.FieldSkillID: - m.ResetSkillID() - return nil - case teamgroupskill.FieldCreatedAt: - m.ResetCreatedAt() - return nil - } - return fmt.Errorf("unknown TeamGroupSkill field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *TeamGroupSkillMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.group != nil { - edges = append(edges, teamgroupskill.EdgeGroup) - } - if m.skill != nil { - edges = append(edges, teamgroupskill.EdgeSkill) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *TeamGroupSkillMutation) AddedIDs(name string) []ent.Value { - switch name { - case teamgroupskill.EdgeGroup: - if id := m.group; id != nil { - return []ent.Value{*id} - } - case teamgroupskill.EdgeSkill: - if id := m.skill; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *TeamGroupSkillMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *TeamGroupSkillMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *TeamGroupSkillMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedgroup { - edges = append(edges, teamgroupskill.EdgeGroup) - } - if m.clearedskill { - edges = append(edges, teamgroupskill.EdgeSkill) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *TeamGroupSkillMutation) EdgeCleared(name string) bool { - switch name { - case teamgroupskill.EdgeGroup: - return m.clearedgroup - case teamgroupskill.EdgeSkill: - return m.clearedskill - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *TeamGroupSkillMutation) ClearEdge(name string) error { - switch name { - case teamgroupskill.EdgeGroup: - m.ClearGroup() - return nil - case teamgroupskill.EdgeSkill: - m.ClearSkill() - return nil - } - return fmt.Errorf("unknown TeamGroupSkill unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *TeamGroupSkillMutation) ResetEdge(name string) error { - switch name { - case teamgroupskill.EdgeGroup: - m.ResetGroup() - return nil - case teamgroupskill.EdgeSkill: - m.ResetSkill() - return nil - } - return fmt.Errorf("unknown TeamGroupSkill edge %s", name) -} - // TeamHostMutation represents an operation that mutates the TeamHost nodes in the graph. type TeamHostMutation struct { config @@ -41511,546 +48605,6 @@ func (m *TeamOIDCConfigMutation) ResetEdge(name string) error { return fmt.Errorf("unknown TeamOIDCConfig edge %s", name) } -// TeamSkillMutation represents an operation that mutates the TeamSkill nodes in the graph. -type TeamSkillMutation struct { - config - op Op - typ string - id *uuid.UUID - created_at *time.Time - clearedFields map[string]struct{} - team *uuid.UUID - clearedteam bool - skill *uuid.UUID - clearedskill bool - done bool - oldValue func(context.Context) (*TeamSkill, error) - predicates []predicate.TeamSkill -} - -var _ ent.Mutation = (*TeamSkillMutation)(nil) - -// teamskillOption allows management of the mutation configuration using functional options. -type teamskillOption func(*TeamSkillMutation) - -// newTeamSkillMutation creates new mutation for the TeamSkill entity. -func newTeamSkillMutation(c config, op Op, opts ...teamskillOption) *TeamSkillMutation { - m := &TeamSkillMutation{ - config: c, - op: op, - typ: TypeTeamSkill, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withTeamSkillID sets the ID field of the mutation. -func withTeamSkillID(id uuid.UUID) teamskillOption { - return func(m *TeamSkillMutation) { - var ( - err error - once sync.Once - value *TeamSkill - ) - m.oldValue = func(ctx context.Context) (*TeamSkill, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().TeamSkill.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withTeamSkill sets the old TeamSkill of the mutation. -func withTeamSkill(node *TeamSkill) teamskillOption { - return func(m *TeamSkillMutation) { - m.oldValue = func(context.Context) (*TeamSkill, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m TeamSkillMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m TeamSkillMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("db: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of TeamSkill entities. -func (m *TeamSkillMutation) SetID(id uuid.UUID) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *TeamSkillMutation) ID() (id uuid.UUID, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *TeamSkillMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []uuid.UUID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().TeamSkill.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetTeamID sets the "team_id" field. -func (m *TeamSkillMutation) SetTeamID(u uuid.UUID) { - m.team = &u -} - -// TeamID returns the value of the "team_id" field in the mutation. -func (m *TeamSkillMutation) TeamID() (r uuid.UUID, exists bool) { - v := m.team - if v == nil { - return - } - return *v, true -} - -// OldTeamID returns the old "team_id" field's value of the TeamSkill entity. -// If the TeamSkill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TeamSkillMutation) OldTeamID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTeamID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTeamID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTeamID: %w", err) - } - return oldValue.TeamID, nil -} - -// ResetTeamID resets all changes to the "team_id" field. -func (m *TeamSkillMutation) ResetTeamID() { - m.team = nil -} - -// SetSkillID sets the "skill_id" field. -func (m *TeamSkillMutation) SetSkillID(u uuid.UUID) { - m.skill = &u -} - -// SkillID returns the value of the "skill_id" field in the mutation. -func (m *TeamSkillMutation) SkillID() (r uuid.UUID, exists bool) { - v := m.skill - if v == nil { - return - } - return *v, true -} - -// OldSkillID returns the old "skill_id" field's value of the TeamSkill entity. -// If the TeamSkill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TeamSkillMutation) OldSkillID(ctx context.Context) (v uuid.UUID, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSkillID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSkillID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSkillID: %w", err) - } - return oldValue.SkillID, nil -} - -// ResetSkillID resets all changes to the "skill_id" field. -func (m *TeamSkillMutation) ResetSkillID() { - m.skill = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *TeamSkillMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *TeamSkillMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the TeamSkill entity. -// If the TeamSkill object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TeamSkillMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *TeamSkillMutation) ResetCreatedAt() { - m.created_at = nil -} - -// ClearTeam clears the "team" edge to the Team entity. -func (m *TeamSkillMutation) ClearTeam() { - m.clearedteam = true - m.clearedFields[teamskill.FieldTeamID] = struct{}{} -} - -// TeamCleared reports if the "team" edge to the Team entity was cleared. -func (m *TeamSkillMutation) TeamCleared() bool { - return m.clearedteam -} - -// TeamIDs returns the "team" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TeamID instead. It exists only for internal usage by the builders. -func (m *TeamSkillMutation) TeamIDs() (ids []uuid.UUID) { - if id := m.team; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetTeam resets all changes to the "team" edge. -func (m *TeamSkillMutation) ResetTeam() { - m.team = nil - m.clearedteam = false -} - -// ClearSkill clears the "skill" edge to the Skill entity. -func (m *TeamSkillMutation) ClearSkill() { - m.clearedskill = true - m.clearedFields[teamskill.FieldSkillID] = struct{}{} -} - -// SkillCleared reports if the "skill" edge to the Skill entity was cleared. -func (m *TeamSkillMutation) SkillCleared() bool { - return m.clearedskill -} - -// SkillIDs returns the "skill" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// SkillID instead. It exists only for internal usage by the builders. -func (m *TeamSkillMutation) SkillIDs() (ids []uuid.UUID) { - if id := m.skill; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetSkill resets all changes to the "skill" edge. -func (m *TeamSkillMutation) ResetSkill() { - m.skill = nil - m.clearedskill = false -} - -// Where appends a list predicates to the TeamSkillMutation builder. -func (m *TeamSkillMutation) Where(ps ...predicate.TeamSkill) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the TeamSkillMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *TeamSkillMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.TeamSkill, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *TeamSkillMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *TeamSkillMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (TeamSkill). -func (m *TeamSkillMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *TeamSkillMutation) Fields() []string { - fields := make([]string, 0, 3) - if m.team != nil { - fields = append(fields, teamskill.FieldTeamID) - } - if m.skill != nil { - fields = append(fields, teamskill.FieldSkillID) - } - if m.created_at != nil { - fields = append(fields, teamskill.FieldCreatedAt) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *TeamSkillMutation) Field(name string) (ent.Value, bool) { - switch name { - case teamskill.FieldTeamID: - return m.TeamID() - case teamskill.FieldSkillID: - return m.SkillID() - case teamskill.FieldCreatedAt: - return m.CreatedAt() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *TeamSkillMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case teamskill.FieldTeamID: - return m.OldTeamID(ctx) - case teamskill.FieldSkillID: - return m.OldSkillID(ctx) - case teamskill.FieldCreatedAt: - return m.OldCreatedAt(ctx) - } - return nil, fmt.Errorf("unknown TeamSkill field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *TeamSkillMutation) SetField(name string, value ent.Value) error { - switch name { - case teamskill.FieldTeamID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTeamID(v) - return nil - case teamskill.FieldSkillID: - v, ok := value.(uuid.UUID) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSkillID(v) - return nil - case teamskill.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - } - return fmt.Errorf("unknown TeamSkill field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *TeamSkillMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *TeamSkillMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *TeamSkillMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown TeamSkill numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *TeamSkillMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *TeamSkillMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *TeamSkillMutation) ClearField(name string) error { - return fmt.Errorf("unknown TeamSkill nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *TeamSkillMutation) ResetField(name string) error { - switch name { - case teamskill.FieldTeamID: - m.ResetTeamID() - return nil - case teamskill.FieldSkillID: - m.ResetSkillID() - return nil - case teamskill.FieldCreatedAt: - m.ResetCreatedAt() - return nil - } - return fmt.Errorf("unknown TeamSkill field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *TeamSkillMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.team != nil { - edges = append(edges, teamskill.EdgeTeam) - } - if m.skill != nil { - edges = append(edges, teamskill.EdgeSkill) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *TeamSkillMutation) AddedIDs(name string) []ent.Value { - switch name { - case teamskill.EdgeTeam: - if id := m.team; id != nil { - return []ent.Value{*id} - } - case teamskill.EdgeSkill: - if id := m.skill; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *TeamSkillMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *TeamSkillMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *TeamSkillMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedteam { - edges = append(edges, teamskill.EdgeTeam) - } - if m.clearedskill { - edges = append(edges, teamskill.EdgeSkill) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *TeamSkillMutation) EdgeCleared(name string) bool { - switch name { - case teamskill.EdgeTeam: - return m.clearedteam - case teamskill.EdgeSkill: - return m.clearedskill - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *TeamSkillMutation) ClearEdge(name string) error { - switch name { - case teamskill.EdgeTeam: - m.ClearTeam() - return nil - case teamskill.EdgeSkill: - m.ClearSkill() - return nil - } - return fmt.Errorf("unknown TeamSkill unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *TeamSkillMutation) ResetEdge(name string) error { - switch name { - case teamskill.EdgeTeam: - m.ResetTeam() - return nil - case teamskill.EdgeSkill: - m.ResetSkill() - return nil - } - return fmt.Errorf("unknown TeamSkill edge %s", name) -} - // UserMutation represents an operation that mutates the User nodes in the graph. type UserMutation struct { config @@ -42087,9 +48641,6 @@ type UserMutation struct { images map[uuid.UUID]struct{} removedimages map[uuid.UUID]struct{} clearedimages bool - skills map[uuid.UUID]struct{} - removedskills map[uuid.UUID]struct{} - clearedskills bool hosts map[string]struct{} removedhosts map[string]struct{} clearedhosts bool @@ -43029,60 +49580,6 @@ func (m *UserMutation) ResetImages() { m.removedimages = nil } -// AddSkillIDs adds the "skills" edge to the Skill entity by ids. -func (m *UserMutation) AddSkillIDs(ids ...uuid.UUID) { - if m.skills == nil { - m.skills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.skills[ids[i]] = struct{}{} - } -} - -// ClearSkills clears the "skills" edge to the Skill entity. -func (m *UserMutation) ClearSkills() { - m.clearedskills = true -} - -// SkillsCleared reports if the "skills" edge to the Skill entity was cleared. -func (m *UserMutation) SkillsCleared() bool { - return m.clearedskills -} - -// RemoveSkillIDs removes the "skills" edge to the Skill entity by IDs. -func (m *UserMutation) RemoveSkillIDs(ids ...uuid.UUID) { - if m.removedskills == nil { - m.removedskills = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.skills, ids[i]) - m.removedskills[ids[i]] = struct{}{} - } -} - -// RemovedSkills returns the removed IDs of the "skills" edge to the Skill entity. -func (m *UserMutation) RemovedSkillsIDs() (ids []uuid.UUID) { - for id := range m.removedskills { - ids = append(ids, id) - } - return -} - -// SkillsIDs returns the "skills" edge IDs in the mutation. -func (m *UserMutation) SkillsIDs() (ids []uuid.UUID) { - for id := range m.skills { - ids = append(ids, id) - } - return -} - -// ResetSkills resets all changes to the "skills" edge. -func (m *UserMutation) ResetSkills() { - m.skills = nil - m.clearedskills = false - m.removedskills = nil -} - // AddHostIDs adds the "hosts" edge to the Host entity by ids. func (m *UserMutation) AddHostIDs(ids ...string) { if m.hosts == nil { @@ -44229,7 +50726,7 @@ func (m *UserMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *UserMutation) AddedEdges() []string { - edges := make([]string, 0, 22) + edges := make([]string, 0, 21) if m.identities != nil { edges = append(edges, user.EdgeIdentities) } @@ -44248,9 +50745,6 @@ func (m *UserMutation) AddedEdges() []string { if m.images != nil { edges = append(edges, user.EdgeImages) } - if m.skills != nil { - edges = append(edges, user.EdgeSkills) - } if m.hosts != nil { edges = append(edges, user.EdgeHosts) } @@ -44339,12 +50833,6 @@ func (m *UserMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case user.EdgeSkills: - ids := make([]ent.Value, 0, len(m.skills)) - for id := range m.skills { - ids = append(ids, id) - } - return ids case user.EdgeHosts: ids := make([]ent.Value, 0, len(m.hosts)) for id := range m.hosts { @@ -44441,7 +50929,7 @@ func (m *UserMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *UserMutation) RemovedEdges() []string { - edges := make([]string, 0, 22) + edges := make([]string, 0, 21) if m.removedidentities != nil { edges = append(edges, user.EdgeIdentities) } @@ -44460,9 +50948,6 @@ func (m *UserMutation) RemovedEdges() []string { if m.removedimages != nil { edges = append(edges, user.EdgeImages) } - if m.removedskills != nil { - edges = append(edges, user.EdgeSkills) - } if m.removedhosts != nil { edges = append(edges, user.EdgeHosts) } @@ -44551,12 +51036,6 @@ func (m *UserMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case user.EdgeSkills: - ids := make([]ent.Value, 0, len(m.removedskills)) - for id := range m.removedskills { - ids = append(ids, id) - } - return ids case user.EdgeHosts: ids := make([]ent.Value, 0, len(m.removedhosts)) for id := range m.removedhosts { @@ -44653,7 +51132,7 @@ func (m *UserMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *UserMutation) ClearedEdges() []string { - edges := make([]string, 0, 22) + edges := make([]string, 0, 21) if m.clearedidentities { edges = append(edges, user.EdgeIdentities) } @@ -44672,9 +51151,6 @@ func (m *UserMutation) ClearedEdges() []string { if m.clearedimages { edges = append(edges, user.EdgeImages) } - if m.clearedskills { - edges = append(edges, user.EdgeSkills) - } if m.clearedhosts { edges = append(edges, user.EdgeHosts) } @@ -44739,8 +51215,6 @@ func (m *UserMutation) EdgeCleared(name string) bool { return m.clearedmodels case user.EdgeImages: return m.clearedimages - case user.EdgeSkills: - return m.clearedskills case user.EdgeHosts: return m.clearedhosts case user.EdgeVms: @@ -44805,9 +51279,6 @@ func (m *UserMutation) ResetEdge(name string) error { case user.EdgeImages: m.ResetImages() return nil - case user.EdgeSkills: - m.ResetSkills() - return nil case user.EdgeHosts: m.ResetHosts() return nil diff --git a/backend/db/page.go b/backend/db/page.go index 125c1a87..06d95f82 100644 --- a/backend/db/page.go +++ b/backend/db/page.go @@ -11,7 +11,7 @@ type PageInfo struct { TotalCount int64 `json:"total_count"` } -func (_m *AuditQuery) Page(ctx context.Context, page, size int) ([]*Audit, *PageInfo, error) { +func (_m *AgentPluginQuery) Page(ctx context.Context, page, size int) ([]*AgentPlugin, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -25,7 +25,7 @@ func (_m *AuditQuery) Page(ctx context.Context, page, size int) ([]*Audit, *Page return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *GitBotQuery) Page(ctx context.Context, page, size int) ([]*GitBot, *PageInfo, error) { +func (_m *AgentPluginRepoQuery) Page(ctx context.Context, page, size int) ([]*AgentPluginRepo, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -39,7 +39,7 @@ func (_m *GitBotQuery) Page(ctx context.Context, page, size int) ([]*GitBot, *Pa return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *GitBotTaskQuery) Page(ctx context.Context, page, size int) ([]*GitBotTask, *PageInfo, error) { +func (_m *AgentPluginVersionQuery) Page(ctx context.Context, page, size int) ([]*AgentPluginVersion, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -53,7 +53,7 @@ func (_m *GitBotTaskQuery) Page(ctx context.Context, page, size int) ([]*GitBotT return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *GitBotUserQuery) Page(ctx context.Context, page, size int) ([]*GitBotUser, *PageInfo, error) { +func (_m *AgentRuleQuery) Page(ctx context.Context, page, size int) ([]*AgentRule, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -67,7 +67,7 @@ func (_m *GitBotUserQuery) Page(ctx context.Context, page, size int) ([]*GitBotU return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *GitIdentityQuery) Page(ctx context.Context, page, size int) ([]*GitIdentity, *PageInfo, error) { +func (_m *AgentRuleVersionQuery) Page(ctx context.Context, page, size int) ([]*AgentRuleVersion, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -81,7 +81,7 @@ func (_m *GitIdentityQuery) Page(ctx context.Context, page, size int) ([]*GitIde return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *GitTaskQuery) Page(ctx context.Context, page, size int) ([]*GitTask, *PageInfo, error) { +func (_m *AgentSkillQuery) Page(ctx context.Context, page, size int) ([]*AgentSkill, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -95,7 +95,7 @@ func (_m *GitTaskQuery) Page(ctx context.Context, page, size int) ([]*GitTask, * return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *HostQuery) Page(ctx context.Context, page, size int) ([]*Host, *PageInfo, error) { +func (_m *AgentSkillGroupBindingQuery) Page(ctx context.Context, page, size int) ([]*AgentSkillGroupBinding, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -109,7 +109,7 @@ func (_m *HostQuery) Page(ctx context.Context, page, size int) ([]*Host, *PageIn return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *ImageQuery) Page(ctx context.Context, page, size int) ([]*Image, *PageInfo, error) { +func (_m *AgentSkillRepoQuery) Page(ctx context.Context, page, size int) ([]*AgentSkillRepo, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -123,7 +123,7 @@ func (_m *ImageQuery) Page(ctx context.Context, page, size int) ([]*Image, *Page return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *MCPToolQuery) Page(ctx context.Context, page, size int) ([]*MCPTool, *PageInfo, error) { +func (_m *AgentSkillVersionQuery) Page(ctx context.Context, page, size int) ([]*AgentSkillVersion, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -137,7 +137,7 @@ func (_m *MCPToolQuery) Page(ctx context.Context, page, size int) ([]*MCPTool, * return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *MCPUpstreamQuery) Page(ctx context.Context, page, size int) ([]*MCPUpstream, *PageInfo, error) { +func (_m *AgentSyncJobQuery) Page(ctx context.Context, page, size int) ([]*AgentSyncJob, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -151,7 +151,7 @@ func (_m *MCPUpstreamQuery) Page(ctx context.Context, page, size int) ([]*MCPUps return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *MCPUserToolSettingQuery) Page(ctx context.Context, page, size int) ([]*MCPUserToolSetting, *PageInfo, error) { +func (_m *AuditQuery) Page(ctx context.Context, page, size int) ([]*Audit, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -165,7 +165,7 @@ func (_m *MCPUserToolSettingQuery) Page(ctx context.Context, page, size int) ([] return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *ModelQuery) Page(ctx context.Context, page, size int) ([]*Model, *PageInfo, error) { +func (_m *GitBotQuery) Page(ctx context.Context, page, size int) ([]*GitBot, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -179,7 +179,7 @@ func (_m *ModelQuery) Page(ctx context.Context, page, size int) ([]*Model, *Page return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *ModelApiKeyQuery) Page(ctx context.Context, page, size int) ([]*ModelApiKey, *PageInfo, error) { +func (_m *GitBotTaskQuery) Page(ctx context.Context, page, size int) ([]*GitBotTask, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -193,7 +193,7 @@ func (_m *ModelApiKeyQuery) Page(ctx context.Context, page, size int) ([]*ModelA return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *ModelPricingQuery) Page(ctx context.Context, page, size int) ([]*ModelPricing, *PageInfo, error) { +func (_m *GitBotUserQuery) Page(ctx context.Context, page, size int) ([]*GitBotUser, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -207,7 +207,7 @@ func (_m *ModelPricingQuery) Page(ctx context.Context, page, size int) ([]*Model return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *NotifyChannelQuery) Page(ctx context.Context, page, size int) ([]*NotifyChannel, *PageInfo, error) { +func (_m *GitIdentityQuery) Page(ctx context.Context, page, size int) ([]*GitIdentity, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -221,7 +221,7 @@ func (_m *NotifyChannelQuery) Page(ctx context.Context, page, size int) ([]*Noti return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *NotifySendLogQuery) Page(ctx context.Context, page, size int) ([]*NotifySendLog, *PageInfo, error) { +func (_m *GitTaskQuery) Page(ctx context.Context, page, size int) ([]*GitTask, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -235,7 +235,7 @@ func (_m *NotifySendLogQuery) Page(ctx context.Context, page, size int) ([]*Noti return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *NotifySubscriptionQuery) Page(ctx context.Context, page, size int) ([]*NotifySubscription, *PageInfo, error) { +func (_m *HostQuery) Page(ctx context.Context, page, size int) ([]*Host, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -249,7 +249,7 @@ func (_m *NotifySubscriptionQuery) Page(ctx context.Context, page, size int) ([] return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *ProjectQuery) Page(ctx context.Context, page, size int) ([]*Project, *PageInfo, error) { +func (_m *ImageQuery) Page(ctx context.Context, page, size int) ([]*Image, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -263,7 +263,7 @@ func (_m *ProjectQuery) Page(ctx context.Context, page, size int) ([]*Project, * return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *ProjectCollaboratorQuery) Page(ctx context.Context, page, size int) ([]*ProjectCollaborator, *PageInfo, error) { +func (_m *MCPToolQuery) Page(ctx context.Context, page, size int) ([]*MCPTool, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -277,7 +277,7 @@ func (_m *ProjectCollaboratorQuery) Page(ctx context.Context, page, size int) ([ return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *ProjectGitBotQuery) Page(ctx context.Context, page, size int) ([]*ProjectGitBot, *PageInfo, error) { +func (_m *MCPUpstreamQuery) Page(ctx context.Context, page, size int) ([]*MCPUpstream, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -291,7 +291,7 @@ func (_m *ProjectGitBotQuery) Page(ctx context.Context, page, size int) ([]*Proj return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *ProjectIssueQuery) Page(ctx context.Context, page, size int) ([]*ProjectIssue, *PageInfo, error) { +func (_m *MCPUserToolSettingQuery) Page(ctx context.Context, page, size int) ([]*MCPUserToolSetting, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -305,7 +305,7 @@ func (_m *ProjectIssueQuery) Page(ctx context.Context, page, size int) ([]*Proje return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *ProjectIssueCommentQuery) Page(ctx context.Context, page, size int) ([]*ProjectIssueComment, *PageInfo, error) { +func (_m *ModelQuery) Page(ctx context.Context, page, size int) ([]*Model, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -319,7 +319,7 @@ func (_m *ProjectIssueCommentQuery) Page(ctx context.Context, page, size int) ([ return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *ProjectTaskQuery) Page(ctx context.Context, page, size int) ([]*ProjectTask, *PageInfo, error) { +func (_m *ModelApiKeyQuery) Page(ctx context.Context, page, size int) ([]*ModelApiKey, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -333,7 +333,7 @@ func (_m *ProjectTaskQuery) Page(ctx context.Context, page, size int) ([]*Projec return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *SkillQuery) Page(ctx context.Context, page, size int) ([]*Skill, *PageInfo, error) { +func (_m *ModelPricingQuery) Page(ctx context.Context, page, size int) ([]*ModelPricing, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -347,7 +347,7 @@ func (_m *SkillQuery) Page(ctx context.Context, page, size int) ([]*Skill, *Page return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TaskQuery) Page(ctx context.Context, page, size int) ([]*Task, *PageInfo, error) { +func (_m *NotifyChannelQuery) Page(ctx context.Context, page, size int) ([]*NotifyChannel, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -361,7 +361,7 @@ func (_m *TaskQuery) Page(ctx context.Context, page, size int) ([]*Task, *PageIn return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TaskModelSwitchQuery) Page(ctx context.Context, page, size int) ([]*TaskModelSwitch, *PageInfo, error) { +func (_m *NotifySendLogQuery) Page(ctx context.Context, page, size int) ([]*NotifySendLog, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -375,7 +375,7 @@ func (_m *TaskModelSwitchQuery) Page(ctx context.Context, page, size int) ([]*Ta return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TaskUsageStatQuery) Page(ctx context.Context, page, size int) ([]*TaskUsageStat, *PageInfo, error) { +func (_m *NotifySubscriptionQuery) Page(ctx context.Context, page, size int) ([]*NotifySubscription, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -389,7 +389,7 @@ func (_m *TaskUsageStatQuery) Page(ctx context.Context, page, size int) ([]*Task return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TaskVirtualMachineQuery) Page(ctx context.Context, page, size int) ([]*TaskVirtualMachine, *PageInfo, error) { +func (_m *ProjectQuery) Page(ctx context.Context, page, size int) ([]*Project, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -403,7 +403,7 @@ func (_m *TaskVirtualMachineQuery) Page(ctx context.Context, page, size int) ([] return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamQuery) Page(ctx context.Context, page, size int) ([]*Team, *PageInfo, error) { +func (_m *ProjectCollaboratorQuery) Page(ctx context.Context, page, size int) ([]*ProjectCollaborator, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -417,7 +417,7 @@ func (_m *TeamQuery) Page(ctx context.Context, page, size int) ([]*Team, *PageIn return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamExtensionImageArchiveQuery) Page(ctx context.Context, page, size int) ([]*TeamExtensionImageArchive, *PageInfo, error) { +func (_m *ProjectGitBotQuery) Page(ctx context.Context, page, size int) ([]*ProjectGitBot, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -431,7 +431,7 @@ func (_m *TeamExtensionImageArchiveQuery) Page(ctx context.Context, page, size i return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamGroupQuery) Page(ctx context.Context, page, size int) ([]*TeamGroup, *PageInfo, error) { +func (_m *ProjectIssueQuery) Page(ctx context.Context, page, size int) ([]*ProjectIssue, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -445,7 +445,7 @@ func (_m *TeamGroupQuery) Page(ctx context.Context, page, size int) ([]*TeamGrou return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamGroupHostQuery) Page(ctx context.Context, page, size int) ([]*TeamGroupHost, *PageInfo, error) { +func (_m *ProjectIssueCommentQuery) Page(ctx context.Context, page, size int) ([]*ProjectIssueComment, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -459,7 +459,7 @@ func (_m *TeamGroupHostQuery) Page(ctx context.Context, page, size int) ([]*Team return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamGroupImageQuery) Page(ctx context.Context, page, size int) ([]*TeamGroupImage, *PageInfo, error) { +func (_m *ProjectTaskQuery) Page(ctx context.Context, page, size int) ([]*ProjectTask, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -473,7 +473,7 @@ func (_m *TeamGroupImageQuery) Page(ctx context.Context, page, size int) ([]*Tea return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamGroupMemberQuery) Page(ctx context.Context, page, size int) ([]*TeamGroupMember, *PageInfo, error) { +func (_m *TaskQuery) Page(ctx context.Context, page, size int) ([]*Task, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -487,7 +487,7 @@ func (_m *TeamGroupMemberQuery) Page(ctx context.Context, page, size int) ([]*Te return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamGroupModelQuery) Page(ctx context.Context, page, size int) ([]*TeamGroupModel, *PageInfo, error) { +func (_m *TaskModelSwitchQuery) Page(ctx context.Context, page, size int) ([]*TaskModelSwitch, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -501,7 +501,7 @@ func (_m *TeamGroupModelQuery) Page(ctx context.Context, page, size int) ([]*Tea return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamGroupSkillQuery) Page(ctx context.Context, page, size int) ([]*TeamGroupSkill, *PageInfo, error) { +func (_m *TaskUsageStatQuery) Page(ctx context.Context, page, size int) ([]*TaskUsageStat, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -515,7 +515,7 @@ func (_m *TeamGroupSkillQuery) Page(ctx context.Context, page, size int) ([]*Tea return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamHostQuery) Page(ctx context.Context, page, size int) ([]*TeamHost, *PageInfo, error) { +func (_m *TaskVirtualMachineQuery) Page(ctx context.Context, page, size int) ([]*TaskVirtualMachine, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -529,7 +529,7 @@ func (_m *TeamHostQuery) Page(ctx context.Context, page, size int) ([]*TeamHost, return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamImageQuery) Page(ctx context.Context, page, size int) ([]*TeamImage, *PageInfo, error) { +func (_m *TeamQuery) Page(ctx context.Context, page, size int) ([]*Team, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -543,7 +543,7 @@ func (_m *TeamImageQuery) Page(ctx context.Context, page, size int) ([]*TeamImag return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamMemberQuery) Page(ctx context.Context, page, size int) ([]*TeamMember, *PageInfo, error) { +func (_m *TeamExtensionImageArchiveQuery) Page(ctx context.Context, page, size int) ([]*TeamExtensionImageArchive, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -557,7 +557,7 @@ func (_m *TeamMemberQuery) Page(ctx context.Context, page, size int) ([]*TeamMem return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamModelQuery) Page(ctx context.Context, page, size int) ([]*TeamModel, *PageInfo, error) { +func (_m *TeamGroupQuery) Page(ctx context.Context, page, size int) ([]*TeamGroup, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -571,7 +571,7 @@ func (_m *TeamModelQuery) Page(ctx context.Context, page, size int) ([]*TeamMode return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamOIDCConfigQuery) Page(ctx context.Context, page, size int) ([]*TeamOIDCConfig, *PageInfo, error) { +func (_m *TeamGroupHostQuery) Page(ctx context.Context, page, size int) ([]*TeamGroupHost, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err @@ -585,7 +585,105 @@ func (_m *TeamOIDCConfigQuery) Page(ctx context.Context, page, size int) ([]*Tea return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil } -func (_m *TeamSkillQuery) Page(ctx context.Context, page, size int) ([]*TeamSkill, *PageInfo, error) { +func (_m *TeamGroupImageQuery) Page(ctx context.Context, page, size int) ([]*TeamGroupImage, *PageInfo, error) { + cnt, err := _m.Count(ctx) + if err != nil { + return nil, nil, err + } + offset := size * (page - 1) + rs, err := _m.Offset(offset).Limit(size).All(ctx) + if err != nil { + return nil, nil, err + } + has := (page * size) < cnt + return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil +} + +func (_m *TeamGroupMemberQuery) Page(ctx context.Context, page, size int) ([]*TeamGroupMember, *PageInfo, error) { + cnt, err := _m.Count(ctx) + if err != nil { + return nil, nil, err + } + offset := size * (page - 1) + rs, err := _m.Offset(offset).Limit(size).All(ctx) + if err != nil { + return nil, nil, err + } + has := (page * size) < cnt + return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil +} + +func (_m *TeamGroupModelQuery) Page(ctx context.Context, page, size int) ([]*TeamGroupModel, *PageInfo, error) { + cnt, err := _m.Count(ctx) + if err != nil { + return nil, nil, err + } + offset := size * (page - 1) + rs, err := _m.Offset(offset).Limit(size).All(ctx) + if err != nil { + return nil, nil, err + } + has := (page * size) < cnt + return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil +} + +func (_m *TeamHostQuery) Page(ctx context.Context, page, size int) ([]*TeamHost, *PageInfo, error) { + cnt, err := _m.Count(ctx) + if err != nil { + return nil, nil, err + } + offset := size * (page - 1) + rs, err := _m.Offset(offset).Limit(size).All(ctx) + if err != nil { + return nil, nil, err + } + has := (page * size) < cnt + return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil +} + +func (_m *TeamImageQuery) Page(ctx context.Context, page, size int) ([]*TeamImage, *PageInfo, error) { + cnt, err := _m.Count(ctx) + if err != nil { + return nil, nil, err + } + offset := size * (page - 1) + rs, err := _m.Offset(offset).Limit(size).All(ctx) + if err != nil { + return nil, nil, err + } + has := (page * size) < cnt + return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil +} + +func (_m *TeamMemberQuery) Page(ctx context.Context, page, size int) ([]*TeamMember, *PageInfo, error) { + cnt, err := _m.Count(ctx) + if err != nil { + return nil, nil, err + } + offset := size * (page - 1) + rs, err := _m.Offset(offset).Limit(size).All(ctx) + if err != nil { + return nil, nil, err + } + has := (page * size) < cnt + return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil +} + +func (_m *TeamModelQuery) Page(ctx context.Context, page, size int) ([]*TeamModel, *PageInfo, error) { + cnt, err := _m.Count(ctx) + if err != nil { + return nil, nil, err + } + offset := size * (page - 1) + rs, err := _m.Offset(offset).Limit(size).All(ctx) + if err != nil { + return nil, nil, err + } + has := (page * size) < cnt + return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil +} + +func (_m *TeamOIDCConfigQuery) Page(ctx context.Context, page, size int) ([]*TeamOIDCConfig, *PageInfo, error) { cnt, err := _m.Count(ctx) if err != nil { return nil, nil, err diff --git a/backend/db/predicate/predicate.go b/backend/db/predicate/predicate.go index dbbf3613..8116d719 100644 --- a/backend/db/predicate/predicate.go +++ b/backend/db/predicate/predicate.go @@ -6,6 +6,36 @@ import ( "entgo.io/ent/dialect/sql" ) +// AgentPlugin is the predicate function for agentplugin builders. +type AgentPlugin func(*sql.Selector) + +// AgentPluginRepo is the predicate function for agentpluginrepo builders. +type AgentPluginRepo func(*sql.Selector) + +// AgentPluginVersion is the predicate function for agentpluginversion builders. +type AgentPluginVersion func(*sql.Selector) + +// AgentRule is the predicate function for agentrule builders. +type AgentRule func(*sql.Selector) + +// AgentRuleVersion is the predicate function for agentruleversion builders. +type AgentRuleVersion func(*sql.Selector) + +// AgentSkill is the predicate function for agentskill builders. +type AgentSkill func(*sql.Selector) + +// AgentSkillGroupBinding is the predicate function for agentskillgroupbinding builders. +type AgentSkillGroupBinding func(*sql.Selector) + +// AgentSkillRepo is the predicate function for agentskillrepo builders. +type AgentSkillRepo func(*sql.Selector) + +// AgentSkillVersion is the predicate function for agentskillversion builders. +type AgentSkillVersion func(*sql.Selector) + +// AgentSyncJob is the predicate function for agentsyncjob builders. +type AgentSyncJob func(*sql.Selector) + // Audit is the predicate function for audit builders. type Audit func(*sql.Selector) @@ -75,9 +105,6 @@ type ProjectIssueComment func(*sql.Selector) // ProjectTask is the predicate function for projecttask builders. type ProjectTask func(*sql.Selector) -// Skill is the predicate function for skill builders. -type Skill func(*sql.Selector) - // Task is the predicate function for task builders. type Task func(*sql.Selector) @@ -111,9 +138,6 @@ type TeamGroupMember func(*sql.Selector) // TeamGroupModel is the predicate function for teamgroupmodel builders. type TeamGroupModel func(*sql.Selector) -// TeamGroupSkill is the predicate function for teamgroupskill builders. -type TeamGroupSkill func(*sql.Selector) - // TeamHost is the predicate function for teamhost builders. type TeamHost func(*sql.Selector) @@ -129,9 +153,6 @@ type TeamModel func(*sql.Selector) // TeamOIDCConfig is the predicate function for teamoidcconfig builders. type TeamOIDCConfig func(*sql.Selector) -// TeamSkill is the predicate function for teamskill builders. -type TeamSkill func(*sql.Selector) - // User is the predicate function for user builders. type User func(*sql.Selector) diff --git a/backend/db/runtime/runtime.go b/backend/db/runtime/runtime.go index 16452fe2..2485cdc3 100644 --- a/backend/db/runtime/runtime.go +++ b/backend/db/runtime/runtime.go @@ -6,6 +6,16 @@ import ( "time" "github.com/chaitin/MonkeyCode/backend/consts" + "github.com/chaitin/MonkeyCode/backend/db/agentplugin" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentpluginversion" + "github.com/chaitin/MonkeyCode/backend/db/agentrule" + "github.com/chaitin/MonkeyCode/backend/db/agentruleversion" + "github.com/chaitin/MonkeyCode/backend/db/agentskill" + "github.com/chaitin/MonkeyCode/backend/db/agentskillgroupbinding" + "github.com/chaitin/MonkeyCode/backend/db/agentskillrepo" + "github.com/chaitin/MonkeyCode/backend/db/agentskillversion" + "github.com/chaitin/MonkeyCode/backend/db/agentsyncjob" "github.com/chaitin/MonkeyCode/backend/db/audit" "github.com/chaitin/MonkeyCode/backend/db/gitbot" "github.com/chaitin/MonkeyCode/backend/db/gitbottask" @@ -29,7 +39,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/projectissue" "github.com/chaitin/MonkeyCode/backend/db/projectissuecomment" "github.com/chaitin/MonkeyCode/backend/db/projecttask" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/task" "github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch" "github.com/chaitin/MonkeyCode/backend/db/taskusagestat" @@ -41,13 +50,11 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/teamgroupimage" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmember" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/chaitin/MonkeyCode/backend/db/teamhost" "github.com/chaitin/MonkeyCode/backend/db/teamimage" "github.com/chaitin/MonkeyCode/backend/db/teammember" "github.com/chaitin/MonkeyCode/backend/db/teammodel" "github.com/chaitin/MonkeyCode/backend/db/teamoidcconfig" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/chaitin/MonkeyCode/backend/db/useridentity" "github.com/chaitin/MonkeyCode/backend/db/virtualmachine" @@ -59,6 +66,264 @@ import ( // (default values, validators, hooks and policies) and stitches it // to their package variables. func init() { + agentpluginFields := schema.AgentPlugin{}.Fields() + _ = agentpluginFields + // agentpluginDescName is the schema descriptor for name field. + agentpluginDescName := agentpluginFields[2].Descriptor() + // agentplugin.NameValidator is a validator for the "name" field. It is called by the builders before save. + agentplugin.NameValidator = agentpluginDescName.Validators[0].(func(string) error) + // agentpluginDescScopeID is the schema descriptor for scope_id field. + agentpluginDescScopeID := agentpluginFields[5].Descriptor() + // agentplugin.DefaultScopeID holds the default value on creation for the scope_id field. + agentplugin.DefaultScopeID = agentpluginDescScopeID.Default.(string) + // agentpluginDescIsForceDelivery is the schema descriptor for is_force_delivery field. + agentpluginDescIsForceDelivery := agentpluginFields[8].Descriptor() + // agentplugin.DefaultIsForceDelivery holds the default value on creation for the is_force_delivery field. + agentplugin.DefaultIsForceDelivery = agentpluginDescIsForceDelivery.Default.(bool) + // agentpluginDescIsOrphan is the schema descriptor for is_orphan field. + agentpluginDescIsOrphan := agentpluginFields[9].Descriptor() + // agentplugin.DefaultIsOrphan holds the default value on creation for the is_orphan field. + agentplugin.DefaultIsOrphan = agentpluginDescIsOrphan.Default.(bool) + // agentpluginDescIsDeleted is the schema descriptor for is_deleted field. + agentpluginDescIsDeleted := agentpluginFields[10].Descriptor() + // agentplugin.DefaultIsDeleted holds the default value on creation for the is_deleted field. + agentplugin.DefaultIsDeleted = agentpluginDescIsDeleted.Default.(bool) + // agentpluginDescEnabled is the schema descriptor for enabled field. + agentpluginDescEnabled := agentpluginFields[11].Descriptor() + // agentplugin.DefaultEnabled holds the default value on creation for the enabled field. + agentplugin.DefaultEnabled = agentpluginDescEnabled.Default.(bool) + // agentpluginDescCreatedAt is the schema descriptor for created_at field. + agentpluginDescCreatedAt := agentpluginFields[12].Descriptor() + // agentplugin.DefaultCreatedAt holds the default value on creation for the created_at field. + agentplugin.DefaultCreatedAt = agentpluginDescCreatedAt.Default.(func() time.Time) + // agentpluginDescUpdatedAt is the schema descriptor for updated_at field. + agentpluginDescUpdatedAt := agentpluginFields[13].Descriptor() + // agentplugin.DefaultUpdatedAt holds the default value on creation for the updated_at field. + agentplugin.DefaultUpdatedAt = agentpluginDescUpdatedAt.Default.(func() time.Time) + // agentplugin.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + agentplugin.UpdateDefaultUpdatedAt = agentpluginDescUpdatedAt.UpdateDefault.(func() time.Time) + // agentpluginDescID is the schema descriptor for id field. + agentpluginDescID := agentpluginFields[0].Descriptor() + // agentplugin.DefaultID holds the default value on creation for the id field. + agentplugin.DefaultID = agentpluginDescID.Default.(func() uuid.UUID) + agentpluginrepoFields := schema.AgentPluginRepo{}.Fields() + _ = agentpluginrepoFields + // agentpluginrepoDescName is the schema descriptor for name field. + agentpluginrepoDescName := agentpluginrepoFields[1].Descriptor() + // agentpluginrepo.NameValidator is a validator for the "name" field. It is called by the builders before save. + agentpluginrepo.NameValidator = agentpluginrepoDescName.Validators[0].(func(string) error) + // agentpluginrepoDescScopeID is the schema descriptor for scope_id field. + agentpluginrepoDescScopeID := agentpluginrepoFields[3].Descriptor() + // agentpluginrepo.DefaultScopeID holds the default value on creation for the scope_id field. + agentpluginrepo.DefaultScopeID = agentpluginrepoDescScopeID.Default.(string) + // agentpluginrepoDescPluginDiscoveryAutoPackageJSON is the schema descriptor for plugin_discovery_auto_package_json field. + agentpluginrepoDescPluginDiscoveryAutoPackageJSON := agentpluginrepoFields[11].Descriptor() + // agentpluginrepo.DefaultPluginDiscoveryAutoPackageJSON holds the default value on creation for the plugin_discovery_auto_package_json field. + agentpluginrepo.DefaultPluginDiscoveryAutoPackageJSON = agentpluginrepoDescPluginDiscoveryAutoPackageJSON.Default.(bool) + // agentpluginrepoDescIsDeleted is the schema descriptor for is_deleted field. + agentpluginrepoDescIsDeleted := agentpluginrepoFields[16].Descriptor() + // agentpluginrepo.DefaultIsDeleted holds the default value on creation for the is_deleted field. + agentpluginrepo.DefaultIsDeleted = agentpluginrepoDescIsDeleted.Default.(bool) + // agentpluginrepoDescCreatedAt is the schema descriptor for created_at field. + agentpluginrepoDescCreatedAt := agentpluginrepoFields[17].Descriptor() + // agentpluginrepo.DefaultCreatedAt holds the default value on creation for the created_at field. + agentpluginrepo.DefaultCreatedAt = agentpluginrepoDescCreatedAt.Default.(func() time.Time) + // agentpluginrepoDescUpdatedAt is the schema descriptor for updated_at field. + agentpluginrepoDescUpdatedAt := agentpluginrepoFields[18].Descriptor() + // agentpluginrepo.DefaultUpdatedAt holds the default value on creation for the updated_at field. + agentpluginrepo.DefaultUpdatedAt = agentpluginrepoDescUpdatedAt.Default.(func() time.Time) + // agentpluginrepo.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + agentpluginrepo.UpdateDefaultUpdatedAt = agentpluginrepoDescUpdatedAt.UpdateDefault.(func() time.Time) + // agentpluginrepoDescID is the schema descriptor for id field. + agentpluginrepoDescID := agentpluginrepoFields[0].Descriptor() + // agentpluginrepo.DefaultID holds the default value on creation for the id field. + agentpluginrepo.DefaultID = agentpluginrepoDescID.Default.(func() uuid.UUID) + agentpluginversionFields := schema.AgentPluginVersion{}.Fields() + _ = agentpluginversionFields + // agentpluginversionDescVersion is the schema descriptor for version field. + agentpluginversionDescVersion := agentpluginversionFields[2].Descriptor() + // agentpluginversion.VersionValidator is a validator for the "version" field. It is called by the builders before save. + agentpluginversion.VersionValidator = agentpluginversionDescVersion.Validators[0].(func(string) error) + // agentpluginversionDescS3Key is the schema descriptor for s3_key field. + agentpluginversionDescS3Key := agentpluginversionFields[3].Descriptor() + // agentpluginversion.S3KeyValidator is a validator for the "s3_key" field. It is called by the builders before save. + agentpluginversion.S3KeyValidator = agentpluginversionDescS3Key.Validators[0].(func(string) error) + // agentpluginversionDescCreatedAt is the schema descriptor for created_at field. + agentpluginversionDescCreatedAt := agentpluginversionFields[5].Descriptor() + // agentpluginversion.DefaultCreatedAt holds the default value on creation for the created_at field. + agentpluginversion.DefaultCreatedAt = agentpluginversionDescCreatedAt.Default.(func() time.Time) + // agentpluginversionDescID is the schema descriptor for id field. + agentpluginversionDescID := agentpluginversionFields[0].Descriptor() + // agentpluginversion.DefaultID holds the default value on creation for the id field. + agentpluginversion.DefaultID = agentpluginversionDescID.Default.(func() uuid.UUID) + agentruleFields := schema.AgentRule{}.Fields() + _ = agentruleFields + // agentruleDescName is the schema descriptor for name field. + agentruleDescName := agentruleFields[1].Descriptor() + // agentrule.NameValidator is a validator for the "name" field. It is called by the builders before save. + agentrule.NameValidator = agentruleDescName.Validators[0].(func(string) error) + // agentruleDescScopeID is the schema descriptor for scope_id field. + agentruleDescScopeID := agentruleFields[4].Descriptor() + // agentrule.DefaultScopeID holds the default value on creation for the scope_id field. + agentrule.DefaultScopeID = agentruleDescScopeID.Default.(string) + // agentruleDescIsDeleted is the schema descriptor for is_deleted field. + agentruleDescIsDeleted := agentruleFields[7].Descriptor() + // agentrule.DefaultIsDeleted holds the default value on creation for the is_deleted field. + agentrule.DefaultIsDeleted = agentruleDescIsDeleted.Default.(bool) + // agentruleDescCreatedAt is the schema descriptor for created_at field. + agentruleDescCreatedAt := agentruleFields[8].Descriptor() + // agentrule.DefaultCreatedAt holds the default value on creation for the created_at field. + agentrule.DefaultCreatedAt = agentruleDescCreatedAt.Default.(func() time.Time) + // agentruleDescUpdatedAt is the schema descriptor for updated_at field. + agentruleDescUpdatedAt := agentruleFields[9].Descriptor() + // agentrule.DefaultUpdatedAt holds the default value on creation for the updated_at field. + agentrule.DefaultUpdatedAt = agentruleDescUpdatedAt.Default.(func() time.Time) + // agentrule.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + agentrule.UpdateDefaultUpdatedAt = agentruleDescUpdatedAt.UpdateDefault.(func() time.Time) + // agentruleDescID is the schema descriptor for id field. + agentruleDescID := agentruleFields[0].Descriptor() + // agentrule.DefaultID holds the default value on creation for the id field. + agentrule.DefaultID = agentruleDescID.Default.(func() uuid.UUID) + agentruleversionFields := schema.AgentRuleVersion{}.Fields() + _ = agentruleversionFields + // agentruleversionDescVersion is the schema descriptor for version field. + agentruleversionDescVersion := agentruleversionFields[2].Descriptor() + // agentruleversion.VersionValidator is a validator for the "version" field. It is called by the builders before save. + agentruleversion.VersionValidator = func() func(string) error { + validators := agentruleversionDescVersion.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(version string) error { + for _, fn := range fns { + if err := fn(version); err != nil { + return err + } + } + return nil + } + }() + // agentruleversionDescCreatedAt is the schema descriptor for created_at field. + agentruleversionDescCreatedAt := agentruleversionFields[4].Descriptor() + // agentruleversion.DefaultCreatedAt holds the default value on creation for the created_at field. + agentruleversion.DefaultCreatedAt = agentruleversionDescCreatedAt.Default.(func() time.Time) + // agentruleversionDescID is the schema descriptor for id field. + agentruleversionDescID := agentruleversionFields[0].Descriptor() + // agentruleversion.DefaultID holds the default value on creation for the id field. + agentruleversion.DefaultID = agentruleversionDescID.Default.(func() uuid.UUID) + agentskillFields := schema.AgentSkill{}.Fields() + _ = agentskillFields + // agentskillDescName is the schema descriptor for name field. + agentskillDescName := agentskillFields[2].Descriptor() + // agentskill.NameValidator is a validator for the "name" field. It is called by the builders before save. + agentskill.NameValidator = agentskillDescName.Validators[0].(func(string) error) + // agentskillDescScopeID is the schema descriptor for scope_id field. + agentskillDescScopeID := agentskillFields[5].Descriptor() + // agentskill.DefaultScopeID holds the default value on creation for the scope_id field. + agentskill.DefaultScopeID = agentskillDescScopeID.Default.(string) + // agentskillDescIsForceDelivery is the schema descriptor for is_force_delivery field. + agentskillDescIsForceDelivery := agentskillFields[8].Descriptor() + // agentskill.DefaultIsForceDelivery holds the default value on creation for the is_force_delivery field. + agentskill.DefaultIsForceDelivery = agentskillDescIsForceDelivery.Default.(bool) + // agentskillDescIsOrphan is the schema descriptor for is_orphan field. + agentskillDescIsOrphan := agentskillFields[9].Descriptor() + // agentskill.DefaultIsOrphan holds the default value on creation for the is_orphan field. + agentskill.DefaultIsOrphan = agentskillDescIsOrphan.Default.(bool) + // agentskillDescIsDeleted is the schema descriptor for is_deleted field. + agentskillDescIsDeleted := agentskillFields[10].Descriptor() + // agentskill.DefaultIsDeleted holds the default value on creation for the is_deleted field. + agentskill.DefaultIsDeleted = agentskillDescIsDeleted.Default.(bool) + // agentskillDescEnabled is the schema descriptor for enabled field. + agentskillDescEnabled := agentskillFields[11].Descriptor() + // agentskill.DefaultEnabled holds the default value on creation for the enabled field. + agentskill.DefaultEnabled = agentskillDescEnabled.Default.(bool) + // agentskillDescCreatedAt is the schema descriptor for created_at field. + agentskillDescCreatedAt := agentskillFields[15].Descriptor() + // agentskill.DefaultCreatedAt holds the default value on creation for the created_at field. + agentskill.DefaultCreatedAt = agentskillDescCreatedAt.Default.(func() time.Time) + // agentskillDescUpdatedAt is the schema descriptor for updated_at field. + agentskillDescUpdatedAt := agentskillFields[16].Descriptor() + // agentskill.DefaultUpdatedAt holds the default value on creation for the updated_at field. + agentskill.DefaultUpdatedAt = agentskillDescUpdatedAt.Default.(func() time.Time) + // agentskill.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + agentskill.UpdateDefaultUpdatedAt = agentskillDescUpdatedAt.UpdateDefault.(func() time.Time) + // agentskillDescID is the schema descriptor for id field. + agentskillDescID := agentskillFields[0].Descriptor() + // agentskill.DefaultID holds the default value on creation for the id field. + agentskill.DefaultID = agentskillDescID.Default.(func() uuid.UUID) + agentskillgroupbindingFields := schema.AgentSkillGroupBinding{}.Fields() + _ = agentskillgroupbindingFields + // agentskillgroupbindingDescCreatedAt is the schema descriptor for created_at field. + agentskillgroupbindingDescCreatedAt := agentskillgroupbindingFields[3].Descriptor() + // agentskillgroupbinding.DefaultCreatedAt holds the default value on creation for the created_at field. + agentskillgroupbinding.DefaultCreatedAt = agentskillgroupbindingDescCreatedAt.Default.(func() time.Time) + // agentskillgroupbindingDescID is the schema descriptor for id field. + agentskillgroupbindingDescID := agentskillgroupbindingFields[0].Descriptor() + // agentskillgroupbinding.DefaultID holds the default value on creation for the id field. + agentskillgroupbinding.DefaultID = agentskillgroupbindingDescID.Default.(func() uuid.UUID) + agentskillrepoFields := schema.AgentSkillRepo{}.Fields() + _ = agentskillrepoFields + // agentskillrepoDescName is the schema descriptor for name field. + agentskillrepoDescName := agentskillrepoFields[1].Descriptor() + // agentskillrepo.NameValidator is a validator for the "name" field. It is called by the builders before save. + agentskillrepo.NameValidator = agentskillrepoDescName.Validators[0].(func(string) error) + // agentskillrepoDescScopeID is the schema descriptor for scope_id field. + agentskillrepoDescScopeID := agentskillrepoFields[3].Descriptor() + // agentskillrepo.DefaultScopeID holds the default value on creation for the scope_id field. + agentskillrepo.DefaultScopeID = agentskillrepoDescScopeID.Default.(string) + // agentskillrepoDescIsDeleted is the schema descriptor for is_deleted field. + agentskillrepoDescIsDeleted := agentskillrepoFields[11].Descriptor() + // agentskillrepo.DefaultIsDeleted holds the default value on creation for the is_deleted field. + agentskillrepo.DefaultIsDeleted = agentskillrepoDescIsDeleted.Default.(bool) + // agentskillrepoDescCreatedAt is the schema descriptor for created_at field. + agentskillrepoDescCreatedAt := agentskillrepoFields[12].Descriptor() + // agentskillrepo.DefaultCreatedAt holds the default value on creation for the created_at field. + agentskillrepo.DefaultCreatedAt = agentskillrepoDescCreatedAt.Default.(func() time.Time) + // agentskillrepoDescUpdatedAt is the schema descriptor for updated_at field. + agentskillrepoDescUpdatedAt := agentskillrepoFields[13].Descriptor() + // agentskillrepo.DefaultUpdatedAt holds the default value on creation for the updated_at field. + agentskillrepo.DefaultUpdatedAt = agentskillrepoDescUpdatedAt.Default.(func() time.Time) + // agentskillrepo.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + agentskillrepo.UpdateDefaultUpdatedAt = agentskillrepoDescUpdatedAt.UpdateDefault.(func() time.Time) + // agentskillrepoDescID is the schema descriptor for id field. + agentskillrepoDescID := agentskillrepoFields[0].Descriptor() + // agentskillrepo.DefaultID holds the default value on creation for the id field. + agentskillrepo.DefaultID = agentskillrepoDescID.Default.(func() uuid.UUID) + agentskillversionFields := schema.AgentSkillVersion{}.Fields() + _ = agentskillversionFields + // agentskillversionDescVersion is the schema descriptor for version field. + agentskillversionDescVersion := agentskillversionFields[2].Descriptor() + // agentskillversion.VersionValidator is a validator for the "version" field. It is called by the builders before save. + agentskillversion.VersionValidator = agentskillversionDescVersion.Validators[0].(func(string) error) + // agentskillversionDescS3Key is the schema descriptor for s3_key field. + agentskillversionDescS3Key := agentskillversionFields[3].Descriptor() + // agentskillversion.S3KeyValidator is a validator for the "s3_key" field. It is called by the builders before save. + agentskillversion.S3KeyValidator = agentskillversionDescS3Key.Validators[0].(func(string) error) + // agentskillversionDescCreatedAt is the schema descriptor for created_at field. + agentskillversionDescCreatedAt := agentskillversionFields[5].Descriptor() + // agentskillversion.DefaultCreatedAt holds the default value on creation for the created_at field. + agentskillversion.DefaultCreatedAt = agentskillversionDescCreatedAt.Default.(func() time.Time) + // agentskillversionDescID is the schema descriptor for id field. + agentskillversionDescID := agentskillversionFields[0].Descriptor() + // agentskillversion.DefaultID holds the default value on creation for the id field. + agentskillversion.DefaultID = agentskillversionDescID.Default.(func() uuid.UUID) + agentsyncjobFields := schema.AgentSyncJob{}.Fields() + _ = agentsyncjobFields + // agentsyncjobDescCreatedAt is the schema descriptor for created_at field. + agentsyncjobDescCreatedAt := agentsyncjobFields[12].Descriptor() + // agentsyncjob.DefaultCreatedAt holds the default value on creation for the created_at field. + agentsyncjob.DefaultCreatedAt = agentsyncjobDescCreatedAt.Default.(func() time.Time) + // agentsyncjobDescUpdatedAt is the schema descriptor for updated_at field. + agentsyncjobDescUpdatedAt := agentsyncjobFields[13].Descriptor() + // agentsyncjob.DefaultUpdatedAt holds the default value on creation for the updated_at field. + agentsyncjob.DefaultUpdatedAt = agentsyncjobDescUpdatedAt.Default.(func() time.Time) + // agentsyncjob.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + agentsyncjob.UpdateDefaultUpdatedAt = agentsyncjobDescUpdatedAt.UpdateDefault.(func() time.Time) + // agentsyncjobDescID is the schema descriptor for id field. + agentsyncjobDescID := agentsyncjobFields[0].Descriptor() + // agentsyncjob.DefaultID holds the default value on creation for the id field. + agentsyncjob.DefaultID = agentsyncjobDescID.Default.(func() uuid.UUID) auditFields := schema.Audit{}.Fields() _ = auditFields // auditDescCreatedAt is the schema descriptor for created_at field. @@ -661,43 +926,6 @@ func init() { projecttaskDescCreatedAt := projecttaskFields[11].Descriptor() // projecttask.DefaultCreatedAt holds the default value on creation for the created_at field. projecttask.DefaultCreatedAt = projecttaskDescCreatedAt.Default.(func() time.Time) - skillMixin := schema.Skill{}.Mixin() - skillMixinHooks0 := skillMixin[0].Hooks() - skill.Hooks[0] = skillMixinHooks0[0] - skillMixinInters0 := skillMixin[0].Interceptors() - skill.Interceptors[0] = skillMixinInters0[0] - skillFields := schema.Skill{}.Fields() - _ = skillFields - // skillDescName is the schema descriptor for name field. - skillDescName := skillFields[2].Descriptor() - // skill.NameValidator is a validator for the "name" field. It is called by the builders before save. - skill.NameValidator = skillDescName.Validators[0].(func(string) error) - // skillDescDescription is the schema descriptor for description field. - skillDescDescription := skillFields[3].Descriptor() - // skill.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - skill.DescriptionValidator = skillDescDescription.Validators[0].(func(string) error) - // skillDescContent is the schema descriptor for content field. - skillDescContent := skillFields[5].Descriptor() - // skill.ContentValidator is a validator for the "content" field. It is called by the builders before save. - skill.ContentValidator = skillDescContent.Validators[0].(func(string) error) - // skillDescSourceType is the schema descriptor for source_type field. - skillDescSourceType := skillFields[8].Descriptor() - // skill.SourceTypeValidator is a validator for the "source_type" field. It is called by the builders before save. - skill.SourceTypeValidator = skillDescSourceType.Validators[0].(func(string) error) - // skillDescSourceLabel is the schema descriptor for source_label field. - skillDescSourceLabel := skillFields[9].Descriptor() - // skill.SourceLabelValidator is a validator for the "source_label" field. It is called by the builders before save. - skill.SourceLabelValidator = skillDescSourceLabel.Validators[0].(func(string) error) - // skillDescCreatedAt is the schema descriptor for created_at field. - skillDescCreatedAt := skillFields[14].Descriptor() - // skill.DefaultCreatedAt holds the default value on creation for the created_at field. - skill.DefaultCreatedAt = skillDescCreatedAt.Default.(func() time.Time) - // skillDescUpdatedAt is the schema descriptor for updated_at field. - skillDescUpdatedAt := skillFields[15].Descriptor() - // skill.DefaultUpdatedAt holds the default value on creation for the updated_at field. - skill.DefaultUpdatedAt = skillDescUpdatedAt.Default.(func() time.Time) - // skill.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. - skill.UpdateDefaultUpdatedAt = skillDescUpdatedAt.UpdateDefault.(func() time.Time) taskMixin := schema.Task{}.Mixin() taskMixinHooks0 := taskMixin[0].Hooks() task.Hooks[0] = taskMixinHooks0[0] @@ -909,12 +1137,6 @@ func init() { teamgroupmodelDescCreatedAt := teamgroupmodelFields[3].Descriptor() // teamgroupmodel.DefaultCreatedAt holds the default value on creation for the created_at field. teamgroupmodel.DefaultCreatedAt = teamgroupmodelDescCreatedAt.Default.(func() time.Time) - teamgroupskillFields := schema.TeamGroupSkill{}.Fields() - _ = teamgroupskillFields - // teamgroupskillDescCreatedAt is the schema descriptor for created_at field. - teamgroupskillDescCreatedAt := teamgroupskillFields[3].Descriptor() - // teamgroupskill.DefaultCreatedAt holds the default value on creation for the created_at field. - teamgroupskill.DefaultCreatedAt = teamgroupskillDescCreatedAt.Default.(func() time.Time) teamhostFields := schema.TeamHost{}.Fields() _ = teamhostFields // teamhostDescCreatedAt is the schema descriptor for created_at field. @@ -979,12 +1201,6 @@ func init() { teamoidcconfig.DefaultUpdatedAt = teamoidcconfigDescUpdatedAt.Default.(func() time.Time) // teamoidcconfig.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. teamoidcconfig.UpdateDefaultUpdatedAt = teamoidcconfigDescUpdatedAt.UpdateDefault.(func() time.Time) - teamskillFields := schema.TeamSkill{}.Fields() - _ = teamskillFields - // teamskillDescCreatedAt is the schema descriptor for created_at field. - teamskillDescCreatedAt := teamskillFields[3].Descriptor() - // teamskill.DefaultCreatedAt holds the default value on creation for the created_at field. - teamskill.DefaultCreatedAt = teamskillDescCreatedAt.Default.(func() time.Time) userMixin := schema.User{}.Mixin() userMixinHooks0 := userMixin[0].Hooks() user.Hooks[0] = userMixinHooks0[0] diff --git a/backend/db/skill.go b/backend/db/skill.go deleted file mode 100644 index 85c1d276..00000000 --- a/backend/db/skill.go +++ /dev/null @@ -1,370 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package db - -import ( - "encoding/json" - "fmt" - "strings" - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/chaitin/MonkeyCode/backend/db/skill" - "github.com/chaitin/MonkeyCode/backend/db/user" - "github.com/google/uuid" -) - -// Skill is the model entity for the Skill schema. -type Skill struct { - config `json:"-"` - // ID of the ent. - ID uuid.UUID `json:"id,omitempty"` - // DeletedAt holds the value of the "deleted_at" field. - DeletedAt time.Time `json:"deleted_at,omitempty"` - // UserID holds the value of the "user_id" field. - UserID uuid.UUID `json:"user_id,omitempty"` - // Name holds the value of the "name" field. - Name string `json:"name,omitempty"` - // Description holds the value of the "description" field. - Description string `json:"description,omitempty"` - // Tags holds the value of the "tags" field. - Tags []string `json:"tags,omitempty"` - // Content holds the value of the "content" field. - Content string `json:"content,omitempty"` - // PackageObjectKey holds the value of the "package_object_key" field. - PackageObjectKey string `json:"package_object_key,omitempty"` - // PackageURL holds the value of the "package_url" field. - PackageURL string `json:"package_url,omitempty"` - // SourceType holds the value of the "source_type" field. - SourceType string `json:"source_type,omitempty"` - // SourceLabel holds the value of the "source_label" field. - SourceLabel string `json:"source_label,omitempty"` - // SkillMdPath holds the value of the "skill_md_path" field. - SkillMdPath string `json:"skill_md_path,omitempty"` - // ExtensionPackageID holds the value of the "extension_package_id" field. - ExtensionPackageID string `json:"extension_package_id,omitempty"` - // ExtensionSkillID holds the value of the "extension_skill_id" field. - ExtensionSkillID string `json:"extension_skill_id,omitempty"` - // ExtensionVersion holds the value of the "extension_version" field. - ExtensionVersion string `json:"extension_version,omitempty"` - // CreatedAt holds the value of the "created_at" field. - CreatedAt time.Time `json:"created_at,omitempty"` - // UpdatedAt holds the value of the "updated_at" field. - UpdatedAt time.Time `json:"updated_at,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the SkillQuery when eager-loading is set. - Edges SkillEdges `json:"edges"` - selectValues sql.SelectValues -} - -// SkillEdges holds the relations/edges for other nodes in the graph. -type SkillEdges struct { - // User holds the value of the user edge. - User *User `json:"user,omitempty"` - // Teams holds the value of the teams edge. - Teams []*Team `json:"teams,omitempty"` - // Groups holds the value of the groups edge. - Groups []*TeamGroup `json:"groups,omitempty"` - // TeamSkills holds the value of the team_skills edge. - TeamSkills []*TeamSkill `json:"team_skills,omitempty"` - // TeamGroupSkills holds the value of the team_group_skills edge. - TeamGroupSkills []*TeamGroupSkill `json:"team_group_skills,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [5]bool -} - -// UserOrErr returns the User value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e SkillEdges) UserOrErr() (*User, error) { - if e.User != nil { - return e.User, nil - } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: user.Label} - } - return nil, &NotLoadedError{edge: "user"} -} - -// TeamsOrErr returns the Teams value or an error if the edge -// was not loaded in eager-loading. -func (e SkillEdges) TeamsOrErr() ([]*Team, error) { - if e.loadedTypes[1] { - return e.Teams, nil - } - return nil, &NotLoadedError{edge: "teams"} -} - -// GroupsOrErr returns the Groups value or an error if the edge -// was not loaded in eager-loading. -func (e SkillEdges) GroupsOrErr() ([]*TeamGroup, error) { - if e.loadedTypes[2] { - return e.Groups, nil - } - return nil, &NotLoadedError{edge: "groups"} -} - -// TeamSkillsOrErr returns the TeamSkills value or an error if the edge -// was not loaded in eager-loading. -func (e SkillEdges) TeamSkillsOrErr() ([]*TeamSkill, error) { - if e.loadedTypes[3] { - return e.TeamSkills, nil - } - return nil, &NotLoadedError{edge: "team_skills"} -} - -// TeamGroupSkillsOrErr returns the TeamGroupSkills value or an error if the edge -// was not loaded in eager-loading. -func (e SkillEdges) TeamGroupSkillsOrErr() ([]*TeamGroupSkill, error) { - if e.loadedTypes[4] { - return e.TeamGroupSkills, nil - } - return nil, &NotLoadedError{edge: "team_group_skills"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*Skill) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case skill.FieldTags: - values[i] = new([]byte) - case skill.FieldName, skill.FieldDescription, skill.FieldContent, skill.FieldPackageObjectKey, skill.FieldPackageURL, skill.FieldSourceType, skill.FieldSourceLabel, skill.FieldSkillMdPath, skill.FieldExtensionPackageID, skill.FieldExtensionSkillID, skill.FieldExtensionVersion: - values[i] = new(sql.NullString) - case skill.FieldDeletedAt, skill.FieldCreatedAt, skill.FieldUpdatedAt: - values[i] = new(sql.NullTime) - case skill.FieldID, skill.FieldUserID: - values[i] = new(uuid.UUID) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the Skill fields. -func (_m *Skill) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case skill.FieldID: - if value, ok := values[i].(*uuid.UUID); !ok { - return fmt.Errorf("unexpected type %T for field id", values[i]) - } else if value != nil { - _m.ID = *value - } - case skill.FieldDeletedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) - } else if value.Valid { - _m.DeletedAt = value.Time - } - case skill.FieldUserID: - if value, ok := values[i].(*uuid.UUID); !ok { - return fmt.Errorf("unexpected type %T for field user_id", values[i]) - } else if value != nil { - _m.UserID = *value - } - case skill.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - _m.Name = value.String - } - case skill.FieldDescription: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field description", values[i]) - } else if value.Valid { - _m.Description = value.String - } - case skill.FieldTags: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field tags", values[i]) - } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &_m.Tags); err != nil { - return fmt.Errorf("unmarshal field tags: %w", err) - } - } - case skill.FieldContent: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field content", values[i]) - } else if value.Valid { - _m.Content = value.String - } - case skill.FieldPackageObjectKey: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field package_object_key", values[i]) - } else if value.Valid { - _m.PackageObjectKey = value.String - } - case skill.FieldPackageURL: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field package_url", values[i]) - } else if value.Valid { - _m.PackageURL = value.String - } - case skill.FieldSourceType: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field source_type", values[i]) - } else if value.Valid { - _m.SourceType = value.String - } - case skill.FieldSourceLabel: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field source_label", values[i]) - } else if value.Valid { - _m.SourceLabel = value.String - } - case skill.FieldSkillMdPath: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field skill_md_path", values[i]) - } else if value.Valid { - _m.SkillMdPath = value.String - } - case skill.FieldExtensionPackageID: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field extension_package_id", values[i]) - } else if value.Valid { - _m.ExtensionPackageID = value.String - } - case skill.FieldExtensionSkillID: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field extension_skill_id", values[i]) - } else if value.Valid { - _m.ExtensionSkillID = value.String - } - case skill.FieldExtensionVersion: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field extension_version", values[i]) - } else if value.Valid { - _m.ExtensionVersion = value.String - } - case skill.FieldCreatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field created_at", values[i]) - } else if value.Valid { - _m.CreatedAt = value.Time - } - case skill.FieldUpdatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field updated_at", values[i]) - } else if value.Valid { - _m.UpdatedAt = value.Time - } - default: - _m.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the Skill. -// This includes values selected through modifiers, order, etc. -func (_m *Skill) Value(name string) (ent.Value, error) { - return _m.selectValues.Get(name) -} - -// QueryUser queries the "user" edge of the Skill entity. -func (_m *Skill) QueryUser() *UserQuery { - return NewSkillClient(_m.config).QueryUser(_m) -} - -// QueryTeams queries the "teams" edge of the Skill entity. -func (_m *Skill) QueryTeams() *TeamQuery { - return NewSkillClient(_m.config).QueryTeams(_m) -} - -// QueryGroups queries the "groups" edge of the Skill entity. -func (_m *Skill) QueryGroups() *TeamGroupQuery { - return NewSkillClient(_m.config).QueryGroups(_m) -} - -// QueryTeamSkills queries the "team_skills" edge of the Skill entity. -func (_m *Skill) QueryTeamSkills() *TeamSkillQuery { - return NewSkillClient(_m.config).QueryTeamSkills(_m) -} - -// QueryTeamGroupSkills queries the "team_group_skills" edge of the Skill entity. -func (_m *Skill) QueryTeamGroupSkills() *TeamGroupSkillQuery { - return NewSkillClient(_m.config).QueryTeamGroupSkills(_m) -} - -// Update returns a builder for updating this Skill. -// Note that you need to call Skill.Unwrap() before calling this method if this Skill -// was returned from a transaction, and the transaction was committed or rolled back. -func (_m *Skill) Update() *SkillUpdateOne { - return NewSkillClient(_m.config).UpdateOne(_m) -} - -// Unwrap unwraps the Skill entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (_m *Skill) Unwrap() *Skill { - _tx, ok := _m.config.driver.(*txDriver) - if !ok { - panic("db: Skill is not a transactional entity") - } - _m.config.driver = _tx.drv - return _m -} - -// String implements the fmt.Stringer. -func (_m *Skill) String() string { - var builder strings.Builder - builder.WriteString("Skill(") - builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - builder.WriteString("deleted_at=") - builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("user_id=") - builder.WriteString(fmt.Sprintf("%v", _m.UserID)) - builder.WriteString(", ") - builder.WriteString("name=") - builder.WriteString(_m.Name) - builder.WriteString(", ") - builder.WriteString("description=") - builder.WriteString(_m.Description) - builder.WriteString(", ") - builder.WriteString("tags=") - builder.WriteString(fmt.Sprintf("%v", _m.Tags)) - builder.WriteString(", ") - builder.WriteString("content=") - builder.WriteString(_m.Content) - builder.WriteString(", ") - builder.WriteString("package_object_key=") - builder.WriteString(_m.PackageObjectKey) - builder.WriteString(", ") - builder.WriteString("package_url=") - builder.WriteString(_m.PackageURL) - builder.WriteString(", ") - builder.WriteString("source_type=") - builder.WriteString(_m.SourceType) - builder.WriteString(", ") - builder.WriteString("source_label=") - builder.WriteString(_m.SourceLabel) - builder.WriteString(", ") - builder.WriteString("skill_md_path=") - builder.WriteString(_m.SkillMdPath) - builder.WriteString(", ") - builder.WriteString("extension_package_id=") - builder.WriteString(_m.ExtensionPackageID) - builder.WriteString(", ") - builder.WriteString("extension_skill_id=") - builder.WriteString(_m.ExtensionSkillID) - builder.WriteString(", ") - builder.WriteString("extension_version=") - builder.WriteString(_m.ExtensionVersion) - builder.WriteString(", ") - builder.WriteString("created_at=") - builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("updated_at=") - builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) - builder.WriteByte(')') - return builder.String() -} - -// Skills is a parsable slice of Skill. -type Skills []*Skill diff --git a/backend/db/skill/skill.go b/backend/db/skill/skill.go deleted file mode 100644 index 951ab027..00000000 --- a/backend/db/skill/skill.go +++ /dev/null @@ -1,340 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package skill - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the skill type in the database. - Label = "skill" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldDeletedAt holds the string denoting the deleted_at field in the database. - FieldDeletedAt = "deleted_at" - // FieldUserID holds the string denoting the user_id field in the database. - FieldUserID = "user_id" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldTags holds the string denoting the tags field in the database. - FieldTags = "tags" - // FieldContent holds the string denoting the content field in the database. - FieldContent = "content" - // FieldPackageObjectKey holds the string denoting the package_object_key field in the database. - FieldPackageObjectKey = "package_object_key" - // FieldPackageURL holds the string denoting the package_url field in the database. - FieldPackageURL = "package_url" - // FieldSourceType holds the string denoting the source_type field in the database. - FieldSourceType = "source_type" - // FieldSourceLabel holds the string denoting the source_label field in the database. - FieldSourceLabel = "source_label" - // FieldSkillMdPath holds the string denoting the skill_md_path field in the database. - FieldSkillMdPath = "skill_md_path" - // FieldExtensionPackageID holds the string denoting the extension_package_id field in the database. - FieldExtensionPackageID = "extension_package_id" - // FieldExtensionSkillID holds the string denoting the extension_skill_id field in the database. - FieldExtensionSkillID = "extension_skill_id" - // FieldExtensionVersion holds the string denoting the extension_version field in the database. - FieldExtensionVersion = "extension_version" - // FieldCreatedAt holds the string denoting the created_at field in the database. - FieldCreatedAt = "created_at" - // FieldUpdatedAt holds the string denoting the updated_at field in the database. - FieldUpdatedAt = "updated_at" - // EdgeUser holds the string denoting the user edge name in mutations. - EdgeUser = "user" - // EdgeTeams holds the string denoting the teams edge name in mutations. - EdgeTeams = "teams" - // EdgeGroups holds the string denoting the groups edge name in mutations. - EdgeGroups = "groups" - // EdgeTeamSkills holds the string denoting the team_skills edge name in mutations. - EdgeTeamSkills = "team_skills" - // EdgeTeamGroupSkills holds the string denoting the team_group_skills edge name in mutations. - EdgeTeamGroupSkills = "team_group_skills" - // Table holds the table name of the skill in the database. - Table = "skills" - // UserTable is the table that holds the user relation/edge. - UserTable = "skills" - // UserInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UserInverseTable = "users" - // UserColumn is the table column denoting the user relation/edge. - UserColumn = "user_id" - // TeamsTable is the table that holds the teams relation/edge. The primary key declared below. - TeamsTable = "team_skills" - // TeamsInverseTable is the table name for the Team entity. - // It exists in this package in order to avoid circular dependency with the "team" package. - TeamsInverseTable = "teams" - // GroupsTable is the table that holds the groups relation/edge. The primary key declared below. - GroupsTable = "team_group_skills" - // GroupsInverseTable is the table name for the TeamGroup entity. - // It exists in this package in order to avoid circular dependency with the "teamgroup" package. - GroupsInverseTable = "team_groups" - // TeamSkillsTable is the table that holds the team_skills relation/edge. - TeamSkillsTable = "team_skills" - // TeamSkillsInverseTable is the table name for the TeamSkill entity. - // It exists in this package in order to avoid circular dependency with the "teamskill" package. - TeamSkillsInverseTable = "team_skills" - // TeamSkillsColumn is the table column denoting the team_skills relation/edge. - TeamSkillsColumn = "skill_id" - // TeamGroupSkillsTable is the table that holds the team_group_skills relation/edge. - TeamGroupSkillsTable = "team_group_skills" - // TeamGroupSkillsInverseTable is the table name for the TeamGroupSkill entity. - // It exists in this package in order to avoid circular dependency with the "teamgroupskill" package. - TeamGroupSkillsInverseTable = "team_group_skills" - // TeamGroupSkillsColumn is the table column denoting the team_group_skills relation/edge. - TeamGroupSkillsColumn = "skill_id" -) - -// Columns holds all SQL columns for skill fields. -var Columns = []string{ - FieldID, - FieldDeletedAt, - FieldUserID, - FieldName, - FieldDescription, - FieldTags, - FieldContent, - FieldPackageObjectKey, - FieldPackageURL, - FieldSourceType, - FieldSourceLabel, - FieldSkillMdPath, - FieldExtensionPackageID, - FieldExtensionSkillID, - FieldExtensionVersion, - FieldCreatedAt, - FieldUpdatedAt, -} - -var ( - // TeamsPrimaryKey and TeamsColumn2 are the table columns denoting the - // primary key for the teams relation (M2M). - TeamsPrimaryKey = []string{"team_id", "skill_id"} - // GroupsPrimaryKey and GroupsColumn2 are the table columns denoting the - // primary key for the groups relation (M2M). - GroupsPrimaryKey = []string{"group_id", "skill_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -// Note that the variables below are initialized by the runtime -// package on the initialization of the application. Therefore, -// it should be imported in the main as follows: -// -// import _ "github.com/chaitin/MonkeyCode/backend/db/runtime" -var ( - Hooks [1]ent.Hook - Interceptors [1]ent.Interceptor - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - DescriptionValidator func(string) error - // ContentValidator is a validator for the "content" field. It is called by the builders before save. - ContentValidator func(string) error - // SourceTypeValidator is a validator for the "source_type" field. It is called by the builders before save. - SourceTypeValidator func(string) error - // SourceLabelValidator is a validator for the "source_label" field. It is called by the builders before save. - SourceLabelValidator func(string) error - // DefaultCreatedAt holds the default value on creation for the "created_at" field. - DefaultCreatedAt func() time.Time - // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. - DefaultUpdatedAt func() time.Time - // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. - UpdateDefaultUpdatedAt func() time.Time -) - -// OrderOption defines the ordering options for the Skill queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByDeletedAt orders the results by the deleted_at field. -func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() -} - -// ByUserID orders the results by the user_id field. -func ByUserID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUserID, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() -} - -// ByContent orders the results by the content field. -func ByContent(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldContent, opts...).ToFunc() -} - -// ByPackageObjectKey orders the results by the package_object_key field. -func ByPackageObjectKey(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPackageObjectKey, opts...).ToFunc() -} - -// ByPackageURL orders the results by the package_url field. -func ByPackageURL(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPackageURL, opts...).ToFunc() -} - -// BySourceType orders the results by the source_type field. -func BySourceType(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSourceType, opts...).ToFunc() -} - -// BySourceLabel orders the results by the source_label field. -func BySourceLabel(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSourceLabel, opts...).ToFunc() -} - -// BySkillMdPath orders the results by the skill_md_path field. -func BySkillMdPath(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSkillMdPath, opts...).ToFunc() -} - -// ByExtensionPackageID orders the results by the extension_package_id field. -func ByExtensionPackageID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldExtensionPackageID, opts...).ToFunc() -} - -// ByExtensionSkillID orders the results by the extension_skill_id field. -func ByExtensionSkillID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldExtensionSkillID, opts...).ToFunc() -} - -// ByExtensionVersion orders the results by the extension_version field. -func ByExtensionVersion(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldExtensionVersion, opts...).ToFunc() -} - -// ByCreatedAt orders the results by the created_at field. -func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() -} - -// ByUpdatedAt orders the results by the updated_at field. -func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() -} - -// ByUserField orders the results by user field. -func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) - } -} - -// ByTeamsCount orders the results by teams count. -func ByTeamsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newTeamsStep(), opts...) - } -} - -// ByTeams orders the results by teams terms. -func ByTeams(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newTeamsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByGroupsCount orders the results by groups count. -func ByGroupsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newGroupsStep(), opts...) - } -} - -// ByGroups orders the results by groups terms. -func ByGroups(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newGroupsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByTeamSkillsCount orders the results by team_skills count. -func ByTeamSkillsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newTeamSkillsStep(), opts...) - } -} - -// ByTeamSkills orders the results by team_skills terms. -func ByTeamSkills(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newTeamSkillsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByTeamGroupSkillsCount orders the results by team_group_skills count. -func ByTeamGroupSkillsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newTeamGroupSkillsStep(), opts...) - } -} - -// ByTeamGroupSkills orders the results by team_group_skills terms. -func ByTeamGroupSkills(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newTeamGroupSkillsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newUserStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), - ) -} -func newTeamsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(TeamsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, TeamsTable, TeamsPrimaryKey...), - ) -} -func newGroupsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(GroupsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, GroupsTable, GroupsPrimaryKey...), - ) -} -func newTeamSkillsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(TeamSkillsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, TeamSkillsTable, TeamSkillsColumn), - ) -} -func newTeamGroupSkillsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(TeamGroupSkillsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, TeamGroupSkillsTable, TeamGroupSkillsColumn), - ) -} diff --git a/backend/db/skill/where.go b/backend/db/skill/where.go deleted file mode 100644 index a6f9b69f..00000000 --- a/backend/db/skill/where.go +++ /dev/null @@ -1,1197 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package skill - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/google/uuid" -) - -// ID filters vertices based on their ID field. -func ID(id uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldID, id)) -} - -// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. -func DeletedAt(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldDeletedAt, v)) -} - -// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. -func UserID(v uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldUserID, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldName, v)) -} - -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldDescription, v)) -} - -// Content applies equality check predicate on the "content" field. It's identical to ContentEQ. -func Content(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldContent, v)) -} - -// PackageObjectKey applies equality check predicate on the "package_object_key" field. It's identical to PackageObjectKeyEQ. -func PackageObjectKey(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldPackageObjectKey, v)) -} - -// PackageURL applies equality check predicate on the "package_url" field. It's identical to PackageURLEQ. -func PackageURL(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldPackageURL, v)) -} - -// SourceType applies equality check predicate on the "source_type" field. It's identical to SourceTypeEQ. -func SourceType(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldSourceType, v)) -} - -// SourceLabel applies equality check predicate on the "source_label" field. It's identical to SourceLabelEQ. -func SourceLabel(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldSourceLabel, v)) -} - -// SkillMdPath applies equality check predicate on the "skill_md_path" field. It's identical to SkillMdPathEQ. -func SkillMdPath(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldSkillMdPath, v)) -} - -// ExtensionPackageID applies equality check predicate on the "extension_package_id" field. It's identical to ExtensionPackageIDEQ. -func ExtensionPackageID(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldExtensionPackageID, v)) -} - -// ExtensionSkillID applies equality check predicate on the "extension_skill_id" field. It's identical to ExtensionSkillIDEQ. -func ExtensionSkillID(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldExtensionSkillID, v)) -} - -// ExtensionVersion applies equality check predicate on the "extension_version" field. It's identical to ExtensionVersionEQ. -func ExtensionVersion(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldExtensionVersion, v)) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldCreatedAt, v)) -} - -// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. -func UpdatedAt(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldUpdatedAt, v)) -} - -// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. -func DeletedAtEQ(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldDeletedAt, v)) -} - -// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. -func DeletedAtNEQ(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldDeletedAt, v)) -} - -// DeletedAtIn applies the In predicate on the "deleted_at" field. -func DeletedAtIn(vs ...time.Time) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldDeletedAt, vs...)) -} - -// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. -func DeletedAtNotIn(vs ...time.Time) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldDeletedAt, vs...)) -} - -// DeletedAtGT applies the GT predicate on the "deleted_at" field. -func DeletedAtGT(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldDeletedAt, v)) -} - -// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. -func DeletedAtGTE(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldDeletedAt, v)) -} - -// DeletedAtLT applies the LT predicate on the "deleted_at" field. -func DeletedAtLT(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldDeletedAt, v)) -} - -// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. -func DeletedAtLTE(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldDeletedAt, v)) -} - -// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. -func DeletedAtIsNil() predicate.Skill { - return predicate.Skill(sql.FieldIsNull(FieldDeletedAt)) -} - -// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. -func DeletedAtNotNil() predicate.Skill { - return predicate.Skill(sql.FieldNotNull(FieldDeletedAt)) -} - -// UserIDEQ applies the EQ predicate on the "user_id" field. -func UserIDEQ(v uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldUserID, v)) -} - -// UserIDNEQ applies the NEQ predicate on the "user_id" field. -func UserIDNEQ(v uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldUserID, v)) -} - -// UserIDIn applies the In predicate on the "user_id" field. -func UserIDIn(vs ...uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldUserID, vs...)) -} - -// UserIDNotIn applies the NotIn predicate on the "user_id" field. -func UserIDNotIn(vs ...uuid.UUID) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldUserID, vs...)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldName, v)) -} - -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldDescription, v)) -} - -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldDescription, v)) -} - -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldDescription, vs...)) -} - -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldDescription, vs...)) -} - -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldDescription, v)) -} - -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldDescription, v)) -} - -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldDescription, v)) -} - -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldDescription, v)) -} - -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldDescription, v)) -} - -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldDescription, v)) -} - -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldDescription, v)) -} - -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldDescription, v)) -} - -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldDescription, v)) -} - -// TagsIsNil applies the IsNil predicate on the "tags" field. -func TagsIsNil() predicate.Skill { - return predicate.Skill(sql.FieldIsNull(FieldTags)) -} - -// TagsNotNil applies the NotNil predicate on the "tags" field. -func TagsNotNil() predicate.Skill { - return predicate.Skill(sql.FieldNotNull(FieldTags)) -} - -// ContentEQ applies the EQ predicate on the "content" field. -func ContentEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldContent, v)) -} - -// ContentNEQ applies the NEQ predicate on the "content" field. -func ContentNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldContent, v)) -} - -// ContentIn applies the In predicate on the "content" field. -func ContentIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldContent, vs...)) -} - -// ContentNotIn applies the NotIn predicate on the "content" field. -func ContentNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldContent, vs...)) -} - -// ContentGT applies the GT predicate on the "content" field. -func ContentGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldContent, v)) -} - -// ContentGTE applies the GTE predicate on the "content" field. -func ContentGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldContent, v)) -} - -// ContentLT applies the LT predicate on the "content" field. -func ContentLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldContent, v)) -} - -// ContentLTE applies the LTE predicate on the "content" field. -func ContentLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldContent, v)) -} - -// ContentContains applies the Contains predicate on the "content" field. -func ContentContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldContent, v)) -} - -// ContentHasPrefix applies the HasPrefix predicate on the "content" field. -func ContentHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldContent, v)) -} - -// ContentHasSuffix applies the HasSuffix predicate on the "content" field. -func ContentHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldContent, v)) -} - -// ContentEqualFold applies the EqualFold predicate on the "content" field. -func ContentEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldContent, v)) -} - -// ContentContainsFold applies the ContainsFold predicate on the "content" field. -func ContentContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldContent, v)) -} - -// PackageObjectKeyEQ applies the EQ predicate on the "package_object_key" field. -func PackageObjectKeyEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldPackageObjectKey, v)) -} - -// PackageObjectKeyNEQ applies the NEQ predicate on the "package_object_key" field. -func PackageObjectKeyNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldPackageObjectKey, v)) -} - -// PackageObjectKeyIn applies the In predicate on the "package_object_key" field. -func PackageObjectKeyIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldPackageObjectKey, vs...)) -} - -// PackageObjectKeyNotIn applies the NotIn predicate on the "package_object_key" field. -func PackageObjectKeyNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldPackageObjectKey, vs...)) -} - -// PackageObjectKeyGT applies the GT predicate on the "package_object_key" field. -func PackageObjectKeyGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldPackageObjectKey, v)) -} - -// PackageObjectKeyGTE applies the GTE predicate on the "package_object_key" field. -func PackageObjectKeyGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldPackageObjectKey, v)) -} - -// PackageObjectKeyLT applies the LT predicate on the "package_object_key" field. -func PackageObjectKeyLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldPackageObjectKey, v)) -} - -// PackageObjectKeyLTE applies the LTE predicate on the "package_object_key" field. -func PackageObjectKeyLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldPackageObjectKey, v)) -} - -// PackageObjectKeyContains applies the Contains predicate on the "package_object_key" field. -func PackageObjectKeyContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldPackageObjectKey, v)) -} - -// PackageObjectKeyHasPrefix applies the HasPrefix predicate on the "package_object_key" field. -func PackageObjectKeyHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldPackageObjectKey, v)) -} - -// PackageObjectKeyHasSuffix applies the HasSuffix predicate on the "package_object_key" field. -func PackageObjectKeyHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldPackageObjectKey, v)) -} - -// PackageObjectKeyIsNil applies the IsNil predicate on the "package_object_key" field. -func PackageObjectKeyIsNil() predicate.Skill { - return predicate.Skill(sql.FieldIsNull(FieldPackageObjectKey)) -} - -// PackageObjectKeyNotNil applies the NotNil predicate on the "package_object_key" field. -func PackageObjectKeyNotNil() predicate.Skill { - return predicate.Skill(sql.FieldNotNull(FieldPackageObjectKey)) -} - -// PackageObjectKeyEqualFold applies the EqualFold predicate on the "package_object_key" field. -func PackageObjectKeyEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldPackageObjectKey, v)) -} - -// PackageObjectKeyContainsFold applies the ContainsFold predicate on the "package_object_key" field. -func PackageObjectKeyContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldPackageObjectKey, v)) -} - -// PackageURLEQ applies the EQ predicate on the "package_url" field. -func PackageURLEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldPackageURL, v)) -} - -// PackageURLNEQ applies the NEQ predicate on the "package_url" field. -func PackageURLNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldPackageURL, v)) -} - -// PackageURLIn applies the In predicate on the "package_url" field. -func PackageURLIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldPackageURL, vs...)) -} - -// PackageURLNotIn applies the NotIn predicate on the "package_url" field. -func PackageURLNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldPackageURL, vs...)) -} - -// PackageURLGT applies the GT predicate on the "package_url" field. -func PackageURLGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldPackageURL, v)) -} - -// PackageURLGTE applies the GTE predicate on the "package_url" field. -func PackageURLGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldPackageURL, v)) -} - -// PackageURLLT applies the LT predicate on the "package_url" field. -func PackageURLLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldPackageURL, v)) -} - -// PackageURLLTE applies the LTE predicate on the "package_url" field. -func PackageURLLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldPackageURL, v)) -} - -// PackageURLContains applies the Contains predicate on the "package_url" field. -func PackageURLContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldPackageURL, v)) -} - -// PackageURLHasPrefix applies the HasPrefix predicate on the "package_url" field. -func PackageURLHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldPackageURL, v)) -} - -// PackageURLHasSuffix applies the HasSuffix predicate on the "package_url" field. -func PackageURLHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldPackageURL, v)) -} - -// PackageURLIsNil applies the IsNil predicate on the "package_url" field. -func PackageURLIsNil() predicate.Skill { - return predicate.Skill(sql.FieldIsNull(FieldPackageURL)) -} - -// PackageURLNotNil applies the NotNil predicate on the "package_url" field. -func PackageURLNotNil() predicate.Skill { - return predicate.Skill(sql.FieldNotNull(FieldPackageURL)) -} - -// PackageURLEqualFold applies the EqualFold predicate on the "package_url" field. -func PackageURLEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldPackageURL, v)) -} - -// PackageURLContainsFold applies the ContainsFold predicate on the "package_url" field. -func PackageURLContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldPackageURL, v)) -} - -// SourceTypeEQ applies the EQ predicate on the "source_type" field. -func SourceTypeEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldSourceType, v)) -} - -// SourceTypeNEQ applies the NEQ predicate on the "source_type" field. -func SourceTypeNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldSourceType, v)) -} - -// SourceTypeIn applies the In predicate on the "source_type" field. -func SourceTypeIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldSourceType, vs...)) -} - -// SourceTypeNotIn applies the NotIn predicate on the "source_type" field. -func SourceTypeNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldSourceType, vs...)) -} - -// SourceTypeGT applies the GT predicate on the "source_type" field. -func SourceTypeGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldSourceType, v)) -} - -// SourceTypeGTE applies the GTE predicate on the "source_type" field. -func SourceTypeGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldSourceType, v)) -} - -// SourceTypeLT applies the LT predicate on the "source_type" field. -func SourceTypeLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldSourceType, v)) -} - -// SourceTypeLTE applies the LTE predicate on the "source_type" field. -func SourceTypeLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldSourceType, v)) -} - -// SourceTypeContains applies the Contains predicate on the "source_type" field. -func SourceTypeContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldSourceType, v)) -} - -// SourceTypeHasPrefix applies the HasPrefix predicate on the "source_type" field. -func SourceTypeHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldSourceType, v)) -} - -// SourceTypeHasSuffix applies the HasSuffix predicate on the "source_type" field. -func SourceTypeHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldSourceType, v)) -} - -// SourceTypeEqualFold applies the EqualFold predicate on the "source_type" field. -func SourceTypeEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldSourceType, v)) -} - -// SourceTypeContainsFold applies the ContainsFold predicate on the "source_type" field. -func SourceTypeContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldSourceType, v)) -} - -// SourceLabelEQ applies the EQ predicate on the "source_label" field. -func SourceLabelEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldSourceLabel, v)) -} - -// SourceLabelNEQ applies the NEQ predicate on the "source_label" field. -func SourceLabelNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldSourceLabel, v)) -} - -// SourceLabelIn applies the In predicate on the "source_label" field. -func SourceLabelIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldSourceLabel, vs...)) -} - -// SourceLabelNotIn applies the NotIn predicate on the "source_label" field. -func SourceLabelNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldSourceLabel, vs...)) -} - -// SourceLabelGT applies the GT predicate on the "source_label" field. -func SourceLabelGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldSourceLabel, v)) -} - -// SourceLabelGTE applies the GTE predicate on the "source_label" field. -func SourceLabelGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldSourceLabel, v)) -} - -// SourceLabelLT applies the LT predicate on the "source_label" field. -func SourceLabelLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldSourceLabel, v)) -} - -// SourceLabelLTE applies the LTE predicate on the "source_label" field. -func SourceLabelLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldSourceLabel, v)) -} - -// SourceLabelContains applies the Contains predicate on the "source_label" field. -func SourceLabelContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldSourceLabel, v)) -} - -// SourceLabelHasPrefix applies the HasPrefix predicate on the "source_label" field. -func SourceLabelHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldSourceLabel, v)) -} - -// SourceLabelHasSuffix applies the HasSuffix predicate on the "source_label" field. -func SourceLabelHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldSourceLabel, v)) -} - -// SourceLabelEqualFold applies the EqualFold predicate on the "source_label" field. -func SourceLabelEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldSourceLabel, v)) -} - -// SourceLabelContainsFold applies the ContainsFold predicate on the "source_label" field. -func SourceLabelContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldSourceLabel, v)) -} - -// SkillMdPathEQ applies the EQ predicate on the "skill_md_path" field. -func SkillMdPathEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldSkillMdPath, v)) -} - -// SkillMdPathNEQ applies the NEQ predicate on the "skill_md_path" field. -func SkillMdPathNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldSkillMdPath, v)) -} - -// SkillMdPathIn applies the In predicate on the "skill_md_path" field. -func SkillMdPathIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldSkillMdPath, vs...)) -} - -// SkillMdPathNotIn applies the NotIn predicate on the "skill_md_path" field. -func SkillMdPathNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldSkillMdPath, vs...)) -} - -// SkillMdPathGT applies the GT predicate on the "skill_md_path" field. -func SkillMdPathGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldSkillMdPath, v)) -} - -// SkillMdPathGTE applies the GTE predicate on the "skill_md_path" field. -func SkillMdPathGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldSkillMdPath, v)) -} - -// SkillMdPathLT applies the LT predicate on the "skill_md_path" field. -func SkillMdPathLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldSkillMdPath, v)) -} - -// SkillMdPathLTE applies the LTE predicate on the "skill_md_path" field. -func SkillMdPathLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldSkillMdPath, v)) -} - -// SkillMdPathContains applies the Contains predicate on the "skill_md_path" field. -func SkillMdPathContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldSkillMdPath, v)) -} - -// SkillMdPathHasPrefix applies the HasPrefix predicate on the "skill_md_path" field. -func SkillMdPathHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldSkillMdPath, v)) -} - -// SkillMdPathHasSuffix applies the HasSuffix predicate on the "skill_md_path" field. -func SkillMdPathHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldSkillMdPath, v)) -} - -// SkillMdPathIsNil applies the IsNil predicate on the "skill_md_path" field. -func SkillMdPathIsNil() predicate.Skill { - return predicate.Skill(sql.FieldIsNull(FieldSkillMdPath)) -} - -// SkillMdPathNotNil applies the NotNil predicate on the "skill_md_path" field. -func SkillMdPathNotNil() predicate.Skill { - return predicate.Skill(sql.FieldNotNull(FieldSkillMdPath)) -} - -// SkillMdPathEqualFold applies the EqualFold predicate on the "skill_md_path" field. -func SkillMdPathEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldSkillMdPath, v)) -} - -// SkillMdPathContainsFold applies the ContainsFold predicate on the "skill_md_path" field. -func SkillMdPathContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldSkillMdPath, v)) -} - -// ExtensionPackageIDEQ applies the EQ predicate on the "extension_package_id" field. -func ExtensionPackageIDEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldExtensionPackageID, v)) -} - -// ExtensionPackageIDNEQ applies the NEQ predicate on the "extension_package_id" field. -func ExtensionPackageIDNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldExtensionPackageID, v)) -} - -// ExtensionPackageIDIn applies the In predicate on the "extension_package_id" field. -func ExtensionPackageIDIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldExtensionPackageID, vs...)) -} - -// ExtensionPackageIDNotIn applies the NotIn predicate on the "extension_package_id" field. -func ExtensionPackageIDNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldExtensionPackageID, vs...)) -} - -// ExtensionPackageIDGT applies the GT predicate on the "extension_package_id" field. -func ExtensionPackageIDGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldExtensionPackageID, v)) -} - -// ExtensionPackageIDGTE applies the GTE predicate on the "extension_package_id" field. -func ExtensionPackageIDGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldExtensionPackageID, v)) -} - -// ExtensionPackageIDLT applies the LT predicate on the "extension_package_id" field. -func ExtensionPackageIDLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldExtensionPackageID, v)) -} - -// ExtensionPackageIDLTE applies the LTE predicate on the "extension_package_id" field. -func ExtensionPackageIDLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldExtensionPackageID, v)) -} - -// ExtensionPackageIDContains applies the Contains predicate on the "extension_package_id" field. -func ExtensionPackageIDContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldExtensionPackageID, v)) -} - -// ExtensionPackageIDHasPrefix applies the HasPrefix predicate on the "extension_package_id" field. -func ExtensionPackageIDHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldExtensionPackageID, v)) -} - -// ExtensionPackageIDHasSuffix applies the HasSuffix predicate on the "extension_package_id" field. -func ExtensionPackageIDHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldExtensionPackageID, v)) -} - -// ExtensionPackageIDIsNil applies the IsNil predicate on the "extension_package_id" field. -func ExtensionPackageIDIsNil() predicate.Skill { - return predicate.Skill(sql.FieldIsNull(FieldExtensionPackageID)) -} - -// ExtensionPackageIDNotNil applies the NotNil predicate on the "extension_package_id" field. -func ExtensionPackageIDNotNil() predicate.Skill { - return predicate.Skill(sql.FieldNotNull(FieldExtensionPackageID)) -} - -// ExtensionPackageIDEqualFold applies the EqualFold predicate on the "extension_package_id" field. -func ExtensionPackageIDEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldExtensionPackageID, v)) -} - -// ExtensionPackageIDContainsFold applies the ContainsFold predicate on the "extension_package_id" field. -func ExtensionPackageIDContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldExtensionPackageID, v)) -} - -// ExtensionSkillIDEQ applies the EQ predicate on the "extension_skill_id" field. -func ExtensionSkillIDEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldExtensionSkillID, v)) -} - -// ExtensionSkillIDNEQ applies the NEQ predicate on the "extension_skill_id" field. -func ExtensionSkillIDNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldExtensionSkillID, v)) -} - -// ExtensionSkillIDIn applies the In predicate on the "extension_skill_id" field. -func ExtensionSkillIDIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldExtensionSkillID, vs...)) -} - -// ExtensionSkillIDNotIn applies the NotIn predicate on the "extension_skill_id" field. -func ExtensionSkillIDNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldExtensionSkillID, vs...)) -} - -// ExtensionSkillIDGT applies the GT predicate on the "extension_skill_id" field. -func ExtensionSkillIDGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldExtensionSkillID, v)) -} - -// ExtensionSkillIDGTE applies the GTE predicate on the "extension_skill_id" field. -func ExtensionSkillIDGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldExtensionSkillID, v)) -} - -// ExtensionSkillIDLT applies the LT predicate on the "extension_skill_id" field. -func ExtensionSkillIDLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldExtensionSkillID, v)) -} - -// ExtensionSkillIDLTE applies the LTE predicate on the "extension_skill_id" field. -func ExtensionSkillIDLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldExtensionSkillID, v)) -} - -// ExtensionSkillIDContains applies the Contains predicate on the "extension_skill_id" field. -func ExtensionSkillIDContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldExtensionSkillID, v)) -} - -// ExtensionSkillIDHasPrefix applies the HasPrefix predicate on the "extension_skill_id" field. -func ExtensionSkillIDHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldExtensionSkillID, v)) -} - -// ExtensionSkillIDHasSuffix applies the HasSuffix predicate on the "extension_skill_id" field. -func ExtensionSkillIDHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldExtensionSkillID, v)) -} - -// ExtensionSkillIDIsNil applies the IsNil predicate on the "extension_skill_id" field. -func ExtensionSkillIDIsNil() predicate.Skill { - return predicate.Skill(sql.FieldIsNull(FieldExtensionSkillID)) -} - -// ExtensionSkillIDNotNil applies the NotNil predicate on the "extension_skill_id" field. -func ExtensionSkillIDNotNil() predicate.Skill { - return predicate.Skill(sql.FieldNotNull(FieldExtensionSkillID)) -} - -// ExtensionSkillIDEqualFold applies the EqualFold predicate on the "extension_skill_id" field. -func ExtensionSkillIDEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldExtensionSkillID, v)) -} - -// ExtensionSkillIDContainsFold applies the ContainsFold predicate on the "extension_skill_id" field. -func ExtensionSkillIDContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldExtensionSkillID, v)) -} - -// ExtensionVersionEQ applies the EQ predicate on the "extension_version" field. -func ExtensionVersionEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldExtensionVersion, v)) -} - -// ExtensionVersionNEQ applies the NEQ predicate on the "extension_version" field. -func ExtensionVersionNEQ(v string) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldExtensionVersion, v)) -} - -// ExtensionVersionIn applies the In predicate on the "extension_version" field. -func ExtensionVersionIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldExtensionVersion, vs...)) -} - -// ExtensionVersionNotIn applies the NotIn predicate on the "extension_version" field. -func ExtensionVersionNotIn(vs ...string) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldExtensionVersion, vs...)) -} - -// ExtensionVersionGT applies the GT predicate on the "extension_version" field. -func ExtensionVersionGT(v string) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldExtensionVersion, v)) -} - -// ExtensionVersionGTE applies the GTE predicate on the "extension_version" field. -func ExtensionVersionGTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldExtensionVersion, v)) -} - -// ExtensionVersionLT applies the LT predicate on the "extension_version" field. -func ExtensionVersionLT(v string) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldExtensionVersion, v)) -} - -// ExtensionVersionLTE applies the LTE predicate on the "extension_version" field. -func ExtensionVersionLTE(v string) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldExtensionVersion, v)) -} - -// ExtensionVersionContains applies the Contains predicate on the "extension_version" field. -func ExtensionVersionContains(v string) predicate.Skill { - return predicate.Skill(sql.FieldContains(FieldExtensionVersion, v)) -} - -// ExtensionVersionHasPrefix applies the HasPrefix predicate on the "extension_version" field. -func ExtensionVersionHasPrefix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasPrefix(FieldExtensionVersion, v)) -} - -// ExtensionVersionHasSuffix applies the HasSuffix predicate on the "extension_version" field. -func ExtensionVersionHasSuffix(v string) predicate.Skill { - return predicate.Skill(sql.FieldHasSuffix(FieldExtensionVersion, v)) -} - -// ExtensionVersionIsNil applies the IsNil predicate on the "extension_version" field. -func ExtensionVersionIsNil() predicate.Skill { - return predicate.Skill(sql.FieldIsNull(FieldExtensionVersion)) -} - -// ExtensionVersionNotNil applies the NotNil predicate on the "extension_version" field. -func ExtensionVersionNotNil() predicate.Skill { - return predicate.Skill(sql.FieldNotNull(FieldExtensionVersion)) -} - -// ExtensionVersionEqualFold applies the EqualFold predicate on the "extension_version" field. -func ExtensionVersionEqualFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldEqualFold(FieldExtensionVersion, v)) -} - -// ExtensionVersionContainsFold applies the ContainsFold predicate on the "extension_version" field. -func ExtensionVersionContainsFold(v string) predicate.Skill { - return predicate.Skill(sql.FieldContainsFold(FieldExtensionVersion, v)) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldCreatedAt, v)) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldCreatedAt, v)) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldCreatedAt, vs...)) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldCreatedAt, vs...)) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldCreatedAt, v)) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldCreatedAt, v)) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldCreatedAt, v)) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldCreatedAt, v)) -} - -// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. -func UpdatedAtEQ(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldEQ(FieldUpdatedAt, v)) -} - -// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. -func UpdatedAtNEQ(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldNEQ(FieldUpdatedAt, v)) -} - -// UpdatedAtIn applies the In predicate on the "updated_at" field. -func UpdatedAtIn(vs ...time.Time) predicate.Skill { - return predicate.Skill(sql.FieldIn(FieldUpdatedAt, vs...)) -} - -// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. -func UpdatedAtNotIn(vs ...time.Time) predicate.Skill { - return predicate.Skill(sql.FieldNotIn(FieldUpdatedAt, vs...)) -} - -// UpdatedAtGT applies the GT predicate on the "updated_at" field. -func UpdatedAtGT(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldGT(FieldUpdatedAt, v)) -} - -// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. -func UpdatedAtGTE(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldGTE(FieldUpdatedAt, v)) -} - -// UpdatedAtLT applies the LT predicate on the "updated_at" field. -func UpdatedAtLT(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldLT(FieldUpdatedAt, v)) -} - -// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. -func UpdatedAtLTE(v time.Time) predicate.Skill { - return predicate.Skill(sql.FieldLTE(FieldUpdatedAt, v)) -} - -// HasUser applies the HasEdge predicate on the "user" edge. -func HasUser() predicate.Skill { - return predicate.Skill(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). -func HasUserWith(preds ...predicate.User) predicate.Skill { - return predicate.Skill(func(s *sql.Selector) { - step := newUserStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasTeams applies the HasEdge predicate on the "teams" edge. -func HasTeams() predicate.Skill { - return predicate.Skill(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, TeamsTable, TeamsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasTeamsWith applies the HasEdge predicate on the "teams" edge with a given conditions (other predicates). -func HasTeamsWith(preds ...predicate.Team) predicate.Skill { - return predicate.Skill(func(s *sql.Selector) { - step := newTeamsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasGroups applies the HasEdge predicate on the "groups" edge. -func HasGroups() predicate.Skill { - return predicate.Skill(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, GroupsTable, GroupsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasGroupsWith applies the HasEdge predicate on the "groups" edge with a given conditions (other predicates). -func HasGroupsWith(preds ...predicate.TeamGroup) predicate.Skill { - return predicate.Skill(func(s *sql.Selector) { - step := newGroupsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasTeamSkills applies the HasEdge predicate on the "team_skills" edge. -func HasTeamSkills() predicate.Skill { - return predicate.Skill(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, TeamSkillsTable, TeamSkillsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasTeamSkillsWith applies the HasEdge predicate on the "team_skills" edge with a given conditions (other predicates). -func HasTeamSkillsWith(preds ...predicate.TeamSkill) predicate.Skill { - return predicate.Skill(func(s *sql.Selector) { - step := newTeamSkillsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasTeamGroupSkills applies the HasEdge predicate on the "team_group_skills" edge. -func HasTeamGroupSkills() predicate.Skill { - return predicate.Skill(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, TeamGroupSkillsTable, TeamGroupSkillsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasTeamGroupSkillsWith applies the HasEdge predicate on the "team_group_skills" edge with a given conditions (other predicates). -func HasTeamGroupSkillsWith(preds ...predicate.TeamGroupSkill) predicate.Skill { - return predicate.Skill(func(s *sql.Selector) { - step := newTeamGroupSkillsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Skill) predicate.Skill { - return predicate.Skill(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Skill) predicate.Skill { - return predicate.Skill(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Skill) predicate.Skill { - return predicate.Skill(sql.NotPredicates(p)) -} diff --git a/backend/db/skill_create.go b/backend/db/skill_create.go deleted file mode 100644 index c44adca6..00000000 --- a/backend/db/skill_create.go +++ /dev/null @@ -1,1700 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package db - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/chaitin/MonkeyCode/backend/db/skill" - "github.com/chaitin/MonkeyCode/backend/db/team" - "github.com/chaitin/MonkeyCode/backend/db/teamgroup" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" - "github.com/chaitin/MonkeyCode/backend/db/user" - "github.com/google/uuid" -) - -// SkillCreate is the builder for creating a Skill entity. -type SkillCreate struct { - config - mutation *SkillMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetDeletedAt sets the "deleted_at" field. -func (_c *SkillCreate) SetDeletedAt(v time.Time) *SkillCreate { - _c.mutation.SetDeletedAt(v) - return _c -} - -// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. -func (_c *SkillCreate) SetNillableDeletedAt(v *time.Time) *SkillCreate { - if v != nil { - _c.SetDeletedAt(*v) - } - return _c -} - -// SetUserID sets the "user_id" field. -func (_c *SkillCreate) SetUserID(v uuid.UUID) *SkillCreate { - _c.mutation.SetUserID(v) - return _c -} - -// SetName sets the "name" field. -func (_c *SkillCreate) SetName(v string) *SkillCreate { - _c.mutation.SetName(v) - return _c -} - -// SetDescription sets the "description" field. -func (_c *SkillCreate) SetDescription(v string) *SkillCreate { - _c.mutation.SetDescription(v) - return _c -} - -// SetTags sets the "tags" field. -func (_c *SkillCreate) SetTags(v []string) *SkillCreate { - _c.mutation.SetTags(v) - return _c -} - -// SetContent sets the "content" field. -func (_c *SkillCreate) SetContent(v string) *SkillCreate { - _c.mutation.SetContent(v) - return _c -} - -// SetPackageObjectKey sets the "package_object_key" field. -func (_c *SkillCreate) SetPackageObjectKey(v string) *SkillCreate { - _c.mutation.SetPackageObjectKey(v) - return _c -} - -// SetNillablePackageObjectKey sets the "package_object_key" field if the given value is not nil. -func (_c *SkillCreate) SetNillablePackageObjectKey(v *string) *SkillCreate { - if v != nil { - _c.SetPackageObjectKey(*v) - } - return _c -} - -// SetPackageURL sets the "package_url" field. -func (_c *SkillCreate) SetPackageURL(v string) *SkillCreate { - _c.mutation.SetPackageURL(v) - return _c -} - -// SetNillablePackageURL sets the "package_url" field if the given value is not nil. -func (_c *SkillCreate) SetNillablePackageURL(v *string) *SkillCreate { - if v != nil { - _c.SetPackageURL(*v) - } - return _c -} - -// SetSourceType sets the "source_type" field. -func (_c *SkillCreate) SetSourceType(v string) *SkillCreate { - _c.mutation.SetSourceType(v) - return _c -} - -// SetSourceLabel sets the "source_label" field. -func (_c *SkillCreate) SetSourceLabel(v string) *SkillCreate { - _c.mutation.SetSourceLabel(v) - return _c -} - -// SetSkillMdPath sets the "skill_md_path" field. -func (_c *SkillCreate) SetSkillMdPath(v string) *SkillCreate { - _c.mutation.SetSkillMdPath(v) - return _c -} - -// SetNillableSkillMdPath sets the "skill_md_path" field if the given value is not nil. -func (_c *SkillCreate) SetNillableSkillMdPath(v *string) *SkillCreate { - if v != nil { - _c.SetSkillMdPath(*v) - } - return _c -} - -// SetExtensionPackageID sets the "extension_package_id" field. -func (_c *SkillCreate) SetExtensionPackageID(v string) *SkillCreate { - _c.mutation.SetExtensionPackageID(v) - return _c -} - -// SetNillableExtensionPackageID sets the "extension_package_id" field if the given value is not nil. -func (_c *SkillCreate) SetNillableExtensionPackageID(v *string) *SkillCreate { - if v != nil { - _c.SetExtensionPackageID(*v) - } - return _c -} - -// SetExtensionSkillID sets the "extension_skill_id" field. -func (_c *SkillCreate) SetExtensionSkillID(v string) *SkillCreate { - _c.mutation.SetExtensionSkillID(v) - return _c -} - -// SetNillableExtensionSkillID sets the "extension_skill_id" field if the given value is not nil. -func (_c *SkillCreate) SetNillableExtensionSkillID(v *string) *SkillCreate { - if v != nil { - _c.SetExtensionSkillID(*v) - } - return _c -} - -// SetExtensionVersion sets the "extension_version" field. -func (_c *SkillCreate) SetExtensionVersion(v string) *SkillCreate { - _c.mutation.SetExtensionVersion(v) - return _c -} - -// SetNillableExtensionVersion sets the "extension_version" field if the given value is not nil. -func (_c *SkillCreate) SetNillableExtensionVersion(v *string) *SkillCreate { - if v != nil { - _c.SetExtensionVersion(*v) - } - return _c -} - -// SetCreatedAt sets the "created_at" field. -func (_c *SkillCreate) SetCreatedAt(v time.Time) *SkillCreate { - _c.mutation.SetCreatedAt(v) - return _c -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (_c *SkillCreate) SetNillableCreatedAt(v *time.Time) *SkillCreate { - if v != nil { - _c.SetCreatedAt(*v) - } - return _c -} - -// SetUpdatedAt sets the "updated_at" field. -func (_c *SkillCreate) SetUpdatedAt(v time.Time) *SkillCreate { - _c.mutation.SetUpdatedAt(v) - return _c -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (_c *SkillCreate) SetNillableUpdatedAt(v *time.Time) *SkillCreate { - if v != nil { - _c.SetUpdatedAt(*v) - } - return _c -} - -// SetID sets the "id" field. -func (_c *SkillCreate) SetID(v uuid.UUID) *SkillCreate { - _c.mutation.SetID(v) - return _c -} - -// SetUser sets the "user" edge to the User entity. -func (_c *SkillCreate) SetUser(v *User) *SkillCreate { - return _c.SetUserID(v.ID) -} - -// AddTeamIDs adds the "teams" edge to the Team entity by IDs. -func (_c *SkillCreate) AddTeamIDs(ids ...uuid.UUID) *SkillCreate { - _c.mutation.AddTeamIDs(ids...) - return _c -} - -// AddTeams adds the "teams" edges to the Team entity. -func (_c *SkillCreate) AddTeams(v ...*Team) *SkillCreate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddTeamIDs(ids...) -} - -// AddGroupIDs adds the "groups" edge to the TeamGroup entity by IDs. -func (_c *SkillCreate) AddGroupIDs(ids ...uuid.UUID) *SkillCreate { - _c.mutation.AddGroupIDs(ids...) - return _c -} - -// AddGroups adds the "groups" edges to the TeamGroup entity. -func (_c *SkillCreate) AddGroups(v ...*TeamGroup) *SkillCreate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddGroupIDs(ids...) -} - -// AddTeamSkillIDs adds the "team_skills" edge to the TeamSkill entity by IDs. -func (_c *SkillCreate) AddTeamSkillIDs(ids ...uuid.UUID) *SkillCreate { - _c.mutation.AddTeamSkillIDs(ids...) - return _c -} - -// AddTeamSkills adds the "team_skills" edges to the TeamSkill entity. -func (_c *SkillCreate) AddTeamSkills(v ...*TeamSkill) *SkillCreate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddTeamSkillIDs(ids...) -} - -// AddTeamGroupSkillIDs adds the "team_group_skills" edge to the TeamGroupSkill entity by IDs. -func (_c *SkillCreate) AddTeamGroupSkillIDs(ids ...uuid.UUID) *SkillCreate { - _c.mutation.AddTeamGroupSkillIDs(ids...) - return _c -} - -// AddTeamGroupSkills adds the "team_group_skills" edges to the TeamGroupSkill entity. -func (_c *SkillCreate) AddTeamGroupSkills(v ...*TeamGroupSkill) *SkillCreate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddTeamGroupSkillIDs(ids...) -} - -// Mutation returns the SkillMutation object of the builder. -func (_c *SkillCreate) Mutation() *SkillMutation { - return _c.mutation -} - -// Save creates the Skill in the database. -func (_c *SkillCreate) Save(ctx context.Context) (*Skill, error) { - if err := _c.defaults(); err != nil { - return nil, err - } - return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (_c *SkillCreate) SaveX(ctx context.Context) *Skill { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *SkillCreate) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *SkillCreate) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_c *SkillCreate) defaults() error { - if _, ok := _c.mutation.CreatedAt(); !ok { - if skill.DefaultCreatedAt == nil { - return fmt.Errorf("db: uninitialized skill.DefaultCreatedAt (forgotten import db/runtime?)") - } - v := skill.DefaultCreatedAt() - _c.mutation.SetCreatedAt(v) - } - if _, ok := _c.mutation.UpdatedAt(); !ok { - if skill.DefaultUpdatedAt == nil { - return fmt.Errorf("db: uninitialized skill.DefaultUpdatedAt (forgotten import db/runtime?)") - } - v := skill.DefaultUpdatedAt() - _c.mutation.SetUpdatedAt(v) - } - return nil -} - -// check runs all checks and user-defined validators on the builder. -func (_c *SkillCreate) check() error { - if _, ok := _c.mutation.UserID(); !ok { - return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "Skill.user_id"`)} - } - if _, ok := _c.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`db: missing required field "Skill.name"`)} - } - if v, ok := _c.mutation.Name(); ok { - if err := skill.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "Skill.name": %w`, err)} - } - } - if _, ok := _c.mutation.Description(); !ok { - return &ValidationError{Name: "description", err: errors.New(`db: missing required field "Skill.description"`)} - } - if v, ok := _c.mutation.Description(); ok { - if err := skill.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`db: validator failed for field "Skill.description": %w`, err)} - } - } - if _, ok := _c.mutation.Content(); !ok { - return &ValidationError{Name: "content", err: errors.New(`db: missing required field "Skill.content"`)} - } - if v, ok := _c.mutation.Content(); ok { - if err := skill.ContentValidator(v); err != nil { - return &ValidationError{Name: "content", err: fmt.Errorf(`db: validator failed for field "Skill.content": %w`, err)} - } - } - if _, ok := _c.mutation.SourceType(); !ok { - return &ValidationError{Name: "source_type", err: errors.New(`db: missing required field "Skill.source_type"`)} - } - if v, ok := _c.mutation.SourceType(); ok { - if err := skill.SourceTypeValidator(v); err != nil { - return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "Skill.source_type": %w`, err)} - } - } - if _, ok := _c.mutation.SourceLabel(); !ok { - return &ValidationError{Name: "source_label", err: errors.New(`db: missing required field "Skill.source_label"`)} - } - if v, ok := _c.mutation.SourceLabel(); ok { - if err := skill.SourceLabelValidator(v); err != nil { - return &ValidationError{Name: "source_label", err: fmt.Errorf(`db: validator failed for field "Skill.source_label": %w`, err)} - } - } - if _, ok := _c.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "Skill.created_at"`)} - } - if _, ok := _c.mutation.UpdatedAt(); !ok { - return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "Skill.updated_at"`)} - } - if len(_c.mutation.UserIDs()) == 0 { - return &ValidationError{Name: "user", err: errors.New(`db: missing required edge "Skill.user"`)} - } - return nil -} - -func (_c *SkillCreate) sqlSave(ctx context.Context) (*Skill, error) { - if err := _c.check(); err != nil { - return nil, err - } - _node, _spec := _c.createSpec() - if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != nil { - if id, ok := _spec.ID.Value.(*uuid.UUID); ok { - _node.ID = *id - } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { - return nil, err - } - } - _c.mutation.id = &_node.ID - _c.mutation.done = true - return _node, nil -} - -func (_c *SkillCreate) createSpec() (*Skill, *sqlgraph.CreateSpec) { - var ( - _node = &Skill{config: _c.config} - _spec = sqlgraph.NewCreateSpec(skill.Table, sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID)) - ) - _spec.OnConflict = _c.conflict - if id, ok := _c.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = &id - } - if value, ok := _c.mutation.DeletedAt(); ok { - _spec.SetField(skill.FieldDeletedAt, field.TypeTime, value) - _node.DeletedAt = value - } - if value, ok := _c.mutation.Name(); ok { - _spec.SetField(skill.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := _c.mutation.Description(); ok { - _spec.SetField(skill.FieldDescription, field.TypeString, value) - _node.Description = value - } - if value, ok := _c.mutation.Tags(); ok { - _spec.SetField(skill.FieldTags, field.TypeJSON, value) - _node.Tags = value - } - if value, ok := _c.mutation.Content(); ok { - _spec.SetField(skill.FieldContent, field.TypeString, value) - _node.Content = value - } - if value, ok := _c.mutation.PackageObjectKey(); ok { - _spec.SetField(skill.FieldPackageObjectKey, field.TypeString, value) - _node.PackageObjectKey = value - } - if value, ok := _c.mutation.PackageURL(); ok { - _spec.SetField(skill.FieldPackageURL, field.TypeString, value) - _node.PackageURL = value - } - if value, ok := _c.mutation.SourceType(); ok { - _spec.SetField(skill.FieldSourceType, field.TypeString, value) - _node.SourceType = value - } - if value, ok := _c.mutation.SourceLabel(); ok { - _spec.SetField(skill.FieldSourceLabel, field.TypeString, value) - _node.SourceLabel = value - } - if value, ok := _c.mutation.SkillMdPath(); ok { - _spec.SetField(skill.FieldSkillMdPath, field.TypeString, value) - _node.SkillMdPath = value - } - if value, ok := _c.mutation.ExtensionPackageID(); ok { - _spec.SetField(skill.FieldExtensionPackageID, field.TypeString, value) - _node.ExtensionPackageID = value - } - if value, ok := _c.mutation.ExtensionSkillID(); ok { - _spec.SetField(skill.FieldExtensionSkillID, field.TypeString, value) - _node.ExtensionSkillID = value - } - if value, ok := _c.mutation.ExtensionVersion(); ok { - _spec.SetField(skill.FieldExtensionVersion, field.TypeString, value) - _node.ExtensionVersion = value - } - if value, ok := _c.mutation.CreatedAt(); ok { - _spec.SetField(skill.FieldCreatedAt, field.TypeTime, value) - _node.CreatedAt = value - } - if value, ok := _c.mutation.UpdatedAt(); ok { - _spec.SetField(skill.FieldUpdatedAt, field.TypeTime, value) - _node.UpdatedAt = value - } - if nodes := _c.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: skill.UserTable, - Columns: []string{skill.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.UserID = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.TeamsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.TeamsTable, - Columns: skill.TeamsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamSkillCreate{config: _c.config, mutation: newTeamSkillMutation(_c.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.GroupsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.GroupsTable, - Columns: skill.GroupsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamGroupSkillCreate{config: _c.config, mutation: newTeamGroupSkillMutation(_c.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.TeamSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamSkillsTable, - Columns: []string{skill.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.TeamGroupSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamGroupSkillsTable, - Columns: []string{skill.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.Skill.Create(). -// SetDeletedAt(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.SkillUpsert) { -// SetDeletedAt(v+v). -// }). -// Exec(ctx) -func (_c *SkillCreate) OnConflict(opts ...sql.ConflictOption) *SkillUpsertOne { - _c.conflict = opts - return &SkillUpsertOne{ - create: _c, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.Skill.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (_c *SkillCreate) OnConflictColumns(columns ...string) *SkillUpsertOne { - _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) - return &SkillUpsertOne{ - create: _c, - } -} - -type ( - // SkillUpsertOne is the builder for "upsert"-ing - // one Skill node. - SkillUpsertOne struct { - create *SkillCreate - } - - // SkillUpsert is the "OnConflict" setter. - SkillUpsert struct { - *sql.UpdateSet - } -) - -// SetDeletedAt sets the "deleted_at" field. -func (u *SkillUpsert) SetDeletedAt(v time.Time) *SkillUpsert { - u.Set(skill.FieldDeletedAt, v) - return u -} - -// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. -func (u *SkillUpsert) UpdateDeletedAt() *SkillUpsert { - u.SetExcluded(skill.FieldDeletedAt) - return u -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (u *SkillUpsert) ClearDeletedAt() *SkillUpsert { - u.SetNull(skill.FieldDeletedAt) - return u -} - -// SetUserID sets the "user_id" field. -func (u *SkillUpsert) SetUserID(v uuid.UUID) *SkillUpsert { - u.Set(skill.FieldUserID, v) - return u -} - -// UpdateUserID sets the "user_id" field to the value that was provided on create. -func (u *SkillUpsert) UpdateUserID() *SkillUpsert { - u.SetExcluded(skill.FieldUserID) - return u -} - -// SetName sets the "name" field. -func (u *SkillUpsert) SetName(v string) *SkillUpsert { - u.Set(skill.FieldName, v) - return u -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *SkillUpsert) UpdateName() *SkillUpsert { - u.SetExcluded(skill.FieldName) - return u -} - -// SetDescription sets the "description" field. -func (u *SkillUpsert) SetDescription(v string) *SkillUpsert { - u.Set(skill.FieldDescription, v) - return u -} - -// UpdateDescription sets the "description" field to the value that was provided on create. -func (u *SkillUpsert) UpdateDescription() *SkillUpsert { - u.SetExcluded(skill.FieldDescription) - return u -} - -// SetTags sets the "tags" field. -func (u *SkillUpsert) SetTags(v []string) *SkillUpsert { - u.Set(skill.FieldTags, v) - return u -} - -// UpdateTags sets the "tags" field to the value that was provided on create. -func (u *SkillUpsert) UpdateTags() *SkillUpsert { - u.SetExcluded(skill.FieldTags) - return u -} - -// ClearTags clears the value of the "tags" field. -func (u *SkillUpsert) ClearTags() *SkillUpsert { - u.SetNull(skill.FieldTags) - return u -} - -// SetContent sets the "content" field. -func (u *SkillUpsert) SetContent(v string) *SkillUpsert { - u.Set(skill.FieldContent, v) - return u -} - -// UpdateContent sets the "content" field to the value that was provided on create. -func (u *SkillUpsert) UpdateContent() *SkillUpsert { - u.SetExcluded(skill.FieldContent) - return u -} - -// SetPackageObjectKey sets the "package_object_key" field. -func (u *SkillUpsert) SetPackageObjectKey(v string) *SkillUpsert { - u.Set(skill.FieldPackageObjectKey, v) - return u -} - -// UpdatePackageObjectKey sets the "package_object_key" field to the value that was provided on create. -func (u *SkillUpsert) UpdatePackageObjectKey() *SkillUpsert { - u.SetExcluded(skill.FieldPackageObjectKey) - return u -} - -// ClearPackageObjectKey clears the value of the "package_object_key" field. -func (u *SkillUpsert) ClearPackageObjectKey() *SkillUpsert { - u.SetNull(skill.FieldPackageObjectKey) - return u -} - -// SetPackageURL sets the "package_url" field. -func (u *SkillUpsert) SetPackageURL(v string) *SkillUpsert { - u.Set(skill.FieldPackageURL, v) - return u -} - -// UpdatePackageURL sets the "package_url" field to the value that was provided on create. -func (u *SkillUpsert) UpdatePackageURL() *SkillUpsert { - u.SetExcluded(skill.FieldPackageURL) - return u -} - -// ClearPackageURL clears the value of the "package_url" field. -func (u *SkillUpsert) ClearPackageURL() *SkillUpsert { - u.SetNull(skill.FieldPackageURL) - return u -} - -// SetSourceType sets the "source_type" field. -func (u *SkillUpsert) SetSourceType(v string) *SkillUpsert { - u.Set(skill.FieldSourceType, v) - return u -} - -// UpdateSourceType sets the "source_type" field to the value that was provided on create. -func (u *SkillUpsert) UpdateSourceType() *SkillUpsert { - u.SetExcluded(skill.FieldSourceType) - return u -} - -// SetSourceLabel sets the "source_label" field. -func (u *SkillUpsert) SetSourceLabel(v string) *SkillUpsert { - u.Set(skill.FieldSourceLabel, v) - return u -} - -// UpdateSourceLabel sets the "source_label" field to the value that was provided on create. -func (u *SkillUpsert) UpdateSourceLabel() *SkillUpsert { - u.SetExcluded(skill.FieldSourceLabel) - return u -} - -// SetSkillMdPath sets the "skill_md_path" field. -func (u *SkillUpsert) SetSkillMdPath(v string) *SkillUpsert { - u.Set(skill.FieldSkillMdPath, v) - return u -} - -// UpdateSkillMdPath sets the "skill_md_path" field to the value that was provided on create. -func (u *SkillUpsert) UpdateSkillMdPath() *SkillUpsert { - u.SetExcluded(skill.FieldSkillMdPath) - return u -} - -// ClearSkillMdPath clears the value of the "skill_md_path" field. -func (u *SkillUpsert) ClearSkillMdPath() *SkillUpsert { - u.SetNull(skill.FieldSkillMdPath) - return u -} - -// SetExtensionPackageID sets the "extension_package_id" field. -func (u *SkillUpsert) SetExtensionPackageID(v string) *SkillUpsert { - u.Set(skill.FieldExtensionPackageID, v) - return u -} - -// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create. -func (u *SkillUpsert) UpdateExtensionPackageID() *SkillUpsert { - u.SetExcluded(skill.FieldExtensionPackageID) - return u -} - -// ClearExtensionPackageID clears the value of the "extension_package_id" field. -func (u *SkillUpsert) ClearExtensionPackageID() *SkillUpsert { - u.SetNull(skill.FieldExtensionPackageID) - return u -} - -// SetExtensionSkillID sets the "extension_skill_id" field. -func (u *SkillUpsert) SetExtensionSkillID(v string) *SkillUpsert { - u.Set(skill.FieldExtensionSkillID, v) - return u -} - -// UpdateExtensionSkillID sets the "extension_skill_id" field to the value that was provided on create. -func (u *SkillUpsert) UpdateExtensionSkillID() *SkillUpsert { - u.SetExcluded(skill.FieldExtensionSkillID) - return u -} - -// ClearExtensionSkillID clears the value of the "extension_skill_id" field. -func (u *SkillUpsert) ClearExtensionSkillID() *SkillUpsert { - u.SetNull(skill.FieldExtensionSkillID) - return u -} - -// SetExtensionVersion sets the "extension_version" field. -func (u *SkillUpsert) SetExtensionVersion(v string) *SkillUpsert { - u.Set(skill.FieldExtensionVersion, v) - return u -} - -// UpdateExtensionVersion sets the "extension_version" field to the value that was provided on create. -func (u *SkillUpsert) UpdateExtensionVersion() *SkillUpsert { - u.SetExcluded(skill.FieldExtensionVersion) - return u -} - -// ClearExtensionVersion clears the value of the "extension_version" field. -func (u *SkillUpsert) ClearExtensionVersion() *SkillUpsert { - u.SetNull(skill.FieldExtensionVersion) - return u -} - -// SetCreatedAt sets the "created_at" field. -func (u *SkillUpsert) SetCreatedAt(v time.Time) *SkillUpsert { - u.Set(skill.FieldCreatedAt, v) - return u -} - -// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. -func (u *SkillUpsert) UpdateCreatedAt() *SkillUpsert { - u.SetExcluded(skill.FieldCreatedAt) - return u -} - -// SetUpdatedAt sets the "updated_at" field. -func (u *SkillUpsert) SetUpdatedAt(v time.Time) *SkillUpsert { - u.Set(skill.FieldUpdatedAt, v) - return u -} - -// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. -func (u *SkillUpsert) UpdateUpdatedAt() *SkillUpsert { - u.SetExcluded(skill.FieldUpdatedAt) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. -// Using this option is equivalent to using: -// -// client.Skill.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// sql.ResolveWith(func(u *sql.UpdateSet) { -// u.SetIgnore(skill.FieldID) -// }), -// ). -// Exec(ctx) -func (u *SkillUpsertOne) UpdateNewValues() *SkillUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { - if _, exists := u.create.mutation.ID(); exists { - s.SetIgnore(skill.FieldID) - } - })) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.Skill.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *SkillUpsertOne) Ignore() *SkillUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *SkillUpsertOne) DoNothing() *SkillUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the SkillCreate.OnConflict -// documentation for more info. -func (u *SkillUpsertOne) Update(set func(*SkillUpsert)) *SkillUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&SkillUpsert{UpdateSet: update}) - })) - return u -} - -// SetDeletedAt sets the "deleted_at" field. -func (u *SkillUpsertOne) SetDeletedAt(v time.Time) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetDeletedAt(v) - }) -} - -// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateDeletedAt() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateDeletedAt() - }) -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (u *SkillUpsertOne) ClearDeletedAt() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.ClearDeletedAt() - }) -} - -// SetUserID sets the "user_id" field. -func (u *SkillUpsertOne) SetUserID(v uuid.UUID) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetUserID(v) - }) -} - -// UpdateUserID sets the "user_id" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateUserID() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateUserID() - }) -} - -// SetName sets the "name" field. -func (u *SkillUpsertOne) SetName(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetName(v) - }) -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateName() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateName() - }) -} - -// SetDescription sets the "description" field. -func (u *SkillUpsertOne) SetDescription(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetDescription(v) - }) -} - -// UpdateDescription sets the "description" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateDescription() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateDescription() - }) -} - -// SetTags sets the "tags" field. -func (u *SkillUpsertOne) SetTags(v []string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetTags(v) - }) -} - -// UpdateTags sets the "tags" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateTags() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateTags() - }) -} - -// ClearTags clears the value of the "tags" field. -func (u *SkillUpsertOne) ClearTags() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.ClearTags() - }) -} - -// SetContent sets the "content" field. -func (u *SkillUpsertOne) SetContent(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetContent(v) - }) -} - -// UpdateContent sets the "content" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateContent() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateContent() - }) -} - -// SetPackageObjectKey sets the "package_object_key" field. -func (u *SkillUpsertOne) SetPackageObjectKey(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetPackageObjectKey(v) - }) -} - -// UpdatePackageObjectKey sets the "package_object_key" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdatePackageObjectKey() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdatePackageObjectKey() - }) -} - -// ClearPackageObjectKey clears the value of the "package_object_key" field. -func (u *SkillUpsertOne) ClearPackageObjectKey() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.ClearPackageObjectKey() - }) -} - -// SetPackageURL sets the "package_url" field. -func (u *SkillUpsertOne) SetPackageURL(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetPackageURL(v) - }) -} - -// UpdatePackageURL sets the "package_url" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdatePackageURL() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdatePackageURL() - }) -} - -// ClearPackageURL clears the value of the "package_url" field. -func (u *SkillUpsertOne) ClearPackageURL() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.ClearPackageURL() - }) -} - -// SetSourceType sets the "source_type" field. -func (u *SkillUpsertOne) SetSourceType(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetSourceType(v) - }) -} - -// UpdateSourceType sets the "source_type" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateSourceType() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateSourceType() - }) -} - -// SetSourceLabel sets the "source_label" field. -func (u *SkillUpsertOne) SetSourceLabel(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetSourceLabel(v) - }) -} - -// UpdateSourceLabel sets the "source_label" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateSourceLabel() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateSourceLabel() - }) -} - -// SetSkillMdPath sets the "skill_md_path" field. -func (u *SkillUpsertOne) SetSkillMdPath(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetSkillMdPath(v) - }) -} - -// UpdateSkillMdPath sets the "skill_md_path" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateSkillMdPath() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateSkillMdPath() - }) -} - -// ClearSkillMdPath clears the value of the "skill_md_path" field. -func (u *SkillUpsertOne) ClearSkillMdPath() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.ClearSkillMdPath() - }) -} - -// SetExtensionPackageID sets the "extension_package_id" field. -func (u *SkillUpsertOne) SetExtensionPackageID(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetExtensionPackageID(v) - }) -} - -// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateExtensionPackageID() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateExtensionPackageID() - }) -} - -// ClearExtensionPackageID clears the value of the "extension_package_id" field. -func (u *SkillUpsertOne) ClearExtensionPackageID() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.ClearExtensionPackageID() - }) -} - -// SetExtensionSkillID sets the "extension_skill_id" field. -func (u *SkillUpsertOne) SetExtensionSkillID(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetExtensionSkillID(v) - }) -} - -// UpdateExtensionSkillID sets the "extension_skill_id" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateExtensionSkillID() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateExtensionSkillID() - }) -} - -// ClearExtensionSkillID clears the value of the "extension_skill_id" field. -func (u *SkillUpsertOne) ClearExtensionSkillID() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.ClearExtensionSkillID() - }) -} - -// SetExtensionVersion sets the "extension_version" field. -func (u *SkillUpsertOne) SetExtensionVersion(v string) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetExtensionVersion(v) - }) -} - -// UpdateExtensionVersion sets the "extension_version" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateExtensionVersion() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateExtensionVersion() - }) -} - -// ClearExtensionVersion clears the value of the "extension_version" field. -func (u *SkillUpsertOne) ClearExtensionVersion() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.ClearExtensionVersion() - }) -} - -// SetCreatedAt sets the "created_at" field. -func (u *SkillUpsertOne) SetCreatedAt(v time.Time) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetCreatedAt(v) - }) -} - -// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateCreatedAt() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateCreatedAt() - }) -} - -// SetUpdatedAt sets the "updated_at" field. -func (u *SkillUpsertOne) SetUpdatedAt(v time.Time) *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.SetUpdatedAt(v) - }) -} - -// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. -func (u *SkillUpsertOne) UpdateUpdatedAt() *SkillUpsertOne { - return u.Update(func(s *SkillUpsert) { - s.UpdateUpdatedAt() - }) -} - -// Exec executes the query. -func (u *SkillUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("db: missing options for SkillCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *SkillUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *SkillUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { - if u.create.driver.Dialect() == dialect.MySQL { - // In case of "ON CONFLICT", there is no way to get back non-numeric ID - // fields from the database since MySQL does not support the RETURNING clause. - return id, errors.New("db: SkillUpsertOne.ID is not supported by MySQL driver. Use SkillUpsertOne.Exec instead") - } - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *SkillUpsertOne) IDX(ctx context.Context) uuid.UUID { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// SkillCreateBulk is the builder for creating many Skill entities in bulk. -type SkillCreateBulk struct { - config - err error - builders []*SkillCreate - conflict []sql.ConflictOption -} - -// Save creates the Skill entities in the database. -func (_c *SkillCreateBulk) Save(ctx context.Context) ([]*Skill, error) { - if _c.err != nil { - return nil, _c.err - } - specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*Skill, len(_c.builders)) - mutators := make([]Mutator, len(_c.builders)) - for i := range _c.builders { - func(i int, root context.Context) { - builder := _c.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*SkillMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = _c.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (_c *SkillCreateBulk) SaveX(ctx context.Context) []*Skill { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *SkillCreateBulk) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *SkillCreateBulk) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.Skill.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.SkillUpsert) { -// SetDeletedAt(v+v). -// }). -// Exec(ctx) -func (_c *SkillCreateBulk) OnConflict(opts ...sql.ConflictOption) *SkillUpsertBulk { - _c.conflict = opts - return &SkillUpsertBulk{ - create: _c, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.Skill.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (_c *SkillCreateBulk) OnConflictColumns(columns ...string) *SkillUpsertBulk { - _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) - return &SkillUpsertBulk{ - create: _c, - } -} - -// SkillUpsertBulk is the builder for "upsert"-ing -// a bulk of Skill nodes. -type SkillUpsertBulk struct { - create *SkillCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.Skill.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// sql.ResolveWith(func(u *sql.UpdateSet) { -// u.SetIgnore(skill.FieldID) -// }), -// ). -// Exec(ctx) -func (u *SkillUpsertBulk) UpdateNewValues() *SkillUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { - for _, b := range u.create.builders { - if _, exists := b.mutation.ID(); exists { - s.SetIgnore(skill.FieldID) - } - } - })) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.Skill.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *SkillUpsertBulk) Ignore() *SkillUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *SkillUpsertBulk) DoNothing() *SkillUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the SkillCreateBulk.OnConflict -// documentation for more info. -func (u *SkillUpsertBulk) Update(set func(*SkillUpsert)) *SkillUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&SkillUpsert{UpdateSet: update}) - })) - return u -} - -// SetDeletedAt sets the "deleted_at" field. -func (u *SkillUpsertBulk) SetDeletedAt(v time.Time) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetDeletedAt(v) - }) -} - -// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateDeletedAt() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateDeletedAt() - }) -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (u *SkillUpsertBulk) ClearDeletedAt() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.ClearDeletedAt() - }) -} - -// SetUserID sets the "user_id" field. -func (u *SkillUpsertBulk) SetUserID(v uuid.UUID) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetUserID(v) - }) -} - -// UpdateUserID sets the "user_id" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateUserID() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateUserID() - }) -} - -// SetName sets the "name" field. -func (u *SkillUpsertBulk) SetName(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetName(v) - }) -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateName() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateName() - }) -} - -// SetDescription sets the "description" field. -func (u *SkillUpsertBulk) SetDescription(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetDescription(v) - }) -} - -// UpdateDescription sets the "description" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateDescription() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateDescription() - }) -} - -// SetTags sets the "tags" field. -func (u *SkillUpsertBulk) SetTags(v []string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetTags(v) - }) -} - -// UpdateTags sets the "tags" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateTags() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateTags() - }) -} - -// ClearTags clears the value of the "tags" field. -func (u *SkillUpsertBulk) ClearTags() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.ClearTags() - }) -} - -// SetContent sets the "content" field. -func (u *SkillUpsertBulk) SetContent(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetContent(v) - }) -} - -// UpdateContent sets the "content" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateContent() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateContent() - }) -} - -// SetPackageObjectKey sets the "package_object_key" field. -func (u *SkillUpsertBulk) SetPackageObjectKey(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetPackageObjectKey(v) - }) -} - -// UpdatePackageObjectKey sets the "package_object_key" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdatePackageObjectKey() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdatePackageObjectKey() - }) -} - -// ClearPackageObjectKey clears the value of the "package_object_key" field. -func (u *SkillUpsertBulk) ClearPackageObjectKey() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.ClearPackageObjectKey() - }) -} - -// SetPackageURL sets the "package_url" field. -func (u *SkillUpsertBulk) SetPackageURL(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetPackageURL(v) - }) -} - -// UpdatePackageURL sets the "package_url" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdatePackageURL() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdatePackageURL() - }) -} - -// ClearPackageURL clears the value of the "package_url" field. -func (u *SkillUpsertBulk) ClearPackageURL() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.ClearPackageURL() - }) -} - -// SetSourceType sets the "source_type" field. -func (u *SkillUpsertBulk) SetSourceType(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetSourceType(v) - }) -} - -// UpdateSourceType sets the "source_type" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateSourceType() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateSourceType() - }) -} - -// SetSourceLabel sets the "source_label" field. -func (u *SkillUpsertBulk) SetSourceLabel(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetSourceLabel(v) - }) -} - -// UpdateSourceLabel sets the "source_label" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateSourceLabel() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateSourceLabel() - }) -} - -// SetSkillMdPath sets the "skill_md_path" field. -func (u *SkillUpsertBulk) SetSkillMdPath(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetSkillMdPath(v) - }) -} - -// UpdateSkillMdPath sets the "skill_md_path" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateSkillMdPath() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateSkillMdPath() - }) -} - -// ClearSkillMdPath clears the value of the "skill_md_path" field. -func (u *SkillUpsertBulk) ClearSkillMdPath() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.ClearSkillMdPath() - }) -} - -// SetExtensionPackageID sets the "extension_package_id" field. -func (u *SkillUpsertBulk) SetExtensionPackageID(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetExtensionPackageID(v) - }) -} - -// UpdateExtensionPackageID sets the "extension_package_id" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateExtensionPackageID() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateExtensionPackageID() - }) -} - -// ClearExtensionPackageID clears the value of the "extension_package_id" field. -func (u *SkillUpsertBulk) ClearExtensionPackageID() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.ClearExtensionPackageID() - }) -} - -// SetExtensionSkillID sets the "extension_skill_id" field. -func (u *SkillUpsertBulk) SetExtensionSkillID(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetExtensionSkillID(v) - }) -} - -// UpdateExtensionSkillID sets the "extension_skill_id" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateExtensionSkillID() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateExtensionSkillID() - }) -} - -// ClearExtensionSkillID clears the value of the "extension_skill_id" field. -func (u *SkillUpsertBulk) ClearExtensionSkillID() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.ClearExtensionSkillID() - }) -} - -// SetExtensionVersion sets the "extension_version" field. -func (u *SkillUpsertBulk) SetExtensionVersion(v string) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetExtensionVersion(v) - }) -} - -// UpdateExtensionVersion sets the "extension_version" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateExtensionVersion() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateExtensionVersion() - }) -} - -// ClearExtensionVersion clears the value of the "extension_version" field. -func (u *SkillUpsertBulk) ClearExtensionVersion() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.ClearExtensionVersion() - }) -} - -// SetCreatedAt sets the "created_at" field. -func (u *SkillUpsertBulk) SetCreatedAt(v time.Time) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetCreatedAt(v) - }) -} - -// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateCreatedAt() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateCreatedAt() - }) -} - -// SetUpdatedAt sets the "updated_at" field. -func (u *SkillUpsertBulk) SetUpdatedAt(v time.Time) *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.SetUpdatedAt(v) - }) -} - -// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. -func (u *SkillUpsertBulk) UpdateUpdatedAt() *SkillUpsertBulk { - return u.Update(func(s *SkillUpsert) { - s.UpdateUpdatedAt() - }) -} - -// Exec executes the query. -func (u *SkillUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the SkillCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("db: missing options for SkillCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *SkillUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/backend/db/skill_query.go b/backend/db/skill_query.go deleted file mode 100644 index 88ae4d44..00000000 --- a/backend/db/skill_query.go +++ /dev/null @@ -1,1016 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package db - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" - "github.com/chaitin/MonkeyCode/backend/db/team" - "github.com/chaitin/MonkeyCode/backend/db/teamgroup" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" - "github.com/chaitin/MonkeyCode/backend/db/user" - "github.com/google/uuid" -) - -// SkillQuery is the builder for querying Skill entities. -type SkillQuery struct { - config - ctx *QueryContext - order []skill.OrderOption - inters []Interceptor - predicates []predicate.Skill - withUser *UserQuery - withTeams *TeamQuery - withGroups *TeamGroupQuery - withTeamSkills *TeamSkillQuery - withTeamGroupSkills *TeamGroupSkillQuery - modifiers []func(*sql.Selector) - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the SkillQuery builder. -func (_q *SkillQuery) Where(ps ...predicate.Skill) *SkillQuery { - _q.predicates = append(_q.predicates, ps...) - return _q -} - -// Limit the number of records to be returned by this query. -func (_q *SkillQuery) Limit(limit int) *SkillQuery { - _q.ctx.Limit = &limit - return _q -} - -// Offset to start from. -func (_q *SkillQuery) Offset(offset int) *SkillQuery { - _q.ctx.Offset = &offset - return _q -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (_q *SkillQuery) Unique(unique bool) *SkillQuery { - _q.ctx.Unique = &unique - return _q -} - -// Order specifies how the records should be ordered. -func (_q *SkillQuery) Order(o ...skill.OrderOption) *SkillQuery { - _q.order = append(_q.order, o...) - return _q -} - -// QueryUser chains the current query on the "user" edge. -func (_q *SkillQuery) QueryUser() *UserQuery { - query := (&UserClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(skill.Table, skill.FieldID, selector), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, skill.UserTable, skill.UserColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryTeams chains the current query on the "teams" edge. -func (_q *SkillQuery) QueryTeams() *TeamQuery { - query := (&TeamClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(skill.Table, skill.FieldID, selector), - sqlgraph.To(team.Table, team.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, skill.TeamsTable, skill.TeamsPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryGroups chains the current query on the "groups" edge. -func (_q *SkillQuery) QueryGroups() *TeamGroupQuery { - query := (&TeamGroupClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(skill.Table, skill.FieldID, selector), - sqlgraph.To(teamgroup.Table, teamgroup.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, skill.GroupsTable, skill.GroupsPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryTeamSkills chains the current query on the "team_skills" edge. -func (_q *SkillQuery) QueryTeamSkills() *TeamSkillQuery { - query := (&TeamSkillClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(skill.Table, skill.FieldID, selector), - sqlgraph.To(teamskill.Table, teamskill.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, skill.TeamSkillsTable, skill.TeamSkillsColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryTeamGroupSkills chains the current query on the "team_group_skills" edge. -func (_q *SkillQuery) QueryTeamGroupSkills() *TeamGroupSkillQuery { - query := (&TeamGroupSkillClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(skill.Table, skill.FieldID, selector), - sqlgraph.To(teamgroupskill.Table, teamgroupskill.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, skill.TeamGroupSkillsTable, skill.TeamGroupSkillsColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Skill entity from the query. -// Returns a *NotFoundError when no Skill was found. -func (_q *SkillQuery) First(ctx context.Context) (*Skill, error) { - nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{skill.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (_q *SkillQuery) FirstX(ctx context.Context) *Skill { - node, err := _q.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first Skill ID from the query. -// Returns a *NotFoundError when no Skill ID was found. -func (_q *SkillQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { - var ids []uuid.UUID - if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{skill.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (_q *SkillQuery) FirstIDX(ctx context.Context) uuid.UUID { - id, err := _q.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single Skill entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one Skill entity is found. -// Returns a *NotFoundError when no Skill entities are found. -func (_q *SkillQuery) Only(ctx context.Context) (*Skill, error) { - nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{skill.Label} - default: - return nil, &NotSingularError{skill.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (_q *SkillQuery) OnlyX(ctx context.Context) *Skill { - node, err := _q.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only Skill ID in the query. -// Returns a *NotSingularError when more than one Skill ID is found. -// Returns a *NotFoundError when no entities are found. -func (_q *SkillQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { - var ids []uuid.UUID - if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{skill.Label} - default: - err = &NotSingularError{skill.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *SkillQuery) OnlyIDX(ctx context.Context) uuid.UUID { - id, err := _q.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Skills. -func (_q *SkillQuery) All(ctx context.Context) ([]*Skill, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*Skill, *SkillQuery]() - return withInterceptors[[]*Skill](ctx, _q, qr, _q.inters) -} - -// AllX is like All, but panics if an error occurs. -func (_q *SkillQuery) AllX(ctx context.Context) []*Skill { - nodes, err := _q.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of Skill IDs. -func (_q *SkillQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { - if _q.ctx.Unique == nil && _q.path != nil { - _q.Unique(true) - } - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(skill.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (_q *SkillQuery) IDsX(ctx context.Context) []uuid.UUID { - ids, err := _q.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (_q *SkillQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) - if err := _q.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, _q, querierCount[*SkillQuery](), _q.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (_q *SkillQuery) CountX(ctx context.Context) int { - count, err := _q.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (_q *SkillQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) - switch _, err := _q.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("db: check existence: %w", err) - default: - return true, nil - } -} - -// ExistX is like Exist, but panics if an error occurs. -func (_q *SkillQuery) ExistX(ctx context.Context) bool { - exist, err := _q.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the SkillQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (_q *SkillQuery) Clone() *SkillQuery { - if _q == nil { - return nil - } - return &SkillQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]skill.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.Skill{}, _q.predicates...), - withUser: _q.withUser.Clone(), - withTeams: _q.withTeams.Clone(), - withGroups: _q.withGroups.Clone(), - withTeamSkills: _q.withTeamSkills.Clone(), - withTeamGroupSkills: _q.withTeamGroupSkills.Clone(), - // clone intermediate query. - sql: _q.sql.Clone(), - path: _q.path, - modifiers: append([]func(*sql.Selector){}, _q.modifiers...), - } -} - -// WithUser tells the query-builder to eager-load the nodes that are connected to -// the "user" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *SkillQuery) WithUser(opts ...func(*UserQuery)) *SkillQuery { - query := (&UserClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withUser = query - return _q -} - -// WithTeams tells the query-builder to eager-load the nodes that are connected to -// the "teams" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *SkillQuery) WithTeams(opts ...func(*TeamQuery)) *SkillQuery { - query := (&TeamClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withTeams = query - return _q -} - -// WithGroups tells the query-builder to eager-load the nodes that are connected to -// the "groups" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *SkillQuery) WithGroups(opts ...func(*TeamGroupQuery)) *SkillQuery { - query := (&TeamGroupClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withGroups = query - return _q -} - -// WithTeamSkills tells the query-builder to eager-load the nodes that are connected to -// the "team_skills" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *SkillQuery) WithTeamSkills(opts ...func(*TeamSkillQuery)) *SkillQuery { - query := (&TeamSkillClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withTeamSkills = query - return _q -} - -// WithTeamGroupSkills tells the query-builder to eager-load the nodes that are connected to -// the "team_group_skills" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *SkillQuery) WithTeamGroupSkills(opts ...func(*TeamGroupSkillQuery)) *SkillQuery { - query := (&TeamGroupSkillClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withTeamGroupSkills = query - return _q -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// DeletedAt time.Time `json:"deleted_at,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.Skill.Query(). -// GroupBy(skill.FieldDeletedAt). -// Aggregate(db.Count()). -// Scan(ctx, &v) -func (_q *SkillQuery) GroupBy(field string, fields ...string) *SkillGroupBy { - _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &SkillGroupBy{build: _q} - grbuild.flds = &_q.ctx.Fields - grbuild.label = skill.Label - grbuild.scan = grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// DeletedAt time.Time `json:"deleted_at,omitempty"` -// } -// -// client.Skill.Query(). -// Select(skill.FieldDeletedAt). -// Scan(ctx, &v) -func (_q *SkillQuery) Select(fields ...string) *SkillSelect { - _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &SkillSelect{SkillQuery: _q} - sbuild.label = skill.Label - sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a SkillSelect configured with the given aggregations. -func (_q *SkillQuery) Aggregate(fns ...AggregateFunc) *SkillSelect { - return _q.Select().Aggregate(fns...) -} - -func (_q *SkillQuery) prepareQuery(ctx context.Context) error { - for _, inter := range _q.inters { - if inter == nil { - return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") - } - if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, _q); err != nil { - return err - } - } - } - for _, f := range _q.ctx.Fields { - if !skill.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} - } - } - if _q.path != nil { - prev, err := _q.path(ctx) - if err != nil { - return err - } - _q.sql = prev - } - return nil -} - -func (_q *SkillQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Skill, error) { - var ( - nodes = []*Skill{} - _spec = _q.querySpec() - loadedTypes = [5]bool{ - _q.withUser != nil, - _q.withTeams != nil, - _q.withGroups != nil, - _q.withTeamSkills != nil, - _q.withTeamGroupSkills != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*Skill).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &Skill{config: _q.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := _q.withUser; query != nil { - if err := _q.loadUser(ctx, query, nodes, nil, - func(n *Skill, e *User) { n.Edges.User = e }); err != nil { - return nil, err - } - } - if query := _q.withTeams; query != nil { - if err := _q.loadTeams(ctx, query, nodes, - func(n *Skill) { n.Edges.Teams = []*Team{} }, - func(n *Skill, e *Team) { n.Edges.Teams = append(n.Edges.Teams, e) }); err != nil { - return nil, err - } - } - if query := _q.withGroups; query != nil { - if err := _q.loadGroups(ctx, query, nodes, - func(n *Skill) { n.Edges.Groups = []*TeamGroup{} }, - func(n *Skill, e *TeamGroup) { n.Edges.Groups = append(n.Edges.Groups, e) }); err != nil { - return nil, err - } - } - if query := _q.withTeamSkills; query != nil { - if err := _q.loadTeamSkills(ctx, query, nodes, - func(n *Skill) { n.Edges.TeamSkills = []*TeamSkill{} }, - func(n *Skill, e *TeamSkill) { n.Edges.TeamSkills = append(n.Edges.TeamSkills, e) }); err != nil { - return nil, err - } - } - if query := _q.withTeamGroupSkills; query != nil { - if err := _q.loadTeamGroupSkills(ctx, query, nodes, - func(n *Skill) { n.Edges.TeamGroupSkills = []*TeamGroupSkill{} }, - func(n *Skill, e *TeamGroupSkill) { n.Edges.TeamGroupSkills = append(n.Edges.TeamGroupSkills, e) }); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (_q *SkillQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*Skill, init func(*Skill), assign func(*Skill, *User)) error { - ids := make([]uuid.UUID, 0, len(nodes)) - nodeids := make(map[uuid.UUID][]*Skill) - for i := range nodes { - fk := nodes[i].UserID - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(user.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "user_id" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} -func (_q *SkillQuery) loadTeams(ctx context.Context, query *TeamQuery, nodes []*Skill, init func(*Skill), assign func(*Skill, *Team)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[uuid.UUID]*Skill) - nids := make(map[uuid.UUID]map[*Skill]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(skill.TeamsTable) - s.Join(joinT).On(s.C(team.FieldID), joinT.C(skill.TeamsPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(skill.TeamsPrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(skill.TeamsPrimaryKey[1])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(uuid.UUID)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := *values[0].(*uuid.UUID) - inValue := *values[1].(*uuid.UUID) - if nids[inValue] == nil { - nids[inValue] = map[*Skill]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Team](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "teams" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (_q *SkillQuery) loadGroups(ctx context.Context, query *TeamGroupQuery, nodes []*Skill, init func(*Skill), assign func(*Skill, *TeamGroup)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[uuid.UUID]*Skill) - nids := make(map[uuid.UUID]map[*Skill]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(skill.GroupsTable) - s.Join(joinT).On(s.C(teamgroup.FieldID), joinT.C(skill.GroupsPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(skill.GroupsPrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(skill.GroupsPrimaryKey[1])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(uuid.UUID)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := *values[0].(*uuid.UUID) - inValue := *values[1].(*uuid.UUID) - if nids[inValue] == nil { - nids[inValue] = map[*Skill]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*TeamGroup](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "groups" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (_q *SkillQuery) loadTeamSkills(ctx context.Context, query *TeamSkillQuery, nodes []*Skill, init func(*Skill), assign func(*Skill, *TeamSkill)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[uuid.UUID]*Skill) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(teamskill.FieldSkillID) - } - query.Where(predicate.TeamSkill(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(skill.TeamSkillsColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.SkillID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "skill_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} -func (_q *SkillQuery) loadTeamGroupSkills(ctx context.Context, query *TeamGroupSkillQuery, nodes []*Skill, init func(*Skill), assign func(*Skill, *TeamGroupSkill)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[uuid.UUID]*Skill) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(teamgroupskill.FieldSkillID) - } - query.Where(predicate.TeamGroupSkill(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(skill.TeamGroupSkillsColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.SkillID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "skill_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} - -func (_q *SkillQuery) sqlCount(ctx context.Context) (int, error) { - _spec := _q.querySpec() - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - _spec.Node.Columns = _q.ctx.Fields - if len(_q.ctx.Fields) > 0 { - _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique - } - return sqlgraph.CountNodes(ctx, _q.driver, _spec) -} - -func (_q *SkillQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(skill.Table, skill.Columns, sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID)) - _spec.From = _q.sql - if unique := _q.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if _q.path != nil { - _spec.Unique = true - } - if fields := _q.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, skill.FieldID) - for i := range fields { - if fields[i] != skill.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - if _q.withUser != nil { - _spec.Node.AddColumnOnce(skill.FieldUserID) - } - } - if ps := _q.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := _q.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := _q.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := _q.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (_q *SkillQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(skill.Table) - columns := _q.ctx.Fields - if len(columns) == 0 { - columns = skill.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if _q.sql != nil { - selector = _q.sql - selector.Select(selector.Columns(columns...)...) - } - if _q.ctx.Unique != nil && *_q.ctx.Unique { - selector.Distinct() - } - for _, m := range _q.modifiers { - m(selector) - } - for _, p := range _q.predicates { - p(selector) - } - for _, p := range _q.order { - p(selector) - } - if offset := _q.ctx.Offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := _q.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// ForUpdate locks the selected rows against concurrent updates, and prevent them from being -// updated, deleted or "selected ... for update" by other sessions, until the transaction is -// either committed or rolled-back. -func (_q *SkillQuery) ForUpdate(opts ...sql.LockOption) *SkillQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForUpdate(opts...) - }) - return _q -} - -// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock -// on any rows that are read. Other sessions can read the rows, but cannot modify them -// until your transaction commits. -func (_q *SkillQuery) ForShare(opts ...sql.LockOption) *SkillQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForShare(opts...) - }) - return _q -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_q *SkillQuery) Modify(modifiers ...func(s *sql.Selector)) *SkillSelect { - _q.modifiers = append(_q.modifiers, modifiers...) - return _q.Select() -} - -// SkillGroupBy is the group-by builder for Skill entities. -type SkillGroupBy struct { - selector - build *SkillQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (_g *SkillGroupBy) Aggregate(fns ...AggregateFunc) *SkillGroupBy { - _g.fns = append(_g.fns, fns...) - return _g -} - -// Scan applies the selector query and scans the result into the given value. -func (_g *SkillGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) - if err := _g.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*SkillQuery, *SkillGroupBy](ctx, _g.build, _g, _g.build.inters, v) -} - -func (_g *SkillGroupBy) sqlScan(ctx context.Context, root *SkillQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(_g.fns)) - for _, fn := range _g.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) - for _, f := range *_g.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*_g.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// SkillSelect is the builder for selecting fields of Skill entities. -type SkillSelect struct { - *SkillQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (_s *SkillSelect) Aggregate(fns ...AggregateFunc) *SkillSelect { - _s.fns = append(_s.fns, fns...) - return _s -} - -// Scan applies the selector query and scans the result into the given value. -func (_s *SkillSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) - if err := _s.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*SkillQuery, *SkillSelect](ctx, _s.SkillQuery, _s, _s.inters, v) -} - -func (_s *SkillSelect) sqlScan(ctx context.Context, root *SkillQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(_s.fns)) - for _, fn := range _s.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*_s.selector.flds); { - case n == 0 && len(aggregation) > 0: - selector.Select(aggregation...) - case n != 0 && len(aggregation) > 0: - selector.AppendSelect(aggregation...) - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _s.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_s *SkillSelect) Modify(modifiers ...func(s *sql.Selector)) *SkillSelect { - _s.modifiers = append(_s.modifiers, modifiers...) - return _s -} diff --git a/backend/db/skill_update.go b/backend/db/skill_update.go deleted file mode 100644 index e511b9bb..00000000 --- a/backend/db/skill_update.go +++ /dev/null @@ -1,1749 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package db - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/dialect/sql/sqljson" - "entgo.io/ent/schema/field" - "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" - "github.com/chaitin/MonkeyCode/backend/db/team" - "github.com/chaitin/MonkeyCode/backend/db/teamgroup" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" - "github.com/chaitin/MonkeyCode/backend/db/user" - "github.com/google/uuid" -) - -// SkillUpdate is the builder for updating Skill entities. -type SkillUpdate struct { - config - hooks []Hook - mutation *SkillMutation - modifiers []func(*sql.UpdateBuilder) -} - -// Where appends a list predicates to the SkillUpdate builder. -func (_u *SkillUpdate) Where(ps ...predicate.Skill) *SkillUpdate { - _u.mutation.Where(ps...) - return _u -} - -// SetDeletedAt sets the "deleted_at" field. -func (_u *SkillUpdate) SetDeletedAt(v time.Time) *SkillUpdate { - _u.mutation.SetDeletedAt(v) - return _u -} - -// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableDeletedAt(v *time.Time) *SkillUpdate { - if v != nil { - _u.SetDeletedAt(*v) - } - return _u -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (_u *SkillUpdate) ClearDeletedAt() *SkillUpdate { - _u.mutation.ClearDeletedAt() - return _u -} - -// SetUserID sets the "user_id" field. -func (_u *SkillUpdate) SetUserID(v uuid.UUID) *SkillUpdate { - _u.mutation.SetUserID(v) - return _u -} - -// SetNillableUserID sets the "user_id" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableUserID(v *uuid.UUID) *SkillUpdate { - if v != nil { - _u.SetUserID(*v) - } - return _u -} - -// SetName sets the "name" field. -func (_u *SkillUpdate) SetName(v string) *SkillUpdate { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableName(v *string) *SkillUpdate { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetDescription sets the "description" field. -func (_u *SkillUpdate) SetDescription(v string) *SkillUpdate { - _u.mutation.SetDescription(v) - return _u -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableDescription(v *string) *SkillUpdate { - if v != nil { - _u.SetDescription(*v) - } - return _u -} - -// SetTags sets the "tags" field. -func (_u *SkillUpdate) SetTags(v []string) *SkillUpdate { - _u.mutation.SetTags(v) - return _u -} - -// AppendTags appends value to the "tags" field. -func (_u *SkillUpdate) AppendTags(v []string) *SkillUpdate { - _u.mutation.AppendTags(v) - return _u -} - -// ClearTags clears the value of the "tags" field. -func (_u *SkillUpdate) ClearTags() *SkillUpdate { - _u.mutation.ClearTags() - return _u -} - -// SetContent sets the "content" field. -func (_u *SkillUpdate) SetContent(v string) *SkillUpdate { - _u.mutation.SetContent(v) - return _u -} - -// SetNillableContent sets the "content" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableContent(v *string) *SkillUpdate { - if v != nil { - _u.SetContent(*v) - } - return _u -} - -// SetPackageObjectKey sets the "package_object_key" field. -func (_u *SkillUpdate) SetPackageObjectKey(v string) *SkillUpdate { - _u.mutation.SetPackageObjectKey(v) - return _u -} - -// SetNillablePackageObjectKey sets the "package_object_key" field if the given value is not nil. -func (_u *SkillUpdate) SetNillablePackageObjectKey(v *string) *SkillUpdate { - if v != nil { - _u.SetPackageObjectKey(*v) - } - return _u -} - -// ClearPackageObjectKey clears the value of the "package_object_key" field. -func (_u *SkillUpdate) ClearPackageObjectKey() *SkillUpdate { - _u.mutation.ClearPackageObjectKey() - return _u -} - -// SetPackageURL sets the "package_url" field. -func (_u *SkillUpdate) SetPackageURL(v string) *SkillUpdate { - _u.mutation.SetPackageURL(v) - return _u -} - -// SetNillablePackageURL sets the "package_url" field if the given value is not nil. -func (_u *SkillUpdate) SetNillablePackageURL(v *string) *SkillUpdate { - if v != nil { - _u.SetPackageURL(*v) - } - return _u -} - -// ClearPackageURL clears the value of the "package_url" field. -func (_u *SkillUpdate) ClearPackageURL() *SkillUpdate { - _u.mutation.ClearPackageURL() - return _u -} - -// SetSourceType sets the "source_type" field. -func (_u *SkillUpdate) SetSourceType(v string) *SkillUpdate { - _u.mutation.SetSourceType(v) - return _u -} - -// SetNillableSourceType sets the "source_type" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableSourceType(v *string) *SkillUpdate { - if v != nil { - _u.SetSourceType(*v) - } - return _u -} - -// SetSourceLabel sets the "source_label" field. -func (_u *SkillUpdate) SetSourceLabel(v string) *SkillUpdate { - _u.mutation.SetSourceLabel(v) - return _u -} - -// SetNillableSourceLabel sets the "source_label" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableSourceLabel(v *string) *SkillUpdate { - if v != nil { - _u.SetSourceLabel(*v) - } - return _u -} - -// SetSkillMdPath sets the "skill_md_path" field. -func (_u *SkillUpdate) SetSkillMdPath(v string) *SkillUpdate { - _u.mutation.SetSkillMdPath(v) - return _u -} - -// SetNillableSkillMdPath sets the "skill_md_path" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableSkillMdPath(v *string) *SkillUpdate { - if v != nil { - _u.SetSkillMdPath(*v) - } - return _u -} - -// ClearSkillMdPath clears the value of the "skill_md_path" field. -func (_u *SkillUpdate) ClearSkillMdPath() *SkillUpdate { - _u.mutation.ClearSkillMdPath() - return _u -} - -// SetExtensionPackageID sets the "extension_package_id" field. -func (_u *SkillUpdate) SetExtensionPackageID(v string) *SkillUpdate { - _u.mutation.SetExtensionPackageID(v) - return _u -} - -// SetNillableExtensionPackageID sets the "extension_package_id" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableExtensionPackageID(v *string) *SkillUpdate { - if v != nil { - _u.SetExtensionPackageID(*v) - } - return _u -} - -// ClearExtensionPackageID clears the value of the "extension_package_id" field. -func (_u *SkillUpdate) ClearExtensionPackageID() *SkillUpdate { - _u.mutation.ClearExtensionPackageID() - return _u -} - -// SetExtensionSkillID sets the "extension_skill_id" field. -func (_u *SkillUpdate) SetExtensionSkillID(v string) *SkillUpdate { - _u.mutation.SetExtensionSkillID(v) - return _u -} - -// SetNillableExtensionSkillID sets the "extension_skill_id" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableExtensionSkillID(v *string) *SkillUpdate { - if v != nil { - _u.SetExtensionSkillID(*v) - } - return _u -} - -// ClearExtensionSkillID clears the value of the "extension_skill_id" field. -func (_u *SkillUpdate) ClearExtensionSkillID() *SkillUpdate { - _u.mutation.ClearExtensionSkillID() - return _u -} - -// SetExtensionVersion sets the "extension_version" field. -func (_u *SkillUpdate) SetExtensionVersion(v string) *SkillUpdate { - _u.mutation.SetExtensionVersion(v) - return _u -} - -// SetNillableExtensionVersion sets the "extension_version" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableExtensionVersion(v *string) *SkillUpdate { - if v != nil { - _u.SetExtensionVersion(*v) - } - return _u -} - -// ClearExtensionVersion clears the value of the "extension_version" field. -func (_u *SkillUpdate) ClearExtensionVersion() *SkillUpdate { - _u.mutation.ClearExtensionVersion() - return _u -} - -// SetCreatedAt sets the "created_at" field. -func (_u *SkillUpdate) SetCreatedAt(v time.Time) *SkillUpdate { - _u.mutation.SetCreatedAt(v) - return _u -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (_u *SkillUpdate) SetNillableCreatedAt(v *time.Time) *SkillUpdate { - if v != nil { - _u.SetCreatedAt(*v) - } - return _u -} - -// SetUpdatedAt sets the "updated_at" field. -func (_u *SkillUpdate) SetUpdatedAt(v time.Time) *SkillUpdate { - _u.mutation.SetUpdatedAt(v) - return _u -} - -// SetUser sets the "user" edge to the User entity. -func (_u *SkillUpdate) SetUser(v *User) *SkillUpdate { - return _u.SetUserID(v.ID) -} - -// AddTeamIDs adds the "teams" edge to the Team entity by IDs. -func (_u *SkillUpdate) AddTeamIDs(ids ...uuid.UUID) *SkillUpdate { - _u.mutation.AddTeamIDs(ids...) - return _u -} - -// AddTeams adds the "teams" edges to the Team entity. -func (_u *SkillUpdate) AddTeams(v ...*Team) *SkillUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddTeamIDs(ids...) -} - -// AddGroupIDs adds the "groups" edge to the TeamGroup entity by IDs. -func (_u *SkillUpdate) AddGroupIDs(ids ...uuid.UUID) *SkillUpdate { - _u.mutation.AddGroupIDs(ids...) - return _u -} - -// AddGroups adds the "groups" edges to the TeamGroup entity. -func (_u *SkillUpdate) AddGroups(v ...*TeamGroup) *SkillUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddGroupIDs(ids...) -} - -// AddTeamSkillIDs adds the "team_skills" edge to the TeamSkill entity by IDs. -func (_u *SkillUpdate) AddTeamSkillIDs(ids ...uuid.UUID) *SkillUpdate { - _u.mutation.AddTeamSkillIDs(ids...) - return _u -} - -// AddTeamSkills adds the "team_skills" edges to the TeamSkill entity. -func (_u *SkillUpdate) AddTeamSkills(v ...*TeamSkill) *SkillUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddTeamSkillIDs(ids...) -} - -// AddTeamGroupSkillIDs adds the "team_group_skills" edge to the TeamGroupSkill entity by IDs. -func (_u *SkillUpdate) AddTeamGroupSkillIDs(ids ...uuid.UUID) *SkillUpdate { - _u.mutation.AddTeamGroupSkillIDs(ids...) - return _u -} - -// AddTeamGroupSkills adds the "team_group_skills" edges to the TeamGroupSkill entity. -func (_u *SkillUpdate) AddTeamGroupSkills(v ...*TeamGroupSkill) *SkillUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddTeamGroupSkillIDs(ids...) -} - -// Mutation returns the SkillMutation object of the builder. -func (_u *SkillUpdate) Mutation() *SkillMutation { - return _u.mutation -} - -// ClearUser clears the "user" edge to the User entity. -func (_u *SkillUpdate) ClearUser() *SkillUpdate { - _u.mutation.ClearUser() - return _u -} - -// ClearTeams clears all "teams" edges to the Team entity. -func (_u *SkillUpdate) ClearTeams() *SkillUpdate { - _u.mutation.ClearTeams() - return _u -} - -// RemoveTeamIDs removes the "teams" edge to Team entities by IDs. -func (_u *SkillUpdate) RemoveTeamIDs(ids ...uuid.UUID) *SkillUpdate { - _u.mutation.RemoveTeamIDs(ids...) - return _u -} - -// RemoveTeams removes "teams" edges to Team entities. -func (_u *SkillUpdate) RemoveTeams(v ...*Team) *SkillUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveTeamIDs(ids...) -} - -// ClearGroups clears all "groups" edges to the TeamGroup entity. -func (_u *SkillUpdate) ClearGroups() *SkillUpdate { - _u.mutation.ClearGroups() - return _u -} - -// RemoveGroupIDs removes the "groups" edge to TeamGroup entities by IDs. -func (_u *SkillUpdate) RemoveGroupIDs(ids ...uuid.UUID) *SkillUpdate { - _u.mutation.RemoveGroupIDs(ids...) - return _u -} - -// RemoveGroups removes "groups" edges to TeamGroup entities. -func (_u *SkillUpdate) RemoveGroups(v ...*TeamGroup) *SkillUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveGroupIDs(ids...) -} - -// ClearTeamSkills clears all "team_skills" edges to the TeamSkill entity. -func (_u *SkillUpdate) ClearTeamSkills() *SkillUpdate { - _u.mutation.ClearTeamSkills() - return _u -} - -// RemoveTeamSkillIDs removes the "team_skills" edge to TeamSkill entities by IDs. -func (_u *SkillUpdate) RemoveTeamSkillIDs(ids ...uuid.UUID) *SkillUpdate { - _u.mutation.RemoveTeamSkillIDs(ids...) - return _u -} - -// RemoveTeamSkills removes "team_skills" edges to TeamSkill entities. -func (_u *SkillUpdate) RemoveTeamSkills(v ...*TeamSkill) *SkillUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveTeamSkillIDs(ids...) -} - -// ClearTeamGroupSkills clears all "team_group_skills" edges to the TeamGroupSkill entity. -func (_u *SkillUpdate) ClearTeamGroupSkills() *SkillUpdate { - _u.mutation.ClearTeamGroupSkills() - return _u -} - -// RemoveTeamGroupSkillIDs removes the "team_group_skills" edge to TeamGroupSkill entities by IDs. -func (_u *SkillUpdate) RemoveTeamGroupSkillIDs(ids ...uuid.UUID) *SkillUpdate { - _u.mutation.RemoveTeamGroupSkillIDs(ids...) - return _u -} - -// RemoveTeamGroupSkills removes "team_group_skills" edges to TeamGroupSkill entities. -func (_u *SkillUpdate) RemoveTeamGroupSkills(v ...*TeamGroupSkill) *SkillUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveTeamGroupSkillIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (_u *SkillUpdate) Save(ctx context.Context) (int, error) { - if err := _u.defaults(); err != nil { - return 0, err - } - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *SkillUpdate) SaveX(ctx context.Context) int { - affected, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (_u *SkillUpdate) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *SkillUpdate) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *SkillUpdate) defaults() error { - if _, ok := _u.mutation.UpdatedAt(); !ok { - if skill.UpdateDefaultUpdatedAt == nil { - return fmt.Errorf("db: uninitialized skill.UpdateDefaultUpdatedAt (forgotten import db/runtime?)") - } - v := skill.UpdateDefaultUpdatedAt() - _u.mutation.SetUpdatedAt(v) - } - return nil -} - -// check runs all checks and user-defined validators on the builder. -func (_u *SkillUpdate) check() error { - if v, ok := _u.mutation.Name(); ok { - if err := skill.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "Skill.name": %w`, err)} - } - } - if v, ok := _u.mutation.Description(); ok { - if err := skill.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`db: validator failed for field "Skill.description": %w`, err)} - } - } - if v, ok := _u.mutation.Content(); ok { - if err := skill.ContentValidator(v); err != nil { - return &ValidationError{Name: "content", err: fmt.Errorf(`db: validator failed for field "Skill.content": %w`, err)} - } - } - if v, ok := _u.mutation.SourceType(); ok { - if err := skill.SourceTypeValidator(v); err != nil { - return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "Skill.source_type": %w`, err)} - } - } - if v, ok := _u.mutation.SourceLabel(); ok { - if err := skill.SourceLabelValidator(v); err != nil { - return &ValidationError{Name: "source_label", err: fmt.Errorf(`db: validator failed for field "Skill.source_label": %w`, err)} - } - } - if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { - return errors.New(`db: clearing a required unique edge "Skill.user"`) - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *SkillUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SkillUpdate { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *SkillUpdate) sqlSave(ctx context.Context) (_node int, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(skill.Table, skill.Columns, sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID)) - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.DeletedAt(); ok { - _spec.SetField(skill.FieldDeletedAt, field.TypeTime, value) - } - if _u.mutation.DeletedAtCleared() { - _spec.ClearField(skill.FieldDeletedAt, field.TypeTime) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(skill.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(skill.FieldDescription, field.TypeString, value) - } - if value, ok := _u.mutation.Tags(); ok { - _spec.SetField(skill.FieldTags, field.TypeJSON, value) - } - if value, ok := _u.mutation.AppendedTags(); ok { - _spec.AddModifier(func(u *sql.UpdateBuilder) { - sqljson.Append(u, skill.FieldTags, value) - }) - } - if _u.mutation.TagsCleared() { - _spec.ClearField(skill.FieldTags, field.TypeJSON) - } - if value, ok := _u.mutation.Content(); ok { - _spec.SetField(skill.FieldContent, field.TypeString, value) - } - if value, ok := _u.mutation.PackageObjectKey(); ok { - _spec.SetField(skill.FieldPackageObjectKey, field.TypeString, value) - } - if _u.mutation.PackageObjectKeyCleared() { - _spec.ClearField(skill.FieldPackageObjectKey, field.TypeString) - } - if value, ok := _u.mutation.PackageURL(); ok { - _spec.SetField(skill.FieldPackageURL, field.TypeString, value) - } - if _u.mutation.PackageURLCleared() { - _spec.ClearField(skill.FieldPackageURL, field.TypeString) - } - if value, ok := _u.mutation.SourceType(); ok { - _spec.SetField(skill.FieldSourceType, field.TypeString, value) - } - if value, ok := _u.mutation.SourceLabel(); ok { - _spec.SetField(skill.FieldSourceLabel, field.TypeString, value) - } - if value, ok := _u.mutation.SkillMdPath(); ok { - _spec.SetField(skill.FieldSkillMdPath, field.TypeString, value) - } - if _u.mutation.SkillMdPathCleared() { - _spec.ClearField(skill.FieldSkillMdPath, field.TypeString) - } - if value, ok := _u.mutation.ExtensionPackageID(); ok { - _spec.SetField(skill.FieldExtensionPackageID, field.TypeString, value) - } - if _u.mutation.ExtensionPackageIDCleared() { - _spec.ClearField(skill.FieldExtensionPackageID, field.TypeString) - } - if value, ok := _u.mutation.ExtensionSkillID(); ok { - _spec.SetField(skill.FieldExtensionSkillID, field.TypeString, value) - } - if _u.mutation.ExtensionSkillIDCleared() { - _spec.ClearField(skill.FieldExtensionSkillID, field.TypeString) - } - if value, ok := _u.mutation.ExtensionVersion(); ok { - _spec.SetField(skill.FieldExtensionVersion, field.TypeString, value) - } - if _u.mutation.ExtensionVersionCleared() { - _spec.ClearField(skill.FieldExtensionVersion, field.TypeString) - } - if value, ok := _u.mutation.CreatedAt(); ok { - _spec.SetField(skill.FieldCreatedAt, field.TypeTime, value) - } - if value, ok := _u.mutation.UpdatedAt(); ok { - _spec.SetField(skill.FieldUpdatedAt, field.TypeTime, value) - } - if _u.mutation.UserCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: skill.UserTable, - Columns: []string{skill.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: skill.UserTable, - Columns: []string{skill.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.TeamsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.TeamsTable, - Columns: skill.TeamsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedTeamsIDs(); len(nodes) > 0 && !_u.mutation.TeamsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.TeamsTable, - Columns: skill.TeamsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.TeamsTable, - Columns: skill.TeamsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.GroupsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.GroupsTable, - Columns: skill.GroupsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), - }, - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedGroupsIDs(); len(nodes) > 0 && !_u.mutation.GroupsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.GroupsTable, - Columns: skill.GroupsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.GroupsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.GroupsTable, - Columns: skill.GroupsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.TeamSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamSkillsTable, - Columns: []string{skill.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedTeamSkillsIDs(); len(nodes) > 0 && !_u.mutation.TeamSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamSkillsTable, - Columns: []string{skill.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamSkillsTable, - Columns: []string{skill.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.TeamGroupSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamGroupSkillsTable, - Columns: []string{skill.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedTeamGroupSkillsIDs(); len(nodes) > 0 && !_u.mutation.TeamGroupSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamGroupSkillsTable, - Columns: []string{skill.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamGroupSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamGroupSkillsTable, - Columns: []string{skill.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{skill.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - _u.mutation.done = true - return _node, nil -} - -// SkillUpdateOne is the builder for updating a single Skill entity. -type SkillUpdateOne struct { - config - fields []string - hooks []Hook - mutation *SkillMutation - modifiers []func(*sql.UpdateBuilder) -} - -// SetDeletedAt sets the "deleted_at" field. -func (_u *SkillUpdateOne) SetDeletedAt(v time.Time) *SkillUpdateOne { - _u.mutation.SetDeletedAt(v) - return _u -} - -// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableDeletedAt(v *time.Time) *SkillUpdateOne { - if v != nil { - _u.SetDeletedAt(*v) - } - return _u -} - -// ClearDeletedAt clears the value of the "deleted_at" field. -func (_u *SkillUpdateOne) ClearDeletedAt() *SkillUpdateOne { - _u.mutation.ClearDeletedAt() - return _u -} - -// SetUserID sets the "user_id" field. -func (_u *SkillUpdateOne) SetUserID(v uuid.UUID) *SkillUpdateOne { - _u.mutation.SetUserID(v) - return _u -} - -// SetNillableUserID sets the "user_id" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableUserID(v *uuid.UUID) *SkillUpdateOne { - if v != nil { - _u.SetUserID(*v) - } - return _u -} - -// SetName sets the "name" field. -func (_u *SkillUpdateOne) SetName(v string) *SkillUpdateOne { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableName(v *string) *SkillUpdateOne { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetDescription sets the "description" field. -func (_u *SkillUpdateOne) SetDescription(v string) *SkillUpdateOne { - _u.mutation.SetDescription(v) - return _u -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableDescription(v *string) *SkillUpdateOne { - if v != nil { - _u.SetDescription(*v) - } - return _u -} - -// SetTags sets the "tags" field. -func (_u *SkillUpdateOne) SetTags(v []string) *SkillUpdateOne { - _u.mutation.SetTags(v) - return _u -} - -// AppendTags appends value to the "tags" field. -func (_u *SkillUpdateOne) AppendTags(v []string) *SkillUpdateOne { - _u.mutation.AppendTags(v) - return _u -} - -// ClearTags clears the value of the "tags" field. -func (_u *SkillUpdateOne) ClearTags() *SkillUpdateOne { - _u.mutation.ClearTags() - return _u -} - -// SetContent sets the "content" field. -func (_u *SkillUpdateOne) SetContent(v string) *SkillUpdateOne { - _u.mutation.SetContent(v) - return _u -} - -// SetNillableContent sets the "content" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableContent(v *string) *SkillUpdateOne { - if v != nil { - _u.SetContent(*v) - } - return _u -} - -// SetPackageObjectKey sets the "package_object_key" field. -func (_u *SkillUpdateOne) SetPackageObjectKey(v string) *SkillUpdateOne { - _u.mutation.SetPackageObjectKey(v) - return _u -} - -// SetNillablePackageObjectKey sets the "package_object_key" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillablePackageObjectKey(v *string) *SkillUpdateOne { - if v != nil { - _u.SetPackageObjectKey(*v) - } - return _u -} - -// ClearPackageObjectKey clears the value of the "package_object_key" field. -func (_u *SkillUpdateOne) ClearPackageObjectKey() *SkillUpdateOne { - _u.mutation.ClearPackageObjectKey() - return _u -} - -// SetPackageURL sets the "package_url" field. -func (_u *SkillUpdateOne) SetPackageURL(v string) *SkillUpdateOne { - _u.mutation.SetPackageURL(v) - return _u -} - -// SetNillablePackageURL sets the "package_url" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillablePackageURL(v *string) *SkillUpdateOne { - if v != nil { - _u.SetPackageURL(*v) - } - return _u -} - -// ClearPackageURL clears the value of the "package_url" field. -func (_u *SkillUpdateOne) ClearPackageURL() *SkillUpdateOne { - _u.mutation.ClearPackageURL() - return _u -} - -// SetSourceType sets the "source_type" field. -func (_u *SkillUpdateOne) SetSourceType(v string) *SkillUpdateOne { - _u.mutation.SetSourceType(v) - return _u -} - -// SetNillableSourceType sets the "source_type" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableSourceType(v *string) *SkillUpdateOne { - if v != nil { - _u.SetSourceType(*v) - } - return _u -} - -// SetSourceLabel sets the "source_label" field. -func (_u *SkillUpdateOne) SetSourceLabel(v string) *SkillUpdateOne { - _u.mutation.SetSourceLabel(v) - return _u -} - -// SetNillableSourceLabel sets the "source_label" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableSourceLabel(v *string) *SkillUpdateOne { - if v != nil { - _u.SetSourceLabel(*v) - } - return _u -} - -// SetSkillMdPath sets the "skill_md_path" field. -func (_u *SkillUpdateOne) SetSkillMdPath(v string) *SkillUpdateOne { - _u.mutation.SetSkillMdPath(v) - return _u -} - -// SetNillableSkillMdPath sets the "skill_md_path" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableSkillMdPath(v *string) *SkillUpdateOne { - if v != nil { - _u.SetSkillMdPath(*v) - } - return _u -} - -// ClearSkillMdPath clears the value of the "skill_md_path" field. -func (_u *SkillUpdateOne) ClearSkillMdPath() *SkillUpdateOne { - _u.mutation.ClearSkillMdPath() - return _u -} - -// SetExtensionPackageID sets the "extension_package_id" field. -func (_u *SkillUpdateOne) SetExtensionPackageID(v string) *SkillUpdateOne { - _u.mutation.SetExtensionPackageID(v) - return _u -} - -// SetNillableExtensionPackageID sets the "extension_package_id" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableExtensionPackageID(v *string) *SkillUpdateOne { - if v != nil { - _u.SetExtensionPackageID(*v) - } - return _u -} - -// ClearExtensionPackageID clears the value of the "extension_package_id" field. -func (_u *SkillUpdateOne) ClearExtensionPackageID() *SkillUpdateOne { - _u.mutation.ClearExtensionPackageID() - return _u -} - -// SetExtensionSkillID sets the "extension_skill_id" field. -func (_u *SkillUpdateOne) SetExtensionSkillID(v string) *SkillUpdateOne { - _u.mutation.SetExtensionSkillID(v) - return _u -} - -// SetNillableExtensionSkillID sets the "extension_skill_id" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableExtensionSkillID(v *string) *SkillUpdateOne { - if v != nil { - _u.SetExtensionSkillID(*v) - } - return _u -} - -// ClearExtensionSkillID clears the value of the "extension_skill_id" field. -func (_u *SkillUpdateOne) ClearExtensionSkillID() *SkillUpdateOne { - _u.mutation.ClearExtensionSkillID() - return _u -} - -// SetExtensionVersion sets the "extension_version" field. -func (_u *SkillUpdateOne) SetExtensionVersion(v string) *SkillUpdateOne { - _u.mutation.SetExtensionVersion(v) - return _u -} - -// SetNillableExtensionVersion sets the "extension_version" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableExtensionVersion(v *string) *SkillUpdateOne { - if v != nil { - _u.SetExtensionVersion(*v) - } - return _u -} - -// ClearExtensionVersion clears the value of the "extension_version" field. -func (_u *SkillUpdateOne) ClearExtensionVersion() *SkillUpdateOne { - _u.mutation.ClearExtensionVersion() - return _u -} - -// SetCreatedAt sets the "created_at" field. -func (_u *SkillUpdateOne) SetCreatedAt(v time.Time) *SkillUpdateOne { - _u.mutation.SetCreatedAt(v) - return _u -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (_u *SkillUpdateOne) SetNillableCreatedAt(v *time.Time) *SkillUpdateOne { - if v != nil { - _u.SetCreatedAt(*v) - } - return _u -} - -// SetUpdatedAt sets the "updated_at" field. -func (_u *SkillUpdateOne) SetUpdatedAt(v time.Time) *SkillUpdateOne { - _u.mutation.SetUpdatedAt(v) - return _u -} - -// SetUser sets the "user" edge to the User entity. -func (_u *SkillUpdateOne) SetUser(v *User) *SkillUpdateOne { - return _u.SetUserID(v.ID) -} - -// AddTeamIDs adds the "teams" edge to the Team entity by IDs. -func (_u *SkillUpdateOne) AddTeamIDs(ids ...uuid.UUID) *SkillUpdateOne { - _u.mutation.AddTeamIDs(ids...) - return _u -} - -// AddTeams adds the "teams" edges to the Team entity. -func (_u *SkillUpdateOne) AddTeams(v ...*Team) *SkillUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddTeamIDs(ids...) -} - -// AddGroupIDs adds the "groups" edge to the TeamGroup entity by IDs. -func (_u *SkillUpdateOne) AddGroupIDs(ids ...uuid.UUID) *SkillUpdateOne { - _u.mutation.AddGroupIDs(ids...) - return _u -} - -// AddGroups adds the "groups" edges to the TeamGroup entity. -func (_u *SkillUpdateOne) AddGroups(v ...*TeamGroup) *SkillUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddGroupIDs(ids...) -} - -// AddTeamSkillIDs adds the "team_skills" edge to the TeamSkill entity by IDs. -func (_u *SkillUpdateOne) AddTeamSkillIDs(ids ...uuid.UUID) *SkillUpdateOne { - _u.mutation.AddTeamSkillIDs(ids...) - return _u -} - -// AddTeamSkills adds the "team_skills" edges to the TeamSkill entity. -func (_u *SkillUpdateOne) AddTeamSkills(v ...*TeamSkill) *SkillUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddTeamSkillIDs(ids...) -} - -// AddTeamGroupSkillIDs adds the "team_group_skills" edge to the TeamGroupSkill entity by IDs. -func (_u *SkillUpdateOne) AddTeamGroupSkillIDs(ids ...uuid.UUID) *SkillUpdateOne { - _u.mutation.AddTeamGroupSkillIDs(ids...) - return _u -} - -// AddTeamGroupSkills adds the "team_group_skills" edges to the TeamGroupSkill entity. -func (_u *SkillUpdateOne) AddTeamGroupSkills(v ...*TeamGroupSkill) *SkillUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddTeamGroupSkillIDs(ids...) -} - -// Mutation returns the SkillMutation object of the builder. -func (_u *SkillUpdateOne) Mutation() *SkillMutation { - return _u.mutation -} - -// ClearUser clears the "user" edge to the User entity. -func (_u *SkillUpdateOne) ClearUser() *SkillUpdateOne { - _u.mutation.ClearUser() - return _u -} - -// ClearTeams clears all "teams" edges to the Team entity. -func (_u *SkillUpdateOne) ClearTeams() *SkillUpdateOne { - _u.mutation.ClearTeams() - return _u -} - -// RemoveTeamIDs removes the "teams" edge to Team entities by IDs. -func (_u *SkillUpdateOne) RemoveTeamIDs(ids ...uuid.UUID) *SkillUpdateOne { - _u.mutation.RemoveTeamIDs(ids...) - return _u -} - -// RemoveTeams removes "teams" edges to Team entities. -func (_u *SkillUpdateOne) RemoveTeams(v ...*Team) *SkillUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveTeamIDs(ids...) -} - -// ClearGroups clears all "groups" edges to the TeamGroup entity. -func (_u *SkillUpdateOne) ClearGroups() *SkillUpdateOne { - _u.mutation.ClearGroups() - return _u -} - -// RemoveGroupIDs removes the "groups" edge to TeamGroup entities by IDs. -func (_u *SkillUpdateOne) RemoveGroupIDs(ids ...uuid.UUID) *SkillUpdateOne { - _u.mutation.RemoveGroupIDs(ids...) - return _u -} - -// RemoveGroups removes "groups" edges to TeamGroup entities. -func (_u *SkillUpdateOne) RemoveGroups(v ...*TeamGroup) *SkillUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveGroupIDs(ids...) -} - -// ClearTeamSkills clears all "team_skills" edges to the TeamSkill entity. -func (_u *SkillUpdateOne) ClearTeamSkills() *SkillUpdateOne { - _u.mutation.ClearTeamSkills() - return _u -} - -// RemoveTeamSkillIDs removes the "team_skills" edge to TeamSkill entities by IDs. -func (_u *SkillUpdateOne) RemoveTeamSkillIDs(ids ...uuid.UUID) *SkillUpdateOne { - _u.mutation.RemoveTeamSkillIDs(ids...) - return _u -} - -// RemoveTeamSkills removes "team_skills" edges to TeamSkill entities. -func (_u *SkillUpdateOne) RemoveTeamSkills(v ...*TeamSkill) *SkillUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveTeamSkillIDs(ids...) -} - -// ClearTeamGroupSkills clears all "team_group_skills" edges to the TeamGroupSkill entity. -func (_u *SkillUpdateOne) ClearTeamGroupSkills() *SkillUpdateOne { - _u.mutation.ClearTeamGroupSkills() - return _u -} - -// RemoveTeamGroupSkillIDs removes the "team_group_skills" edge to TeamGroupSkill entities by IDs. -func (_u *SkillUpdateOne) RemoveTeamGroupSkillIDs(ids ...uuid.UUID) *SkillUpdateOne { - _u.mutation.RemoveTeamGroupSkillIDs(ids...) - return _u -} - -// RemoveTeamGroupSkills removes "team_group_skills" edges to TeamGroupSkill entities. -func (_u *SkillUpdateOne) RemoveTeamGroupSkills(v ...*TeamGroupSkill) *SkillUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveTeamGroupSkillIDs(ids...) -} - -// Where appends a list predicates to the SkillUpdate builder. -func (_u *SkillUpdateOne) Where(ps ...predicate.Skill) *SkillUpdateOne { - _u.mutation.Where(ps...) - return _u -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (_u *SkillUpdateOne) Select(field string, fields ...string) *SkillUpdateOne { - _u.fields = append([]string{field}, fields...) - return _u -} - -// Save executes the query and returns the updated Skill entity. -func (_u *SkillUpdateOne) Save(ctx context.Context) (*Skill, error) { - if err := _u.defaults(); err != nil { - return nil, err - } - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *SkillUpdateOne) SaveX(ctx context.Context) *Skill { - node, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (_u *SkillUpdateOne) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *SkillUpdateOne) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *SkillUpdateOne) defaults() error { - if _, ok := _u.mutation.UpdatedAt(); !ok { - if skill.UpdateDefaultUpdatedAt == nil { - return fmt.Errorf("db: uninitialized skill.UpdateDefaultUpdatedAt (forgotten import db/runtime?)") - } - v := skill.UpdateDefaultUpdatedAt() - _u.mutation.SetUpdatedAt(v) - } - return nil -} - -// check runs all checks and user-defined validators on the builder. -func (_u *SkillUpdateOne) check() error { - if v, ok := _u.mutation.Name(); ok { - if err := skill.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "Skill.name": %w`, err)} - } - } - if v, ok := _u.mutation.Description(); ok { - if err := skill.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`db: validator failed for field "Skill.description": %w`, err)} - } - } - if v, ok := _u.mutation.Content(); ok { - if err := skill.ContentValidator(v); err != nil { - return &ValidationError{Name: "content", err: fmt.Errorf(`db: validator failed for field "Skill.content": %w`, err)} - } - } - if v, ok := _u.mutation.SourceType(); ok { - if err := skill.SourceTypeValidator(v); err != nil { - return &ValidationError{Name: "source_type", err: fmt.Errorf(`db: validator failed for field "Skill.source_type": %w`, err)} - } - } - if v, ok := _u.mutation.SourceLabel(); ok { - if err := skill.SourceLabelValidator(v); err != nil { - return &ValidationError{Name: "source_label", err: fmt.Errorf(`db: validator failed for field "Skill.source_label": %w`, err)} - } - } - if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { - return errors.New(`db: clearing a required unique edge "Skill.user"`) - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *SkillUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SkillUpdateOne { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *SkillUpdateOne) sqlSave(ctx context.Context) (_node *Skill, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(skill.Table, skill.Columns, sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID)) - id, ok := _u.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "Skill.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := _u.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, skill.FieldID) - for _, f := range fields { - if !skill.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} - } - if f != skill.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.DeletedAt(); ok { - _spec.SetField(skill.FieldDeletedAt, field.TypeTime, value) - } - if _u.mutation.DeletedAtCleared() { - _spec.ClearField(skill.FieldDeletedAt, field.TypeTime) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(skill.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(skill.FieldDescription, field.TypeString, value) - } - if value, ok := _u.mutation.Tags(); ok { - _spec.SetField(skill.FieldTags, field.TypeJSON, value) - } - if value, ok := _u.mutation.AppendedTags(); ok { - _spec.AddModifier(func(u *sql.UpdateBuilder) { - sqljson.Append(u, skill.FieldTags, value) - }) - } - if _u.mutation.TagsCleared() { - _spec.ClearField(skill.FieldTags, field.TypeJSON) - } - if value, ok := _u.mutation.Content(); ok { - _spec.SetField(skill.FieldContent, field.TypeString, value) - } - if value, ok := _u.mutation.PackageObjectKey(); ok { - _spec.SetField(skill.FieldPackageObjectKey, field.TypeString, value) - } - if _u.mutation.PackageObjectKeyCleared() { - _spec.ClearField(skill.FieldPackageObjectKey, field.TypeString) - } - if value, ok := _u.mutation.PackageURL(); ok { - _spec.SetField(skill.FieldPackageURL, field.TypeString, value) - } - if _u.mutation.PackageURLCleared() { - _spec.ClearField(skill.FieldPackageURL, field.TypeString) - } - if value, ok := _u.mutation.SourceType(); ok { - _spec.SetField(skill.FieldSourceType, field.TypeString, value) - } - if value, ok := _u.mutation.SourceLabel(); ok { - _spec.SetField(skill.FieldSourceLabel, field.TypeString, value) - } - if value, ok := _u.mutation.SkillMdPath(); ok { - _spec.SetField(skill.FieldSkillMdPath, field.TypeString, value) - } - if _u.mutation.SkillMdPathCleared() { - _spec.ClearField(skill.FieldSkillMdPath, field.TypeString) - } - if value, ok := _u.mutation.ExtensionPackageID(); ok { - _spec.SetField(skill.FieldExtensionPackageID, field.TypeString, value) - } - if _u.mutation.ExtensionPackageIDCleared() { - _spec.ClearField(skill.FieldExtensionPackageID, field.TypeString) - } - if value, ok := _u.mutation.ExtensionSkillID(); ok { - _spec.SetField(skill.FieldExtensionSkillID, field.TypeString, value) - } - if _u.mutation.ExtensionSkillIDCleared() { - _spec.ClearField(skill.FieldExtensionSkillID, field.TypeString) - } - if value, ok := _u.mutation.ExtensionVersion(); ok { - _spec.SetField(skill.FieldExtensionVersion, field.TypeString, value) - } - if _u.mutation.ExtensionVersionCleared() { - _spec.ClearField(skill.FieldExtensionVersion, field.TypeString) - } - if value, ok := _u.mutation.CreatedAt(); ok { - _spec.SetField(skill.FieldCreatedAt, field.TypeTime, value) - } - if value, ok := _u.mutation.UpdatedAt(); ok { - _spec.SetField(skill.FieldUpdatedAt, field.TypeTime, value) - } - if _u.mutation.UserCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: skill.UserTable, - Columns: []string{skill.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: skill.UserTable, - Columns: []string{skill.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.TeamsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.TeamsTable, - Columns: skill.TeamsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedTeamsIDs(); len(nodes) > 0 && !_u.mutation.TeamsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.TeamsTable, - Columns: skill.TeamsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.TeamsTable, - Columns: skill.TeamsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.GroupsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.GroupsTable, - Columns: skill.GroupsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), - }, - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedGroupsIDs(); len(nodes) > 0 && !_u.mutation.GroupsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.GroupsTable, - Columns: skill.GroupsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.GroupsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: skill.GroupsTable, - Columns: skill.GroupsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.TeamSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamSkillsTable, - Columns: []string{skill.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedTeamSkillsIDs(); len(nodes) > 0 && !_u.mutation.TeamSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamSkillsTable, - Columns: []string{skill.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamSkillsTable, - Columns: []string{skill.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.TeamGroupSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamGroupSkillsTable, - Columns: []string{skill.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedTeamGroupSkillsIDs(); len(nodes) > 0 && !_u.mutation.TeamGroupSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamGroupSkillsTable, - Columns: []string{skill.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamGroupSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: skill.TeamGroupSkillsTable, - Columns: []string{skill.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - _node = &Skill{config: _u.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{skill.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - _u.mutation.done = true - return _node, nil -} diff --git a/backend/db/team.go b/backend/db/team.go index d6f1e251..eb6bfa21 100644 --- a/backend/db/team.go +++ b/backend/db/team.go @@ -54,8 +54,6 @@ type TeamEdges struct { Models []*Model `json:"models,omitempty"` // Images holds the value of the images edge. Images []*Image `json:"images,omitempty"` - // Skills holds the value of the skills edge. - Skills []*Skill `json:"skills,omitempty"` // ExtensionImageArchives holds the value of the extension_image_archives edge. ExtensionImageArchives []*TeamExtensionImageArchive `json:"extension_image_archives,omitempty"` // TeamMembers holds the value of the team_members edge. @@ -64,11 +62,9 @@ type TeamEdges struct { TeamModels []*TeamModel `json:"team_models,omitempty"` // TeamImages holds the value of the team_images edge. TeamImages []*TeamImage `json:"team_images,omitempty"` - // TeamSkills holds the value of the team_skills edge. - TeamSkills []*TeamSkill `json:"team_skills,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [10]bool + loadedTypes [8]bool } // GroupsOrErr returns the Groups value or an error if the edge @@ -107,19 +103,10 @@ func (e TeamEdges) ImagesOrErr() ([]*Image, error) { return nil, &NotLoadedError{edge: "images"} } -// SkillsOrErr returns the Skills value or an error if the edge -// was not loaded in eager-loading. -func (e TeamEdges) SkillsOrErr() ([]*Skill, error) { - if e.loadedTypes[4] { - return e.Skills, nil - } - return nil, &NotLoadedError{edge: "skills"} -} - // ExtensionImageArchivesOrErr returns the ExtensionImageArchives value or an error if the edge // was not loaded in eager-loading. func (e TeamEdges) ExtensionImageArchivesOrErr() ([]*TeamExtensionImageArchive, error) { - if e.loadedTypes[5] { + if e.loadedTypes[4] { return e.ExtensionImageArchives, nil } return nil, &NotLoadedError{edge: "extension_image_archives"} @@ -128,7 +115,7 @@ func (e TeamEdges) ExtensionImageArchivesOrErr() ([]*TeamExtensionImageArchive, // TeamMembersOrErr returns the TeamMembers value or an error if the edge // was not loaded in eager-loading. func (e TeamEdges) TeamMembersOrErr() ([]*TeamMember, error) { - if e.loadedTypes[6] { + if e.loadedTypes[5] { return e.TeamMembers, nil } return nil, &NotLoadedError{edge: "team_members"} @@ -137,7 +124,7 @@ func (e TeamEdges) TeamMembersOrErr() ([]*TeamMember, error) { // TeamModelsOrErr returns the TeamModels value or an error if the edge // was not loaded in eager-loading. func (e TeamEdges) TeamModelsOrErr() ([]*TeamModel, error) { - if e.loadedTypes[7] { + if e.loadedTypes[6] { return e.TeamModels, nil } return nil, &NotLoadedError{edge: "team_models"} @@ -146,21 +133,12 @@ func (e TeamEdges) TeamModelsOrErr() ([]*TeamModel, error) { // TeamImagesOrErr returns the TeamImages value or an error if the edge // was not loaded in eager-loading. func (e TeamEdges) TeamImagesOrErr() ([]*TeamImage, error) { - if e.loadedTypes[8] { + if e.loadedTypes[7] { return e.TeamImages, nil } return nil, &NotLoadedError{edge: "team_images"} } -// TeamSkillsOrErr returns the TeamSkills value or an error if the edge -// was not loaded in eager-loading. -func (e TeamEdges) TeamSkillsOrErr() ([]*TeamSkill, error) { - if e.loadedTypes[9] { - return e.TeamSkills, nil - } - return nil, &NotLoadedError{edge: "team_skills"} -} - // scanValues returns the types for scanning values from sql.Rows. func (*Team) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -290,11 +268,6 @@ func (_m *Team) QueryImages() *ImageQuery { return NewTeamClient(_m.config).QueryImages(_m) } -// QuerySkills queries the "skills" edge of the Team entity. -func (_m *Team) QuerySkills() *SkillQuery { - return NewTeamClient(_m.config).QuerySkills(_m) -} - // QueryExtensionImageArchives queries the "extension_image_archives" edge of the Team entity. func (_m *Team) QueryExtensionImageArchives() *TeamExtensionImageArchiveQuery { return NewTeamClient(_m.config).QueryExtensionImageArchives(_m) @@ -315,11 +288,6 @@ func (_m *Team) QueryTeamImages() *TeamImageQuery { return NewTeamClient(_m.config).QueryTeamImages(_m) } -// QueryTeamSkills queries the "team_skills" edge of the Team entity. -func (_m *Team) QueryTeamSkills() *TeamSkillQuery { - return NewTeamClient(_m.config).QueryTeamSkills(_m) -} - // Update returns a builder for updating this Team. // Note that you need to call Team.Unwrap() before calling this method if this Team // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/backend/db/team/team.go b/backend/db/team/team.go index 6efb6c2d..7b5e0818 100644 --- a/backend/db/team/team.go +++ b/backend/db/team/team.go @@ -43,8 +43,6 @@ const ( EdgeModels = "models" // EdgeImages holds the string denoting the images edge name in mutations. EdgeImages = "images" - // EdgeSkills holds the string denoting the skills edge name in mutations. - EdgeSkills = "skills" // EdgeExtensionImageArchives holds the string denoting the extension_image_archives edge name in mutations. EdgeExtensionImageArchives = "extension_image_archives" // EdgeTeamMembers holds the string denoting the team_members edge name in mutations. @@ -53,8 +51,6 @@ const ( EdgeTeamModels = "team_models" // EdgeTeamImages holds the string denoting the team_images edge name in mutations. EdgeTeamImages = "team_images" - // EdgeTeamSkills holds the string denoting the team_skills edge name in mutations. - EdgeTeamSkills = "team_skills" // Table holds the table name of the team in the database. Table = "teams" // GroupsTable is the table that holds the groups relation/edge. @@ -79,11 +75,6 @@ const ( // ImagesInverseTable is the table name for the Image entity. // It exists in this package in order to avoid circular dependency with the "image" package. ImagesInverseTable = "images" - // SkillsTable is the table that holds the skills relation/edge. The primary key declared below. - SkillsTable = "team_skills" - // SkillsInverseTable is the table name for the Skill entity. - // It exists in this package in order to avoid circular dependency with the "skill" package. - SkillsInverseTable = "skills" // ExtensionImageArchivesTable is the table that holds the extension_image_archives relation/edge. ExtensionImageArchivesTable = "team_extension_image_archives" // ExtensionImageArchivesInverseTable is the table name for the TeamExtensionImageArchive entity. @@ -112,13 +103,6 @@ const ( TeamImagesInverseTable = "team_images" // TeamImagesColumn is the table column denoting the team_images relation/edge. TeamImagesColumn = "team_id" - // TeamSkillsTable is the table that holds the team_skills relation/edge. - TeamSkillsTable = "team_skills" - // TeamSkillsInverseTable is the table name for the TeamSkill entity. - // It exists in this package in order to avoid circular dependency with the "teamskill" package. - TeamSkillsInverseTable = "team_skills" - // TeamSkillsColumn is the table column denoting the team_skills relation/edge. - TeamSkillsColumn = "team_id" ) // Columns holds all SQL columns for team fields. @@ -146,9 +130,6 @@ var ( // ImagesPrimaryKey and ImagesColumn2 are the table columns denoting the // primary key for the images relation (M2M). ImagesPrimaryKey = []string{"team_id", "image_id"} - // SkillsPrimaryKey and SkillsColumn2 are the table columns denoting the - // primary key for the skills relation (M2M). - SkillsPrimaryKey = []string{"team_id", "skill_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -303,20 +284,6 @@ func ByImages(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } -// BySkillsCount orders the results by skills count. -func BySkillsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newSkillsStep(), opts...) - } -} - -// BySkills orders the results by skills terms. -func BySkills(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSkillsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - // ByExtensionImageArchivesCount orders the results by extension_image_archives count. func ByExtensionImageArchivesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -372,20 +339,6 @@ func ByTeamImages(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newTeamImagesStep(), append([]sql.OrderTerm{term}, terms...)...) } } - -// ByTeamSkillsCount orders the results by team_skills count. -func ByTeamSkillsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newTeamSkillsStep(), opts...) - } -} - -// ByTeamSkills orders the results by team_skills terms. -func ByTeamSkills(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newTeamSkillsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} func newGroupsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -414,13 +367,6 @@ func newImagesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, false, ImagesTable, ImagesPrimaryKey...), ) } -func newSkillsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(SkillsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SkillsTable, SkillsPrimaryKey...), - ) -} func newExtensionImageArchivesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -449,10 +395,3 @@ func newTeamImagesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, true, TeamImagesTable, TeamImagesColumn), ) } -func newTeamSkillsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(TeamSkillsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, TeamSkillsTable, TeamSkillsColumn), - ) -} diff --git a/backend/db/team/where.go b/backend/db/team/where.go index c76886bd..1d015371 100644 --- a/backend/db/team/where.go +++ b/backend/db/team/where.go @@ -573,29 +573,6 @@ func HasImagesWith(preds ...predicate.Image) predicate.Team { }) } -// HasSkills applies the HasEdge predicate on the "skills" edge. -func HasSkills() predicate.Team { - return predicate.Team(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SkillsTable, SkillsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSkillsWith applies the HasEdge predicate on the "skills" edge with a given conditions (other predicates). -func HasSkillsWith(preds ...predicate.Skill) predicate.Team { - return predicate.Team(func(s *sql.Selector) { - step := newSkillsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - // HasExtensionImageArchives applies the HasEdge predicate on the "extension_image_archives" edge. func HasExtensionImageArchives() predicate.Team { return predicate.Team(func(s *sql.Selector) { @@ -688,29 +665,6 @@ func HasTeamImagesWith(preds ...predicate.TeamImage) predicate.Team { }) } -// HasTeamSkills applies the HasEdge predicate on the "team_skills" edge. -func HasTeamSkills() predicate.Team { - return predicate.Team(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, TeamSkillsTable, TeamSkillsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasTeamSkillsWith applies the HasEdge predicate on the "team_skills" edge with a given conditions (other predicates). -func HasTeamSkillsWith(preds ...predicate.TeamSkill) predicate.Team { - return predicate.Team(func(s *sql.Selector) { - step := newTeamSkillsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - // And groups predicates with the AND operator between them. func And(predicates ...predicate.Team) predicate.Team { return predicate.Team(sql.AndPredicates(predicates...)) diff --git a/backend/db/team_create.go b/backend/db/team_create.go index 0c3d52f1..f56be1e8 100644 --- a/backend/db/team_create.go +++ b/backend/db/team_create.go @@ -14,14 +14,12 @@ import ( "entgo.io/ent/schema/field" "github.com/chaitin/MonkeyCode/backend/db/image" "github.com/chaitin/MonkeyCode/backend/db/model" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/team" "github.com/chaitin/MonkeyCode/backend/db/teamextensionimagearchive" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" "github.com/chaitin/MonkeyCode/backend/db/teamimage" "github.com/chaitin/MonkeyCode/backend/db/teammember" "github.com/chaitin/MonkeyCode/backend/db/teammodel" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/google/uuid" ) @@ -224,21 +222,6 @@ func (_c *TeamCreate) AddImages(v ...*Image) *TeamCreate { return _c.AddImageIDs(ids...) } -// AddSkillIDs adds the "skills" edge to the Skill entity by IDs. -func (_c *TeamCreate) AddSkillIDs(ids ...uuid.UUID) *TeamCreate { - _c.mutation.AddSkillIDs(ids...) - return _c -} - -// AddSkills adds the "skills" edges to the Skill entity. -func (_c *TeamCreate) AddSkills(v ...*Skill) *TeamCreate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddSkillIDs(ids...) -} - // AddExtensionImageArchiveIDs adds the "extension_image_archives" edge to the TeamExtensionImageArchive entity by IDs. func (_c *TeamCreate) AddExtensionImageArchiveIDs(ids ...uuid.UUID) *TeamCreate { _c.mutation.AddExtensionImageArchiveIDs(ids...) @@ -299,21 +282,6 @@ func (_c *TeamCreate) AddTeamImages(v ...*TeamImage) *TeamCreate { return _c.AddTeamImageIDs(ids...) } -// AddTeamSkillIDs adds the "team_skills" edge to the TeamSkill entity by IDs. -func (_c *TeamCreate) AddTeamSkillIDs(ids ...uuid.UUID) *TeamCreate { - _c.mutation.AddTeamSkillIDs(ids...) - return _c -} - -// AddTeamSkills adds the "team_skills" edges to the TeamSkill entity. -func (_c *TeamCreate) AddTeamSkills(v ...*TeamSkill) *TeamCreate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddTeamSkillIDs(ids...) -} - // Mutation returns the TeamMutation object of the builder. func (_c *TeamCreate) Mutation() *TeamMutation { return _c.mutation @@ -579,26 +547,6 @@ func (_c *TeamCreate) createSpec() (*Team, *sqlgraph.CreateSpec) { edge.Target.Fields = specE.Fields _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.SkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: team.SkillsTable, - Columns: team.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamSkillCreate{config: _c.config, mutation: newTeamSkillMutation(_c.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges = append(_spec.Edges, edge) - } if nodes := _c.mutation.ExtensionImageArchivesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -663,22 +611,6 @@ func (_c *TeamCreate) createSpec() (*Team, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.TeamSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: team.TeamSkillsTable, - Columns: []string{team.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } return _node, _spec } diff --git a/backend/db/team_query.go b/backend/db/team_query.go index eab470d2..0195ba38 100644 --- a/backend/db/team_query.go +++ b/backend/db/team_query.go @@ -16,14 +16,12 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/image" "github.com/chaitin/MonkeyCode/backend/db/model" "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/team" "github.com/chaitin/MonkeyCode/backend/db/teamextensionimagearchive" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" "github.com/chaitin/MonkeyCode/backend/db/teamimage" "github.com/chaitin/MonkeyCode/backend/db/teammember" "github.com/chaitin/MonkeyCode/backend/db/teammodel" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/google/uuid" ) @@ -39,12 +37,10 @@ type TeamQuery struct { withMembers *UserQuery withModels *ModelQuery withImages *ImageQuery - withSkills *SkillQuery withExtensionImageArchives *TeamExtensionImageArchiveQuery withTeamMembers *TeamMemberQuery withTeamModels *TeamModelQuery withTeamImages *TeamImageQuery - withTeamSkills *TeamSkillQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -170,28 +166,6 @@ func (_q *TeamQuery) QueryImages() *ImageQuery { return query } -// QuerySkills chains the current query on the "skills" edge. -func (_q *TeamQuery) QuerySkills() *SkillQuery { - query := (&SkillClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(team.Table, team.FieldID, selector), - sqlgraph.To(skill.Table, skill.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, team.SkillsTable, team.SkillsPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - // QueryExtensionImageArchives chains the current query on the "extension_image_archives" edge. func (_q *TeamQuery) QueryExtensionImageArchives() *TeamExtensionImageArchiveQuery { query := (&TeamExtensionImageArchiveClient{config: _q.config}).Query() @@ -280,28 +254,6 @@ func (_q *TeamQuery) QueryTeamImages() *TeamImageQuery { return query } -// QueryTeamSkills chains the current query on the "team_skills" edge. -func (_q *TeamQuery) QueryTeamSkills() *TeamSkillQuery { - query := (&TeamSkillClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(team.Table, team.FieldID, selector), - sqlgraph.To(teamskill.Table, teamskill.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, team.TeamSkillsTable, team.TeamSkillsColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - // First returns the first Team entity from the query. // Returns a *NotFoundError when no Team was found. func (_q *TeamQuery) First(ctx context.Context) (*Team, error) { @@ -498,12 +450,10 @@ func (_q *TeamQuery) Clone() *TeamQuery { withMembers: _q.withMembers.Clone(), withModels: _q.withModels.Clone(), withImages: _q.withImages.Clone(), - withSkills: _q.withSkills.Clone(), withExtensionImageArchives: _q.withExtensionImageArchives.Clone(), withTeamMembers: _q.withTeamMembers.Clone(), withTeamModels: _q.withTeamModels.Clone(), withTeamImages: _q.withTeamImages.Clone(), - withTeamSkills: _q.withTeamSkills.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, @@ -555,17 +505,6 @@ func (_q *TeamQuery) WithImages(opts ...func(*ImageQuery)) *TeamQuery { return _q } -// WithSkills tells the query-builder to eager-load the nodes that are connected to -// the "skills" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *TeamQuery) WithSkills(opts ...func(*SkillQuery)) *TeamQuery { - query := (&SkillClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withSkills = query - return _q -} - // WithExtensionImageArchives tells the query-builder to eager-load the nodes that are connected to // the "extension_image_archives" edge. The optional arguments are used to configure the query builder of the edge. func (_q *TeamQuery) WithExtensionImageArchives(opts ...func(*TeamExtensionImageArchiveQuery)) *TeamQuery { @@ -610,17 +549,6 @@ func (_q *TeamQuery) WithTeamImages(opts ...func(*TeamImageQuery)) *TeamQuery { return _q } -// WithTeamSkills tells the query-builder to eager-load the nodes that are connected to -// the "team_skills" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *TeamQuery) WithTeamSkills(opts ...func(*TeamSkillQuery)) *TeamQuery { - query := (&TeamSkillClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withTeamSkills = query - return _q -} - // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -699,17 +627,15 @@ func (_q *TeamQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Team, e var ( nodes = []*Team{} _spec = _q.querySpec() - loadedTypes = [10]bool{ + loadedTypes = [8]bool{ _q.withGroups != nil, _q.withMembers != nil, _q.withModels != nil, _q.withImages != nil, - _q.withSkills != nil, _q.withExtensionImageArchives != nil, _q.withTeamMembers != nil, _q.withTeamModels != nil, _q.withTeamImages != nil, - _q.withTeamSkills != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -761,13 +687,6 @@ func (_q *TeamQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Team, e return nil, err } } - if query := _q.withSkills; query != nil { - if err := _q.loadSkills(ctx, query, nodes, - func(n *Team) { n.Edges.Skills = []*Skill{} }, - func(n *Team, e *Skill) { n.Edges.Skills = append(n.Edges.Skills, e) }); err != nil { - return nil, err - } - } if query := _q.withExtensionImageArchives; query != nil { if err := _q.loadExtensionImageArchives(ctx, query, nodes, func(n *Team) { n.Edges.ExtensionImageArchives = []*TeamExtensionImageArchive{} }, @@ -798,13 +717,6 @@ func (_q *TeamQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Team, e return nil, err } } - if query := _q.withTeamSkills; query != nil { - if err := _q.loadTeamSkills(ctx, query, nodes, - func(n *Team) { n.Edges.TeamSkills = []*TeamSkill{} }, - func(n *Team, e *TeamSkill) { n.Edges.TeamSkills = append(n.Edges.TeamSkills, e) }); err != nil { - return nil, err - } - } return nodes, nil } @@ -1021,67 +933,6 @@ func (_q *TeamQuery) loadImages(ctx context.Context, query *ImageQuery, nodes [] } return nil } -func (_q *TeamQuery) loadSkills(ctx context.Context, query *SkillQuery, nodes []*Team, init func(*Team), assign func(*Team, *Skill)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[uuid.UUID]*Team) - nids := make(map[uuid.UUID]map[*Team]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(team.SkillsTable) - s.Join(joinT).On(s.C(skill.FieldID), joinT.C(team.SkillsPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(team.SkillsPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(team.SkillsPrimaryKey[0])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(uuid.UUID)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := *values[0].(*uuid.UUID) - inValue := *values[1].(*uuid.UUID) - if nids[inValue] == nil { - nids[inValue] = map[*Team]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Skill](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "skills" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} func (_q *TeamQuery) loadExtensionImageArchives(ctx context.Context, query *TeamExtensionImageArchiveQuery, nodes []*Team, init func(*Team), assign func(*Team, *TeamExtensionImageArchive)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[uuid.UUID]*Team) @@ -1202,36 +1053,6 @@ func (_q *TeamQuery) loadTeamImages(ctx context.Context, query *TeamImageQuery, } return nil } -func (_q *TeamQuery) loadTeamSkills(ctx context.Context, query *TeamSkillQuery, nodes []*Team, init func(*Team), assign func(*Team, *TeamSkill)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[uuid.UUID]*Team) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(teamskill.FieldTeamID) - } - query.Where(predicate.TeamSkill(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(team.TeamSkillsColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.TeamID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "team_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} func (_q *TeamQuery) sqlCount(ctx context.Context) (int, error) { _spec := _q.querySpec() diff --git a/backend/db/team_update.go b/backend/db/team_update.go index be06e3e0..7752acd3 100644 --- a/backend/db/team_update.go +++ b/backend/db/team_update.go @@ -14,14 +14,12 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/image" "github.com/chaitin/MonkeyCode/backend/db/model" "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/team" "github.com/chaitin/MonkeyCode/backend/db/teamextensionimagearchive" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" "github.com/chaitin/MonkeyCode/backend/db/teamimage" "github.com/chaitin/MonkeyCode/backend/db/teammember" "github.com/chaitin/MonkeyCode/backend/db/teammodel" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/google/uuid" ) @@ -274,21 +272,6 @@ func (_u *TeamUpdate) AddImages(v ...*Image) *TeamUpdate { return _u.AddImageIDs(ids...) } -// AddSkillIDs adds the "skills" edge to the Skill entity by IDs. -func (_u *TeamUpdate) AddSkillIDs(ids ...uuid.UUID) *TeamUpdate { - _u.mutation.AddSkillIDs(ids...) - return _u -} - -// AddSkills adds the "skills" edges to the Skill entity. -func (_u *TeamUpdate) AddSkills(v ...*Skill) *TeamUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddSkillIDs(ids...) -} - // AddExtensionImageArchiveIDs adds the "extension_image_archives" edge to the TeamExtensionImageArchive entity by IDs. func (_u *TeamUpdate) AddExtensionImageArchiveIDs(ids ...uuid.UUID) *TeamUpdate { _u.mutation.AddExtensionImageArchiveIDs(ids...) @@ -349,21 +332,6 @@ func (_u *TeamUpdate) AddTeamImages(v ...*TeamImage) *TeamUpdate { return _u.AddTeamImageIDs(ids...) } -// AddTeamSkillIDs adds the "team_skills" edge to the TeamSkill entity by IDs. -func (_u *TeamUpdate) AddTeamSkillIDs(ids ...uuid.UUID) *TeamUpdate { - _u.mutation.AddTeamSkillIDs(ids...) - return _u -} - -// AddTeamSkills adds the "team_skills" edges to the TeamSkill entity. -func (_u *TeamUpdate) AddTeamSkills(v ...*TeamSkill) *TeamUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddTeamSkillIDs(ids...) -} - // Mutation returns the TeamMutation object of the builder. func (_u *TeamUpdate) Mutation() *TeamMutation { return _u.mutation @@ -453,27 +421,6 @@ func (_u *TeamUpdate) RemoveImages(v ...*Image) *TeamUpdate { return _u.RemoveImageIDs(ids...) } -// ClearSkills clears all "skills" edges to the Skill entity. -func (_u *TeamUpdate) ClearSkills() *TeamUpdate { - _u.mutation.ClearSkills() - return _u -} - -// RemoveSkillIDs removes the "skills" edge to Skill entities by IDs. -func (_u *TeamUpdate) RemoveSkillIDs(ids ...uuid.UUID) *TeamUpdate { - _u.mutation.RemoveSkillIDs(ids...) - return _u -} - -// RemoveSkills removes "skills" edges to Skill entities. -func (_u *TeamUpdate) RemoveSkills(v ...*Skill) *TeamUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveSkillIDs(ids...) -} - // ClearExtensionImageArchives clears all "extension_image_archives" edges to the TeamExtensionImageArchive entity. func (_u *TeamUpdate) ClearExtensionImageArchives() *TeamUpdate { _u.mutation.ClearExtensionImageArchives() @@ -558,27 +505,6 @@ func (_u *TeamUpdate) RemoveTeamImages(v ...*TeamImage) *TeamUpdate { return _u.RemoveTeamImageIDs(ids...) } -// ClearTeamSkills clears all "team_skills" edges to the TeamSkill entity. -func (_u *TeamUpdate) ClearTeamSkills() *TeamUpdate { - _u.mutation.ClearTeamSkills() - return _u -} - -// RemoveTeamSkillIDs removes the "team_skills" edge to TeamSkill entities by IDs. -func (_u *TeamUpdate) RemoveTeamSkillIDs(ids ...uuid.UUID) *TeamUpdate { - _u.mutation.RemoveTeamSkillIDs(ids...) - return _u -} - -// RemoveTeamSkills removes "team_skills" edges to TeamSkill entities. -func (_u *TeamUpdate) RemoveTeamSkills(v ...*TeamSkill) *TeamUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveTeamSkillIDs(ids...) -} - // Save executes the query and returns the number of nodes affected by the update operation. func (_u *TeamUpdate) Save(ctx context.Context) (int, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) @@ -900,63 +826,6 @@ func (_u *TeamUpdate) sqlSave(ctx context.Context) (_node int, err error) { edge.Target.Fields = specE.Fields _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: team.SkillsTable, - Columns: team.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedSkillsIDs(); len(nodes) > 0 && !_u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: team.SkillsTable, - Columns: team.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.SkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: team.SkillsTable, - Columns: team.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } if _u.mutation.ExtensionImageArchivesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -1137,51 +1006,6 @@ func (_u *TeamUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.TeamSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: team.TeamSkillsTable, - Columns: []string{team.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedTeamSkillsIDs(); len(nodes) > 0 && !_u.mutation.TeamSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: team.TeamSkillsTable, - Columns: []string{team.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: team.TeamSkillsTable, - Columns: []string{team.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } _spec.AddModifiers(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -1438,21 +1262,6 @@ func (_u *TeamUpdateOne) AddImages(v ...*Image) *TeamUpdateOne { return _u.AddImageIDs(ids...) } -// AddSkillIDs adds the "skills" edge to the Skill entity by IDs. -func (_u *TeamUpdateOne) AddSkillIDs(ids ...uuid.UUID) *TeamUpdateOne { - _u.mutation.AddSkillIDs(ids...) - return _u -} - -// AddSkills adds the "skills" edges to the Skill entity. -func (_u *TeamUpdateOne) AddSkills(v ...*Skill) *TeamUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddSkillIDs(ids...) -} - // AddExtensionImageArchiveIDs adds the "extension_image_archives" edge to the TeamExtensionImageArchive entity by IDs. func (_u *TeamUpdateOne) AddExtensionImageArchiveIDs(ids ...uuid.UUID) *TeamUpdateOne { _u.mutation.AddExtensionImageArchiveIDs(ids...) @@ -1513,21 +1322,6 @@ func (_u *TeamUpdateOne) AddTeamImages(v ...*TeamImage) *TeamUpdateOne { return _u.AddTeamImageIDs(ids...) } -// AddTeamSkillIDs adds the "team_skills" edge to the TeamSkill entity by IDs. -func (_u *TeamUpdateOne) AddTeamSkillIDs(ids ...uuid.UUID) *TeamUpdateOne { - _u.mutation.AddTeamSkillIDs(ids...) - return _u -} - -// AddTeamSkills adds the "team_skills" edges to the TeamSkill entity. -func (_u *TeamUpdateOne) AddTeamSkills(v ...*TeamSkill) *TeamUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddTeamSkillIDs(ids...) -} - // Mutation returns the TeamMutation object of the builder. func (_u *TeamUpdateOne) Mutation() *TeamMutation { return _u.mutation @@ -1617,27 +1411,6 @@ func (_u *TeamUpdateOne) RemoveImages(v ...*Image) *TeamUpdateOne { return _u.RemoveImageIDs(ids...) } -// ClearSkills clears all "skills" edges to the Skill entity. -func (_u *TeamUpdateOne) ClearSkills() *TeamUpdateOne { - _u.mutation.ClearSkills() - return _u -} - -// RemoveSkillIDs removes the "skills" edge to Skill entities by IDs. -func (_u *TeamUpdateOne) RemoveSkillIDs(ids ...uuid.UUID) *TeamUpdateOne { - _u.mutation.RemoveSkillIDs(ids...) - return _u -} - -// RemoveSkills removes "skills" edges to Skill entities. -func (_u *TeamUpdateOne) RemoveSkills(v ...*Skill) *TeamUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveSkillIDs(ids...) -} - // ClearExtensionImageArchives clears all "extension_image_archives" edges to the TeamExtensionImageArchive entity. func (_u *TeamUpdateOne) ClearExtensionImageArchives() *TeamUpdateOne { _u.mutation.ClearExtensionImageArchives() @@ -1722,27 +1495,6 @@ func (_u *TeamUpdateOne) RemoveTeamImages(v ...*TeamImage) *TeamUpdateOne { return _u.RemoveTeamImageIDs(ids...) } -// ClearTeamSkills clears all "team_skills" edges to the TeamSkill entity. -func (_u *TeamUpdateOne) ClearTeamSkills() *TeamUpdateOne { - _u.mutation.ClearTeamSkills() - return _u -} - -// RemoveTeamSkillIDs removes the "team_skills" edge to TeamSkill entities by IDs. -func (_u *TeamUpdateOne) RemoveTeamSkillIDs(ids ...uuid.UUID) *TeamUpdateOne { - _u.mutation.RemoveTeamSkillIDs(ids...) - return _u -} - -// RemoveTeamSkills removes "team_skills" edges to TeamSkill entities. -func (_u *TeamUpdateOne) RemoveTeamSkills(v ...*TeamSkill) *TeamUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveTeamSkillIDs(ids...) -} - // Where appends a list predicates to the TeamUpdate builder. func (_u *TeamUpdateOne) Where(ps ...predicate.Team) *TeamUpdateOne { _u.mutation.Where(ps...) @@ -2094,63 +1846,6 @@ func (_u *TeamUpdateOne) sqlSave(ctx context.Context) (_node *Team, err error) { edge.Target.Fields = specE.Fields _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: team.SkillsTable, - Columns: team.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedSkillsIDs(); len(nodes) > 0 && !_u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: team.SkillsTable, - Columns: team.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.SkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: team.SkillsTable, - Columns: team.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamSkillCreate{config: _u.config, mutation: newTeamSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } if _u.mutation.ExtensionImageArchivesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -2331,51 +2026,6 @@ func (_u *TeamUpdateOne) sqlSave(ctx context.Context) (_node *Team, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.TeamSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: team.TeamSkillsTable, - Columns: []string{team.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedTeamSkillsIDs(); len(nodes) > 0 && !_u.mutation.TeamSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: team.TeamSkillsTable, - Columns: []string{team.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: team.TeamSkillsTable, - Columns: []string{team.TeamSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } _spec.AddModifiers(_u.modifiers...) _node = &Team{config: _u.config} _spec.Assign = _node.assignValues diff --git a/backend/db/teamgroup.go b/backend/db/teamgroup.go index b8b67492..8c7c21bd 100644 --- a/backend/db/teamgroup.go +++ b/backend/db/teamgroup.go @@ -47,8 +47,6 @@ type TeamGroupEdges struct { Images []*Image `json:"images,omitempty"` // Hosts holds the value of the hosts edge. Hosts []*Host `json:"hosts,omitempty"` - // Skills holds the value of the skills edge. - Skills []*Skill `json:"skills,omitempty"` // TeamGroupMembers holds the value of the team_group_members edge. TeamGroupMembers []*TeamGroupMember `json:"team_group_members,omitempty"` // TeamGroupModels holds the value of the team_group_models edge. @@ -57,11 +55,9 @@ type TeamGroupEdges struct { TeamGroupImages []*TeamGroupImage `json:"team_group_images,omitempty"` // TeamGroupHosts holds the value of the team_group_hosts edge. TeamGroupHosts []*TeamGroupHost `json:"team_group_hosts,omitempty"` - // TeamGroupSkills holds the value of the team_group_skills edge. - TeamGroupSkills []*TeamGroupSkill `json:"team_group_skills,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [11]bool + loadedTypes [9]bool } // MembersOrErr returns the Members value or an error if the edge @@ -111,19 +107,10 @@ func (e TeamGroupEdges) HostsOrErr() ([]*Host, error) { return nil, &NotLoadedError{edge: "hosts"} } -// SkillsOrErr returns the Skills value or an error if the edge -// was not loaded in eager-loading. -func (e TeamGroupEdges) SkillsOrErr() ([]*Skill, error) { - if e.loadedTypes[5] { - return e.Skills, nil - } - return nil, &NotLoadedError{edge: "skills"} -} - // TeamGroupMembersOrErr returns the TeamGroupMembers value or an error if the edge // was not loaded in eager-loading. func (e TeamGroupEdges) TeamGroupMembersOrErr() ([]*TeamGroupMember, error) { - if e.loadedTypes[6] { + if e.loadedTypes[5] { return e.TeamGroupMembers, nil } return nil, &NotLoadedError{edge: "team_group_members"} @@ -132,7 +119,7 @@ func (e TeamGroupEdges) TeamGroupMembersOrErr() ([]*TeamGroupMember, error) { // TeamGroupModelsOrErr returns the TeamGroupModels value or an error if the edge // was not loaded in eager-loading. func (e TeamGroupEdges) TeamGroupModelsOrErr() ([]*TeamGroupModel, error) { - if e.loadedTypes[7] { + if e.loadedTypes[6] { return e.TeamGroupModels, nil } return nil, &NotLoadedError{edge: "team_group_models"} @@ -141,7 +128,7 @@ func (e TeamGroupEdges) TeamGroupModelsOrErr() ([]*TeamGroupModel, error) { // TeamGroupImagesOrErr returns the TeamGroupImages value or an error if the edge // was not loaded in eager-loading. func (e TeamGroupEdges) TeamGroupImagesOrErr() ([]*TeamGroupImage, error) { - if e.loadedTypes[8] { + if e.loadedTypes[7] { return e.TeamGroupImages, nil } return nil, &NotLoadedError{edge: "team_group_images"} @@ -150,21 +137,12 @@ func (e TeamGroupEdges) TeamGroupImagesOrErr() ([]*TeamGroupImage, error) { // TeamGroupHostsOrErr returns the TeamGroupHosts value or an error if the edge // was not loaded in eager-loading. func (e TeamGroupEdges) TeamGroupHostsOrErr() ([]*TeamGroupHost, error) { - if e.loadedTypes[9] { + if e.loadedTypes[8] { return e.TeamGroupHosts, nil } return nil, &NotLoadedError{edge: "team_group_hosts"} } -// TeamGroupSkillsOrErr returns the TeamGroupSkills value or an error if the edge -// was not loaded in eager-loading. -func (e TeamGroupEdges) TeamGroupSkillsOrErr() ([]*TeamGroupSkill, error) { - if e.loadedTypes[10] { - return e.TeamGroupSkills, nil - } - return nil, &NotLoadedError{edge: "team_group_skills"} -} - // scanValues returns the types for scanning values from sql.Rows. func (*TeamGroup) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -265,11 +243,6 @@ func (_m *TeamGroup) QueryHosts() *HostQuery { return NewTeamGroupClient(_m.config).QueryHosts(_m) } -// QuerySkills queries the "skills" edge of the TeamGroup entity. -func (_m *TeamGroup) QuerySkills() *SkillQuery { - return NewTeamGroupClient(_m.config).QuerySkills(_m) -} - // QueryTeamGroupMembers queries the "team_group_members" edge of the TeamGroup entity. func (_m *TeamGroup) QueryTeamGroupMembers() *TeamGroupMemberQuery { return NewTeamGroupClient(_m.config).QueryTeamGroupMembers(_m) @@ -290,11 +263,6 @@ func (_m *TeamGroup) QueryTeamGroupHosts() *TeamGroupHostQuery { return NewTeamGroupClient(_m.config).QueryTeamGroupHosts(_m) } -// QueryTeamGroupSkills queries the "team_group_skills" edge of the TeamGroup entity. -func (_m *TeamGroup) QueryTeamGroupSkills() *TeamGroupSkillQuery { - return NewTeamGroupClient(_m.config).QueryTeamGroupSkills(_m) -} - // Update returns a builder for updating this TeamGroup. // Note that you need to call TeamGroup.Unwrap() before calling this method if this TeamGroup // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/backend/db/teamgroup/teamgroup.go b/backend/db/teamgroup/teamgroup.go index 77707ea3..d71ec41b 100644 --- a/backend/db/teamgroup/teamgroup.go +++ b/backend/db/teamgroup/teamgroup.go @@ -35,8 +35,6 @@ const ( EdgeImages = "images" // EdgeHosts holds the string denoting the hosts edge name in mutations. EdgeHosts = "hosts" - // EdgeSkills holds the string denoting the skills edge name in mutations. - EdgeSkills = "skills" // EdgeTeamGroupMembers holds the string denoting the team_group_members edge name in mutations. EdgeTeamGroupMembers = "team_group_members" // EdgeTeamGroupModels holds the string denoting the team_group_models edge name in mutations. @@ -45,8 +43,6 @@ const ( EdgeTeamGroupImages = "team_group_images" // EdgeTeamGroupHosts holds the string denoting the team_group_hosts edge name in mutations. EdgeTeamGroupHosts = "team_group_hosts" - // EdgeTeamGroupSkills holds the string denoting the team_group_skills edge name in mutations. - EdgeTeamGroupSkills = "team_group_skills" // Table holds the table name of the teamgroup in the database. Table = "team_groups" // MembersTable is the table that holds the members relation/edge. The primary key declared below. @@ -76,11 +72,6 @@ const ( // HostsInverseTable is the table name for the Host entity. // It exists in this package in order to avoid circular dependency with the "host" package. HostsInverseTable = "hosts" - // SkillsTable is the table that holds the skills relation/edge. The primary key declared below. - SkillsTable = "team_group_skills" - // SkillsInverseTable is the table name for the Skill entity. - // It exists in this package in order to avoid circular dependency with the "skill" package. - SkillsInverseTable = "skills" // TeamGroupMembersTable is the table that holds the team_group_members relation/edge. TeamGroupMembersTable = "team_group_members" // TeamGroupMembersInverseTable is the table name for the TeamGroupMember entity. @@ -109,13 +100,6 @@ const ( TeamGroupHostsInverseTable = "team_group_hosts" // TeamGroupHostsColumn is the table column denoting the team_group_hosts relation/edge. TeamGroupHostsColumn = "group_id" - // TeamGroupSkillsTable is the table that holds the team_group_skills relation/edge. - TeamGroupSkillsTable = "team_group_skills" - // TeamGroupSkillsInverseTable is the table name for the TeamGroupSkill entity. - // It exists in this package in order to avoid circular dependency with the "teamgroupskill" package. - TeamGroupSkillsInverseTable = "team_group_skills" - // TeamGroupSkillsColumn is the table column denoting the team_group_skills relation/edge. - TeamGroupSkillsColumn = "group_id" ) // Columns holds all SQL columns for teamgroup fields. @@ -141,9 +125,6 @@ var ( // HostsPrimaryKey and HostsColumn2 are the table columns denoting the // primary key for the hosts relation (M2M). HostsPrimaryKey = []string{"group_id", "host_id"} - // SkillsPrimaryKey and SkillsColumn2 are the table columns denoting the - // primary key for the skills relation (M2M). - SkillsPrimaryKey = []string{"group_id", "skill_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -268,20 +249,6 @@ func ByHosts(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } -// BySkillsCount orders the results by skills count. -func BySkillsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newSkillsStep(), opts...) - } -} - -// BySkills orders the results by skills terms. -func BySkills(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSkillsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - // ByTeamGroupMembersCount orders the results by team_group_members count. func ByTeamGroupMembersCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -337,20 +304,6 @@ func ByTeamGroupHosts(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newTeamGroupHostsStep(), append([]sql.OrderTerm{term}, terms...)...) } } - -// ByTeamGroupSkillsCount orders the results by team_group_skills count. -func ByTeamGroupSkillsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newTeamGroupSkillsStep(), opts...) - } -} - -// ByTeamGroupSkills orders the results by team_group_skills terms. -func ByTeamGroupSkills(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newTeamGroupSkillsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} func newMembersStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -386,13 +339,6 @@ func newHostsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, false, HostsTable, HostsPrimaryKey...), ) } -func newSkillsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(SkillsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SkillsTable, SkillsPrimaryKey...), - ) -} func newTeamGroupMembersStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -421,10 +367,3 @@ func newTeamGroupHostsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, true, TeamGroupHostsTable, TeamGroupHostsColumn), ) } -func newTeamGroupSkillsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(TeamGroupSkillsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, TeamGroupSkillsTable, TeamGroupSkillsColumn), - ) -} diff --git a/backend/db/teamgroup/where.go b/backend/db/teamgroup/where.go index ef994886..93e7954a 100644 --- a/backend/db/teamgroup/where.go +++ b/backend/db/teamgroup/where.go @@ -411,29 +411,6 @@ func HasHostsWith(preds ...predicate.Host) predicate.TeamGroup { }) } -// HasSkills applies the HasEdge predicate on the "skills" edge. -func HasSkills() predicate.TeamGroup { - return predicate.TeamGroup(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SkillsTable, SkillsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSkillsWith applies the HasEdge predicate on the "skills" edge with a given conditions (other predicates). -func HasSkillsWith(preds ...predicate.Skill) predicate.TeamGroup { - return predicate.TeamGroup(func(s *sql.Selector) { - step := newSkillsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - // HasTeamGroupMembers applies the HasEdge predicate on the "team_group_members" edge. func HasTeamGroupMembers() predicate.TeamGroup { return predicate.TeamGroup(func(s *sql.Selector) { @@ -526,29 +503,6 @@ func HasTeamGroupHostsWith(preds ...predicate.TeamGroupHost) predicate.TeamGroup }) } -// HasTeamGroupSkills applies the HasEdge predicate on the "team_group_skills" edge. -func HasTeamGroupSkills() predicate.TeamGroup { - return predicate.TeamGroup(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, TeamGroupSkillsTable, TeamGroupSkillsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasTeamGroupSkillsWith applies the HasEdge predicate on the "team_group_skills" edge with a given conditions (other predicates). -func HasTeamGroupSkillsWith(preds ...predicate.TeamGroupSkill) predicate.TeamGroup { - return predicate.TeamGroup(func(s *sql.Selector) { - step := newTeamGroupSkillsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - // And groups predicates with the AND operator between them. func And(predicates ...predicate.TeamGroup) predicate.TeamGroup { return predicate.TeamGroup(sql.AndPredicates(predicates...)) diff --git a/backend/db/teamgroup_create.go b/backend/db/teamgroup_create.go index 8fb6cdfd..0adb5a5e 100644 --- a/backend/db/teamgroup_create.go +++ b/backend/db/teamgroup_create.go @@ -15,14 +15,12 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/host" "github.com/chaitin/MonkeyCode/backend/db/image" "github.com/chaitin/MonkeyCode/backend/db/model" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/team" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" "github.com/chaitin/MonkeyCode/backend/db/teamgrouphost" "github.com/chaitin/MonkeyCode/backend/db/teamgroupimage" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmember" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/google/uuid" ) @@ -160,21 +158,6 @@ func (_c *TeamGroupCreate) AddHosts(v ...*Host) *TeamGroupCreate { return _c.AddHostIDs(ids...) } -// AddSkillIDs adds the "skills" edge to the Skill entity by IDs. -func (_c *TeamGroupCreate) AddSkillIDs(ids ...uuid.UUID) *TeamGroupCreate { - _c.mutation.AddSkillIDs(ids...) - return _c -} - -// AddSkills adds the "skills" edges to the Skill entity. -func (_c *TeamGroupCreate) AddSkills(v ...*Skill) *TeamGroupCreate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddSkillIDs(ids...) -} - // AddTeamGroupMemberIDs adds the "team_group_members" edge to the TeamGroupMember entity by IDs. func (_c *TeamGroupCreate) AddTeamGroupMemberIDs(ids ...uuid.UUID) *TeamGroupCreate { _c.mutation.AddTeamGroupMemberIDs(ids...) @@ -235,21 +218,6 @@ func (_c *TeamGroupCreate) AddTeamGroupHosts(v ...*TeamGroupHost) *TeamGroupCrea return _c.AddTeamGroupHostIDs(ids...) } -// AddTeamGroupSkillIDs adds the "team_group_skills" edge to the TeamGroupSkill entity by IDs. -func (_c *TeamGroupCreate) AddTeamGroupSkillIDs(ids ...uuid.UUID) *TeamGroupCreate { - _c.mutation.AddTeamGroupSkillIDs(ids...) - return _c -} - -// AddTeamGroupSkills adds the "team_group_skills" edges to the TeamGroupSkill entity. -func (_c *TeamGroupCreate) AddTeamGroupSkills(v ...*TeamGroupSkill) *TeamGroupCreate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddTeamGroupSkillIDs(ids...) -} - // Mutation returns the TeamGroupMutation object of the builder. func (_c *TeamGroupCreate) Mutation() *TeamGroupMutation { return _c.mutation @@ -470,26 +438,6 @@ func (_c *TeamGroupCreate) createSpec() (*TeamGroup, *sqlgraph.CreateSpec) { edge.Target.Fields = specE.Fields _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.SkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: teamgroup.SkillsTable, - Columns: teamgroup.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamGroupSkillCreate{config: _c.config, mutation: newTeamGroupSkillMutation(_c.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges = append(_spec.Edges, edge) - } if nodes := _c.mutation.TeamGroupMembersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -554,22 +502,6 @@ func (_c *TeamGroupCreate) createSpec() (*TeamGroup, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.TeamGroupSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: teamgroup.TeamGroupSkillsTable, - Columns: []string{teamgroup.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } return _node, _spec } diff --git a/backend/db/teamgroup_query.go b/backend/db/teamgroup_query.go index 5ec664b6..794b1caf 100644 --- a/backend/db/teamgroup_query.go +++ b/backend/db/teamgroup_query.go @@ -17,14 +17,12 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/image" "github.com/chaitin/MonkeyCode/backend/db/model" "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/team" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" "github.com/chaitin/MonkeyCode/backend/db/teamgrouphost" "github.com/chaitin/MonkeyCode/backend/db/teamgroupimage" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmember" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/google/uuid" ) @@ -41,12 +39,10 @@ type TeamGroupQuery struct { withModels *ModelQuery withImages *ImageQuery withHosts *HostQuery - withSkills *SkillQuery withTeamGroupMembers *TeamGroupMemberQuery withTeamGroupModels *TeamGroupModelQuery withTeamGroupImages *TeamGroupImageQuery withTeamGroupHosts *TeamGroupHostQuery - withTeamGroupSkills *TeamGroupSkillQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -194,28 +190,6 @@ func (_q *TeamGroupQuery) QueryHosts() *HostQuery { return query } -// QuerySkills chains the current query on the "skills" edge. -func (_q *TeamGroupQuery) QuerySkills() *SkillQuery { - query := (&SkillClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(teamgroup.Table, teamgroup.FieldID, selector), - sqlgraph.To(skill.Table, skill.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, teamgroup.SkillsTable, teamgroup.SkillsPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - // QueryTeamGroupMembers chains the current query on the "team_group_members" edge. func (_q *TeamGroupQuery) QueryTeamGroupMembers() *TeamGroupMemberQuery { query := (&TeamGroupMemberClient{config: _q.config}).Query() @@ -304,28 +278,6 @@ func (_q *TeamGroupQuery) QueryTeamGroupHosts() *TeamGroupHostQuery { return query } -// QueryTeamGroupSkills chains the current query on the "team_group_skills" edge. -func (_q *TeamGroupQuery) QueryTeamGroupSkills() *TeamGroupSkillQuery { - query := (&TeamGroupSkillClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(teamgroup.Table, teamgroup.FieldID, selector), - sqlgraph.To(teamgroupskill.Table, teamgroupskill.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, teamgroup.TeamGroupSkillsTable, teamgroup.TeamGroupSkillsColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - // First returns the first TeamGroup entity from the query. // Returns a *NotFoundError when no TeamGroup was found. func (_q *TeamGroupQuery) First(ctx context.Context) (*TeamGroup, error) { @@ -523,12 +475,10 @@ func (_q *TeamGroupQuery) Clone() *TeamGroupQuery { withModels: _q.withModels.Clone(), withImages: _q.withImages.Clone(), withHosts: _q.withHosts.Clone(), - withSkills: _q.withSkills.Clone(), withTeamGroupMembers: _q.withTeamGroupMembers.Clone(), withTeamGroupModels: _q.withTeamGroupModels.Clone(), withTeamGroupImages: _q.withTeamGroupImages.Clone(), withTeamGroupHosts: _q.withTeamGroupHosts.Clone(), - withTeamGroupSkills: _q.withTeamGroupSkills.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, @@ -591,17 +541,6 @@ func (_q *TeamGroupQuery) WithHosts(opts ...func(*HostQuery)) *TeamGroupQuery { return _q } -// WithSkills tells the query-builder to eager-load the nodes that are connected to -// the "skills" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *TeamGroupQuery) WithSkills(opts ...func(*SkillQuery)) *TeamGroupQuery { - query := (&SkillClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withSkills = query - return _q -} - // WithTeamGroupMembers tells the query-builder to eager-load the nodes that are connected to // the "team_group_members" edge. The optional arguments are used to configure the query builder of the edge. func (_q *TeamGroupQuery) WithTeamGroupMembers(opts ...func(*TeamGroupMemberQuery)) *TeamGroupQuery { @@ -646,17 +585,6 @@ func (_q *TeamGroupQuery) WithTeamGroupHosts(opts ...func(*TeamGroupHostQuery)) return _q } -// WithTeamGroupSkills tells the query-builder to eager-load the nodes that are connected to -// the "team_group_skills" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *TeamGroupQuery) WithTeamGroupSkills(opts ...func(*TeamGroupSkillQuery)) *TeamGroupQuery { - query := (&TeamGroupSkillClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withTeamGroupSkills = query - return _q -} - // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -735,18 +663,16 @@ func (_q *TeamGroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Te var ( nodes = []*TeamGroup{} _spec = _q.querySpec() - loadedTypes = [11]bool{ + loadedTypes = [9]bool{ _q.withMembers != nil, _q.withTeam != nil, _q.withModels != nil, _q.withImages != nil, _q.withHosts != nil, - _q.withSkills != nil, _q.withTeamGroupMembers != nil, _q.withTeamGroupModels != nil, _q.withTeamGroupImages != nil, _q.withTeamGroupHosts != nil, - _q.withTeamGroupSkills != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -804,13 +730,6 @@ func (_q *TeamGroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Te return nil, err } } - if query := _q.withSkills; query != nil { - if err := _q.loadSkills(ctx, query, nodes, - func(n *TeamGroup) { n.Edges.Skills = []*Skill{} }, - func(n *TeamGroup, e *Skill) { n.Edges.Skills = append(n.Edges.Skills, e) }); err != nil { - return nil, err - } - } if query := _q.withTeamGroupMembers; query != nil { if err := _q.loadTeamGroupMembers(ctx, query, nodes, func(n *TeamGroup) { n.Edges.TeamGroupMembers = []*TeamGroupMember{} }, @@ -839,13 +758,6 @@ func (_q *TeamGroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Te return nil, err } } - if query := _q.withTeamGroupSkills; query != nil { - if err := _q.loadTeamGroupSkills(ctx, query, nodes, - func(n *TeamGroup) { n.Edges.TeamGroupSkills = []*TeamGroupSkill{} }, - func(n *TeamGroup, e *TeamGroupSkill) { n.Edges.TeamGroupSkills = append(n.Edges.TeamGroupSkills, e) }); err != nil { - return nil, err - } - } return nodes, nil } @@ -1122,67 +1034,6 @@ func (_q *TeamGroupQuery) loadHosts(ctx context.Context, query *HostQuery, nodes } return nil } -func (_q *TeamGroupQuery) loadSkills(ctx context.Context, query *SkillQuery, nodes []*TeamGroup, init func(*TeamGroup), assign func(*TeamGroup, *Skill)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[uuid.UUID]*TeamGroup) - nids := make(map[uuid.UUID]map[*TeamGroup]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(teamgroup.SkillsTable) - s.Join(joinT).On(s.C(skill.FieldID), joinT.C(teamgroup.SkillsPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(teamgroup.SkillsPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(teamgroup.SkillsPrimaryKey[0])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(uuid.UUID)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := *values[0].(*uuid.UUID) - inValue := *values[1].(*uuid.UUID) - if nids[inValue] == nil { - nids[inValue] = map[*TeamGroup]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Skill](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "skills" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} func (_q *TeamGroupQuery) loadTeamGroupMembers(ctx context.Context, query *TeamGroupMemberQuery, nodes []*TeamGroup, init func(*TeamGroup), assign func(*TeamGroup, *TeamGroupMember)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[uuid.UUID]*TeamGroup) @@ -1303,36 +1154,6 @@ func (_q *TeamGroupQuery) loadTeamGroupHosts(ctx context.Context, query *TeamGro } return nil } -func (_q *TeamGroupQuery) loadTeamGroupSkills(ctx context.Context, query *TeamGroupSkillQuery, nodes []*TeamGroup, init func(*TeamGroup), assign func(*TeamGroup, *TeamGroupSkill)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[uuid.UUID]*TeamGroup) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(teamgroupskill.FieldGroupID) - } - query.Where(predicate.TeamGroupSkill(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(teamgroup.TeamGroupSkillsColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.GroupID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "group_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} func (_q *TeamGroupQuery) sqlCount(ctx context.Context) (int, error) { _spec := _q.querySpec() diff --git a/backend/db/teamgroup_update.go b/backend/db/teamgroup_update.go index c29bf7f3..85457c84 100644 --- a/backend/db/teamgroup_update.go +++ b/backend/db/teamgroup_update.go @@ -15,14 +15,12 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/image" "github.com/chaitin/MonkeyCode/backend/db/model" "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/team" "github.com/chaitin/MonkeyCode/backend/db/teamgroup" "github.com/chaitin/MonkeyCode/backend/db/teamgrouphost" "github.com/chaitin/MonkeyCode/backend/db/teamgroupimage" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmember" "github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel" - "github.com/chaitin/MonkeyCode/backend/db/teamgroupskill" "github.com/chaitin/MonkeyCode/backend/db/user" "github.com/google/uuid" ) @@ -174,21 +172,6 @@ func (_u *TeamGroupUpdate) AddHosts(v ...*Host) *TeamGroupUpdate { return _u.AddHostIDs(ids...) } -// AddSkillIDs adds the "skills" edge to the Skill entity by IDs. -func (_u *TeamGroupUpdate) AddSkillIDs(ids ...uuid.UUID) *TeamGroupUpdate { - _u.mutation.AddSkillIDs(ids...) - return _u -} - -// AddSkills adds the "skills" edges to the Skill entity. -func (_u *TeamGroupUpdate) AddSkills(v ...*Skill) *TeamGroupUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddSkillIDs(ids...) -} - // AddTeamGroupMemberIDs adds the "team_group_members" edge to the TeamGroupMember entity by IDs. func (_u *TeamGroupUpdate) AddTeamGroupMemberIDs(ids ...uuid.UUID) *TeamGroupUpdate { _u.mutation.AddTeamGroupMemberIDs(ids...) @@ -249,21 +232,6 @@ func (_u *TeamGroupUpdate) AddTeamGroupHosts(v ...*TeamGroupHost) *TeamGroupUpda return _u.AddTeamGroupHostIDs(ids...) } -// AddTeamGroupSkillIDs adds the "team_group_skills" edge to the TeamGroupSkill entity by IDs. -func (_u *TeamGroupUpdate) AddTeamGroupSkillIDs(ids ...uuid.UUID) *TeamGroupUpdate { - _u.mutation.AddTeamGroupSkillIDs(ids...) - return _u -} - -// AddTeamGroupSkills adds the "team_group_skills" edges to the TeamGroupSkill entity. -func (_u *TeamGroupUpdate) AddTeamGroupSkills(v ...*TeamGroupSkill) *TeamGroupUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddTeamGroupSkillIDs(ids...) -} - // Mutation returns the TeamGroupMutation object of the builder. func (_u *TeamGroupUpdate) Mutation() *TeamGroupMutation { return _u.mutation @@ -359,27 +327,6 @@ func (_u *TeamGroupUpdate) RemoveHosts(v ...*Host) *TeamGroupUpdate { return _u.RemoveHostIDs(ids...) } -// ClearSkills clears all "skills" edges to the Skill entity. -func (_u *TeamGroupUpdate) ClearSkills() *TeamGroupUpdate { - _u.mutation.ClearSkills() - return _u -} - -// RemoveSkillIDs removes the "skills" edge to Skill entities by IDs. -func (_u *TeamGroupUpdate) RemoveSkillIDs(ids ...uuid.UUID) *TeamGroupUpdate { - _u.mutation.RemoveSkillIDs(ids...) - return _u -} - -// RemoveSkills removes "skills" edges to Skill entities. -func (_u *TeamGroupUpdate) RemoveSkills(v ...*Skill) *TeamGroupUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveSkillIDs(ids...) -} - // ClearTeamGroupMembers clears all "team_group_members" edges to the TeamGroupMember entity. func (_u *TeamGroupUpdate) ClearTeamGroupMembers() *TeamGroupUpdate { _u.mutation.ClearTeamGroupMembers() @@ -464,27 +411,6 @@ func (_u *TeamGroupUpdate) RemoveTeamGroupHosts(v ...*TeamGroupHost) *TeamGroupU return _u.RemoveTeamGroupHostIDs(ids...) } -// ClearTeamGroupSkills clears all "team_group_skills" edges to the TeamGroupSkill entity. -func (_u *TeamGroupUpdate) ClearTeamGroupSkills() *TeamGroupUpdate { - _u.mutation.ClearTeamGroupSkills() - return _u -} - -// RemoveTeamGroupSkillIDs removes the "team_group_skills" edge to TeamGroupSkill entities by IDs. -func (_u *TeamGroupUpdate) RemoveTeamGroupSkillIDs(ids ...uuid.UUID) *TeamGroupUpdate { - _u.mutation.RemoveTeamGroupSkillIDs(ids...) - return _u -} - -// RemoveTeamGroupSkills removes "team_group_skills" edges to TeamGroupSkill entities. -func (_u *TeamGroupUpdate) RemoveTeamGroupSkills(v ...*TeamGroupSkill) *TeamGroupUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveTeamGroupSkillIDs(ids...) -} - // Save executes the query and returns the number of nodes affected by the update operation. func (_u *TeamGroupUpdate) Save(ctx context.Context) (int, error) { if err := _u.defaults(); err != nil { @@ -825,63 +751,6 @@ func (_u *TeamGroupUpdate) sqlSave(ctx context.Context) (_node int, err error) { edge.Target.Fields = specE.Fields _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: teamgroup.SkillsTable, - Columns: teamgroup.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedSkillsIDs(); len(nodes) > 0 && !_u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: teamgroup.SkillsTable, - Columns: teamgroup.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.SkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: teamgroup.SkillsTable, - Columns: teamgroup.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } if _u.mutation.TeamGroupMembersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -1062,51 +931,6 @@ func (_u *TeamGroupUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.TeamGroupSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: teamgroup.TeamGroupSkillsTable, - Columns: []string{teamgroup.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedTeamGroupSkillsIDs(); len(nodes) > 0 && !_u.mutation.TeamGroupSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: teamgroup.TeamGroupSkillsTable, - Columns: []string{teamgroup.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamGroupSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: teamgroup.TeamGroupSkillsTable, - Columns: []string{teamgroup.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } _spec.AddModifiers(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -1262,21 +1086,6 @@ func (_u *TeamGroupUpdateOne) AddHosts(v ...*Host) *TeamGroupUpdateOne { return _u.AddHostIDs(ids...) } -// AddSkillIDs adds the "skills" edge to the Skill entity by IDs. -func (_u *TeamGroupUpdateOne) AddSkillIDs(ids ...uuid.UUID) *TeamGroupUpdateOne { - _u.mutation.AddSkillIDs(ids...) - return _u -} - -// AddSkills adds the "skills" edges to the Skill entity. -func (_u *TeamGroupUpdateOne) AddSkills(v ...*Skill) *TeamGroupUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddSkillIDs(ids...) -} - // AddTeamGroupMemberIDs adds the "team_group_members" edge to the TeamGroupMember entity by IDs. func (_u *TeamGroupUpdateOne) AddTeamGroupMemberIDs(ids ...uuid.UUID) *TeamGroupUpdateOne { _u.mutation.AddTeamGroupMemberIDs(ids...) @@ -1337,21 +1146,6 @@ func (_u *TeamGroupUpdateOne) AddTeamGroupHosts(v ...*TeamGroupHost) *TeamGroupU return _u.AddTeamGroupHostIDs(ids...) } -// AddTeamGroupSkillIDs adds the "team_group_skills" edge to the TeamGroupSkill entity by IDs. -func (_u *TeamGroupUpdateOne) AddTeamGroupSkillIDs(ids ...uuid.UUID) *TeamGroupUpdateOne { - _u.mutation.AddTeamGroupSkillIDs(ids...) - return _u -} - -// AddTeamGroupSkills adds the "team_group_skills" edges to the TeamGroupSkill entity. -func (_u *TeamGroupUpdateOne) AddTeamGroupSkills(v ...*TeamGroupSkill) *TeamGroupUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddTeamGroupSkillIDs(ids...) -} - // Mutation returns the TeamGroupMutation object of the builder. func (_u *TeamGroupUpdateOne) Mutation() *TeamGroupMutation { return _u.mutation @@ -1447,27 +1241,6 @@ func (_u *TeamGroupUpdateOne) RemoveHosts(v ...*Host) *TeamGroupUpdateOne { return _u.RemoveHostIDs(ids...) } -// ClearSkills clears all "skills" edges to the Skill entity. -func (_u *TeamGroupUpdateOne) ClearSkills() *TeamGroupUpdateOne { - _u.mutation.ClearSkills() - return _u -} - -// RemoveSkillIDs removes the "skills" edge to Skill entities by IDs. -func (_u *TeamGroupUpdateOne) RemoveSkillIDs(ids ...uuid.UUID) *TeamGroupUpdateOne { - _u.mutation.RemoveSkillIDs(ids...) - return _u -} - -// RemoveSkills removes "skills" edges to Skill entities. -func (_u *TeamGroupUpdateOne) RemoveSkills(v ...*Skill) *TeamGroupUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveSkillIDs(ids...) -} - // ClearTeamGroupMembers clears all "team_group_members" edges to the TeamGroupMember entity. func (_u *TeamGroupUpdateOne) ClearTeamGroupMembers() *TeamGroupUpdateOne { _u.mutation.ClearTeamGroupMembers() @@ -1552,27 +1325,6 @@ func (_u *TeamGroupUpdateOne) RemoveTeamGroupHosts(v ...*TeamGroupHost) *TeamGro return _u.RemoveTeamGroupHostIDs(ids...) } -// ClearTeamGroupSkills clears all "team_group_skills" edges to the TeamGroupSkill entity. -func (_u *TeamGroupUpdateOne) ClearTeamGroupSkills() *TeamGroupUpdateOne { - _u.mutation.ClearTeamGroupSkills() - return _u -} - -// RemoveTeamGroupSkillIDs removes the "team_group_skills" edge to TeamGroupSkill entities by IDs. -func (_u *TeamGroupUpdateOne) RemoveTeamGroupSkillIDs(ids ...uuid.UUID) *TeamGroupUpdateOne { - _u.mutation.RemoveTeamGroupSkillIDs(ids...) - return _u -} - -// RemoveTeamGroupSkills removes "team_group_skills" edges to TeamGroupSkill entities. -func (_u *TeamGroupUpdateOne) RemoveTeamGroupSkills(v ...*TeamGroupSkill) *TeamGroupUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveTeamGroupSkillIDs(ids...) -} - // Where appends a list predicates to the TeamGroupUpdate builder. func (_u *TeamGroupUpdateOne) Where(ps ...predicate.TeamGroup) *TeamGroupUpdateOne { _u.mutation.Where(ps...) @@ -1943,63 +1695,6 @@ func (_u *TeamGroupUpdateOne) sqlSave(ctx context.Context) (_node *TeamGroup, er edge.Target.Fields = specE.Fields _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: teamgroup.SkillsTable, - Columns: teamgroup.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedSkillsIDs(); len(nodes) > 0 && !_u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: teamgroup.SkillsTable, - Columns: teamgroup.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.SkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: teamgroup.SkillsTable, - Columns: teamgroup.SkillsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - createE := &TeamGroupSkillCreate{config: _u.config, mutation: newTeamGroupSkillMutation(_u.config, OpCreate)} - createE.defaults() - _, specE := createE.createSpec() - edge.Target.Fields = specE.Fields - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } if _u.mutation.TeamGroupMembersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -2180,51 +1875,6 @@ func (_u *TeamGroupUpdateOne) sqlSave(ctx context.Context) (_node *TeamGroup, er } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.TeamGroupSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: teamgroup.TeamGroupSkillsTable, - Columns: []string{teamgroup.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedTeamGroupSkillsIDs(); len(nodes) > 0 && !_u.mutation.TeamGroupSkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: teamgroup.TeamGroupSkillsTable, - Columns: []string{teamgroup.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamGroupSkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: teamgroup.TeamGroupSkillsTable, - Columns: []string{teamgroup.TeamGroupSkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(teamgroupskill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } _spec.AddModifiers(_u.modifiers...) _node = &TeamGroup{config: _u.config} _spec.Assign = _node.assignValues diff --git a/backend/db/teamgroupskill/where.go b/backend/db/teamgroupskill/where.go deleted file mode 100644 index 1a989816..00000000 --- a/backend/db/teamgroupskill/where.go +++ /dev/null @@ -1,213 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package teamgroupskill - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/google/uuid" -) - -// ID filters vertices based on their ID field. -func ID(id uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldLTE(FieldID, id)) -} - -// GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ. -func GroupID(v uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldEQ(FieldGroupID, v)) -} - -// SkillID applies equality check predicate on the "skill_id" field. It's identical to SkillIDEQ. -func SkillID(v uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldEQ(FieldSkillID, v)) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldEQ(FieldCreatedAt, v)) -} - -// GroupIDEQ applies the EQ predicate on the "group_id" field. -func GroupIDEQ(v uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldEQ(FieldGroupID, v)) -} - -// GroupIDNEQ applies the NEQ predicate on the "group_id" field. -func GroupIDNEQ(v uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldNEQ(FieldGroupID, v)) -} - -// GroupIDIn applies the In predicate on the "group_id" field. -func GroupIDIn(vs ...uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldIn(FieldGroupID, vs...)) -} - -// GroupIDNotIn applies the NotIn predicate on the "group_id" field. -func GroupIDNotIn(vs ...uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldNotIn(FieldGroupID, vs...)) -} - -// SkillIDEQ applies the EQ predicate on the "skill_id" field. -func SkillIDEQ(v uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldEQ(FieldSkillID, v)) -} - -// SkillIDNEQ applies the NEQ predicate on the "skill_id" field. -func SkillIDNEQ(v uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldNEQ(FieldSkillID, v)) -} - -// SkillIDIn applies the In predicate on the "skill_id" field. -func SkillIDIn(vs ...uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldIn(FieldSkillID, vs...)) -} - -// SkillIDNotIn applies the NotIn predicate on the "skill_id" field. -func SkillIDNotIn(vs ...uuid.UUID) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldNotIn(FieldSkillID, vs...)) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldEQ(FieldCreatedAt, v)) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldNEQ(FieldCreatedAt, v)) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldIn(FieldCreatedAt, vs...)) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldNotIn(FieldCreatedAt, vs...)) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldGT(FieldCreatedAt, v)) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldGTE(FieldCreatedAt, v)) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldLT(FieldCreatedAt, v)) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.FieldLTE(FieldCreatedAt, v)) -} - -// HasGroup applies the HasEdge predicate on the "group" edge. -func HasGroup() predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, GroupTable, GroupColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates). -func HasGroupWith(preds ...predicate.TeamGroup) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(func(s *sql.Selector) { - step := newGroupStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasSkill applies the HasEdge predicate on the "skill" edge. -func HasSkill() predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, SkillTable, SkillColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSkillWith applies the HasEdge predicate on the "skill" edge with a given conditions (other predicates). -func HasSkillWith(preds ...predicate.Skill) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(func(s *sql.Selector) { - step := newSkillStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.TeamGroupSkill) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.TeamGroupSkill) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.TeamGroupSkill) predicate.TeamGroupSkill { - return predicate.TeamGroupSkill(sql.NotPredicates(p)) -} diff --git a/backend/db/teamskill.go b/backend/db/teamskill.go deleted file mode 100644 index a2d36ca8..00000000 --- a/backend/db/teamskill.go +++ /dev/null @@ -1,175 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package db - -import ( - "fmt" - "strings" - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/chaitin/MonkeyCode/backend/db/skill" - "github.com/chaitin/MonkeyCode/backend/db/team" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" - "github.com/google/uuid" -) - -// TeamSkill is the model entity for the TeamSkill schema. -type TeamSkill struct { - config `json:"-"` - // ID of the ent. - ID uuid.UUID `json:"id,omitempty"` - // TeamID holds the value of the "team_id" field. - TeamID uuid.UUID `json:"team_id,omitempty"` - // SkillID holds the value of the "skill_id" field. - SkillID uuid.UUID `json:"skill_id,omitempty"` - // CreatedAt holds the value of the "created_at" field. - CreatedAt time.Time `json:"created_at,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the TeamSkillQuery when eager-loading is set. - Edges TeamSkillEdges `json:"edges"` - selectValues sql.SelectValues -} - -// TeamSkillEdges holds the relations/edges for other nodes in the graph. -type TeamSkillEdges struct { - // Team holds the value of the team edge. - Team *Team `json:"team,omitempty"` - // Skill holds the value of the skill edge. - Skill *Skill `json:"skill,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool -} - -// TeamOrErr returns the Team value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e TeamSkillEdges) TeamOrErr() (*Team, error) { - if e.Team != nil { - return e.Team, nil - } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: team.Label} - } - return nil, &NotLoadedError{edge: "team"} -} - -// SkillOrErr returns the Skill value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e TeamSkillEdges) SkillOrErr() (*Skill, error) { - if e.Skill != nil { - return e.Skill, nil - } else if e.loadedTypes[1] { - return nil, &NotFoundError{label: skill.Label} - } - return nil, &NotLoadedError{edge: "skill"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*TeamSkill) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case teamskill.FieldCreatedAt: - values[i] = new(sql.NullTime) - case teamskill.FieldID, teamskill.FieldTeamID, teamskill.FieldSkillID: - values[i] = new(uuid.UUID) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the TeamSkill fields. -func (_m *TeamSkill) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case teamskill.FieldID: - if value, ok := values[i].(*uuid.UUID); !ok { - return fmt.Errorf("unexpected type %T for field id", values[i]) - } else if value != nil { - _m.ID = *value - } - case teamskill.FieldTeamID: - if value, ok := values[i].(*uuid.UUID); !ok { - return fmt.Errorf("unexpected type %T for field team_id", values[i]) - } else if value != nil { - _m.TeamID = *value - } - case teamskill.FieldSkillID: - if value, ok := values[i].(*uuid.UUID); !ok { - return fmt.Errorf("unexpected type %T for field skill_id", values[i]) - } else if value != nil { - _m.SkillID = *value - } - case teamskill.FieldCreatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field created_at", values[i]) - } else if value.Valid { - _m.CreatedAt = value.Time - } - default: - _m.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the TeamSkill. -// This includes values selected through modifiers, order, etc. -func (_m *TeamSkill) Value(name string) (ent.Value, error) { - return _m.selectValues.Get(name) -} - -// QueryTeam queries the "team" edge of the TeamSkill entity. -func (_m *TeamSkill) QueryTeam() *TeamQuery { - return NewTeamSkillClient(_m.config).QueryTeam(_m) -} - -// QuerySkill queries the "skill" edge of the TeamSkill entity. -func (_m *TeamSkill) QuerySkill() *SkillQuery { - return NewTeamSkillClient(_m.config).QuerySkill(_m) -} - -// Update returns a builder for updating this TeamSkill. -// Note that you need to call TeamSkill.Unwrap() before calling this method if this TeamSkill -// was returned from a transaction, and the transaction was committed or rolled back. -func (_m *TeamSkill) Update() *TeamSkillUpdateOne { - return NewTeamSkillClient(_m.config).UpdateOne(_m) -} - -// Unwrap unwraps the TeamSkill entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (_m *TeamSkill) Unwrap() *TeamSkill { - _tx, ok := _m.config.driver.(*txDriver) - if !ok { - panic("db: TeamSkill is not a transactional entity") - } - _m.config.driver = _tx.drv - return _m -} - -// String implements the fmt.Stringer. -func (_m *TeamSkill) String() string { - var builder strings.Builder - builder.WriteString("TeamSkill(") - builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - builder.WriteString("team_id=") - builder.WriteString(fmt.Sprintf("%v", _m.TeamID)) - builder.WriteString(", ") - builder.WriteString("skill_id=") - builder.WriteString(fmt.Sprintf("%v", _m.SkillID)) - builder.WriteString(", ") - builder.WriteString("created_at=") - builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) - builder.WriteByte(')') - return builder.String() -} - -// TeamSkills is a parsable slice of TeamSkill. -type TeamSkills []*TeamSkill diff --git a/backend/db/teamskill/teamskill.go b/backend/db/teamskill/teamskill.go deleted file mode 100644 index 1f5d652c..00000000 --- a/backend/db/teamskill/teamskill.go +++ /dev/null @@ -1,117 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package teamskill - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the teamskill type in the database. - Label = "team_skill" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldTeamID holds the string denoting the team_id field in the database. - FieldTeamID = "team_id" - // FieldSkillID holds the string denoting the skill_id field in the database. - FieldSkillID = "skill_id" - // FieldCreatedAt holds the string denoting the created_at field in the database. - FieldCreatedAt = "created_at" - // EdgeTeam holds the string denoting the team edge name in mutations. - EdgeTeam = "team" - // EdgeSkill holds the string denoting the skill edge name in mutations. - EdgeSkill = "skill" - // Table holds the table name of the teamskill in the database. - Table = "team_skills" - // TeamTable is the table that holds the team relation/edge. - TeamTable = "team_skills" - // TeamInverseTable is the table name for the Team entity. - // It exists in this package in order to avoid circular dependency with the "team" package. - TeamInverseTable = "teams" - // TeamColumn is the table column denoting the team relation/edge. - TeamColumn = "team_id" - // SkillTable is the table that holds the skill relation/edge. - SkillTable = "team_skills" - // SkillInverseTable is the table name for the Skill entity. - // It exists in this package in order to avoid circular dependency with the "skill" package. - SkillInverseTable = "skills" - // SkillColumn is the table column denoting the skill relation/edge. - SkillColumn = "skill_id" -) - -// Columns holds all SQL columns for teamskill fields. -var Columns = []string{ - FieldID, - FieldTeamID, - FieldSkillID, - FieldCreatedAt, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreatedAt holds the default value on creation for the "created_at" field. - DefaultCreatedAt func() time.Time -) - -// OrderOption defines the ordering options for the TeamSkill queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByTeamID orders the results by the team_id field. -func ByTeamID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTeamID, opts...).ToFunc() -} - -// BySkillID orders the results by the skill_id field. -func BySkillID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSkillID, opts...).ToFunc() -} - -// ByCreatedAt orders the results by the created_at field. -func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() -} - -// ByTeamField orders the results by team field. -func ByTeamField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newTeamStep(), sql.OrderByField(field, opts...)) - } -} - -// BySkillField orders the results by skill field. -func BySkillField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSkillStep(), sql.OrderByField(field, opts...)) - } -} -func newTeamStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(TeamInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, TeamTable, TeamColumn), - ) -} -func newSkillStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(SkillInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, SkillTable, SkillColumn), - ) -} diff --git a/backend/db/teamskill/where.go b/backend/db/teamskill/where.go deleted file mode 100644 index 5c6f4fe9..00000000 --- a/backend/db/teamskill/where.go +++ /dev/null @@ -1,213 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package teamskill - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/google/uuid" -) - -// ID filters vertices based on their ID field. -func ID(id uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldLTE(FieldID, id)) -} - -// TeamID applies equality check predicate on the "team_id" field. It's identical to TeamIDEQ. -func TeamID(v uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldEQ(FieldTeamID, v)) -} - -// SkillID applies equality check predicate on the "skill_id" field. It's identical to SkillIDEQ. -func SkillID(v uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldEQ(FieldSkillID, v)) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldEQ(FieldCreatedAt, v)) -} - -// TeamIDEQ applies the EQ predicate on the "team_id" field. -func TeamIDEQ(v uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldEQ(FieldTeamID, v)) -} - -// TeamIDNEQ applies the NEQ predicate on the "team_id" field. -func TeamIDNEQ(v uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldNEQ(FieldTeamID, v)) -} - -// TeamIDIn applies the In predicate on the "team_id" field. -func TeamIDIn(vs ...uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldIn(FieldTeamID, vs...)) -} - -// TeamIDNotIn applies the NotIn predicate on the "team_id" field. -func TeamIDNotIn(vs ...uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldNotIn(FieldTeamID, vs...)) -} - -// SkillIDEQ applies the EQ predicate on the "skill_id" field. -func SkillIDEQ(v uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldEQ(FieldSkillID, v)) -} - -// SkillIDNEQ applies the NEQ predicate on the "skill_id" field. -func SkillIDNEQ(v uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldNEQ(FieldSkillID, v)) -} - -// SkillIDIn applies the In predicate on the "skill_id" field. -func SkillIDIn(vs ...uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldIn(FieldSkillID, vs...)) -} - -// SkillIDNotIn applies the NotIn predicate on the "skill_id" field. -func SkillIDNotIn(vs ...uuid.UUID) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldNotIn(FieldSkillID, vs...)) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldEQ(FieldCreatedAt, v)) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldNEQ(FieldCreatedAt, v)) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldIn(FieldCreatedAt, vs...)) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldNotIn(FieldCreatedAt, vs...)) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldGT(FieldCreatedAt, v)) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldGTE(FieldCreatedAt, v)) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldLT(FieldCreatedAt, v)) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.TeamSkill { - return predicate.TeamSkill(sql.FieldLTE(FieldCreatedAt, v)) -} - -// HasTeam applies the HasEdge predicate on the "team" edge. -func HasTeam() predicate.TeamSkill { - return predicate.TeamSkill(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, TeamTable, TeamColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasTeamWith applies the HasEdge predicate on the "team" edge with a given conditions (other predicates). -func HasTeamWith(preds ...predicate.Team) predicate.TeamSkill { - return predicate.TeamSkill(func(s *sql.Selector) { - step := newTeamStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasSkill applies the HasEdge predicate on the "skill" edge. -func HasSkill() predicate.TeamSkill { - return predicate.TeamSkill(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, SkillTable, SkillColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSkillWith applies the HasEdge predicate on the "skill" edge with a given conditions (other predicates). -func HasSkillWith(preds ...predicate.Skill) predicate.TeamSkill { - return predicate.TeamSkill(func(s *sql.Selector) { - step := newSkillStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.TeamSkill) predicate.TeamSkill { - return predicate.TeamSkill(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.TeamSkill) predicate.TeamSkill { - return predicate.TeamSkill(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.TeamSkill) predicate.TeamSkill { - return predicate.TeamSkill(sql.NotPredicates(p)) -} diff --git a/backend/db/teamskill_create.go b/backend/db/teamskill_create.go deleted file mode 100644 index 27d2a5f3..00000000 --- a/backend/db/teamskill_create.go +++ /dev/null @@ -1,659 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package db - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/chaitin/MonkeyCode/backend/db/skill" - "github.com/chaitin/MonkeyCode/backend/db/team" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" - "github.com/google/uuid" -) - -// TeamSkillCreate is the builder for creating a TeamSkill entity. -type TeamSkillCreate struct { - config - mutation *TeamSkillMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetTeamID sets the "team_id" field. -func (_c *TeamSkillCreate) SetTeamID(v uuid.UUID) *TeamSkillCreate { - _c.mutation.SetTeamID(v) - return _c -} - -// SetSkillID sets the "skill_id" field. -func (_c *TeamSkillCreate) SetSkillID(v uuid.UUID) *TeamSkillCreate { - _c.mutation.SetSkillID(v) - return _c -} - -// SetCreatedAt sets the "created_at" field. -func (_c *TeamSkillCreate) SetCreatedAt(v time.Time) *TeamSkillCreate { - _c.mutation.SetCreatedAt(v) - return _c -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (_c *TeamSkillCreate) SetNillableCreatedAt(v *time.Time) *TeamSkillCreate { - if v != nil { - _c.SetCreatedAt(*v) - } - return _c -} - -// SetID sets the "id" field. -func (_c *TeamSkillCreate) SetID(v uuid.UUID) *TeamSkillCreate { - _c.mutation.SetID(v) - return _c -} - -// SetTeam sets the "team" edge to the Team entity. -func (_c *TeamSkillCreate) SetTeam(v *Team) *TeamSkillCreate { - return _c.SetTeamID(v.ID) -} - -// SetSkill sets the "skill" edge to the Skill entity. -func (_c *TeamSkillCreate) SetSkill(v *Skill) *TeamSkillCreate { - return _c.SetSkillID(v.ID) -} - -// Mutation returns the TeamSkillMutation object of the builder. -func (_c *TeamSkillCreate) Mutation() *TeamSkillMutation { - return _c.mutation -} - -// Save creates the TeamSkill in the database. -func (_c *TeamSkillCreate) Save(ctx context.Context) (*TeamSkill, error) { - _c.defaults() - return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (_c *TeamSkillCreate) SaveX(ctx context.Context) *TeamSkill { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *TeamSkillCreate) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *TeamSkillCreate) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_c *TeamSkillCreate) defaults() { - if _, ok := _c.mutation.CreatedAt(); !ok { - v := teamskill.DefaultCreatedAt() - _c.mutation.SetCreatedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_c *TeamSkillCreate) check() error { - if _, ok := _c.mutation.TeamID(); !ok { - return &ValidationError{Name: "team_id", err: errors.New(`db: missing required field "TeamSkill.team_id"`)} - } - if _, ok := _c.mutation.SkillID(); !ok { - return &ValidationError{Name: "skill_id", err: errors.New(`db: missing required field "TeamSkill.skill_id"`)} - } - if _, ok := _c.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "TeamSkill.created_at"`)} - } - if len(_c.mutation.TeamIDs()) == 0 { - return &ValidationError{Name: "team", err: errors.New(`db: missing required edge "TeamSkill.team"`)} - } - if len(_c.mutation.SkillIDs()) == 0 { - return &ValidationError{Name: "skill", err: errors.New(`db: missing required edge "TeamSkill.skill"`)} - } - return nil -} - -func (_c *TeamSkillCreate) sqlSave(ctx context.Context) (*TeamSkill, error) { - if err := _c.check(); err != nil { - return nil, err - } - _node, _spec := _c.createSpec() - if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != nil { - if id, ok := _spec.ID.Value.(*uuid.UUID); ok { - _node.ID = *id - } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { - return nil, err - } - } - _c.mutation.id = &_node.ID - _c.mutation.done = true - return _node, nil -} - -func (_c *TeamSkillCreate) createSpec() (*TeamSkill, *sqlgraph.CreateSpec) { - var ( - _node = &TeamSkill{config: _c.config} - _spec = sqlgraph.NewCreateSpec(teamskill.Table, sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID)) - ) - _spec.OnConflict = _c.conflict - if id, ok := _c.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = &id - } - if value, ok := _c.mutation.CreatedAt(); ok { - _spec.SetField(teamskill.FieldCreatedAt, field.TypeTime, value) - _node.CreatedAt = value - } - if nodes := _c.mutation.TeamIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: teamskill.TeamTable, - Columns: []string{teamskill.TeamColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.TeamID = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.SkillIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: teamskill.SkillTable, - Columns: []string{teamskill.SkillColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.SkillID = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.TeamSkill.Create(). -// SetTeamID(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.TeamSkillUpsert) { -// SetTeamID(v+v). -// }). -// Exec(ctx) -func (_c *TeamSkillCreate) OnConflict(opts ...sql.ConflictOption) *TeamSkillUpsertOne { - _c.conflict = opts - return &TeamSkillUpsertOne{ - create: _c, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.TeamSkill.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (_c *TeamSkillCreate) OnConflictColumns(columns ...string) *TeamSkillUpsertOne { - _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) - return &TeamSkillUpsertOne{ - create: _c, - } -} - -type ( - // TeamSkillUpsertOne is the builder for "upsert"-ing - // one TeamSkill node. - TeamSkillUpsertOne struct { - create *TeamSkillCreate - } - - // TeamSkillUpsert is the "OnConflict" setter. - TeamSkillUpsert struct { - *sql.UpdateSet - } -) - -// SetTeamID sets the "team_id" field. -func (u *TeamSkillUpsert) SetTeamID(v uuid.UUID) *TeamSkillUpsert { - u.Set(teamskill.FieldTeamID, v) - return u -} - -// UpdateTeamID sets the "team_id" field to the value that was provided on create. -func (u *TeamSkillUpsert) UpdateTeamID() *TeamSkillUpsert { - u.SetExcluded(teamskill.FieldTeamID) - return u -} - -// SetSkillID sets the "skill_id" field. -func (u *TeamSkillUpsert) SetSkillID(v uuid.UUID) *TeamSkillUpsert { - u.Set(teamskill.FieldSkillID, v) - return u -} - -// UpdateSkillID sets the "skill_id" field to the value that was provided on create. -func (u *TeamSkillUpsert) UpdateSkillID() *TeamSkillUpsert { - u.SetExcluded(teamskill.FieldSkillID) - return u -} - -// SetCreatedAt sets the "created_at" field. -func (u *TeamSkillUpsert) SetCreatedAt(v time.Time) *TeamSkillUpsert { - u.Set(teamskill.FieldCreatedAt, v) - return u -} - -// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. -func (u *TeamSkillUpsert) UpdateCreatedAt() *TeamSkillUpsert { - u.SetExcluded(teamskill.FieldCreatedAt) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. -// Using this option is equivalent to using: -// -// client.TeamSkill.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// sql.ResolveWith(func(u *sql.UpdateSet) { -// u.SetIgnore(teamskill.FieldID) -// }), -// ). -// Exec(ctx) -func (u *TeamSkillUpsertOne) UpdateNewValues() *TeamSkillUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { - if _, exists := u.create.mutation.ID(); exists { - s.SetIgnore(teamskill.FieldID) - } - })) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.TeamSkill.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *TeamSkillUpsertOne) Ignore() *TeamSkillUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *TeamSkillUpsertOne) DoNothing() *TeamSkillUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the TeamSkillCreate.OnConflict -// documentation for more info. -func (u *TeamSkillUpsertOne) Update(set func(*TeamSkillUpsert)) *TeamSkillUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&TeamSkillUpsert{UpdateSet: update}) - })) - return u -} - -// SetTeamID sets the "team_id" field. -func (u *TeamSkillUpsertOne) SetTeamID(v uuid.UUID) *TeamSkillUpsertOne { - return u.Update(func(s *TeamSkillUpsert) { - s.SetTeamID(v) - }) -} - -// UpdateTeamID sets the "team_id" field to the value that was provided on create. -func (u *TeamSkillUpsertOne) UpdateTeamID() *TeamSkillUpsertOne { - return u.Update(func(s *TeamSkillUpsert) { - s.UpdateTeamID() - }) -} - -// SetSkillID sets the "skill_id" field. -func (u *TeamSkillUpsertOne) SetSkillID(v uuid.UUID) *TeamSkillUpsertOne { - return u.Update(func(s *TeamSkillUpsert) { - s.SetSkillID(v) - }) -} - -// UpdateSkillID sets the "skill_id" field to the value that was provided on create. -func (u *TeamSkillUpsertOne) UpdateSkillID() *TeamSkillUpsertOne { - return u.Update(func(s *TeamSkillUpsert) { - s.UpdateSkillID() - }) -} - -// SetCreatedAt sets the "created_at" field. -func (u *TeamSkillUpsertOne) SetCreatedAt(v time.Time) *TeamSkillUpsertOne { - return u.Update(func(s *TeamSkillUpsert) { - s.SetCreatedAt(v) - }) -} - -// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. -func (u *TeamSkillUpsertOne) UpdateCreatedAt() *TeamSkillUpsertOne { - return u.Update(func(s *TeamSkillUpsert) { - s.UpdateCreatedAt() - }) -} - -// Exec executes the query. -func (u *TeamSkillUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("db: missing options for TeamSkillCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *TeamSkillUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *TeamSkillUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { - if u.create.driver.Dialect() == dialect.MySQL { - // In case of "ON CONFLICT", there is no way to get back non-numeric ID - // fields from the database since MySQL does not support the RETURNING clause. - return id, errors.New("db: TeamSkillUpsertOne.ID is not supported by MySQL driver. Use TeamSkillUpsertOne.Exec instead") - } - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *TeamSkillUpsertOne) IDX(ctx context.Context) uuid.UUID { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// TeamSkillCreateBulk is the builder for creating many TeamSkill entities in bulk. -type TeamSkillCreateBulk struct { - config - err error - builders []*TeamSkillCreate - conflict []sql.ConflictOption -} - -// Save creates the TeamSkill entities in the database. -func (_c *TeamSkillCreateBulk) Save(ctx context.Context) ([]*TeamSkill, error) { - if _c.err != nil { - return nil, _c.err - } - specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*TeamSkill, len(_c.builders)) - mutators := make([]Mutator, len(_c.builders)) - for i := range _c.builders { - func(i int, root context.Context) { - builder := _c.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*TeamSkillMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = _c.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (_c *TeamSkillCreateBulk) SaveX(ctx context.Context) []*TeamSkill { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *TeamSkillCreateBulk) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *TeamSkillCreateBulk) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.TeamSkill.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.TeamSkillUpsert) { -// SetTeamID(v+v). -// }). -// Exec(ctx) -func (_c *TeamSkillCreateBulk) OnConflict(opts ...sql.ConflictOption) *TeamSkillUpsertBulk { - _c.conflict = opts - return &TeamSkillUpsertBulk{ - create: _c, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.TeamSkill.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (_c *TeamSkillCreateBulk) OnConflictColumns(columns ...string) *TeamSkillUpsertBulk { - _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) - return &TeamSkillUpsertBulk{ - create: _c, - } -} - -// TeamSkillUpsertBulk is the builder for "upsert"-ing -// a bulk of TeamSkill nodes. -type TeamSkillUpsertBulk struct { - create *TeamSkillCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.TeamSkill.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// sql.ResolveWith(func(u *sql.UpdateSet) { -// u.SetIgnore(teamskill.FieldID) -// }), -// ). -// Exec(ctx) -func (u *TeamSkillUpsertBulk) UpdateNewValues() *TeamSkillUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { - for _, b := range u.create.builders { - if _, exists := b.mutation.ID(); exists { - s.SetIgnore(teamskill.FieldID) - } - } - })) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.TeamSkill.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *TeamSkillUpsertBulk) Ignore() *TeamSkillUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *TeamSkillUpsertBulk) DoNothing() *TeamSkillUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the TeamSkillCreateBulk.OnConflict -// documentation for more info. -func (u *TeamSkillUpsertBulk) Update(set func(*TeamSkillUpsert)) *TeamSkillUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&TeamSkillUpsert{UpdateSet: update}) - })) - return u -} - -// SetTeamID sets the "team_id" field. -func (u *TeamSkillUpsertBulk) SetTeamID(v uuid.UUID) *TeamSkillUpsertBulk { - return u.Update(func(s *TeamSkillUpsert) { - s.SetTeamID(v) - }) -} - -// UpdateTeamID sets the "team_id" field to the value that was provided on create. -func (u *TeamSkillUpsertBulk) UpdateTeamID() *TeamSkillUpsertBulk { - return u.Update(func(s *TeamSkillUpsert) { - s.UpdateTeamID() - }) -} - -// SetSkillID sets the "skill_id" field. -func (u *TeamSkillUpsertBulk) SetSkillID(v uuid.UUID) *TeamSkillUpsertBulk { - return u.Update(func(s *TeamSkillUpsert) { - s.SetSkillID(v) - }) -} - -// UpdateSkillID sets the "skill_id" field to the value that was provided on create. -func (u *TeamSkillUpsertBulk) UpdateSkillID() *TeamSkillUpsertBulk { - return u.Update(func(s *TeamSkillUpsert) { - s.UpdateSkillID() - }) -} - -// SetCreatedAt sets the "created_at" field. -func (u *TeamSkillUpsertBulk) SetCreatedAt(v time.Time) *TeamSkillUpsertBulk { - return u.Update(func(s *TeamSkillUpsert) { - s.SetCreatedAt(v) - }) -} - -// UpdateCreatedAt sets the "created_at" field to the value that was provided on create. -func (u *TeamSkillUpsertBulk) UpdateCreatedAt() *TeamSkillUpsertBulk { - return u.Update(func(s *TeamSkillUpsert) { - s.UpdateCreatedAt() - }) -} - -// Exec executes the query. -func (u *TeamSkillUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the TeamSkillCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("db: missing options for TeamSkillCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *TeamSkillUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/backend/db/teamskill_update.go b/backend/db/teamskill_update.go deleted file mode 100644 index d9a28374..00000000 --- a/backend/db/teamskill_update.go +++ /dev/null @@ -1,473 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package db - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/chaitin/MonkeyCode/backend/db/predicate" - "github.com/chaitin/MonkeyCode/backend/db/skill" - "github.com/chaitin/MonkeyCode/backend/db/team" - "github.com/chaitin/MonkeyCode/backend/db/teamskill" - "github.com/google/uuid" -) - -// TeamSkillUpdate is the builder for updating TeamSkill entities. -type TeamSkillUpdate struct { - config - hooks []Hook - mutation *TeamSkillMutation - modifiers []func(*sql.UpdateBuilder) -} - -// Where appends a list predicates to the TeamSkillUpdate builder. -func (_u *TeamSkillUpdate) Where(ps ...predicate.TeamSkill) *TeamSkillUpdate { - _u.mutation.Where(ps...) - return _u -} - -// SetTeamID sets the "team_id" field. -func (_u *TeamSkillUpdate) SetTeamID(v uuid.UUID) *TeamSkillUpdate { - _u.mutation.SetTeamID(v) - return _u -} - -// SetNillableTeamID sets the "team_id" field if the given value is not nil. -func (_u *TeamSkillUpdate) SetNillableTeamID(v *uuid.UUID) *TeamSkillUpdate { - if v != nil { - _u.SetTeamID(*v) - } - return _u -} - -// SetSkillID sets the "skill_id" field. -func (_u *TeamSkillUpdate) SetSkillID(v uuid.UUID) *TeamSkillUpdate { - _u.mutation.SetSkillID(v) - return _u -} - -// SetNillableSkillID sets the "skill_id" field if the given value is not nil. -func (_u *TeamSkillUpdate) SetNillableSkillID(v *uuid.UUID) *TeamSkillUpdate { - if v != nil { - _u.SetSkillID(*v) - } - return _u -} - -// SetCreatedAt sets the "created_at" field. -func (_u *TeamSkillUpdate) SetCreatedAt(v time.Time) *TeamSkillUpdate { - _u.mutation.SetCreatedAt(v) - return _u -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (_u *TeamSkillUpdate) SetNillableCreatedAt(v *time.Time) *TeamSkillUpdate { - if v != nil { - _u.SetCreatedAt(*v) - } - return _u -} - -// SetTeam sets the "team" edge to the Team entity. -func (_u *TeamSkillUpdate) SetTeam(v *Team) *TeamSkillUpdate { - return _u.SetTeamID(v.ID) -} - -// SetSkill sets the "skill" edge to the Skill entity. -func (_u *TeamSkillUpdate) SetSkill(v *Skill) *TeamSkillUpdate { - return _u.SetSkillID(v.ID) -} - -// Mutation returns the TeamSkillMutation object of the builder. -func (_u *TeamSkillUpdate) Mutation() *TeamSkillMutation { - return _u.mutation -} - -// ClearTeam clears the "team" edge to the Team entity. -func (_u *TeamSkillUpdate) ClearTeam() *TeamSkillUpdate { - _u.mutation.ClearTeam() - return _u -} - -// ClearSkill clears the "skill" edge to the Skill entity. -func (_u *TeamSkillUpdate) ClearSkill() *TeamSkillUpdate { - _u.mutation.ClearSkill() - return _u -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (_u *TeamSkillUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *TeamSkillUpdate) SaveX(ctx context.Context) int { - affected, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (_u *TeamSkillUpdate) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *TeamSkillUpdate) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *TeamSkillUpdate) check() error { - if _u.mutation.TeamCleared() && len(_u.mutation.TeamIDs()) > 0 { - return errors.New(`db: clearing a required unique edge "TeamSkill.team"`) - } - if _u.mutation.SkillCleared() && len(_u.mutation.SkillIDs()) > 0 { - return errors.New(`db: clearing a required unique edge "TeamSkill.skill"`) - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *TeamSkillUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TeamSkillUpdate { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *TeamSkillUpdate) sqlSave(ctx context.Context) (_node int, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(teamskill.Table, teamskill.Columns, sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID)) - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.CreatedAt(); ok { - _spec.SetField(teamskill.FieldCreatedAt, field.TypeTime, value) - } - if _u.mutation.TeamCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: teamskill.TeamTable, - Columns: []string{teamskill.TeamColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: teamskill.TeamTable, - Columns: []string{teamskill.TeamColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.SkillCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: teamskill.SkillTable, - Columns: []string{teamskill.SkillColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.SkillIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: teamskill.SkillTable, - Columns: []string{teamskill.SkillColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{teamskill.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - _u.mutation.done = true - return _node, nil -} - -// TeamSkillUpdateOne is the builder for updating a single TeamSkill entity. -type TeamSkillUpdateOne struct { - config - fields []string - hooks []Hook - mutation *TeamSkillMutation - modifiers []func(*sql.UpdateBuilder) -} - -// SetTeamID sets the "team_id" field. -func (_u *TeamSkillUpdateOne) SetTeamID(v uuid.UUID) *TeamSkillUpdateOne { - _u.mutation.SetTeamID(v) - return _u -} - -// SetNillableTeamID sets the "team_id" field if the given value is not nil. -func (_u *TeamSkillUpdateOne) SetNillableTeamID(v *uuid.UUID) *TeamSkillUpdateOne { - if v != nil { - _u.SetTeamID(*v) - } - return _u -} - -// SetSkillID sets the "skill_id" field. -func (_u *TeamSkillUpdateOne) SetSkillID(v uuid.UUID) *TeamSkillUpdateOne { - _u.mutation.SetSkillID(v) - return _u -} - -// SetNillableSkillID sets the "skill_id" field if the given value is not nil. -func (_u *TeamSkillUpdateOne) SetNillableSkillID(v *uuid.UUID) *TeamSkillUpdateOne { - if v != nil { - _u.SetSkillID(*v) - } - return _u -} - -// SetCreatedAt sets the "created_at" field. -func (_u *TeamSkillUpdateOne) SetCreatedAt(v time.Time) *TeamSkillUpdateOne { - _u.mutation.SetCreatedAt(v) - return _u -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (_u *TeamSkillUpdateOne) SetNillableCreatedAt(v *time.Time) *TeamSkillUpdateOne { - if v != nil { - _u.SetCreatedAt(*v) - } - return _u -} - -// SetTeam sets the "team" edge to the Team entity. -func (_u *TeamSkillUpdateOne) SetTeam(v *Team) *TeamSkillUpdateOne { - return _u.SetTeamID(v.ID) -} - -// SetSkill sets the "skill" edge to the Skill entity. -func (_u *TeamSkillUpdateOne) SetSkill(v *Skill) *TeamSkillUpdateOne { - return _u.SetSkillID(v.ID) -} - -// Mutation returns the TeamSkillMutation object of the builder. -func (_u *TeamSkillUpdateOne) Mutation() *TeamSkillMutation { - return _u.mutation -} - -// ClearTeam clears the "team" edge to the Team entity. -func (_u *TeamSkillUpdateOne) ClearTeam() *TeamSkillUpdateOne { - _u.mutation.ClearTeam() - return _u -} - -// ClearSkill clears the "skill" edge to the Skill entity. -func (_u *TeamSkillUpdateOne) ClearSkill() *TeamSkillUpdateOne { - _u.mutation.ClearSkill() - return _u -} - -// Where appends a list predicates to the TeamSkillUpdate builder. -func (_u *TeamSkillUpdateOne) Where(ps ...predicate.TeamSkill) *TeamSkillUpdateOne { - _u.mutation.Where(ps...) - return _u -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (_u *TeamSkillUpdateOne) Select(field string, fields ...string) *TeamSkillUpdateOne { - _u.fields = append([]string{field}, fields...) - return _u -} - -// Save executes the query and returns the updated TeamSkill entity. -func (_u *TeamSkillUpdateOne) Save(ctx context.Context) (*TeamSkill, error) { - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *TeamSkillUpdateOne) SaveX(ctx context.Context) *TeamSkill { - node, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (_u *TeamSkillUpdateOne) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *TeamSkillUpdateOne) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *TeamSkillUpdateOne) check() error { - if _u.mutation.TeamCleared() && len(_u.mutation.TeamIDs()) > 0 { - return errors.New(`db: clearing a required unique edge "TeamSkill.team"`) - } - if _u.mutation.SkillCleared() && len(_u.mutation.SkillIDs()) > 0 { - return errors.New(`db: clearing a required unique edge "TeamSkill.skill"`) - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *TeamSkillUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TeamSkillUpdateOne { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *TeamSkillUpdateOne) sqlSave(ctx context.Context) (_node *TeamSkill, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(teamskill.Table, teamskill.Columns, sqlgraph.NewFieldSpec(teamskill.FieldID, field.TypeUUID)) - id, ok := _u.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "TeamSkill.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := _u.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, teamskill.FieldID) - for _, f := range fields { - if !teamskill.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} - } - if f != teamskill.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.CreatedAt(); ok { - _spec.SetField(teamskill.FieldCreatedAt, field.TypeTime, value) - } - if _u.mutation.TeamCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: teamskill.TeamTable, - Columns: []string{teamskill.TeamColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.TeamIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: teamskill.TeamTable, - Columns: []string{teamskill.TeamColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.SkillCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: teamskill.SkillTable, - Columns: []string{teamskill.SkillColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.SkillIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: teamskill.SkillTable, - Columns: []string{teamskill.SkillColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - _node = &TeamSkill{config: _u.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{teamskill.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - _u.mutation.done = true - return _node, nil -} diff --git a/backend/db/tx.go b/backend/db/tx.go index 463c5eaf..65055876 100644 --- a/backend/db/tx.go +++ b/backend/db/tx.go @@ -14,6 +14,26 @@ import ( // Tx is a transactional client that is created by calling Client.Tx(). type Tx struct { config + // AgentPlugin is the client for interacting with the AgentPlugin builders. + AgentPlugin *AgentPluginClient + // AgentPluginRepo is the client for interacting with the AgentPluginRepo builders. + AgentPluginRepo *AgentPluginRepoClient + // AgentPluginVersion is the client for interacting with the AgentPluginVersion builders. + AgentPluginVersion *AgentPluginVersionClient + // AgentRule is the client for interacting with the AgentRule builders. + AgentRule *AgentRuleClient + // AgentRuleVersion is the client for interacting with the AgentRuleVersion builders. + AgentRuleVersion *AgentRuleVersionClient + // AgentSkill is the client for interacting with the AgentSkill builders. + AgentSkill *AgentSkillClient + // AgentSkillGroupBinding is the client for interacting with the AgentSkillGroupBinding builders. + AgentSkillGroupBinding *AgentSkillGroupBindingClient + // AgentSkillRepo is the client for interacting with the AgentSkillRepo builders. + AgentSkillRepo *AgentSkillRepoClient + // AgentSkillVersion is the client for interacting with the AgentSkillVersion builders. + AgentSkillVersion *AgentSkillVersionClient + // AgentSyncJob is the client for interacting with the AgentSyncJob builders. + AgentSyncJob *AgentSyncJobClient // Audit is the client for interacting with the Audit builders. Audit *AuditClient // GitBot is the client for interacting with the GitBot builders. @@ -60,8 +80,6 @@ type Tx struct { ProjectIssueComment *ProjectIssueCommentClient // ProjectTask is the client for interacting with the ProjectTask builders. ProjectTask *ProjectTaskClient - // Skill is the client for interacting with the Skill builders. - Skill *SkillClient // Task is the client for interacting with the Task builders. Task *TaskClient // TaskModelSwitch is the client for interacting with the TaskModelSwitch builders. @@ -84,8 +102,6 @@ type Tx struct { TeamGroupMember *TeamGroupMemberClient // TeamGroupModel is the client for interacting with the TeamGroupModel builders. TeamGroupModel *TeamGroupModelClient - // TeamGroupSkill is the client for interacting with the TeamGroupSkill builders. - TeamGroupSkill *TeamGroupSkillClient // TeamHost is the client for interacting with the TeamHost builders. TeamHost *TeamHostClient // TeamImage is the client for interacting with the TeamImage builders. @@ -96,8 +112,6 @@ type Tx struct { TeamModel *TeamModelClient // TeamOIDCConfig is the client for interacting with the TeamOIDCConfig builders. TeamOIDCConfig *TeamOIDCConfigClient - // TeamSkill is the client for interacting with the TeamSkill builders. - TeamSkill *TeamSkillClient // User is the client for interacting with the User builders. User *UserClient // UserIdentity is the client for interacting with the UserIdentity builders. @@ -235,6 +249,16 @@ func (tx *Tx) Client() *Client { } func (tx *Tx) init() { + tx.AgentPlugin = NewAgentPluginClient(tx.config) + tx.AgentPluginRepo = NewAgentPluginRepoClient(tx.config) + tx.AgentPluginVersion = NewAgentPluginVersionClient(tx.config) + tx.AgentRule = NewAgentRuleClient(tx.config) + tx.AgentRuleVersion = NewAgentRuleVersionClient(tx.config) + tx.AgentSkill = NewAgentSkillClient(tx.config) + tx.AgentSkillGroupBinding = NewAgentSkillGroupBindingClient(tx.config) + tx.AgentSkillRepo = NewAgentSkillRepoClient(tx.config) + tx.AgentSkillVersion = NewAgentSkillVersionClient(tx.config) + tx.AgentSyncJob = NewAgentSyncJobClient(tx.config) tx.Audit = NewAuditClient(tx.config) tx.GitBot = NewGitBotClient(tx.config) tx.GitBotTask = NewGitBotTaskClient(tx.config) @@ -258,7 +282,6 @@ func (tx *Tx) init() { tx.ProjectIssue = NewProjectIssueClient(tx.config) tx.ProjectIssueComment = NewProjectIssueCommentClient(tx.config) tx.ProjectTask = NewProjectTaskClient(tx.config) - tx.Skill = NewSkillClient(tx.config) tx.Task = NewTaskClient(tx.config) tx.TaskModelSwitch = NewTaskModelSwitchClient(tx.config) tx.TaskUsageStat = NewTaskUsageStatClient(tx.config) @@ -270,13 +293,11 @@ func (tx *Tx) init() { tx.TeamGroupImage = NewTeamGroupImageClient(tx.config) tx.TeamGroupMember = NewTeamGroupMemberClient(tx.config) tx.TeamGroupModel = NewTeamGroupModelClient(tx.config) - tx.TeamGroupSkill = NewTeamGroupSkillClient(tx.config) tx.TeamHost = NewTeamHostClient(tx.config) tx.TeamImage = NewTeamImageClient(tx.config) tx.TeamMember = NewTeamMemberClient(tx.config) tx.TeamModel = NewTeamModelClient(tx.config) tx.TeamOIDCConfig = NewTeamOIDCConfigClient(tx.config) - tx.TeamSkill = NewTeamSkillClient(tx.config) tx.User = NewUserClient(tx.config) tx.UserIdentity = NewUserIdentityClient(tx.config) tx.VirtualMachine = NewVirtualMachineClient(tx.config) @@ -289,7 +310,7 @@ func (tx *Tx) init() { // of them in order to commit or rollback the transaction. // // If a closed transaction is embedded in one of the generated entities, and the entity -// applies a query, for example: Audit.QueryXXX(), the query will be executed +// applies a query, for example: AgentPlugin.QueryXXX(), the query will be executed // through the driver which created this transaction. // // Note that txDriver is not goroutine safe. diff --git a/backend/db/user.go b/backend/db/user.go index ae27db50..36dc2187 100644 --- a/backend/db/user.go +++ b/backend/db/user.go @@ -62,8 +62,6 @@ type UserEdges struct { Models []*Model `json:"models,omitempty"` // Images holds the value of the images edge. Images []*Image `json:"images,omitempty"` - // Skills holds the value of the skills edge. - Skills []*Skill `json:"skills,omitempty"` // Hosts holds the value of the hosts edge. Hosts []*Host `json:"hosts,omitempty"` // Vms holds the value of the vms edge. @@ -96,7 +94,7 @@ type UserEdges struct { GitBotUsers []*GitBotUser `json:"git_bot_users,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [22]bool + loadedTypes [21]bool } // IdentitiesOrErr returns the Identities value or an error if the edge @@ -153,19 +151,10 @@ func (e UserEdges) ImagesOrErr() ([]*Image, error) { return nil, &NotLoadedError{edge: "images"} } -// SkillsOrErr returns the Skills value or an error if the edge -// was not loaded in eager-loading. -func (e UserEdges) SkillsOrErr() ([]*Skill, error) { - if e.loadedTypes[6] { - return e.Skills, nil - } - return nil, &NotLoadedError{edge: "skills"} -} - // HostsOrErr returns the Hosts value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) HostsOrErr() ([]*Host, error) { - if e.loadedTypes[7] { + if e.loadedTypes[6] { return e.Hosts, nil } return nil, &NotLoadedError{edge: "hosts"} @@ -174,7 +163,7 @@ func (e UserEdges) HostsOrErr() ([]*Host, error) { // VmsOrErr returns the Vms value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) VmsOrErr() ([]*VirtualMachine, error) { - if e.loadedTypes[8] { + if e.loadedTypes[7] { return e.Vms, nil } return nil, &NotLoadedError{edge: "vms"} @@ -183,7 +172,7 @@ func (e UserEdges) VmsOrErr() ([]*VirtualMachine, error) { // TasksOrErr returns the Tasks value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) TasksOrErr() ([]*Task, error) { - if e.loadedTypes[9] { + if e.loadedTypes[8] { return e.Tasks, nil } return nil, &NotLoadedError{edge: "tasks"} @@ -192,7 +181,7 @@ func (e UserEdges) TasksOrErr() ([]*Task, error) { // TaskModelSwitchesOrErr returns the TaskModelSwitches value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) TaskModelSwitchesOrErr() ([]*TaskModelSwitch, error) { - if e.loadedTypes[10] { + if e.loadedTypes[9] { return e.TaskModelSwitches, nil } return nil, &NotLoadedError{edge: "task_model_switches"} @@ -201,7 +190,7 @@ func (e UserEdges) TaskModelSwitchesOrErr() ([]*TaskModelSwitch, error) { // GitIdentitiesOrErr returns the GitIdentities value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) GitIdentitiesOrErr() ([]*GitIdentity, error) { - if e.loadedTypes[11] { + if e.loadedTypes[10] { return e.GitIdentities, nil } return nil, &NotLoadedError{edge: "git_identities"} @@ -210,7 +199,7 @@ func (e UserEdges) GitIdentitiesOrErr() ([]*GitIdentity, error) { // ProjectsOrErr returns the Projects value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) ProjectsOrErr() ([]*Project, error) { - if e.loadedTypes[12] { + if e.loadedTypes[11] { return e.Projects, nil } return nil, &NotLoadedError{edge: "projects"} @@ -219,7 +208,7 @@ func (e UserEdges) ProjectsOrErr() ([]*Project, error) { // ProjectIssuesOrErr returns the ProjectIssues value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) ProjectIssuesOrErr() ([]*ProjectIssue, error) { - if e.loadedTypes[13] { + if e.loadedTypes[12] { return e.ProjectIssues, nil } return nil, &NotLoadedError{edge: "project_issues"} @@ -228,7 +217,7 @@ func (e UserEdges) ProjectIssuesOrErr() ([]*ProjectIssue, error) { // AssignedIssuesOrErr returns the AssignedIssues value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) AssignedIssuesOrErr() ([]*ProjectIssue, error) { - if e.loadedTypes[14] { + if e.loadedTypes[13] { return e.AssignedIssues, nil } return nil, &NotLoadedError{edge: "assigned_issues"} @@ -237,7 +226,7 @@ func (e UserEdges) AssignedIssuesOrErr() ([]*ProjectIssue, error) { // ProjectCollaboratorsOrErr returns the ProjectCollaborators value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) ProjectCollaboratorsOrErr() ([]*ProjectCollaborator, error) { - if e.loadedTypes[15] { + if e.loadedTypes[14] { return e.ProjectCollaborators, nil } return nil, &NotLoadedError{edge: "project_collaborators"} @@ -246,7 +235,7 @@ func (e UserEdges) ProjectCollaboratorsOrErr() ([]*ProjectCollaborator, error) { // ProjectIssueCommentsOrErr returns the ProjectIssueComments value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) ProjectIssueCommentsOrErr() ([]*ProjectIssueComment, error) { - if e.loadedTypes[16] { + if e.loadedTypes[15] { return e.ProjectIssueComments, nil } return nil, &NotLoadedError{edge: "project_issue_comments"} @@ -255,7 +244,7 @@ func (e UserEdges) ProjectIssueCommentsOrErr() ([]*ProjectIssueComment, error) { // GitBotsOrErr returns the GitBots value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) GitBotsOrErr() ([]*GitBot, error) { - if e.loadedTypes[17] { + if e.loadedTypes[16] { return e.GitBots, nil } return nil, &NotLoadedError{edge: "git_bots"} @@ -264,7 +253,7 @@ func (e UserEdges) GitBotsOrErr() ([]*GitBot, error) { // McpUpstreamsOrErr returns the McpUpstreams value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) McpUpstreamsOrErr() ([]*MCPUpstream, error) { - if e.loadedTypes[18] { + if e.loadedTypes[17] { return e.McpUpstreams, nil } return nil, &NotLoadedError{edge: "mcp_upstreams"} @@ -273,7 +262,7 @@ func (e UserEdges) McpUpstreamsOrErr() ([]*MCPUpstream, error) { // TeamMembersOrErr returns the TeamMembers value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) TeamMembersOrErr() ([]*TeamMember, error) { - if e.loadedTypes[19] { + if e.loadedTypes[18] { return e.TeamMembers, nil } return nil, &NotLoadedError{edge: "team_members"} @@ -282,7 +271,7 @@ func (e UserEdges) TeamMembersOrErr() ([]*TeamMember, error) { // TeamGroupMembersOrErr returns the TeamGroupMembers value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) TeamGroupMembersOrErr() ([]*TeamGroupMember, error) { - if e.loadedTypes[20] { + if e.loadedTypes[19] { return e.TeamGroupMembers, nil } return nil, &NotLoadedError{edge: "team_group_members"} @@ -291,7 +280,7 @@ func (e UserEdges) TeamGroupMembersOrErr() ([]*TeamGroupMember, error) { // GitBotUsersOrErr returns the GitBotUsers value or an error if the edge // was not loaded in eager-loading. func (e UserEdges) GitBotUsersOrErr() ([]*GitBotUser, error) { - if e.loadedTypes[21] { + if e.loadedTypes[20] { return e.GitBotUsers, nil } return nil, &NotLoadedError{edge: "git_bot_users"} @@ -444,11 +433,6 @@ func (_m *User) QueryImages() *ImageQuery { return NewUserClient(_m.config).QueryImages(_m) } -// QuerySkills queries the "skills" edge of the User entity. -func (_m *User) QuerySkills() *SkillQuery { - return NewUserClient(_m.config).QuerySkills(_m) -} - // QueryHosts queries the "hosts" edge of the User entity. func (_m *User) QueryHosts() *HostQuery { return NewUserClient(_m.config).QueryHosts(_m) diff --git a/backend/db/user/user.go b/backend/db/user/user.go index fcd5af6d..0af0a2fc 100644 --- a/backend/db/user/user.go +++ b/backend/db/user/user.go @@ -49,8 +49,6 @@ const ( EdgeModels = "models" // EdgeImages holds the string denoting the images edge name in mutations. EdgeImages = "images" - // EdgeSkills holds the string denoting the skills edge name in mutations. - EdgeSkills = "skills" // EdgeHosts holds the string denoting the hosts edge name in mutations. EdgeHosts = "hosts" // EdgeVms holds the string denoting the vms edge name in mutations. @@ -121,13 +119,6 @@ const ( ImagesInverseTable = "images" // ImagesColumn is the table column denoting the images relation/edge. ImagesColumn = "user_id" - // SkillsTable is the table that holds the skills relation/edge. - SkillsTable = "skills" - // SkillsInverseTable is the table name for the Skill entity. - // It exists in this package in order to avoid circular dependency with the "skill" package. - SkillsInverseTable = "skills" - // SkillsColumn is the table column denoting the skills relation/edge. - SkillsColumn = "user_id" // HostsTable is the table that holds the hosts relation/edge. HostsTable = "hosts" // HostsInverseTable is the table name for the Host entity. @@ -433,20 +424,6 @@ func ByImages(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } -// BySkillsCount orders the results by skills count. -func BySkillsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newSkillsStep(), opts...) - } -} - -// BySkills orders the results by skills terms. -func BySkills(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSkillsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - // ByHostsCount orders the results by hosts count. func ByHostsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -698,13 +675,6 @@ func newImagesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, ImagesTable, ImagesColumn), ) } -func newSkillsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(SkillsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, SkillsTable, SkillsColumn), - ) -} func newHostsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/backend/db/user/where.go b/backend/db/user/where.go index 943eb4f0..984ece12 100644 --- a/backend/db/user/where.go +++ b/backend/db/user/where.go @@ -855,29 +855,6 @@ func HasImagesWith(preds ...predicate.Image) predicate.User { }) } -// HasSkills applies the HasEdge predicate on the "skills" edge. -func HasSkills() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, SkillsTable, SkillsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSkillsWith applies the HasEdge predicate on the "skills" edge with a given conditions (other predicates). -func HasSkillsWith(preds ...predicate.Skill) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := newSkillsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - // HasHosts applies the HasEdge predicate on the "hosts" edge. func HasHosts() predicate.User { return predicate.User(func(s *sql.Selector) { diff --git a/backend/db/user_create.go b/backend/db/user_create.go index 7c7d8d59..f4a502c9 100644 --- a/backend/db/user_create.go +++ b/backend/db/user_create.go @@ -25,7 +25,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/projectcollaborator" "github.com/chaitin/MonkeyCode/backend/db/projectissue" "github.com/chaitin/MonkeyCode/backend/db/projectissuecomment" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/task" "github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch" "github.com/chaitin/MonkeyCode/backend/db/team" @@ -264,21 +263,6 @@ func (_c *UserCreate) AddImages(v ...*Image) *UserCreate { return _c.AddImageIDs(ids...) } -// AddSkillIDs adds the "skills" edge to the Skill entity by IDs. -func (_c *UserCreate) AddSkillIDs(ids ...uuid.UUID) *UserCreate { - _c.mutation.AddSkillIDs(ids...) - return _c -} - -// AddSkills adds the "skills" edges to the Skill entity. -func (_c *UserCreate) AddSkills(v ...*Skill) *UserCreate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddSkillIDs(ids...) -} - // AddHostIDs adds the "hosts" edge to the Host entity by IDs. func (_c *UserCreate) AddHostIDs(ids ...string) *UserCreate { _c.mutation.AddHostIDs(ids...) @@ -771,22 +755,6 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.SkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.SkillsTable, - Columns: []string{user.SkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } if nodes := _c.mutation.HostsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/backend/db/user_query.go b/backend/db/user_query.go index 9c5a47f4..ec5367d1 100644 --- a/backend/db/user_query.go +++ b/backend/db/user_query.go @@ -26,7 +26,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/projectcollaborator" "github.com/chaitin/MonkeyCode/backend/db/projectissue" "github.com/chaitin/MonkeyCode/backend/db/projectissuecomment" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/task" "github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch" "github.com/chaitin/MonkeyCode/backend/db/team" @@ -52,7 +51,6 @@ type UserQuery struct { withGroups *TeamGroupQuery withModels *ModelQuery withImages *ImageQuery - withSkills *SkillQuery withHosts *HostQuery withVms *VirtualMachineQuery withTasks *TaskQuery @@ -237,28 +235,6 @@ func (_q *UserQuery) QueryImages() *ImageQuery { return query } -// QuerySkills chains the current query on the "skills" edge. -func (_q *UserQuery) QuerySkills() *SkillQuery { - query := (&SkillClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, selector), - sqlgraph.To(skill.Table, skill.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, user.SkillsTable, user.SkillsColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - // QueryHosts chains the current query on the "hosts" edge. func (_q *UserQuery) QueryHosts() *HostQuery { query := (&HostClient{config: _q.config}).Query() @@ -787,7 +763,6 @@ func (_q *UserQuery) Clone() *UserQuery { withGroups: _q.withGroups.Clone(), withModels: _q.withModels.Clone(), withImages: _q.withImages.Clone(), - withSkills: _q.withSkills.Clone(), withHosts: _q.withHosts.Clone(), withVms: _q.withVms.Clone(), withTasks: _q.withTasks.Clone(), @@ -876,17 +851,6 @@ func (_q *UserQuery) WithImages(opts ...func(*ImageQuery)) *UserQuery { return _q } -// WithSkills tells the query-builder to eager-load the nodes that are connected to -// the "skills" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *UserQuery) WithSkills(opts ...func(*SkillQuery)) *UserQuery { - query := (&SkillClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withSkills = query - return _q -} - // WithHosts tells the query-builder to eager-load the nodes that are connected to // the "hosts" edge. The optional arguments are used to configure the query builder of the edge. func (_q *UserQuery) WithHosts(opts ...func(*HostQuery)) *UserQuery { @@ -1130,14 +1094,13 @@ func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e var ( nodes = []*User{} _spec = _q.querySpec() - loadedTypes = [22]bool{ + loadedTypes = [21]bool{ _q.withIdentities != nil, _q.withAudits != nil, _q.withTeams != nil, _q.withGroups != nil, _q.withModels != nil, _q.withImages != nil, - _q.withSkills != nil, _q.withHosts != nil, _q.withVms != nil, _q.withTasks != nil, @@ -1218,13 +1181,6 @@ func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e return nil, err } } - if query := _q.withSkills; query != nil { - if err := _q.loadSkills(ctx, query, nodes, - func(n *User) { n.Edges.Skills = []*Skill{} }, - func(n *User, e *Skill) { n.Edges.Skills = append(n.Edges.Skills, e) }); err != nil { - return nil, err - } - } if query := _q.withHosts; query != nil { if err := _q.loadHosts(ctx, query, nodes, func(n *User) { n.Edges.Hosts = []*Host{} }, @@ -1579,36 +1535,6 @@ func (_q *UserQuery) loadImages(ctx context.Context, query *ImageQuery, nodes [] } return nil } -func (_q *UserQuery) loadSkills(ctx context.Context, query *SkillQuery, nodes []*User, init func(*User), assign func(*User, *Skill)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[uuid.UUID]*User) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(skill.FieldUserID) - } - query.Where(predicate.Skill(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(user.SkillsColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.UserID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} func (_q *UserQuery) loadHosts(ctx context.Context, query *HostQuery, nodes []*User, init func(*User), assign func(*User, *Host)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[uuid.UUID]*User) diff --git a/backend/db/user_update.go b/backend/db/user_update.go index 2e95d115..3cc5121f 100644 --- a/backend/db/user_update.go +++ b/backend/db/user_update.go @@ -25,7 +25,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/db/projectcollaborator" "github.com/chaitin/MonkeyCode/backend/db/projectissue" "github.com/chaitin/MonkeyCode/backend/db/projectissuecomment" - "github.com/chaitin/MonkeyCode/backend/db/skill" "github.com/chaitin/MonkeyCode/backend/db/task" "github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch" "github.com/chaitin/MonkeyCode/backend/db/team" @@ -310,21 +309,6 @@ func (_u *UserUpdate) AddImages(v ...*Image) *UserUpdate { return _u.AddImageIDs(ids...) } -// AddSkillIDs adds the "skills" edge to the Skill entity by IDs. -func (_u *UserUpdate) AddSkillIDs(ids ...uuid.UUID) *UserUpdate { - _u.mutation.AddSkillIDs(ids...) - return _u -} - -// AddSkills adds the "skills" edges to the Skill entity. -func (_u *UserUpdate) AddSkills(v ...*Skill) *UserUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddSkillIDs(ids...) -} - // AddHostIDs adds the "hosts" edge to the Host entity by IDs. func (_u *UserUpdate) AddHostIDs(ids ...string) *UserUpdate { _u.mutation.AddHostIDs(ids...) @@ -681,27 +665,6 @@ func (_u *UserUpdate) RemoveImages(v ...*Image) *UserUpdate { return _u.RemoveImageIDs(ids...) } -// ClearSkills clears all "skills" edges to the Skill entity. -func (_u *UserUpdate) ClearSkills() *UserUpdate { - _u.mutation.ClearSkills() - return _u -} - -// RemoveSkillIDs removes the "skills" edge to Skill entities by IDs. -func (_u *UserUpdate) RemoveSkillIDs(ids ...uuid.UUID) *UserUpdate { - _u.mutation.RemoveSkillIDs(ids...) - return _u -} - -// RemoveSkills removes "skills" edges to Skill entities. -func (_u *UserUpdate) RemoveSkills(v ...*Skill) *UserUpdate { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveSkillIDs(ids...) -} - // ClearHosts clears all "hosts" edges to the Host entity. func (_u *UserUpdate) ClearHosts() *UserUpdate { _u.mutation.ClearHosts() @@ -1429,51 +1392,6 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.SkillsTable, - Columns: []string{user.SkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedSkillsIDs(); len(nodes) > 0 && !_u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.SkillsTable, - Columns: []string{user.SkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.SkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.SkillsTable, - Columns: []string{user.SkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } if _u.mutation.HostsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -2450,21 +2368,6 @@ func (_u *UserUpdateOne) AddImages(v ...*Image) *UserUpdateOne { return _u.AddImageIDs(ids...) } -// AddSkillIDs adds the "skills" edge to the Skill entity by IDs. -func (_u *UserUpdateOne) AddSkillIDs(ids ...uuid.UUID) *UserUpdateOne { - _u.mutation.AddSkillIDs(ids...) - return _u -} - -// AddSkills adds the "skills" edges to the Skill entity. -func (_u *UserUpdateOne) AddSkills(v ...*Skill) *UserUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddSkillIDs(ids...) -} - // AddHostIDs adds the "hosts" edge to the Host entity by IDs. func (_u *UserUpdateOne) AddHostIDs(ids ...string) *UserUpdateOne { _u.mutation.AddHostIDs(ids...) @@ -2821,27 +2724,6 @@ func (_u *UserUpdateOne) RemoveImages(v ...*Image) *UserUpdateOne { return _u.RemoveImageIDs(ids...) } -// ClearSkills clears all "skills" edges to the Skill entity. -func (_u *UserUpdateOne) ClearSkills() *UserUpdateOne { - _u.mutation.ClearSkills() - return _u -} - -// RemoveSkillIDs removes the "skills" edge to Skill entities by IDs. -func (_u *UserUpdateOne) RemoveSkillIDs(ids ...uuid.UUID) *UserUpdateOne { - _u.mutation.RemoveSkillIDs(ids...) - return _u -} - -// RemoveSkills removes "skills" edges to Skill entities. -func (_u *UserUpdateOne) RemoveSkills(v ...*Skill) *UserUpdateOne { - ids := make([]uuid.UUID, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveSkillIDs(ids...) -} - // ClearHosts clears all "hosts" edges to the Host entity. func (_u *UserUpdateOne) ClearHosts() *UserUpdateOne { _u.mutation.ClearHosts() @@ -3599,51 +3481,6 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.SkillsTable, - Columns: []string{user.SkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedSkillsIDs(); len(nodes) > 0 && !_u.mutation.SkillsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.SkillsTable, - Columns: []string{user.SkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.SkillsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.SkillsTable, - Columns: []string{user.SkillsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(skill.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } if _u.mutation.HostsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index 0f05dfa2..2230a1c3 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -4,6 +4,55 @@ "contact": {} }, "paths": { + "/api/v1/plugins": { + "get": { + "security": [ + { + "MonkeyCodeAIAuth": [] + } + ], + "description": "并集返回 (global ∪ 用户 active team) 两级 scope 下的 plugin,同名 team\u003eglobal 覆盖;disabled 仍返回但 enabled=false。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "【公共】plugin" + ], + "summary": "获取 Plugins 列表", + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/web.Resp" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.PluginListItem" + } + } + } + } + ] + } + }, + "500": { + "description": "服务器内部错误", + "schema": { + "$ref": "#/definitions/web.Resp" + } + } + } + } + }, "/api/v1/public/captcha/challenge": { "post": { "description": "CreateCaptcha", @@ -61,6 +110,55 @@ } } }, + "/api/v1/skills": { + "get": { + "security": [ + { + "MonkeyCodeAIAuth": [] + } + ], + "description": "并集返回 (global ∪ 用户 active team ∪ 用户个人) 三级 scope 下的 skill,禁用的 skill 返回 enabled=false。", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "【用户】任务管理" + ], + "summary": "获取本用户的 Skill 列表", + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/web.Resp" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.SkillListItem" + } + } + } + } + ] + } + }, + "500": { + "description": "服务器内部错误", + "schema": { + "$ref": "#/definitions/web.Resp" + } + } + } + } + }, "/api/v1/teams/admin": { "post": { "security": [ @@ -330,6 +428,67 @@ } } }, + "/api/v1/teams/extension-packages": { + "post": { + "security": [ + { + "MonkeyCodeAITeamAuth": [] + } + ], + "description": "上传团队扩展包并导入 Skills 和团队镜像记录", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "【Team 管理员】扩展包管理" + ], + "summary": "上传团队扩展包", + "parameters": [ + { + "type": "file", + "description": "扩展包 zip", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/web.Resp" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/domain.ImportTeamExtensionPackageResp" + } + } + } + ] + } + }, + "401": { + "description": "未授权", + "schema": { + "$ref": "#/definitions/web.Resp" + } + }, + "500": { + "description": "服务器内部错误", + "schema": { + "$ref": "#/definitions/web.Resp" + } + } + } + } + }, "/api/v1/teams/groups": { "get": { "security": [ @@ -2058,7 +2217,6 @@ "MonkeyCodeAITeamAuth": [] } ], - "description": "获取团队 Skill 列表", "consumes": [ "application/json" ], @@ -2108,7 +2266,6 @@ "MonkeyCodeAITeamAuth": [] } ], - "description": "添加团队 Skill", "consumes": [ "application/json" ], @@ -2118,7 +2275,7 @@ "tags": [ "【Team 管理员】Skill 管理" ], - "summary": "添加团队 Skill", + "summary": "添加团队 Skill (JSON)", "parameters": [ { "description": "请求参数", @@ -2171,7 +2328,6 @@ "MonkeyCodeAITeamAuth": [] } ], - "description": "上传团队 Skill zip 包", "consumes": [ "multipart/form-data" ], @@ -2181,7 +2337,7 @@ "tags": [ "【Team 管理员】Skill 管理" ], - "summary": "上传团队 Skill zip 包", + "summary": "添加团队 Skill (multipart zip)", "parameters": [ { "type": "string", @@ -2205,10 +2361,9 @@ }, { "type": "string", - "description": "SKILL.md 原文", + "description": "SKILL.md 原文(可选)", "name": "content", - "in": "formData", - "required": true + "in": "formData" }, { "type": "string", @@ -2216,20 +2371,6 @@ "name": "group_ids", "in": "formData" }, - { - "type": "string", - "description": "来源类型", - "name": "source_type", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "来源标签", - "name": "source_label", - "in": "formData", - "required": true - }, { "type": "string", "description": "zip 内 SKILL.md 路径", @@ -2285,7 +2426,7 @@ "MonkeyCodeAITeamAuth": [] } ], - "description": "更新团队 Skill", + "description": "请求参数的 content 非空时,后端将 SKILL.md 重新打包上传 OSS 并创建新的 agent_skill_versions 并切到 active version 到新版本,否则仅更新当前版本的 description / tags / is_force_delivery / group_ids", "consumes": [ "application/json" ], @@ -2353,7 +2494,7 @@ "MonkeyCodeAITeamAuth": [] } ], - "description": "删除团队 Skill", + "description": "从本团队 skill repo 中软删所选 agent skill", "consumes": [ "application/json" ], @@ -9770,12 +9911,11 @@ "required": [ "content", "description", - "name", - "source_label", - "source_type" + "name" ], "properties": { "content": { + "description": "SKILL.md 原文", "type": "string" }, "description": { @@ -9787,6 +9927,9 @@ "type": "string" } }, + "is_force_delivery": { + "type": "boolean" + }, "name": { "type": "string" }, @@ -9797,6 +9940,7 @@ "type": "string" }, "source_type": { + "description": "SourceType ∈ {\"zip\",\"markdown\",\"text\"};SourceLabel 为文件名或 \"粘贴文本\"。\n纯展示元数据,存进 active version 的 parsed_meta。", "type": "string" }, "tags": { @@ -10693,6 +10837,29 @@ } } }, + "domain.ImportTeamExtensionPackageResp": { + "type": "object", + "properties": { + "created_images": { + "type": "integer" + }, + "created_skills": { + "type": "integer" + }, + "package_id": { + "type": "string" + }, + "updated_images": { + "type": "integer" + }, + "updated_skills": { + "type": "integer" + }, + "version": { + "type": "string" + } + } + }, "domain.InstallCommand": { "type": "object", "properties": { @@ -11238,6 +11405,35 @@ } } }, + "domain.PluginListItem": { + "type": "object", + "properties": { + "active_version": { + "type": "string" + }, + "description": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "entry": { + "type": "string" + }, + "id": { + "type": "string" + }, + "is_force_delivery": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "scope": { + "$ref": "#/definitions/domain.SkillScope" + } + } + }, "domain.Project": { "type": "object", "properties": { @@ -11717,6 +11913,72 @@ } } }, + "domain.SkillGroupRef": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "domain.SkillListItem": { + "type": "object", + "properties": { + "active_version": { + "type": "string" + }, + "categories": { + "type": "array", + "items": { + "type": "string" + } + }, + "description": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "groups": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.SkillGroupRef" + } + }, + "id": { + "type": "string" + }, + "is_force_delivery": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "scope": { + "$ref": "#/definitions/domain.SkillScope" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "domain.SkillScope": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, "domain.SpeechRecognitionData": { "type": "object", "properties": { @@ -12003,6 +12265,13 @@ "issue_id": { "type": "string" }, + "plugin_ids": { + "description": "Plugin IDs 数组(仅 OpenCode 真正下发)", + "type": "array", + "items": { + "type": "string" + } + }, "project_id": { "type": "string" }, @@ -12702,7 +12971,17 @@ "domain.TeamSkill": { "type": "object", "properties": { + "active_version": { + "type": "string" + }, + "categories": { + "type": "array", + "items": { + "type": "string" + } + }, "content": { + "description": "SKILL.md 文本,从 active version 当时入库时记录", "type": "string" }, "created_at": { @@ -12711,22 +12990,25 @@ "description": { "type": "string" }, + "enabled": { + "type": "boolean" + }, "groups": { "type": "array", "items": { - "$ref": "#/definitions/domain.TeamGroup" + "$ref": "#/definitions/domain.SkillGroupRef" } }, "id": { "type": "string" }, - "name": { - "type": "string" + "is_force_delivery": { + "type": "boolean" }, - "package_object_key": { + "name": { "type": "string" }, - "package_url": { + "s3_key": { "type": "string" }, "skill_md_path": { @@ -12845,6 +13127,9 @@ "sleep_seconds": { "type": "integer" }, + "task_concurrency_limit": { + "type": "integer" + }, "team_id": { "type": "string" } @@ -13219,7 +13504,11 @@ "type": "string" } }, + "is_force_delivery": { + "type": "boolean" + }, "name": { + "description": "当前不允许改 name(unique 索引硬约束),保留位", "type": "string" }, "skill_md_path": { @@ -13253,6 +13542,9 @@ }, "sleep_seconds": { "type": "integer" + }, + "task_concurrency_limit": { + "type": "integer" } } }, diff --git a/backend/domain/plugin.go b/backend/domain/plugin.go new file mode 100644 index 00000000..8baea4b8 --- /dev/null +++ b/backend/domain/plugin.go @@ -0,0 +1,16 @@ +package domain + +// PluginListItem 公共 plugin 列表项(/api/v1/plugins),仅 OpenCode 任务真正下发。 +// +// 同 SkillListItem,三级 scope 并集 + 覆盖,Enabled=false 仍展示;Groups 留空 +// (plugin 没有团队管理员上传 UI)。 +type PluginListItem struct { + ID string `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + Entry string `json:"entry"` + ActiveVersion string `json:"active_version,omitempty"` + IsForceDelivery bool `json:"is_force_delivery"` + Enabled bool `json:"enabled"` + Scope SkillScope `json:"scope"` +} diff --git a/backend/domain/skill.go b/backend/domain/skill.go new file mode 100644 index 00000000..96294010 --- /dev/null +++ b/backend/domain/skill.go @@ -0,0 +1,32 @@ +package domain + +// SkillListItem 公共 skill 列表项(/api/v1/skills),由 agentresource.Repo +// 从 DB 读取,无文件系统依赖。 +// +// 三级 scope (global/team/user) 并集 + name 覆盖(user > team > global) 后返 +// 回;disabled 的 skill 仍会出现在列表里(Enabled=false),由前端灰显但不允许 +// 勾选(选了 dispatch 端也会跳过)。 +type SkillListItem struct { + ID string `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + Tags []string `json:"tags"` + Categories []string `json:"categories,omitempty"` + ActiveVersion string `json:"active_version,omitempty"` + IsForceDelivery bool `json:"is_force_delivery"` + Enabled bool `json:"enabled"` + Scope SkillScope `json:"scope"` + Groups []SkillGroupRef `json:"groups,omitempty"` +} + +// SkillScope 显示这个 skill 来自哪一层 (global/team/user) 以及对应 id。 +type SkillScope struct { + Type string `json:"type"` + ID string `json:"id"` +} + +// SkillGroupRef 仅 scope=team 的 skill 会带,用于在前端展示"分享给哪些分组"。 +type SkillGroupRef struct { + ID string `json:"id"` + Name string `json:"name"` +} diff --git a/backend/domain/task.go b/backend/domain/task.go index 1c95e87f..b63f3073 100644 --- a/backend/domain/task.go +++ b/backend/domain/task.go @@ -77,6 +77,7 @@ type TaskExtraConfig struct { ProjectID uuid.UUID `json:"project_id" validate:"omitempty"` IssueID uuid.UUID `json:"issue_id" validate:"omitempty"` SkillIDs []string `json:"skill_ids" validate:"omitempty"` + PluginIDs []string `json:"plugin_ids" validate:"omitempty"` // Plugin IDs 数组(仅 OpenCode 真正下发) } // CreateTaskReq 创建任务请求 diff --git a/backend/domain/team_dashboard.go b/backend/domain/team_dashboard.go index acdb5734..c62185ff 100644 --- a/backend/domain/team_dashboard.go +++ b/backend/domain/team_dashboard.go @@ -134,19 +134,19 @@ type TeamDashboardListReq struct { type TeamProjectListResp struct { Projects []*TeamProjectItem `json:"projects"` - Page *db.Cursor `json:"page"` + Page *db.Cursor `json:"page"` } type TeamProjectItem struct { - ID uuid.UUID `json:"id"` - Name string `json:"name"` - RepoURL string `json:"repo_url"` - Branch string `json:"branch"` - Creator *User `json:"creator"` - TaskCount int `json:"task_count"` - IssueCount int `json:"issue_count"` - CreatedAt int64 `json:"created_at"` - UpdatedAt int64 `json:"updated_at"` + ID uuid.UUID `json:"id"` + Name string `json:"name"` + RepoURL string `json:"repo_url"` + Branch string `json:"branch"` + Creator *User `json:"creator"` + TaskCount int `json:"task_count"` + IssueCount int `json:"issue_count"` + CreatedAt int64 `json:"created_at"` + UpdatedAt int64 `json:"updated_at"` } type TeamTaskListResp struct { @@ -169,7 +169,7 @@ type TeamTaskItem struct { type TeamConversationListResp struct { Conversations []*TeamConversationItem `json:"conversations"` - Page *db.Cursor `json:"page"` + Page *db.Cursor `json:"page"` } type TeamConversationItem struct { @@ -178,8 +178,8 @@ type TeamConversationItem struct { TaskTitle string `json:"task_title"` ProjectID uuid.UUID `json:"project_id"` ProjectName string `json:"project_name"` - Creator *User `json:"creator"` - Content string `json:"content"` + Creator *User `json:"creator"` + Content string `json:"content"` AttachmentCount int `json:"attachment_count"` CreatedAt int64 `json:"created_at"` } diff --git a/backend/domain/team_skill.go b/backend/domain/team_skill.go index 23f91cf3..43cb9253 100644 --- a/backend/domain/team_skill.go +++ b/backend/domain/team_skill.go @@ -6,76 +6,99 @@ import ( "github.com/google/uuid" "github.com/chaitin/MonkeyCode/backend/db" - "github.com/chaitin/MonkeyCode/backend/pkg/cvt" ) +// TeamSkill 团队私有 skill 的 DTO,对应 agent_skill 在 scope_type=team 下的一行 +// + 其 active_version 的元数据 + 团队分组关联。 +type TeamSkill struct { + ID uuid.UUID `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + Tags []string `json:"tags"` + Categories []string `json:"categories,omitempty"` + Content string `json:"content"` // SKILL.md 文本,从 active version 当时入库时记录 + ActiveVersion string `json:"active_version,omitempty"` + S3Key string `json:"s3_key,omitempty"` + IsForceDelivery bool `json:"is_force_delivery"` + Enabled bool `json:"enabled"` + SkillMDPath string `json:"skill_md_path,omitempty"` + SourceType string `json:"source_type,omitempty"` + SourceLabel string `json:"source_label,omitempty"` + Groups []SkillGroupRef `json:"groups"` + CreatedAt int64 `json:"created_at"` + UpdatedAt int64 `json:"updated_at"` +} + +// TeamSkillUsecase 是团队管理员侧的 skill CRUD 接口。 type TeamSkillUsecase interface { + List(ctx context.Context, teamUser *TeamUser) (*ListTeamSkillsResp, error) Add(ctx context.Context, teamUser *TeamUser, req *AddTeamSkillReq) (*TeamSkill, error) AddPackage(ctx context.Context, teamUser *TeamUser, req *AddTeamSkillPackageReq) (*TeamSkill, error) - List(ctx context.Context, teamUser *TeamUser) (*ListTeamSkillsResp, error) Update(ctx context.Context, teamUser *TeamUser, req *UpdateTeamSkillReq) (*TeamSkill, error) Delete(ctx context.Context, teamUser *TeamUser, req *DeleteTeamSkillReq) error } +// TeamSkillRepo 是 usecase 用来读写 agent_skill+version+group_bindings 的接口。 type TeamSkillRepo interface { - List(ctx context.Context, teamID uuid.UUID) ([]*db.Skill, error) - Create(ctx context.Context, teamID, userID uuid.UUID, req *AddTeamSkillReq) (*db.Skill, error) - Update(ctx context.Context, teamID uuid.UUID, req *UpdateTeamSkillReq) (*db.Skill, error) - Delete(ctx context.Context, teamID, skillID uuid.UUID) error + List(ctx context.Context, teamID uuid.UUID) ([]*db.AgentSkill, error) + // GetSkill 取单个 team scope 下的 agent_skill 行(变更后回包完整 DTO 用)。 + GetSkill(ctx context.Context, teamID, skillID uuid.UUID) (*db.AgentSkill, error) + GetBareRepoID(ctx context.Context, teamID uuid.UUID) (uuid.UUID, error) + // UpsertSkill 在 bare repo 下按 (repo_id, name) upsert agent_skill; + // 不存在则创建,存在则原样返回(更新由 Update / new version 走单独路径)。 + UpsertSkill(ctx context.Context, teamID, repoID, userID uuid.UUID, name, description string, isForceDelivery bool, extensionPackageID string) (*db.AgentSkill, error) + // CreateVersion 写一行 agent_skill_versions 并把 agent_skill.active_version_id 切到新版本。 + // version 字符串由 usecase 计算(典型 v1/v2/v3)。 + CreateVersion(ctx context.Context, skillID uuid.UUID, version, s3Key string, meta SkillVersionMeta) (*db.AgentSkillVersion, error) + // UpdateMeta 改 agent_skill 行的 name / description / is_force_delivery + // (不产生新版本)。name 为空字符串时不改名,避免误清空。 + UpdateMeta(ctx context.Context, teamID, skillID uuid.UUID, name string, description *string, isForceDelivery *bool) (*db.AgentSkill, error) + // UpdateActiveVersionTags 原地更新 active version 的 parsed_meta.tags + // (不建新版本),供"只改元数据"路径持久化标签编辑。skill 无 active + // version 时为 no-op。 + UpdateActiveVersionTags(ctx context.Context, skillID uuid.UUID, tags []string) error + // SoftDeleteSkill 仅软删 agent_skill 行(repo 不动)。 + SoftDeleteSkill(ctx context.Context, teamID, skillID uuid.UUID) error + // ReplaceGroupBindings 用 groupIDs 全量替换 skill ↔ team_group 的关联。 + ReplaceGroupBindings(ctx context.Context, teamID, skillID uuid.UUID, groupIDs []uuid.UUID) error + // GetActiveVersion 加载 agent_skill 的当前 active_version_id 对应行。 + GetActiveVersion(ctx context.Context, skillID uuid.UUID) (*db.AgentSkillVersion, error) + // NextVersionFor 计算 agent_skill 下一个版本号("v{N+1}")。 + NextVersionFor(ctx context.Context, skillID uuid.UUID) (string, error) + // LoadGroups 返回 skill 关联的 team_group(只返回 id + name)。 + LoadGroups(ctx context.Context, skillID uuid.UUID) ([]SkillGroupRef, error) } -type TeamSkill struct { - ID uuid.UUID `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - Tags []string `json:"tags"` - Content string `json:"content"` - PackageKey string `json:"package_object_key,omitempty"` - PackageURL string `json:"package_url,omitempty"` - Groups []*TeamGroup `json:"groups"` - SourceType string `json:"source_type"` - SourceLabel string `json:"source_label"` - SkillMDPath string `json:"skill_md_path,omitempty"` - CreatedAt int64 `json:"created_at"` - UpdatedAt int64 `json:"updated_at"` -} - -func (t *TeamSkill) From(src *db.Skill) *TeamSkill { - if src == nil { - return t - } - - t.ID = src.ID - t.Name = src.Name - t.Description = src.Description - t.Tags = src.Tags - t.Content = src.Content - t.PackageKey = src.PackageObjectKey - t.PackageURL = src.PackageURL - t.SourceType = src.SourceType - t.SourceLabel = src.SourceLabel - t.SkillMDPath = src.SkillMdPath - t.Groups = cvt.Iter(src.Edges.Groups, func(_ int, g *db.TeamGroup) *TeamGroup { - return cvt.From(g, &TeamGroup{}) - }) - t.CreatedAt = src.CreatedAt.Unix() - t.UpdatedAt = src.UpdatedAt.Unix() - return t +// SkillVersionMeta 写 agent_skill_versions.parsed_meta 时用。 +// description 仍写到 agent_skill 行,这里只放 frontmatter 派生 + 创作来源字段。 +type SkillVersionMeta struct { + Description string + Categories []string + Tags []string + SourceType string + SourceLabel string } +// AddTeamSkillReq 团队管理员用 JSON 直接传 SKILL.md 文本,后端打包成 zip。 +// is_force_delivery 字段允许传(团队管理员 UI 不展示,但平台管理员可通过 +// mcai-admin-new 直写 DB,语义上保留 path),默认 false。 type AddTeamSkillReq struct { - Name string `json:"name" form:"name" validate:"required"` - Description string `json:"description" form:"description" validate:"required"` - Tags []string `json:"tags" validate:"omitempty"` - Content string `json:"content" form:"content" validate:"required"` - PackageObjectKey string `json:"package_object_key,omitempty" swaggerignore:"true"` - PackageURL string `json:"package_url,omitempty" swaggerignore:"true"` - GroupIDs []uuid.UUID `json:"group_ids" validate:"omitempty"` - SourceType string `json:"source_type" form:"source_type" validate:"required"` - SourceLabel string `json:"source_label" form:"source_label" validate:"required"` - SkillMDPath string `json:"skill_md_path" form:"skill_md_path" validate:"omitempty"` + Name string `json:"name" validate:"required"` + Description string `json:"description" validate:"required"` + Tags []string `json:"tags" validate:"omitempty"` + Content string `json:"content" validate:"required"` // SKILL.md 原文 + GroupIDs []uuid.UUID `json:"group_ids" validate:"omitempty"` + SkillMDPath string `json:"skill_md_path" validate:"omitempty"` + IsForceDelivery bool `json:"is_force_delivery,omitempty"` + // SourceType ∈ {"zip","markdown","text"};SourceLabel 为文件名或 "粘贴文本"。 + // 纯展示元数据,存进 active version 的 parsed_meta。 + SourceType string `json:"source_type" validate:"omitempty"` + SourceLabel string `json:"source_label" validate:"omitempty"` + ExtensionPackageID string `json:"extension_package_id,omitempty" swaggerignore:"true"` } +// AddTeamSkillPackageReq multipart 上传:从 zip 包里解 SKILL.md 验证,frontmatter +// 解出 tags 时 form 字段(若 present)覆盖。 type AddTeamSkillPackageReq struct { AddTeamSkillReq PackageFilename string `json:"-" swaggerignore:"true"` @@ -86,16 +109,18 @@ type ListTeamSkillsResp struct { Skills []*TeamSkill `json:"skills"` } +// UpdateTeamSkillReq D3 语义:Content 非空 = 内容变更 → 建新版本;否则只改元数据。 type UpdateTeamSkillReq struct { - SkillID uuid.UUID `param:"skill_id" validate:"required" json:"-" swaggerignore:"true"` - Name string `json:"name" validate:"omitempty"` - Description string `json:"description" validate:"omitempty"` - Tags []string `json:"tags" validate:"omitempty"` - Content string `json:"content" validate:"omitempty"` - GroupIDs []uuid.UUID `json:"group_ids" validate:"omitempty"` - SourceType string `json:"source_type" validate:"omitempty"` - SourceLabel string `json:"source_label" validate:"omitempty"` - SkillMDPath *string `json:"skill_md_path,omitempty" validate:"omitempty"` + SkillID uuid.UUID `param:"skill_id" validate:"required" json:"-" swaggerignore:"true"` + Name string `json:"name" validate:"omitempty"` // 当前不允许改 name(unique 索引硬约束),保留位 + Description *string `json:"description" validate:"omitempty"` + Tags []string `json:"tags" validate:"omitempty"` + Content string `json:"content" validate:"omitempty"` + GroupIDs []uuid.UUID `json:"group_ids" validate:"omitempty"` + SkillMDPath *string `json:"skill_md_path,omitempty" validate:"omitempty"` + IsForceDelivery *bool `json:"is_force_delivery,omitempty"` + SourceType *string `json:"source_type,omitempty" validate:"omitempty"` + SourceLabel *string `json:"source_label,omitempty" validate:"omitempty"` } type DeleteTeamSkillReq struct { diff --git a/backend/ent/schema/agent_plugin.go b/backend/ent/schema/agent_plugin.go new file mode 100644 index 00000000..aaec7b55 --- /dev/null +++ b/backend/ent/schema/agent_plugin.go @@ -0,0 +1,101 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/google/uuid" + + "github.com/chaitin/MonkeyCode/backend/ent/types" +) + +// AgentPlugin holds the schema definition for the agent_plugins entity. +type AgentPlugin struct { + ent.Schema +} + +func (AgentPlugin) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("agent_plugins"), + } +} + +// Fields of the AgentPlugin. +func (AgentPlugin) Fields() []ent.Field { + return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New), + field.UUID("repo_id", uuid.UUID{}), + field.String("name").NotEmpty(), + field.Text("description").Optional(), + field.Enum("scope_type").Values("global", "team", "user").Default("global"), + field.String("scope_id").Default("global"), + field.UUID("created_by", uuid.UUID{}), + field.UUID("active_version_id", uuid.UUID{}).Optional().Nillable(), + field.Bool("is_force_delivery").Default(false), + field.Bool("is_orphan").Default(false), + field.Bool("is_deleted").Default(false), + // enabled:见 AgentSkill 同名字段语义说明。 + field.Bool("enabled").Default(true), + field.Time("created_at").Default(time.Now), + field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), + } +} + +// Edges of the AgentPlugin. +func (AgentPlugin) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("repo", AgentPluginRepo.Type).Ref("plugins").Field("repo_id").Unique().Required(), + edge.To("versions", AgentPluginVersion.Type), + } +} + +// Indexes of the AgentPlugin. +func (AgentPlugin) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("repo_id", "name").Unique(), + index.Fields("scope_type", "scope_id"), + index.Fields("active_version_id"), + } +} + +// AgentPluginVersion holds the schema definition for the agent_plugin_versions entity. +type AgentPluginVersion struct { + ent.Schema +} + +func (AgentPluginVersion) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("agent_plugin_versions"), + } +} + +// Fields of the AgentPluginVersion. +func (AgentPluginVersion) Fields() []ent.Field { + return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New), + field.UUID("resource_id", uuid.UUID{}), + field.String("version").NotEmpty(), + field.String("s3_key").NotEmpty(), + field.JSON("parsed_meta", types.PluginParsedMeta{}).Optional(), + field.Time("created_at").Default(time.Now), + } +} + +// Edges of the AgentPluginVersion. +func (AgentPluginVersion) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("plugin", AgentPlugin.Type).Ref("versions").Field("resource_id").Unique().Required(), + } +} + +// Indexes of the AgentPluginVersion. +func (AgentPluginVersion) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("resource_id"), + } +} diff --git a/backend/ent/schema/agent_plugin_repo.go b/backend/ent/schema/agent_plugin_repo.go new file mode 100644 index 00000000..3352bc84 --- /dev/null +++ b/backend/ent/schema/agent_plugin_repo.go @@ -0,0 +1,70 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/google/uuid" + + "github.com/chaitin/MonkeyCode/backend/ent/types" +) + +// AgentPluginRepo holds the schema definition for the agent_plugin_repos entity. +type AgentPluginRepo struct { + ent.Schema +} + +func (AgentPluginRepo) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("agent_plugin_repos"), + } +} + +// Fields of the AgentPluginRepo. +func (AgentPluginRepo) Fields() []ent.Field { + return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New), + field.String("name").NotEmpty(), + field.Enum("scope_type").Values("global", "team", "user").Default("global"), + field.String("scope_id").Default("global"), + field.UUID("created_by", uuid.UUID{}), + field.Enum("source_type").Values("github", "upload", "npm", "bare"), + // github + field.String("github_url").Optional().Nillable(), + field.Enum("ref_type").Values("branch", "tag", "commit").Optional().Nillable(), + field.String("ref_value").Optional().Nillable(), + // upload + field.String("last_upload_filename").Optional().Nillable(), + field.Time("last_upload_at").Optional().Nillable(), + // plugin discovery / manual entries + field.Bool("plugin_discovery_auto_package_json").Default(true), + field.JSON("plugin_manual_entries", types.PluginManualEntries{}).Optional(), + // npm + field.String("npm_package_name").Optional().Nillable(), + field.String("npm_version_spec").Optional().Nillable(), + field.String("npm_registry_url").Optional().Nillable(), + + field.Bool("is_deleted").Default(false), + field.Time("created_at").Default(time.Now), + field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), + } +} + +// Edges of the AgentPluginRepo. +func (AgentPluginRepo) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("plugins", AgentPlugin.Type), + } +} + +// Indexes of the AgentPluginRepo. +func (AgentPluginRepo) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("scope_type", "scope_id"), + } +} diff --git a/backend/ent/schema/agent_rule.go b/backend/ent/schema/agent_rule.go new file mode 100644 index 00000000..e2d9bc64 --- /dev/null +++ b/backend/ent/schema/agent_rule.go @@ -0,0 +1,91 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/google/uuid" +) + +// AgentRule holds the schema definition for the agent_rules entity. +type AgentRule struct { + ent.Schema +} + +func (AgentRule) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("agent_rules"), + } +} + +// Fields of the AgentRule. +func (AgentRule) Fields() []ent.Field { + return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New), + field.String("name").NotEmpty(), + field.Text("description").Optional(), + field.Enum("scope_type").Values("global").Default("global"), + field.String("scope_id").Default("global"), + field.UUID("created_by", uuid.UUID{}), + field.UUID("active_version_id", uuid.UUID{}).Optional().Nillable(), + field.Bool("is_deleted").Default(false), + field.Time("created_at").Default(time.Now), + field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), + } +} + +// Edges of the AgentRule. +func (AgentRule) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("versions", AgentRuleVersion.Type), + } +} + +// Indexes of the AgentRule. +func (AgentRule) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("scope_type", "scope_id"), + index.Fields("active_version_id"), + } +} + +// AgentRuleVersion holds the schema definition for the agent_rule_versions entity. +type AgentRuleVersion struct { + ent.Schema +} + +func (AgentRuleVersion) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("agent_rule_versions"), + } +} + +// Fields of the AgentRuleVersion. +func (AgentRuleVersion) Fields() []ent.Field { + return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New), + field.UUID("rule_id", uuid.UUID{}), + field.String("version").MaxLen(14).NotEmpty(), + field.Text("content"), + field.Time("created_at").Default(time.Now), + } +} + +// Edges of the AgentRuleVersion. +func (AgentRuleVersion) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("rule", AgentRule.Type).Ref("versions").Field("rule_id").Unique().Required(), + } +} + +// Indexes of the AgentRuleVersion. +func (AgentRuleVersion) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("rule_id"), + } +} diff --git a/backend/ent/schema/agent_skill.go b/backend/ent/schema/agent_skill.go new file mode 100644 index 00000000..00956038 --- /dev/null +++ b/backend/ent/schema/agent_skill.go @@ -0,0 +1,111 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/google/uuid" + + "github.com/chaitin/MonkeyCode/backend/ent/types" +) + +// AgentSkill holds the schema definition for the agent_skills entity. +type AgentSkill struct { + ent.Schema +} + +func (AgentSkill) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("agent_skills"), + } +} + +// Fields of the AgentSkill. +func (AgentSkill) Fields() []ent.Field { + return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New), + field.UUID("repo_id", uuid.UUID{}), + field.String("name").NotEmpty(), + field.Text("description").Optional(), + field.Enum("scope_type").Values("global", "team", "user").Default("global"), + field.String("scope_id").Default("global"), + field.UUID("created_by", uuid.UUID{}), + field.UUID("active_version_id", uuid.UUID{}).Optional().Nillable(), + field.Bool("is_force_delivery").Default(false), + field.Bool("is_orphan").Default(false), + field.Bool("is_deleted").Default(false), + // enabled 由平台管理员(mcai-admin-new 直写 DB)控制。 + // 默认 true;false 时 listing 仍展示 + dispatch 跳过。 + field.Bool("enabled").Default(true), + // admin_description / admin_tags:系统管理员在 mcai-admin-new 手动设置 + // 的覆写值。非 nil 时 /api/v1/skills 优先返回这些而非 parsed_meta 里 + // 从 frontmatter 解析出来的值。sync worker 不碰这两个字段。 + field.String("extension_package_id").Optional().Nillable(), + field.Text("admin_description").Optional().Nillable(), + field.JSON("admin_tags", []string{}).Optional(), + field.Time("created_at").Default(time.Now), + field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), + } +} + +// Edges of the AgentSkill. +func (AgentSkill) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("repo", AgentSkillRepo.Type).Ref("skills").Field("repo_id").Unique().Required(), + edge.To("versions", AgentSkillVersion.Type), + // team scope 下分组共享的关联走 agent_skill_group_bindings 表, + // repo 层显式 join 查,不在 ent edge 上暴露 Through(避免 M2M + // 复杂约束;参考 team_group_models 同款做法)。 + } +} + +// Indexes of the AgentSkill. +func (AgentSkill) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("repo_id", "name").Unique(), + index.Fields("scope_type", "scope_id"), + index.Fields("active_version_id"), + } +} + +// AgentSkillVersion holds the schema definition for the agent_skill_versions entity. +type AgentSkillVersion struct { + ent.Schema +} + +func (AgentSkillVersion) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("agent_skill_versions"), + } +} + +// Fields of the AgentSkillVersion. +func (AgentSkillVersion) Fields() []ent.Field { + return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New), + field.UUID("resource_id", uuid.UUID{}), + field.String("version").NotEmpty(), + field.String("s3_key").NotEmpty(), + field.JSON("parsed_meta", types.SkillParsedMeta{}).Optional(), + field.Time("created_at").Default(time.Now), + } +} + +// Edges of the AgentSkillVersion. +func (AgentSkillVersion) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("skill", AgentSkill.Type).Ref("versions").Field("resource_id").Unique().Required(), + } +} + +// Indexes of the AgentSkillVersion. +func (AgentSkillVersion) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("resource_id"), + } +} diff --git a/backend/ent/schema/agent_skill_group_binding.go b/backend/ent/schema/agent_skill_group_binding.go new file mode 100644 index 00000000..33a6e112 --- /dev/null +++ b/backend/ent/schema/agent_skill_group_binding.go @@ -0,0 +1,49 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/google/uuid" +) + +// AgentSkillGroupBinding 把 team scope 下的 agent_skill 关联到 team_group, +// 用于"按分组共享 skill"语义。仅对 scope_type='team' 的 skill 有意义; +// global/user scope 的 skill 不应出现在这张表里。 +type AgentSkillGroupBinding struct { + ent.Schema +} + +func (AgentSkillGroupBinding) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("agent_skill_group_bindings"), + } +} + +func (AgentSkillGroupBinding) Fields() []ent.Field { + return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New), + field.UUID("skill_id", uuid.UUID{}), + field.UUID("group_id", uuid.UUID{}), + field.Time("created_at").Default(time.Now), + } +} + +func (AgentSkillGroupBinding) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("skill", AgentSkill.Type).Field("skill_id").Unique().Required(), + edge.To("group", TeamGroup.Type).Field("group_id").Unique().Required(), + } +} + +func (AgentSkillGroupBinding) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("skill_id", "group_id").Unique(), + index.Fields("group_id"), + } +} diff --git a/backend/ent/schema/agent_skill_repo.go b/backend/ent/schema/agent_skill_repo.go new file mode 100644 index 00000000..f2f85b29 --- /dev/null +++ b/backend/ent/schema/agent_skill_repo.go @@ -0,0 +1,61 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/google/uuid" +) + +// AgentSkillRepo holds the schema definition for the agent_skill_repos entity. +type AgentSkillRepo struct { + ent.Schema +} + +func (AgentSkillRepo) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("agent_skill_repos"), + } +} + +// Fields of the AgentSkillRepo. +func (AgentSkillRepo) Fields() []ent.Field { + return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New), + field.String("name").NotEmpty(), + field.Enum("scope_type").Values("global", "team", "user").Default("global"), + field.String("scope_id").Default("global"), + field.UUID("created_by", uuid.UUID{}), + field.Enum("source_type").Values("github", "upload", "bare"), + // github + field.String("github_url").Optional().Nillable(), + field.Enum("ref_type").Values("branch", "tag", "commit").Optional().Nillable(), + field.String("ref_value").Optional().Nillable(), + // upload + field.String("last_upload_filename").Optional().Nillable(), + field.Time("last_upload_at").Optional().Nillable(), + + field.Bool("is_deleted").Default(false), + field.Time("created_at").Default(time.Now), + field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), + } +} + +// Edges of the AgentSkillRepo. +func (AgentSkillRepo) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("skills", AgentSkill.Type), + } +} + +// Indexes of the AgentSkillRepo. +func (AgentSkillRepo) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("scope_type", "scope_id"), + } +} diff --git a/backend/ent/schema/agent_sync_job.go b/backend/ent/schema/agent_sync_job.go new file mode 100644 index 00000000..07f94a72 --- /dev/null +++ b/backend/ent/schema/agent_sync_job.go @@ -0,0 +1,59 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/google/uuid" + + "github.com/chaitin/MonkeyCode/backend/ent/types" +) + +// AgentSyncJob holds the schema definition for the agent_sync_jobs entity. +// +// sync_jobs references rule / repo via plain UUID columns (no ent edge), +// because resource_kind decides whether rule_id or repo_id is populated. +type AgentSyncJob struct { + ent.Schema +} + +func (AgentSyncJob) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("agent_sync_jobs"), + } +} + +// Fields of the AgentSyncJob. +func (AgentSyncJob) Fields() []ent.Field { + return []ent.Field{ + field.UUID("id", uuid.UUID{}).Default(uuid.New), + field.Enum("resource_kind").Values("rule", "skill", "plugin"), + field.UUID("rule_id", uuid.UUID{}).Optional().Nillable(), + field.UUID("repo_id", uuid.UUID{}).Optional().Nillable(), + field.Enum("source_type").Values("github", "upload", "npm", "rule_inline"), + field.Enum("status"). + Values("pending", "fetching", "parsing", "uploading", "done", "failed"). + Default("pending"), + field.Enum("trigger_type").Values("manual", "upload", "rule_save"), + field.UUID("triggered_by", uuid.UUID{}).Optional().Nillable(), + field.Time("started_at").Optional().Nillable(), + field.Time("finished_at").Optional().Nillable(), + field.JSON("errors", types.SyncJobErrors{}).Optional(), + field.JSON("result_summary", types.SyncJobResultSummary{}).Optional(), + field.Time("created_at").Default(time.Now), + field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), + } +} + +// Indexes of the AgentSyncJob. +func (AgentSyncJob) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("status", "created_at"), + index.Fields("rule_id"), + index.Fields("repo_id"), + } +} diff --git a/backend/ent/schema/skill.go b/backend/ent/schema/skill.go deleted file mode 100644 index eec1aa5b..00000000 --- a/backend/ent/schema/skill.go +++ /dev/null @@ -1,60 +0,0 @@ -package schema - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "github.com/google/uuid" - - "github.com/chaitin/MonkeyCode/backend/pkg/entx" -) - -type Skill struct { - ent.Schema -} - -func (Skill) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("skills"), - entx.NewCursor(entx.CursorKindCreatedAt), - } -} - -func (Skill) Mixin() []ent.Mixin { - return []ent.Mixin{ - entx.SoftDeleteMixin2{}, - } -} - -func (Skill) Fields() []ent.Field { - return []ent.Field{ - field.UUID("id", uuid.UUID{}).Unique(), - field.UUID("user_id", uuid.UUID{}), - field.String("name").NotEmpty(), - field.Text("description").NotEmpty(), - field.JSON("tags", []string{}).Optional(), - field.Text("content").NotEmpty(), - field.String("package_object_key").Optional(), - field.String("package_url").Optional(), - field.String("source_type").NotEmpty(), - field.String("source_label").NotEmpty(), - field.String("skill_md_path").Optional(), - field.String("extension_package_id").Optional(), - field.String("extension_skill_id").Optional(), - field.String("extension_version").Optional(), - field.Time("created_at").Default(time.Now), - field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), - } -} - -func (Skill) Edges() []ent.Edge { - return []ent.Edge{ - edge.From("user", User.Type).Ref("skills").Field("user_id").Unique().Required(), - edge.From("teams", Team.Type).Ref("skills").Through("team_skills", TeamSkill.Type), - edge.From("groups", TeamGroup.Type).Ref("skills").Through("team_group_skills", TeamGroupSkill.Type), - } -} diff --git a/backend/ent/schema/team.go b/backend/ent/schema/team.go index 72eb288a..ed31f3b0 100644 --- a/backend/ent/schema/team.go +++ b/backend/ent/schema/team.go @@ -53,7 +53,6 @@ func (Team) Edges() []ent.Edge { edge.From("members", User.Type).Ref("teams").Through("team_members", TeamMember.Type), edge.To("models", Model.Type).Through("team_models", TeamModel.Type), edge.To("images", Image.Type).Through("team_images", TeamImage.Type), - edge.To("skills", Skill.Type).Through("team_skills", TeamSkill.Type), edge.To("extension_image_archives", TeamExtensionImageArchive.Type), } } diff --git a/backend/ent/schema/teamgroup.go b/backend/ent/schema/teamgroup.go index 4a8722b1..bb4a8f27 100644 --- a/backend/ent/schema/teamgroup.go +++ b/backend/ent/schema/teamgroup.go @@ -50,6 +50,5 @@ func (TeamGroup) Edges() []ent.Edge { edge.To("models", Model.Type).Through("team_group_models", TeamGroupModel.Type), edge.To("images", Image.Type).Through("team_group_images", TeamGroupImage.Type), edge.To("hosts", Host.Type).Through("team_group_hosts", TeamGroupHost.Type), - edge.To("skills", Skill.Type).Through("team_group_skills", TeamGroupSkill.Type), } } diff --git a/backend/ent/schema/teamgroupskill.go b/backend/ent/schema/teamgroupskill.go deleted file mode 100644 index 1e8201bc..00000000 --- a/backend/ent/schema/teamgroupskill.go +++ /dev/null @@ -1,41 +0,0 @@ -package schema - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "github.com/google/uuid" - - "github.com/chaitin/MonkeyCode/backend/pkg/entx" -) - -type TeamGroupSkill struct { - ent.Schema -} - -func (TeamGroupSkill) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("team_group_skills"), - entx.NewCursor(entx.CursorKindCreatedAt), - } -} - -func (TeamGroupSkill) Fields() []ent.Field { - return []ent.Field{ - field.UUID("id", uuid.UUID{}).Unique(), - field.UUID("group_id", uuid.UUID{}), - field.UUID("skill_id", uuid.UUID{}), - field.Time("created_at").Default(time.Now), - } -} - -func (TeamGroupSkill) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("group", TeamGroup.Type).Field("group_id").Unique().Required(), - edge.To("skill", Skill.Type).Field("skill_id").Unique().Required(), - } -} diff --git a/backend/ent/schema/teamskill.go b/backend/ent/schema/teamskill.go deleted file mode 100644 index ed30a80b..00000000 --- a/backend/ent/schema/teamskill.go +++ /dev/null @@ -1,38 +0,0 @@ -package schema - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "github.com/google/uuid" -) - -type TeamSkill struct { - ent.Schema -} - -func (TeamSkill) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("team_skills"), - } -} - -func (TeamSkill) Fields() []ent.Field { - return []ent.Field{ - field.UUID("id", uuid.UUID{}), - field.UUID("team_id", uuid.UUID{}), - field.UUID("skill_id", uuid.UUID{}), - field.Time("created_at").Default(time.Now), - } -} - -func (TeamSkill) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("team", Team.Type).Field("team_id").Unique().Required(), - edge.To("skill", Skill.Type).Field("skill_id").Unique().Required(), - } -} diff --git a/backend/ent/schema/user.go b/backend/ent/schema/user.go index db66d99e..be079778 100644 --- a/backend/ent/schema/user.go +++ b/backend/ent/schema/user.go @@ -57,7 +57,6 @@ func (User) Edges() []ent.Edge { edge.To("groups", TeamGroup.Type).Through("team_group_members", TeamGroupMember.Type), edge.To("models", Model.Type), edge.To("images", Image.Type), - edge.To("skills", Skill.Type), edge.To("hosts", Host.Type), edge.To("vms", VirtualMachine.Type), edge.To("tasks", Task.Type), diff --git a/backend/ent/types/agent_resources.go b/backend/ent/types/agent_resources.go new file mode 100644 index 00000000..5651d750 --- /dev/null +++ b/backend/ent/types/agent_resources.go @@ -0,0 +1,44 @@ +package types + +// SkillParsedMeta is the parsed_meta jsonb payload for agent_skill_versions. +// It mirrors the SKILL.md frontmatter, plus team-admin authoring metadata. +type SkillParsedMeta struct { + Description string `json:"description,omitempty"` + Categories []string `json:"categories,omitempty"` + Tags []string `json:"tags,omitempty"` + // SourceType / SourceLabel 记录团队管理员创作来源(纯展示用): + // SourceType ∈ {"zip","markdown","text"};SourceLabel 是文件名或 "粘贴文本"。 + SourceType string `json:"source_type,omitempty"` + SourceLabel string `json:"source_label,omitempty"` +} + +// PluginParsedMeta is the parsed_meta jsonb payload for agent_plugin_versions. +type PluginParsedMeta struct { + Entry string `json:"entry"` +} + +// PluginManualEntry is one item in agent_plugin_repos.plugin_manual_entries. +type PluginManualEntry struct { + Name string `json:"name"` + Entrypoint string `json:"entrypoint"` +} + +// PluginManualEntries is the jsonb array stored on agent_plugin_repos. +type PluginManualEntries []PluginManualEntry + +// SyncJobError describes a single failure entry recorded on agent_sync_jobs.errors. +type SyncJobError struct { + Dir string `json:"dir,omitempty"` + Reason string `json:"reason"` + Detail string `json:"detail,omitempty"` +} + +// SyncJobErrors is the jsonb array stored on agent_sync_jobs.errors. +type SyncJobErrors []SyncJobError + +// SyncJobResultSummary is the jsonb payload stored on agent_sync_jobs.result_summary. +type SyncJobResultSummary struct { + Created []string `json:"created,omitempty"` + Updated []string `json:"updated,omitempty"` + Orphaned []string `json:"orphaned,omitempty"` +} diff --git a/backend/go.mod b/backend/go.mod index eba658ac..264527e1 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -10,6 +10,7 @@ require ( github.com/ackcoder/go-cap v1.1.3 github.com/alicebob/miniredis/v2 v2.35.0 github.com/aliyun/alibabacloud-nls-go-sdk v1.1.1 + github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible github.com/anthropics/anthropic-sdk-go v1.40.0 github.com/aws/aws-sdk-go-v2 v1.41.7 github.com/aws/aws-sdk-go-v2/config v1.32.17 diff --git a/backend/go.sum b/backend/go.sum index eed9bd62..e23bd0eb 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -28,6 +28,8 @@ github.com/aliyun/alibaba-cloud-sdk-go v1.61.1376 h1:lExo7heZgdFn5AbaNJEllbA0KSJ github.com/aliyun/alibaba-cloud-sdk-go v1.61.1376/go.mod h1:9CMdKNL3ynIGPpfTcdwTvIm8SGuAZYYC4jFVSSvE1YQ= github.com/aliyun/alibabacloud-nls-go-sdk v1.1.1 h1:LjItoNZuu5xHlsByFo+kr3nGa4LRIESCGWhfurayxBg= github.com/aliyun/alibabacloud-nls-go-sdk v1.1.1/go.mod h1:4BDMUKpEaP/Ct79w0ozR0nbnEj49g1k3mrgX/IKG5I4= +github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible h1:8psS8a+wKfiLt1iVDX79F7Y6wUM49Lcha2FMXt4UM8g= +github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ= github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= github.com/anthropics/anthropic-sdk-go v1.40.0 h1:+lhHU2LdeRlVsazVXHswFMpWr2Q11ShL+gjBNzX36Rw= diff --git a/backend/migration/000019_agent_resources.down.sql b/backend/migration/000019_agent_resources.down.sql new file mode 100644 index 00000000..e99b984b --- /dev/null +++ b/backend/migration/000019_agent_resources.down.sql @@ -0,0 +1,16 @@ +BEGIN; + +-- up 建了全部 agent_* 表,down 直接 DROP(含级联的索引/约束)。 +-- 按外键依赖反序删除。 +DROP TABLE IF EXISTS agent_skill_group_bindings; +DROP TABLE IF EXISTS agent_skill_versions; +DROP TABLE IF EXISTS agent_plugin_versions; +DROP TABLE IF EXISTS agent_sync_jobs; +DROP TABLE IF EXISTS agent_skills; +DROP TABLE IF EXISTS agent_plugins; +DROP TABLE IF EXISTS agent_skill_repos; +DROP TABLE IF EXISTS agent_plugin_repos; +DROP TABLE IF EXISTS agent_rule_versions; +DROP TABLE IF EXISTS agent_rules; + +COMMIT; diff --git a/backend/migration/000019_agent_resources.up.sql b/backend/migration/000019_agent_resources.up.sql new file mode 100644 index 00000000..5e397438 --- /dev/null +++ b/backend/migration/000019_agent_resources.up.sql @@ -0,0 +1,351 @@ +BEGIN; + +-- ===================================================================== +-- agent_rules: 全局规则资源(Markdown 全量内容由 DB 权威) +-- ===================================================================== +CREATE TABLE IF NOT EXISTS agent_rules ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + name VARCHAR(255) NOT NULL, + description TEXT, + scope_type VARCHAR(32) NOT NULL DEFAULT 'global' + CHECK (scope_type = 'global'), + scope_id VARCHAR(64) NOT NULL DEFAULT 'global' + CHECK (scope_id = 'global'), + active_version_id UUID, + created_by UUID NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + updated_at TIMESTAMP NOT NULL DEFAULT NOW(), + is_deleted BOOLEAN NOT NULL DEFAULT FALSE +); + +CREATE INDEX IF NOT EXISTS idx_agent_rules_scope + ON agent_rules (scope_type, scope_id); +CREATE INDEX IF NOT EXISTS idx_agent_rules_active_version + ON agent_rules (active_version_id); +CREATE UNIQUE INDEX IF NOT EXISTS uniq_agent_rules_name_scope + ON agent_rules (name, scope_type, scope_id) + WHERE is_deleted = FALSE; + +-- ===================================================================== +-- agent_rule_versions +-- ===================================================================== +CREATE TABLE IF NOT EXISTS agent_rule_versions ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + rule_id UUID NOT NULL REFERENCES agent_rules(id), + version VARCHAR(14) NOT NULL, + content TEXT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_agent_rule_versions_rule + ON agent_rule_versions (rule_id); + +-- ===================================================================== +-- agent_skill_repos: 三级 scope + bare 类型一步到位 +-- ===================================================================== +CREATE TABLE IF NOT EXISTS agent_skill_repos ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + name VARCHAR(255) NOT NULL, + scope_type VARCHAR(32) NOT NULL DEFAULT 'global' + CHECK (scope_type IN ('global', 'team', 'user')), + scope_id VARCHAR(64) NOT NULL DEFAULT 'global', + created_by UUID NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + updated_at TIMESTAMP NOT NULL DEFAULT NOW(), + is_deleted BOOLEAN NOT NULL DEFAULT FALSE, + source_type VARCHAR(16) NOT NULL + CHECK (source_type IN ('github', 'upload', 'bare')), + github_url VARCHAR(512), + ref_type VARCHAR(16) + CHECK (ref_type IS NULL OR ref_type IN ('branch', 'tag', 'commit')), + ref_value VARCHAR(255), + last_upload_filename VARCHAR(512), + last_upload_at TIMESTAMP, + CONSTRAINT agent_skill_repos_source_fields_chk CHECK ( + (source_type = 'github' + AND github_url IS NOT NULL + AND ref_type IS NOT NULL + AND ref_value IS NOT NULL + AND last_upload_filename IS NULL + AND last_upload_at IS NULL) + OR + (source_type = 'upload' + AND github_url IS NULL + AND ref_type IS NULL + AND ref_value IS NULL) + OR + (source_type = 'bare' + AND github_url IS NULL + AND ref_type IS NULL + AND ref_value IS NULL + AND last_upload_filename IS NULL + AND last_upload_at IS NULL) + ) +); + +CREATE INDEX IF NOT EXISTS idx_agent_skill_repos_scope + ON agent_skill_repos (scope_type, scope_id); +CREATE UNIQUE INDEX IF NOT EXISTS uniq_agent_skill_repos_bare_scope + ON agent_skill_repos (scope_type, scope_id) + WHERE source_type = 'bare' AND is_deleted = FALSE; + +-- ===================================================================== +-- agent_plugin_repos: 同上 + npm +-- ===================================================================== +CREATE TABLE IF NOT EXISTS agent_plugin_repos ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + name VARCHAR(255) NOT NULL, + scope_type VARCHAR(32) NOT NULL DEFAULT 'global' + CHECK (scope_type IN ('global', 'team', 'user')), + scope_id VARCHAR(64) NOT NULL DEFAULT 'global', + created_by UUID NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + updated_at TIMESTAMP NOT NULL DEFAULT NOW(), + is_deleted BOOLEAN NOT NULL DEFAULT FALSE, + source_type VARCHAR(16) NOT NULL + CHECK (source_type IN ('github', 'upload', 'npm', 'bare')), + github_url VARCHAR(512), + ref_type VARCHAR(16) + CHECK (ref_type IS NULL OR ref_type IN ('branch', 'tag', 'commit')), + ref_value VARCHAR(255), + last_upload_filename VARCHAR(512), + last_upload_at TIMESTAMP, + plugin_discovery_auto_package_json BOOLEAN NOT NULL DEFAULT TRUE, + plugin_manual_entries JSONB, + npm_package_name VARCHAR(255), + npm_version_spec VARCHAR(64), + npm_registry_url VARCHAR(512), + CONSTRAINT agent_plugin_repos_source_fields_chk CHECK ( + (source_type = 'github' + AND github_url IS NOT NULL AND ref_type IS NOT NULL AND ref_value IS NOT NULL + AND last_upload_filename IS NULL AND last_upload_at IS NULL + AND npm_package_name IS NULL AND npm_version_spec IS NULL AND npm_registry_url IS NULL) + OR + (source_type = 'upload' + AND github_url IS NULL AND ref_type IS NULL AND ref_value IS NULL + AND npm_package_name IS NULL AND npm_version_spec IS NULL AND npm_registry_url IS NULL) + OR + (source_type = 'npm' + AND npm_package_name IS NOT NULL + AND github_url IS NULL AND ref_type IS NULL AND ref_value IS NULL + AND last_upload_filename IS NULL AND last_upload_at IS NULL) + OR + (source_type = 'bare' + AND github_url IS NULL AND ref_type IS NULL AND ref_value IS NULL + AND last_upload_filename IS NULL AND last_upload_at IS NULL + AND npm_package_name IS NULL AND npm_version_spec IS NULL AND npm_registry_url IS NULL) + ) +); + +CREATE INDEX IF NOT EXISTS idx_agent_plugin_repos_scope + ON agent_plugin_repos (scope_type, scope_id); +CREATE UNIQUE INDEX IF NOT EXISTS uniq_agent_plugin_repos_bare_scope + ON agent_plugin_repos (scope_type, scope_id) + WHERE source_type = 'bare' AND is_deleted = FALSE; + +-- ===================================================================== +-- agent_skills: 字段一步到位(enabled + admin overrides + extension) +-- ===================================================================== +CREATE TABLE IF NOT EXISTS agent_skills ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + name VARCHAR(255) NOT NULL, + description TEXT, + scope_type VARCHAR(32) NOT NULL DEFAULT 'global' + CHECK (scope_type IN ('global', 'team', 'user')), + scope_id VARCHAR(64) NOT NULL DEFAULT 'global', + repo_id UUID NOT NULL REFERENCES agent_skill_repos(id), + created_by UUID NOT NULL, + is_force_delivery BOOLEAN NOT NULL DEFAULT FALSE, + is_orphan BOOLEAN NOT NULL DEFAULT FALSE, + is_deleted BOOLEAN NOT NULL DEFAULT FALSE, + enabled BOOLEAN NOT NULL DEFAULT TRUE, + admin_description TEXT, + admin_tags JSONB, + extension_package_id VARCHAR(255), + active_version_id UUID, + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + updated_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_agent_skills_scope + ON agent_skills (scope_type, scope_id); +CREATE INDEX IF NOT EXISTS idx_agent_skills_repo + ON agent_skills (repo_id); +CREATE INDEX IF NOT EXISTS idx_agent_skills_active_version + ON agent_skills (active_version_id); +CREATE UNIQUE INDEX IF NOT EXISTS uniq_agent_skills_repo_name + ON agent_skills (repo_id, name); + +-- ===================================================================== +-- agent_plugins: 同 agent_skills 结构(无 admin overrides / extension) +-- ===================================================================== +CREATE TABLE IF NOT EXISTS agent_plugins ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + name VARCHAR(255) NOT NULL, + description TEXT, + scope_type VARCHAR(32) NOT NULL DEFAULT 'global' + CHECK (scope_type IN ('global', 'team', 'user')), + scope_id VARCHAR(64) NOT NULL DEFAULT 'global', + repo_id UUID NOT NULL REFERENCES agent_plugin_repos(id), + created_by UUID NOT NULL, + is_force_delivery BOOLEAN NOT NULL DEFAULT FALSE, + is_orphan BOOLEAN NOT NULL DEFAULT FALSE, + is_deleted BOOLEAN NOT NULL DEFAULT FALSE, + enabled BOOLEAN NOT NULL DEFAULT TRUE, + active_version_id UUID, + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + updated_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_agent_plugins_scope + ON agent_plugins (scope_type, scope_id); +CREATE INDEX IF NOT EXISTS idx_agent_plugins_repo + ON agent_plugins (repo_id); +CREATE INDEX IF NOT EXISTS idx_agent_plugins_active_version + ON agent_plugins (active_version_id); +CREATE UNIQUE INDEX IF NOT EXISTS uniq_agent_plugins_repo_name + ON agent_plugins (repo_id, name); + +-- ===================================================================== +-- agent_skill_versions / agent_plugin_versions +-- ===================================================================== +CREATE TABLE IF NOT EXISTS agent_skill_versions ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + resource_id UUID NOT NULL REFERENCES agent_skills(id), + version VARCHAR(64) NOT NULL, + s3_key VARCHAR(512) NOT NULL, + parsed_meta JSONB, + created_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_agent_skill_versions_resource + ON agent_skill_versions (resource_id); + +CREATE TABLE IF NOT EXISTS agent_plugin_versions ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + resource_id UUID NOT NULL REFERENCES agent_plugins(id), + version VARCHAR(64) NOT NULL, + s3_key VARCHAR(512) NOT NULL, + parsed_meta JSONB, + created_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_agent_plugin_versions_resource + ON agent_plugin_versions (resource_id); + +-- ===================================================================== +-- agent_sync_jobs +-- ===================================================================== +CREATE TABLE IF NOT EXISTS agent_sync_jobs ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + resource_kind VARCHAR(16) NOT NULL + CHECK (resource_kind IN ('rule', 'skill', 'plugin')), + rule_id UUID, + repo_id UUID, + source_type VARCHAR(16) NOT NULL + CHECK (source_type IN ('github', 'upload', 'npm', 'rule_inline')), + status VARCHAR(16) NOT NULL + CHECK (status IN ('pending', 'fetching', 'parsing', 'uploading', 'done', 'failed')), + trigger_type VARCHAR(16) NOT NULL + CHECK (trigger_type IN ('manual', 'upload', 'rule_save')), + triggered_by UUID, + started_at TIMESTAMP, + finished_at TIMESTAMP, + errors JSONB, + result_summary JSONB, + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + CONSTRAINT agent_sync_jobs_resource_ref_chk CHECK ( + (resource_kind = 'rule' + AND rule_id IS NOT NULL + AND repo_id IS NULL) + OR + (resource_kind IN ('skill', 'plugin') + AND repo_id IS NOT NULL + AND rule_id IS NULL) + ) +); + +CREATE INDEX IF NOT EXISTS idx_agent_sync_jobs_status_created + ON agent_sync_jobs (status, created_at); +CREATE INDEX IF NOT EXISTS idx_agent_sync_jobs_resource_kind + ON agent_sync_jobs (resource_kind); + +-- ===================================================================== +-- agent_skill_group_bindings: skill ↔ team_group M:N +-- ===================================================================== +CREATE TABLE IF NOT EXISTS agent_skill_group_bindings ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + skill_id UUID NOT NULL REFERENCES agent_skills(id), + group_id UUID NOT NULL REFERENCES team_groups(id), + created_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +CREATE UNIQUE INDEX IF NOT EXISTS uniq_agent_skill_group_bindings + ON agent_skill_group_bindings (skill_id, group_id); +CREATE INDEX IF NOT EXISTS idx_agent_skill_group_bindings_group + ON agent_skill_group_bindings (group_id); + +-- ===================================================================== +-- active_version_id 反向 FK +-- ===================================================================== +ALTER TABLE agent_rules + ADD CONSTRAINT agent_rules_active_version_fk + FOREIGN KEY (active_version_id) REFERENCES agent_rule_versions(id); + +ALTER TABLE agent_skills + ADD CONSTRAINT agent_skills_active_version_fk + FOREIGN KEY (active_version_id) REFERENCES agent_skill_versions(id); + +ALTER TABLE agent_plugins + ADD CONSTRAINT agent_plugins_active_version_fk + FOREIGN KEY (active_version_id) REFERENCES agent_plugin_versions(id); + +-- ===================================================================== +-- Backfill: 每个 team provision bare skill_repo + bare plugin_repo +-- ===================================================================== +INSERT INTO agent_skill_repos (id, name, scope_type, scope_id, created_by, source_type, is_deleted, created_at, updated_at) +SELECT gen_random_uuid(), + 'team-' || t.id::text, + 'team', + t.id::text, + COALESCE( + (SELECT tm.user_id FROM team_members tm + WHERE tm.team_id = t.id AND tm.role = 'admin' + ORDER BY tm.created_at ASC LIMIT 1), + '00000000-0000-0000-0000-000000000000'::uuid + ), + 'bare', FALSE, NOW(), NOW() +FROM teams t +WHERE NOT EXISTS ( + SELECT 1 FROM agent_skill_repos r + WHERE r.scope_type = 'team' AND r.scope_id = t.id::text + AND r.source_type = 'bare' AND r.is_deleted = FALSE +); + +INSERT INTO agent_plugin_repos (id, name, scope_type, scope_id, created_by, source_type, is_deleted, plugin_discovery_auto_package_json, created_at, updated_at) +SELECT gen_random_uuid(), + 'team-' || t.id::text, + 'team', + t.id::text, + COALESCE( + (SELECT tm.user_id FROM team_members tm + WHERE tm.team_id = t.id AND tm.role = 'admin' + ORDER BY tm.created_at ASC LIMIT 1), + '00000000-0000-0000-0000-000000000000'::uuid + ), + 'bare', FALSE, TRUE, NOW(), NOW() +FROM teams t +WHERE NOT EXISTS ( + SELECT 1 FROM agent_plugin_repos r + WHERE r.scope_type = 'team' AND r.scope_id = t.id::text + AND r.source_type = 'bare' AND r.is_deleted = FALSE +); + +-- ===================================================================== +-- 废弃旧团队 skill 模型 (000016_team_skills 创建的表) +-- ===================================================================== +DROP TABLE IF EXISTS team_group_skills; +DROP TABLE IF EXISTS team_skills; +DROP TABLE IF EXISTS skills; + +COMMIT; diff --git a/backend/pkg/oss/aliyun.go b/backend/pkg/oss/aliyun.go new file mode 100644 index 00000000..6a84831c --- /dev/null +++ b/backend/pkg/oss/aliyun.go @@ -0,0 +1,89 @@ +package oss + +import ( + "context" + "errors" + "fmt" + "io" + "strings" + "time" + + "github.com/aliyun/aliyun-oss-go-sdk/oss" + + "github.com/chaitin/MonkeyCode/backend/config" +) + +// AliyunClient is a narrow OSS client backed by aliyun-oss-go-sdk. It exists +// alongside the AWS-SDK-v2 backed Client so the agent-resources read path can +// hit Aliyun OSS without going through the AWS S3 SigV4 signer (Aliyun rejects +// SigV4 with SignatureDoesNotMatch and the path-style URL it produces double- +// prefixes the bucket). +// +// Implements just GetObject + PresignGet — the surface agentresource.Resolver +// needs. Existing avatar/repo/spec/temp upload flows keep using the AWS-SDK +// backed *Client. +type AliyunClient struct { + bucket *oss.Bucket +} + +// NewAliyunOSS builds an AliyunClient from the shared aliyun.public_oss block. +// Empty Endpoint / Bucket / AccessKey / AccessKeySecret is a hard error so +// misconfigured deploys fail fast at DI resolution time rather than at first +// presign attempt. +func NewAliyunOSS(cfg config.AliyunOSSConfig) (*AliyunClient, error) { + if cfg.Endpoint == "" { + return nil, errors.New("aliyun oss: empty Endpoint") + } + if cfg.Bucket == "" { + return nil, errors.New("aliyun oss: empty Bucket") + } + if cfg.AccessKey == "" || cfg.AccessKeySecret == "" { + return nil, errors.New("aliyun oss: empty AccessKey/AccessKeySecret") + } + client, err := oss.New(cfg.Endpoint, cfg.AccessKey, cfg.AccessKeySecret) + if err != nil { + return nil, fmt.Errorf("aliyun oss: new client: %w", err) + } + bucket, err := client.Bucket(cfg.Bucket) + if err != nil { + return nil, fmt.Errorf("aliyun oss: open bucket %q: %w", cfg.Bucket, err) + } + return &AliyunClient{bucket: bucket}, nil +} + +// GetObject downloads the object body at the given key (relative to the +// bucket — no extra prefix is applied). Caller closes the ReadCloser. +func (c *AliyunClient) GetObject(_ context.Context, key string) (io.ReadCloser, error) { + body, err := c.bucket.GetObject(key) + if err != nil { + return nil, fmt.Errorf("aliyun oss: get %q: %w", key, err) + } + return body, nil +} + +// PutFile uploads an object under {prefix}/{basename(filename)}. Used by +// the agentresource bare-repo upload flow. The leading prefix is stripped of +// surrounding slashes to match the AWS-SDK Client's objectKey helper. +func (c *AliyunClient) PutFile(_ context.Context, prefix, filename string, body io.Reader) error { + key := strings.Trim(prefix, "/") + "/" + filename + if err := c.bucket.PutObject(key, body); err != nil { + return fmt.Errorf("aliyun oss: put %q: %w", key, err) + } + return nil +} + +// PresignGet returns a presigned GET URL valid for `expires`. The aliyun SDK +// signs with `OSS4-HMAC-SHA256` (or v1 depending on endpoint), which OSS +// accepts. Aliyun SDK takes expiry as seconds; we floor sub-second values to 1 +// so a defensively-zero ttl doesn't break. +func (c *AliyunClient) PresignGet(_ context.Context, key string, expires time.Duration) (string, error) { + seconds := int64(expires.Seconds()) + if seconds < 1 { + seconds = 1 + } + url, err := c.bucket.SignURL(key, oss.HTTPGet, seconds) + if err != nil { + return "", fmt.Errorf("aliyun oss: presign %q: %w", key, err) + } + return url, nil +} diff --git a/backend/pkg/oss/oss.go b/backend/pkg/oss/oss.go index 12dec82a..a884dc74 100644 --- a/backend/pkg/oss/oss.go +++ b/backend/pkg/oss/oss.go @@ -12,6 +12,7 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" + v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" awsconfig "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/service/s3" @@ -58,6 +59,16 @@ func NewS3Compatible(ctx context.Context, cfg config.ObjectStorageConfig, opt S3 client := s3.NewFromConfig(awsCfg, func(o *s3.Options) { o.BaseEndpoint = aws.String(cfg.Endpoint) o.UsePathStyle = opt.ForcePathStyle + // Aliyun OSS compatibility for aws-sdk-go-v2 >= v1.66: + // disable the default CRC32 trailer (which forces aws-chunked + // Content-Encoding) and switch the x-amz-content-sha256 header + // from the streaming STREAMING-AWS4-HMAC-SHA256-PAYLOAD value + // to UNSIGNED-PAYLOAD, both of which Aliyun OSS rejects with + // 400 "aws-chunked encoding is not supported with the specified + // x-amz-content-sha256 value". + o.RequestChecksumCalculation = aws.RequestChecksumCalculationWhenRequired + o.ResponseChecksumValidation = aws.ResponseChecksumValidationWhenRequired + o.APIOptions = append(o.APIOptions, v4.SwapComputePayloadSHA256ForUnsignedPayloadMiddleware) }) c := &Client{ cfg: cfg, @@ -163,6 +174,23 @@ func (c *Client) HeadFile(ctx context.Context, prefix, filename string) (bool, e return false, err } +// GetObject fetches the object body at the given key (relative to the bucket). +// Used by the agent-resources read path (skill / plugin zip download). +// The key is passed through verbatim — callers already build the full path +// (e.g. "agent-resources/skills/global/global/{repoID}/{name}/{version}.zip") +// and no implicit prefix is added. +// Caller must close the returned io.ReadCloser. +func (c *Client) GetObject(ctx context.Context, key string) (io.ReadCloser, error) { + out, err := c.s3.GetObject(ctx, &s3.GetObjectInput{ + Bucket: aws.String(c.cfg.Bucket), + Key: aws.String(key), + }) + if err != nil { + return nil, fmt.Errorf("oss: get %q: %w", key, err) + } + return out.Body, nil +} + func (c *Client) WithAccessEndpoint(endpoint string) *Client { endpoint = strings.TrimSpace(endpoint) if c == nil || endpoint == "" { @@ -184,6 +212,23 @@ func (c *Client) GetURL(prefix, filename string) string { return appendURLPath(base, objectKey(prefix, filename)) } +// PresignGet returns a presigned GET URL for the given object key. Unlike +// Presign() (which presigns under a {prefix,filename} pair tied to upload +// flows), PresignGet takes the full object key verbatim — callers building +// agent-resource references already have the full S3 key from the version +// row (e.g. "agent-resources/skills/global/global/{repoID}/{name}/{ver}.zip"). +func (c *Client) PresignGet(ctx context.Context, key string, expires time.Duration) (string, error) { + expires = normalizeExpires(expires) + getURL, err := c.presigner.PresignGetObject(ctx, &s3.GetObjectInput{ + Bucket: aws.String(c.cfg.Bucket), + Key: aws.String(key), + }, s3.WithPresignExpires(expires)) + if err != nil { + return "", fmt.Errorf("presign get %q: %w", key, err) + } + return c.publicPresignURL(getURL.URL, key), nil +} + func (c *Client) Presign(ctx context.Context, prefix, filename string, expires time.Duration) (*Presign, error) { expires = normalizeExpires(expires) key := objectKey(prefix, filename) diff --git a/backend/pkg/taskflow/types.go b/backend/pkg/taskflow/types.go index e3f4ec35..2d34e997 100644 --- a/backend/pkg/taskflow/types.go +++ b/backend/pkg/taskflow/types.go @@ -601,19 +601,39 @@ type McpServerConfig struct { Env map[string]string `json:"env,omitempty"` } +// AgentResourceAssetRef mirrors codingmatrix proto +// agent.AgentResources_AssetRef. Skills + plugins share the same shape. +type AgentResourceAssetRef struct { + Name string `json:"name,omitempty"` + Version string `json:"version,omitempty"` + ZipURL string `json:"zip_url,omitempty"` + EntryFilename string `json:"entry_filename,omitempty"` +} + +// AgentResources mirrors codingmatrix proto agent.AgentResources. Skills / +// Plugins are pointer slices so a nil AgentResources or nil sub-slice +// serializes as JSON null / "absent" — matching the proto wire behaviour. +// Rules and opencode.json travel on the legacy ConfigFile inline channel, +// not here. +type AgentResources struct { + Skills []*AgentResourceAssetRef `json:"skills,omitempty"` + Plugins []*AgentResourceAssetRef `json:"plugins,omitempty"` +} + // CreateTaskReq 创建任务请求 type CreateTaskReq struct { - ID uuid.UUID `json:"id"` - VMID string `json:"vm_id"` - SystemPrompt string `json:"system_prompt,omitempty"` - Text string `json:"text,omitempty"` - Attachments []Attachment `json:"attachments,omitempty"` - LLM LLM `json:"llm,omitzero"` - CodingAgent CodingAgent `json:"coding_agent,omitempty"` - Configs []ConfigFile `json:"configs,omitzero"` - McpConfigs []McpServerConfig `json:"mcp_configs,omitzero"` - Env map[string]string `json:"env,omitempty"` - LogStore string `json:"log_store,omitempty"` + ID uuid.UUID `json:"id"` + VMID string `json:"vm_id"` + SystemPrompt string `json:"system_prompt,omitempty"` + Text string `json:"text,omitempty"` + Attachments []Attachment `json:"attachments,omitempty"` + LLM LLM `json:"llm,omitzero"` + CodingAgent CodingAgent `json:"coding_agent,omitempty"` + Configs []ConfigFile `json:"configs,omitzero"` + McpConfigs []McpServerConfig `json:"mcp_configs,omitzero"` + Env map[string]string `json:"env,omitempty"` + LogStore string `json:"log_store,omitempty"` + AgentResources *AgentResources `json:"agent_resources,omitempty"` // skill/plugin presigned URLs + rule content forwarded to codingmatrix agent } // ==================== VirtualMachine 查询类型 ==================== diff --git a/frontend/src/components/console/task/create-default-task-dialog.tsx b/frontend/src/components/console/task/create-default-task-dialog.tsx index d21be402..b0d58de8 100644 --- a/frontend/src/components/console/task/create-default-task-dialog.tsx +++ b/frontend/src/components/console/task/create-default-task-dialog.tsx @@ -76,6 +76,8 @@ import { toast } from "sonner" import { TaskConcurrentLimitDialog } from "./task-concurrent-limit-dialog" import ModelSelect from "./model-select" import { TaskSkillSelector } from "./task-skill-selector" +import { TaskPluginSelector } from "./task-plugin-selector" +import { fetchPluginListing, type PluginListItem } from "@/lib/agent-resources-api" interface CreateDefaultTaskDialogProps { open: boolean @@ -122,6 +124,9 @@ export default function CreateDefaultTaskDialog({ const [selectedSkill, setSelectedSkill] = useState(defaultSkills) const [skillList, setSkillList] = useState([]) const [activeSkillTag, setActiveSkillTag] = useState("全部") + const [pluginPopoverOpen, setPluginPopoverOpen] = useState(false) + const [pluginList, setPluginList] = useState([]) + const [selectedPlugin, setSelectedPlugin] = useState([]) const [advancedOptionsOpen, setAdvancedOptionsOpen] = useState(false) const [selectedModelId, setSelectedModelId] = useState("") const [selectedHostId, setSelectedHostId] = useState("") @@ -160,6 +165,8 @@ export default function CreateDefaultTaskDialog({ setIdentitySearch({}) setSelectedSkill(defaultSkills) setActiveSkillTag("全部") + setPluginPopoverOpen(false) + setSelectedPlugin([]) setAdvancedOptionsOpen(false) setSelectedModelId("") setSelectedHostId("") @@ -169,18 +176,29 @@ export default function CreateDefaultTaskDialog({ return } - if (IS_OFFLINE_EDITION || skillList.length > 0) { + if (IS_OFFLINE_EDITION) { return } - apiRequest("v1SkillsList", {}, [], (resp) => { - if (resp.code === 0) { - setSkillList(resp.data || []) - } else { - toast.error(resp.message || "获取技能列表失败") - } - }) - }, [open, skillList.length]) + if (skillList.length === 0) { + apiRequest("v1SkillsList", {}, [], (resp) => { + if (resp.code === 0) { + setSkillList(resp.data || []) + } else { + toast.error(resp.message || "获取技能列表失败") + } + }) + } + + if (pluginList.length === 0) { + // Plugin picker is best-effort — surface but do not block the dialog. + fetchPluginListing() + .then((items) => setPluginList(items)) + .catch((err: Error) => { + toast.error(err.message || "获取插件列表失败") + }) + } + }, [open, skillList.length, pluginList.length]) useEffect(() => { if (!open) { @@ -308,6 +326,15 @@ export default function CreateDefaultTaskDialog({ }) } + const handlePluginChange = (pluginId: string, checked: boolean) => { + setSelectedPlugin((prev) => { + if (checked) { + return prev.includes(pluginId) ? prev : [...prev, pluginId] + } + return prev.filter((id) => id !== pluginId) + }) + } + const setDefaultConfig = () => { const storedParams = readStoredTaskDialogParams() setSelectedModelId(selectPreferredTaskModel(models, subscription)) @@ -428,6 +455,7 @@ export default function CreateDefaultTaskDialog({ }, extra: { skill_ids: selectedSkill, + plugin_ids: selectedPlugin, }, resource: { core: 2, @@ -762,6 +790,16 @@ export default function CreateDefaultTaskDialog({ triggerClassName="rounded-md" /> )} + {!IS_OFFLINE_EDITION && ( + + )} diff --git a/frontend/src/components/console/task/task-input.tsx b/frontend/src/components/console/task/task-input.tsx index 7362c5ad..d0344a29 100644 --- a/frontend/src/components/console/task/task-input.tsx +++ b/frontend/src/components/console/task/task-input.tsx @@ -30,6 +30,8 @@ import { IS_OFFLINE_EDITION } from "@/utils/edition"; import { readStoredTaskDialogParams, writeStoredTaskDialogParams } from "./task-dialog-params-storage"; import ModelSelect from "./model-select"; import { TaskSkillSelector } from "./task-skill-selector"; +import { TaskPluginSelector } from "./task-plugin-selector"; +import { fetchPluginListing, type PluginListItem } from "@/lib/agent-resources-api"; import { getTaskContentLimitErrorMessage, MAX_TASK_CONTENT_LENGTH } from "./task-content-limit"; interface RepoOption { @@ -73,6 +75,9 @@ export function TaskInput({ repos, onTaskCreated }: TaskInputProps) { const [selectedSkill, setSelectedSkill] = useState(defaultSkills); const [skillList, setSkillList] = useState([]); const [activeSkillTag, setActiveSkillTag] = useState("全部"); + const [pluginPopoverOpen, setPluginPopoverOpen] = useState(false); + const [pluginList, setPluginList] = useState([]); + const [selectedPlugin, setSelectedPlugin] = useState([]); // 运行参数状态(工具固定为 opencode) const [selectedModelId, setSelectedModelId] = useState(""); @@ -115,6 +120,7 @@ export function TaskInput({ repos, onTaskCreated }: TaskInputProps) { useEffect(() => { fetchSkillList(); + fetchPluginList(); }, []); @@ -132,6 +138,28 @@ export function TaskInput({ repos, onTaskCreated }: TaskInputProps) { }); }; + const fetchPluginList = async () => { + if (IS_OFFLINE_EDITION) { + return; + } + try { + const items = await fetchPluginListing(); + setPluginList(items); + } catch (err) { + // Plugin picker is optional/best-effort; warn rather than block the form. + toast.error((err as Error).message || '获取插件列表失败'); + } + }; + + const handlePluginChange = (pluginId: string, checked: boolean) => { + setSelectedPlugin(prev => { + if (checked) { + return prev.includes(pluginId) ? prev : [...prev, pluginId]; + } + return prev.filter(id => id !== pluginId); + }); + }; + const loadReposForAllIdentities = async (flush = false, targetIdentityId?: string) => { const targetIdentities = selectableIdentities.filter((identity) => { if (!identity.id) return false; @@ -300,6 +328,7 @@ export function TaskInput({ repos, onTaskCreated }: TaskInputProps) { }, extra: { skill_ids: selectedSkill, + plugin_ids: selectedPlugin, }, resource: { core: 2, @@ -652,6 +681,17 @@ export function TaskInput({ repos, onTaskCreated }: TaskInputProps) { labelClassName="hidden sm:block" /> )} + {!IS_OFFLINE_EDITION && ( + + )}
{!IS_OFFLINE_EDITION && ( diff --git a/frontend/src/components/console/task/task-plugin-selector.tsx b/frontend/src/components/console/task/task-plugin-selector.tsx new file mode 100644 index 00000000..65b88d30 --- /dev/null +++ b/frontend/src/components/console/task/task-plugin-selector.tsx @@ -0,0 +1,142 @@ +// TaskPluginSelector mirrors TaskSkillSelector but targets the plugin +// listing endpoint (GET /api/v1/plugins, see agent-resources slim spec §7.4). +// +// Plugins use a flat list (no tag tabs) because the listing surface is much +// smaller than skills and the backend does not group them by tag. Like the +// skill picker, plugins flagged `is_force_delivery=true` render as +// checked-and-disabled chips with a 强制下发 badge — the backend re-injects +// these IDs so the form does not submit them. + +import { Badge } from "@/components/ui/badge" +import { Button } from "@/components/ui/button" +import { Checkbox } from "@/components/ui/checkbox" +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover" +import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip" +import type { PluginListItem } from "@/lib/agent-resources-api" +import { cn } from "@/lib/utils" +import { IconPlug } from "@tabler/icons-react" + +interface TaskPluginSelectorProps { + open: boolean + onOpenChange: (open: boolean) => void + /** Plugin IDs currently selected by the user (excludes force-delivered ones). */ + selectedPlugins: string[] + plugins: PluginListItem[] + /** Called with the toggled plugin id and the new checked state. */ + onPluginChange: (pluginId: string, checked: boolean) => void + triggerClassName?: string + labelClassName?: string +} + +interface PluginRowProps { + plugin: PluginListItem + selectedPlugins: string[] + onPluginChange: (pluginId: string, checked: boolean) => void +} + +function PluginRow({ plugin, selectedPlugins, onPluginChange }: PluginRowProps) { + if (!plugin.id) { + return null + } + + const isForceDelivery = plugin.is_force_delivery + const isChecked = isForceDelivery || selectedPlugins.includes(plugin.id) + + return ( +
{ + if (isForceDelivery) { + return + } + onPluginChange(plugin.id, !isChecked) + }} + > + +
+
+ {plugin.name} + {isForceDelivery && ( + + + + 强制下发 + + + 由管理员强制下发,无需选择 + + )} +
+ {plugin.description && ( +
+ {plugin.description} +
+ )} +
+
+ ) +} + +export function TaskPluginSelector({ + open, + onOpenChange, + selectedPlugins, + plugins, + onPluginChange, + triggerClassName, + labelClassName, +}: TaskPluginSelectorProps) { + // Hide force-delivery plugins entirely — backend injects them server-side + // regardless of user selection, so showing them in the picker is just noise. + const visiblePlugins = plugins.filter((p) => !p.is_force_delivery) + return ( + + + + + +
+ {visiblePlugins.length === 0 ? ( +
+ 暂无可用插件 +
+ ) : ( + visiblePlugins.map((plugin) => ( + + )) + )} +
+
+
+ ) +} diff --git a/frontend/src/components/console/task/task-skill-selector.tsx b/frontend/src/components/console/task/task-skill-selector.tsx index c9e22f24..3bc5d83e 100644 --- a/frontend/src/components/console/task/task-skill-selector.tsx +++ b/frontend/src/components/console/task/task-skill-selector.tsx @@ -1,19 +1,31 @@ import type { DomainSkill } from "@/api/Api" +import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" +import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip" import { cn } from "@/lib/utils" import { getSkillTagIcon } from "@/utils/common" import { defaultSkills } from "@/utils/config" import { IconChevronLeft, IconChevronRight, IconPuzzle } from "@tabler/icons-react" import { useCallback, useEffect, useRef, useState } from "react" +/** + * SkillForPicker augments the swagger-generated DomainSkill with the + * `is_force_delivery` flag returned by /api/v1/skills (see + * lib/agent-resources-api.ts SkillListItem). The picker treats + * force-delivered skills as visible-but-disabled chips so the user + * knows about the admin-mandated dependency without being able to + * un-tick it (the backend re-injects these IDs server-side). + */ +type SkillForPicker = DomainSkill & { is_force_delivery?: boolean } + interface TaskSkillSelectorProps { open: boolean onOpenChange: (open: boolean) => void selectedSkills: string[] - skills: DomainSkill[] + skills: SkillForPicker[] skillTags: string[] activeSkillTag: string onActiveSkillTagChange: (tag: string) => void @@ -23,7 +35,7 @@ interface TaskSkillSelectorProps { } interface SkillItemProps { - skill: DomainSkill + skill: SkillForPicker selectedSkills: string[] onSkillChange: (skillId: string, checked: boolean) => void } @@ -33,16 +45,51 @@ function SkillItem({ skill, selectedSkills, onSkillChange }: SkillItemProps) { return null } - const isChecked = selectedSkills.includes(skill.id) + const isForceDelivery = !!skill.is_force_delivery + // Force-delivered + hard-coded legacy default skills are both shown as + // checked-and-disabled. Force-delivered skills are presented as "checked" + // regardless of the parent's selectedSkills state because the backend + // injects them server-side and we do not want users to see an unchecked + // tickbox for something they cannot opt out of. + const isLegacyDefault = defaultSkills.includes(skill.id) + const isDisabled = isLegacyDefault || isForceDelivery + const isChecked = isForceDelivery || selectedSkills.includes(skill.id) return (
onSkillChange(skill.id!, !isChecked)} + className={cn( + "flex flex-row items-center gap-2 rounded-md px-2 py-1", + isDisabled + ? "cursor-not-allowed opacity-80" + : "cursor-pointer hover:bg-accent" + )} + onClick={() => { + if (isDisabled) { + return + } + onSkillChange(skill.id!, !isChecked) + }} > - -
-
{skill.name}
+ +
+
+ {skill.name} + {isForceDelivery && ( + + + + 强制下发 + + + + 由管理员强制下发,无需选择 + + + )} +
{skill.description}
@@ -176,6 +223,7 @@ export function TaskSkillSelector({ className="mt-0 min-h-0 flex-1 overflow-y-auto rounded-md border bg-background p-1" > {skills + .filter((skill) => !skill.is_force_delivery) .filter((skill) => tag === "全部" || (skill.tags || []).includes(tag)) .map((skill) => ( = { + code: number + message: string + data: T +} + +async function request(url: string, init?: RequestInit): Promise { + const res = await fetch(url, { + credentials: "include", + ...(init ?? {}), + headers: { + ...(init?.body && typeof init.body === "string" + ? { "Content-Type": "application/json" } + : {}), + ...(init?.headers ?? {}), + }, + }) + if (res.status === 401) { + if ( + window.location.pathname.includes("/console") || + window.location.pathname.includes("/manager") + ) { + window.location.href = "/login" + } + throw new Error("未登录") + } + if (!res.ok) { + throw new Error(`HTTP ${res.status}: ${res.statusText}`) + } + const json = (await res.json()) as ApiResponse + if (json.code !== 0) { + throw new Error(json.message || "请求失败") + } + return json.data +} + +// ---- Task-creation pickers (skills / plugins listing) ---- +// +// The /api/v1/skills and /api/v1/plugins listing endpoints (mcai-backend, see +// agent-resources slim spec §7.4) return a flat array of "ready-to-pick" +// items: only active, non-orphan resources. + +/** Item returned by GET /api/v1/plugins (task-creation picker). */ +export type PluginListItem = { + id: string + name: string + description: string + entry: string + active_version?: string + is_force_delivery: boolean +} + +export function fetchPluginListing(): Promise { + return request(`/api/v1/plugins`).then( + (data) => data ?? [] + ) +} + +/** Item returned by GET /api/v1/skills (task-creation picker). */ +export type SkillListItem = { + id: string + name: string + description?: string + tags?: string[] + categories?: string[] + args_schema?: Record + content?: string + /** Skill ID surfaced by the swagger model — kept for backward compatibility. */ + skill_id?: string + is_force_delivery?: boolean +}