Files
masonry/sdk/sdk.go
Mason Payne 9b209dfe63 try an SDK and a manually defined lang
I don't think I like the SDK way, and langV2 seems to be so simialr to
V1 that I'm probably going to stick with V1 for now and see if i can get
it to do what I need.
2025-08-20 00:13:41 -06:00

92 lines
3.9 KiB
Go

package sdk
type Definition struct {
Server []Server `json:"server,omitempty"`
Entity []Entity `json:"entity,omitempty"`
Endpoint []Endpoint `json:"endpoint,omitempty"`
Page []Page `json:"page,omitempty"`
}
type Server struct {
Name string `json:"name"`
Settings []ServerSetting `json:"settings,omitempty"`
Endpoints []Endpoint `json:"endpoints,omitempty"` // Optional endpoints for the server
}
type ServerSetting struct {
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
// TODO: Add more settings as needed e.g. TLS, CORS, etc.
}
type Entity struct {
Name string `json:"name"`
Description *string `json:"description,omitempty"`
Fields []Field `json:"fields,omitempty"`
}
type Field struct {
Name string `json:"name"`
Type string `json:"type"`
Required bool `json:"required,omitempty"`
Unique bool `json:"unique,omitempty"`
Index bool `json:"index,omitempty"`
Default *string `json:"default,omitempty"`
Validations []Validation `json:"validations,omitempty"`
Relationship *Relationship `json:"relationship,omitempty"`
}
type Validation struct {
Type string `json:"type"`
Value *string `json:"value,omitempty"`
}
type Relationship struct {
Type string `json:"type"`
Cardinality string `json:"cardinality"`
ForeignKey *string `json:"foreign_key,omitempty"`
Through *string `json:"through,omitempty"`
}
type Endpoint struct {
Method string `json:"method"`
Path string `json:"path"`
Entity Entity `json:"entity,omitempty"`
Description *string `json:"description,omitempty"`
Auth bool `json:"auth,omitempty"`
Permissions []string `json:"permissions,omitempty"`
}
type Page struct {
Name string `json:"name"`
Path string `json:"path"`
Title *string `json:"title,omitempty"`
Description *string `json:"description,omitempty"`
Auth bool `json:"auth,omitempty"`
Permissions []string `json:"permissions,omitempty"`
Components []Component `json:"components,omitempty"` // List of components used in the page
Styles []string `json:"styles,omitempty"` // List of stylesheets or CSS
Script []string `json:"script,omitempty"` // List of scripts or JS files
Metadata map[string]string `json:"metadata,omitempty"` // Additional metadata for the page
}
type Component struct {
Name string `json:"name"` // Name of the component
Description *string `json:"description,omitempty"` // Optional description of the component
Props []Prop `json:"props,omitempty"` // List of properties for the component
Type string `json:"type"` // Type of the component (e.g., "form", "table", etc.)
Entity Entity `json:"entity,omitempty"` // Optional entity this component is associated with
Styles []string `json:"styles,omitempty"` // List of stylesheets or CSS for the component
Script []string `json:"script,omitempty"` // List of scripts or JS files for the component
}
type Prop struct {
Name string `json:"name"` // Name of the property
Description *string `json:"description,omitempty"` // Optional description of the property
Type string `json:"type"` // Type of the property (e.g., "string", "number", "boolean", etc.)
Required bool `json:"required,omitempty"` // Whether the property is required
Default *string `json:"default,omitempty"` // Default value for the property
Validations []Validation `json:"validations,omitempty"` // List of validations for the property
Relationship *Relationship `json:"relationship,omitempty"` // Optional relationship
}