schema

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSchemaModule

func NewSchemaModule(logger logging.Logger, deps *core.Dependencies) core.Module

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

func NewHandler(service *Service, logger logging.Logger) *Handler

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

func NewMCPServer(service *Service, logger logging.Logger) (*MCPServer, error)

NewMCPServer creates a standalone MCP server for schema operations

func (*MCPServer) GetServer

func (s *MCPServer) GetServer() *mcp.Server

GetServer returns the underlying MCP server

func (*MCPServer) RegisterOn

func (s *MCPServer) RegisterOn(server *mcp.Server) error

RegisterOn registers all schema tools and resources onto an external shared server.

func (*MCPServer) Run

func (s *MCPServer) Run(ctx context.Context) error

Run starts the MCP server using stdio transport

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

func (p *Property) UnmarshalJSON(data []byte) error

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) Name

func (m *SchemaModule) Name() string

Name returns the module name

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

type SelectOption struct {
	Value string `json:"value"`
	Label string `json:"label"`
}

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

func NewService(logger logging.Logger, modulesDir string) *Service

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"`
}

type ValidateSchemaOutput

type ValidateSchemaOutput struct {
	Valid   bool   `json:"valid"`
	Message string `json:"message,omitempty"`
	Module  string `json:"module"`
}

type ValidationRules

type ValidationRules struct {
	Required bool     `json:"required,omitempty"`
	Min      *int     `json:"min,omitempty"`
	Max      *int     `json:"max,omitempty"`
	Format   string   `json:"format,omitempty"`
	Enum     []string `json:"enum,omitempty"`
}

ValidationRules defines validation constraints

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL