package ops

import (
	"path/filepath"

	"ops-assistant/internal/core/registry"
	"ops-assistant/internal/core/runbook"
	"ops-assistant/internal/module/cf"
	"ops-assistant/internal/module/cpa"
	"ops-assistant/internal/module/mail"

	"gorm.io/gorm"
)

func BuildDefault(db *gorm.DB, dbPath, baseDir string) *Service {
	r := registry.New()
	exec := runbook.NewExecutor(db, filepath.Join(baseDir, "runbooks"))
	cpaModule := cpa.New(db, exec)
	cfModule := cf.New(db, exec)
	mailModule := mail.New(db, exec)

	r.RegisterModule("cpa", cpaModule.Handle)
	r.RegisterModule("cf", cfModule.Handle)
	r.RegisterModule("mail", mailModule.Handle)
	return NewService(dbPath, baseDir, r)
}
