- Skipped tests related to KB/DB search functionality due to temporary unavailability. - Updated test cases in chat_test.go, search_auth_integration_test.go, search_auto_full_test.go, and others to reflect this change. - Adjusted search handling in search.go to limit search types to "web" only until KB/DB search is re-enabled.
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package docs
|
|
|
|
import (
|
|
_ "embed"
|
|
|
|
goudoc "github.com/yaoapp/gou/doc"
|
|
"github.com/yaoapp/gou/process"
|
|
)
|
|
|
|
//go:embed list.json
|
|
var ListSchemaJSON []byte
|
|
|
|
//go:embed inspect.json
|
|
var InspectSchemaJSON []byte
|
|
|
|
//go:embed validate.json
|
|
var ValidateSchemaJSON []byte
|
|
|
|
// ListHandler is the tools.doc_list process handler.
|
|
// Args[0]: keyword (string, optional — empty lists all)
|
|
// Args[1]: limit (int, default 20)
|
|
func ListHandler(proc *process.Process) interface{} {
|
|
keyword := proc.ArgsString(0)
|
|
limit := proc.ArgsInt(1, 20)
|
|
|
|
var results []*goudoc.Entry
|
|
if keyword != "" {
|
|
results = goudoc.List(goudoc.TypeProcess, goudoc.ListOption{Search: keyword})
|
|
} else {
|
|
results = goudoc.List(goudoc.TypeProcess)
|
|
}
|
|
if len(results) > limit {
|
|
results = results[:limit]
|
|
}
|
|
return results
|
|
}
|
|
|
|
// InspectHandler is the tools.doc_inspect process handler.
|
|
// Args[0]: name (string — process name, e.g. "models.user.Find")
|
|
func InspectHandler(proc *process.Process) interface{} {
|
|
name := proc.ArgsString(0)
|
|
entry, ok := goudoc.Get(goudoc.TypeProcess, name)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
return entry
|
|
}
|
|
|
|
// ValidateHandler is the tools.doc_validate process handler.
|
|
// Args[0]: name (string — process name)
|
|
func ValidateHandler(proc *process.Process) interface{} {
|
|
name := proc.ArgsString(0)
|
|
return goudoc.Validate(goudoc.TypeProcess, name)
|
|
}
|