f750418239
Define los structs que reflejan el schema de docs/:
- Function con campos base + campos de component (props, emits, has_state, framework, variant)
- Type con campos algebraicos (product/sum)
- Enums Kind, Purity, Algebraic como tipos string
- GenerateID para construir IDs canonicos {name}_{lang}_{domain}
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
94 lines
2.8 KiB
Go
94 lines
2.8 KiB
Go
package registry
|
|
|
|
import "time"
|
|
|
|
// Kind classifies a registry entry.
|
|
type Kind string
|
|
|
|
const (
|
|
KindFunction Kind = "function"
|
|
KindPipeline Kind = "pipeline"
|
|
KindComponent Kind = "component"
|
|
)
|
|
|
|
// Purity indicates whether a function has side effects.
|
|
type Purity string
|
|
|
|
const (
|
|
PurityPure Purity = "pure"
|
|
PurityImpure Purity = "impure"
|
|
)
|
|
|
|
// Algebraic classifies a type.
|
|
type Algebraic string
|
|
|
|
const (
|
|
AlgebraicProduct Algebraic = "product"
|
|
AlgebraicSum Algebraic = "sum"
|
|
)
|
|
|
|
// Function represents an entry in the functions table.
|
|
// Covers kind: function, pipeline, and component.
|
|
type Function struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Kind Kind `json:"kind"`
|
|
Lang string `json:"lang"`
|
|
Domain string `json:"domain"`
|
|
Version string `json:"version"`
|
|
Purity Purity `json:"purity"`
|
|
Signature string `json:"signature"`
|
|
Description string `json:"description"`
|
|
Tags []string `json:"tags"`
|
|
UsesFunctions []string `json:"uses_functions"`
|
|
UsesTypes []string `json:"uses_types"`
|
|
Returns []string `json:"returns"`
|
|
ReturnsOptional bool `json:"returns_optional"`
|
|
ErrorType string `json:"error_type"`
|
|
Imports []string `json:"imports"`
|
|
Example string `json:"example"`
|
|
Tested bool `json:"tested"`
|
|
Tests []string `json:"tests"`
|
|
TestFilePath string `json:"test_file_path"`
|
|
FilePath string `json:"file_path"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
// Component-only fields (kind: component)
|
|
Props []PropDef `json:"props,omitempty"`
|
|
Emits []string `json:"emits,omitempty"`
|
|
HasState *bool `json:"has_state,omitempty"`
|
|
Framework string `json:"framework,omitempty"`
|
|
Variant []string `json:"variant,omitempty"`
|
|
}
|
|
|
|
// PropDef describes a component prop.
|
|
type PropDef struct {
|
|
Name string `json:"name"`
|
|
Type string `json:"type"`
|
|
Required bool `json:"required"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// Type represents an entry in the types table.
|
|
type Type struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Lang string `json:"lang"`
|
|
Domain string `json:"domain"`
|
|
Version string `json:"version"`
|
|
Algebraic Algebraic `json:"algebraic"`
|
|
Definition string `json:"definition"`
|
|
Description string `json:"description"`
|
|
Tags []string `json:"tags"`
|
|
UsesTypes []string `json:"uses_types"`
|
|
FilePath string `json:"file_path"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// GenerateID builds the canonical ID: {name}_{lang}_{domain}
|
|
func GenerateID(name, lang, domain string) string {
|
|
return name + "_" + lang + "_" + domain
|
|
}
|