- Removed the db.go and fs.go files, consolidating database and file system interactions into a unified IO interface. - Updated DSL struct to include db and fs fields for improved separation of concerns. - Refactored existing methods across various DSL managers (API, Connector, MCP, Model) to utilize the new IO interfaces for operations like Inspect, Create, Update, Delete, and List. - Enhanced error handling and validation in Create, Update, and Delete methods to ensure robust functionality. - Updated types to include new options for Load, Unload, and Reload operations, improving flexibility and usability.
166 lines
4.1 KiB
Go
166 lines
4.1 KiB
Go
package types
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Type for DSL
|
|
type Type string
|
|
|
|
// Status for DSL
|
|
type Status string
|
|
|
|
// StoreType for DSL store
|
|
type StoreType string
|
|
|
|
// LintSeverity for DSL linter
|
|
type LintSeverity string
|
|
|
|
// StoreType for DSL store
|
|
const (
|
|
StoreTypeDB StoreType = "db"
|
|
StoreTypeFile StoreType = "file"
|
|
)
|
|
|
|
// Status for DSL
|
|
const (
|
|
StatusLoading Status = "loading"
|
|
StatusLoaded Status = "loaded"
|
|
StatusError Status = "error"
|
|
)
|
|
|
|
// LintSeverity for DSL linter
|
|
const (
|
|
LintSeverityError LintSeverity = "error"
|
|
LintSeverityWarning LintSeverity = "warning"
|
|
LintSeverityInfo LintSeverity = "info"
|
|
LintSeverityHint LintSeverity = "hint"
|
|
)
|
|
|
|
// Type for DSL
|
|
const (
|
|
// TypeModel for model
|
|
TypeModel Type = "model"
|
|
// TypeAPI for api
|
|
TypeAPI Type = "api"
|
|
// TypeConnector for connector
|
|
TypeConnector Type = "connector"
|
|
// TypeMCPServer for MCP server
|
|
TypeMCPServer Type = "mcp-server"
|
|
// TypeMCPClient for MCP client
|
|
TypeMCPClient Type = "mcp-client"
|
|
// TypeStore for store
|
|
TypeStore Type = "store"
|
|
// TypeSchedule for schedule
|
|
TypeSchedule Type = "schedule"
|
|
|
|
// TypeTable for table
|
|
TypeTable Type = "table"
|
|
// TypeForm for form
|
|
TypeForm Type = "form"
|
|
// TypeList for list
|
|
TypeList Type = "list"
|
|
// TypeChart for chart
|
|
TypeChart Type = "chart"
|
|
// TypeDashboard for dashboard
|
|
TypeDashboard Type = "dashboard"
|
|
|
|
// TypeFlow for flow
|
|
TypeFlow Type = "flow"
|
|
// TypePipe for pipe
|
|
TypePipe Type = "pipe"
|
|
// TypeAIGC for aigc
|
|
TypeAIGC Type = "aigc"
|
|
|
|
// TypeUnknown for unknown
|
|
TypeUnknown Type = "unknown"
|
|
)
|
|
|
|
// Info for DSL
|
|
type Info struct {
|
|
ID string
|
|
|
|
Type Type
|
|
Label string
|
|
Description string
|
|
Tags []string
|
|
|
|
Sort int
|
|
Path string
|
|
Store StoreType
|
|
|
|
Readable bool
|
|
Builtin bool
|
|
|
|
Status Status
|
|
Mtime time.Time
|
|
Ctime time.Time
|
|
}
|
|
|
|
// ListOptions for DSL list
|
|
type ListOptions struct {
|
|
Sort string
|
|
Order string
|
|
Tags []string
|
|
}
|
|
|
|
// CreateOptions for DSL upsert
|
|
type CreateOptions struct {
|
|
ID string // ID is the id of the DSL, if not provided, a new id will be generated, required
|
|
Source string // Source is the source of the DSL, if not provided, the DSL will be loaded from the file system
|
|
Store StoreType // Store is the store type of the DSL, if not provided, the DSL will be loaded from the file system
|
|
Load map[string]interface{} // LoadOptions is the options for the DSL, if not provided, the DSL will be loaded from the file system
|
|
}
|
|
|
|
// UpdateOptions for DSL upsert
|
|
type UpdateOptions struct {
|
|
ID string // ID is the id of the DSL, if not provided, a new id will be generated, required
|
|
Info *Info // Info is the info of the DSL, if not provided, the DSL will be loaded from the file system, one of info or source must be provided
|
|
Source string // Source is the source of the DSL, if not provided, the DSL will be loaded from the file system, one of info or source must be provided
|
|
Reload map[string]interface{} // ReloadOptions is the options for the DSL, if not provided, the DSL will be loaded from the file system
|
|
}
|
|
|
|
// DeleteOptions for DSL delete options
|
|
type DeleteOptions struct {
|
|
ID string // ID is the id of the DSL, if not provided, a new id will be generated, required
|
|
Path string // Path is the path of the DSL, if not provided, the DSL will be loaded from the file system
|
|
Options map[string]interface{} // Options is the options for the DSL, if not provided, the DSL will be loaded from the file system
|
|
}
|
|
|
|
// LoadOptions for DSL load options
|
|
type LoadOptions struct {
|
|
ID string
|
|
Path string
|
|
Source string
|
|
Store StoreType
|
|
Options map[string]interface{}
|
|
}
|
|
|
|
// UnloadOptions for DSL unload options
|
|
type UnloadOptions struct {
|
|
ID string
|
|
Path string
|
|
Source string
|
|
Store StoreType
|
|
Options map[string]interface{}
|
|
}
|
|
|
|
// ReloadOptions for DSL reload options
|
|
type ReloadOptions struct {
|
|
ID string
|
|
Path string
|
|
Source string
|
|
Store StoreType
|
|
Options map[string]interface{}
|
|
}
|
|
|
|
// LintMessage for DSL linter
|
|
type LintMessage struct {
|
|
File string
|
|
Line int
|
|
Column int
|
|
Message string
|
|
Severity LintSeverity
|
|
}
|
|
|
|
var lintMessages []LintMessage
|