Documentation
¶
Index ¶
- func NewSchemaModule(logger logging.Logger, deps *core.Dependencies) core.Module
- type GetSchemaByModuleInput
- type GetSchemaByNameInput
- type Handler
- type ListSchemasInput
- type ListSchemasOutput
- type MCPServer
- type Property
- type PropertyUI
- type RelationConfig
- type SchemaDetailResponse
- type SchemaFeatures
- type SchemaInfo
- type SchemaListResponse
- type SchemaMetaInfo
- type SchemaModule
- type SchemaUI
- type SelectOption
- type Service
- type UILayout
- type ValidateSchemaInput
- type ValidateSchemaOutput
- type ValidationRules
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSchemaModule ¶
NewSchemaModule creates a new schema module
Types ¶
type GetSchemaByModuleInput ¶
type GetSchemaByModuleInput struct {
Module string `json:"module"`
}
type GetSchemaByNameInput ¶
type GetSchemaByNameInput struct {
Name string `json:"name"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles HTTP requests for schema operations
func NewHandler ¶
NewHandler creates a new schema handler
func (*Handler) GetSchemaByModule ¶
func (h *Handler) GetSchemaByModule(w http.ResponseWriter, r *http.Request)
GetSchemaByModule handles GET /schemas/module/:module @Summary Get schema by module name @Description Get detailed schema information for a specific module @Tags Schema @Produce json @Param module path string true "Module name" @Success 200 {object} SchemaDetailResponse @Failure 400 {string} string "Bad request" @Failure 404 {string} string "Schema not found" @Failure 500 {string} string "Internal server error" @Router /schemas/module/{module} [get]
func (*Handler) GetSchemaByName ¶
func (h *Handler) GetSchemaByName(w http.ResponseWriter, r *http.Request)
GetSchemaByName handles GET /schemas/:name @Summary Get schema by schema name @Description Get detailed schema information by schema name (e.g., User, Role, Menu) @Tags Schema @Produce json @Param name path string true "Schema name" @Success 200 {object} SchemaDetailResponse @Failure 400 {string} string "Bad request" @Failure 404 {string} string "Schema not found" @Failure 500 {string} string "Internal server error" @Router /schemas/{name} [get]
func (*Handler) ListSchemas ¶
func (h *Handler) ListSchemas(w http.ResponseWriter, r *http.Request)
ListSchemas handles GET /schemas @Summary List all schemas @Description Get a list of all available schemas @Tags Schema @Produce json @Success 200 {object} SchemaListResponse @Failure 500 {string} string "Internal server error" @Router /schemas [get]
type ListSchemasInput ¶
type ListSchemasInput struct{}
type ListSchemasOutput ¶
type ListSchemasOutput struct {
Schemas []SchemaInfo `json:"schemas"`
}
type MCPServer ¶
type MCPServer struct {
// contains filtered or unexported fields
}
MCPServer wraps the schema service as an MCP server
func NewMCPServer ¶
NewMCPServer creates a standalone MCP server for schema operations
func (*MCPServer) RegisterOn ¶
RegisterOn registers all schema tools and resources onto an external shared server.
type Property ¶
type Property struct {
Type string `json:"type"`
Label string `json:"label"`
Description string `json:"description,omitempty"`
Default any `json:"default,omitempty"`
Private bool `json:"private,omitempty"`
Writable *bool `json:"writable,omitempty"`
Unique bool `json:"unique,omitempty"`
Queryable bool `json:"queryable,omitempty"`
Exportable bool `json:"exportable,omitempty"`
Validate *ValidationRules `json:"validate,omitempty"`
UI *PropertyUI `json:"ui,omitempty"`
Ref string `json:"$ref,omitempty"`
Relation *RelationConfig `json:"$relation,omitempty"`
}
Property represents a field in the schema
func (*Property) UnmarshalJSON ¶
UnmarshalJSON custom unmarshaler to handle dynamic property types
type PropertyUI ¶
type PropertyUI struct {
Widget string `json:"widget,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Span int `json:"span,omitempty"`
ShowInList bool `json:"showInList,omitempty"`
ShowInForm bool `json:"showInForm,omitempty"`
Sortable bool `json:"sortable,omitempty"`
Filterable bool `json:"filterable,omitempty"`
Multiple bool `json:"multiple,omitempty"`
Options []SelectOption `json:"options,omitempty"`
}
PropertyUI defines UI configuration for a property
type RelationConfig ¶
type RelationConfig struct {
Type string `json:"type"`
LabelField string `json:"labelField,omitempty"`
}
RelationConfig defines relationship configuration
type SchemaDetailResponse ¶
type SchemaDetailResponse struct {
Schema string `json:"$schema"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
SoftDelete bool `json:"softDelete,omitempty"`
Info *SchemaMetaInfo `json:"info,omitempty"`
UI *SchemaUI `json:"ui,omitempty"`
Features *SchemaFeatures `json:"features,omitempty"`
Properties map[string]*Property `json:"properties"`
}
SchemaDetailResponse represents the complete schema structure
type SchemaFeatures ¶
type SchemaFeatures struct {
SoftDelete bool `json:"softDelete,omitempty"`
Export bool `json:"export,omitempty"`
Import bool `json:"import,omitempty"`
Batch bool `json:"batch,omitempty"`
}
SchemaFeatures defines feature flags for the schema
type SchemaInfo ¶
type SchemaInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Module string `json:"module"`
}
SchemaInfo represents basic information about a schema
type SchemaListResponse ¶
type SchemaListResponse struct {
Schemas []SchemaInfo `json:"schemas"`
}
SchemaListResponse represents the response for listing all schemas
type SchemaMetaInfo ¶
type SchemaMetaInfo struct {
CollectionName string `json:"collectionName"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
Icon string `json:"icon"`
Locale string `json:"locale"`
}
SchemaMetaInfo contains metadata about the schema
type SchemaModule ¶
type SchemaModule struct {
// contains filtered or unexported fields
}
SchemaModule represents the schema module
func (*SchemaModule) RegisterPrivateRoutes ¶
func (m *SchemaModule) RegisterPrivateRoutes(r chi.Router)
RegisterPrivateRoutes - schema module has no private routes
func (*SchemaModule) RegisterPublicRoutes ¶
func (m *SchemaModule) RegisterPublicRoutes(r chi.Router)
RegisterPublicRoutes registers public schema endpoints (frontend needs to read schemas)
type SchemaUI ¶
type SchemaUI struct {
SubmitText string `json:"submitText,omitempty"`
ResetText string `json:"resetText,omitempty"`
ShowReset bool `json:"showReset,omitempty"`
Layout *UILayout `json:"layout,omitempty"`
}
SchemaUI contains UI configuration for forms
type SelectOption ¶
SelectOption represents an option in a select widget
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides schema-related business logic
func NewService ¶
NewService creates a new schema service
func (*Service) GetSchemaByModule ¶
func (s *Service) GetSchemaByModule(moduleName string) (*SchemaDetailResponse, error)
GetSchemaByModule returns the schema details for a specific module
func (*Service) GetSchemaByName ¶
func (s *Service) GetSchemaByName(schemaName string) (*SchemaDetailResponse, error)
GetSchemaByName returns the schema details by schema name
func (*Service) ListSchemas ¶
func (s *Service) ListSchemas() (*SchemaListResponse, error)
ListSchemas returns a list of all available schemas
type UILayout ¶
type UILayout struct {
Direction string `json:"direction,omitempty"`
Gap int `json:"gap,omitempty"`
Columns int `json:"columns,omitempty"`
}
UILayout defines the form layout
type ValidateSchemaInput ¶
type ValidateSchemaInput struct {
Module string `json:"module"`
}