refactor: mover .go de tipos Go a functions/{domain}/ para compilación unificada

Los archivos .go de tipos ahora viven junto a las funciones en functions/{domain}/
(mismo paquete Go), resolviendo errores de compilación por tipos no encontrados
(Option, Pair, Result, etc.). Los .md de metadata permanecen en types/{domain}/
con file_path actualizado a functions/. Se elimina types.go duplicado de infra.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-28 23:23:00 +01:00
parent 528a16cd5a
commit 05444f74d3
56 changed files with 27 additions and 55 deletions
+11
View File
@@ -0,0 +1,11 @@
package core
// Error is the standard error type for impure functions in the registry.
// Wraps a message string. Used as error_type reference.
type Error struct {
Message string
}
func (e Error) Error() string {
return e.Message
}
+43
View File
@@ -0,0 +1,43 @@
package core
// Option represents a value that may or may not be present.
// A sum type: Some(T) | None.
type Option[T any] struct {
value *T
}
// Some creates an Option containing a value.
func Some[T any](v T) Option[T] {
return Option[T]{value: &v}
}
// None creates an empty Option.
func None[T any]() Option[T] {
return Option[T]{}
}
// IsSome returns true if the Option contains a value.
func (o Option[T]) IsSome() bool {
return o.value != nil
}
// IsNone returns true if the Option is empty.
func (o Option[T]) IsNone() bool {
return o.value == nil
}
// Unwrap returns the value or panics if None.
func (o Option[T]) Unwrap() T {
if o.value == nil {
panic("called Unwrap on None")
}
return *o.value
}
// UnwrapOr returns the value or a default if None.
func (o Option[T]) UnwrapOr(def T) T {
if o.value != nil {
return *o.value
}
return def
}
+7
View File
@@ -0,0 +1,7 @@
package core
// Pair holds two values of potentially different types.
type Pair[A any, B any] struct {
First A
Second B
}
+52
View File
@@ -0,0 +1,52 @@
package core
// Result is a sum type representing either a successful value or an error.
// Exactly one of Ok or Err is non-nil at any time.
type Result[T any] struct {
ok *T
err error
}
// Ok creates a successful Result.
func Ok[T any](v T) Result[T] {
return Result[T]{ok: &v}
}
// Err creates a failed Result.
func Err[T any](err error) Result[T] {
return Result[T]{err: err}
}
// IsOk returns true if the Result contains a value.
func (r Result[T]) IsOk() bool {
return r.ok != nil
}
// IsErr returns true if the Result contains an error.
func (r Result[T]) IsErr() bool {
return r.err != nil
}
// Unwrap returns the value or panics if the Result is an error.
func (r Result[T]) Unwrap() T {
if r.ok == nil {
panic("called Unwrap on an Err Result")
}
return *r.ok
}
// UnwrapErr returns the error or panics if the Result is Ok.
func (r Result[T]) UnwrapErr() error {
if r.err == nil {
panic("called UnwrapErr on an Ok Result")
}
return r.err
}
// UnwrapOr returns the value or a default if the Result is an error.
func (r Result[T]) UnwrapOr(def T) T {
if r.ok != nil {
return *r.ok
}
return def
}
+53
View File
@@ -0,0 +1,53 @@
package core
import (
"errors"
"testing"
)
func TestResultOk(t *testing.T) {
r := Ok(42)
if !r.IsOk() {
t.Error("expected IsOk")
}
if r.IsErr() {
t.Error("expected not IsErr")
}
if r.Unwrap() != 42 {
t.Errorf("got %d, want 42", r.Unwrap())
}
}
func TestResultErr(t *testing.T) {
r := Err[int](errors.New("fail"))
if r.IsOk() {
t.Error("expected not IsOk")
}
if !r.IsErr() {
t.Error("expected IsErr")
}
if r.UnwrapErr().Error() != "fail" {
t.Errorf("got %v", r.UnwrapErr())
}
}
func TestUnwrapOr(t *testing.T) {
ok := Ok(10)
if ok.UnwrapOr(0) != 10 {
t.Error("UnwrapOr on Ok should return value")
}
err := Err[int](errors.New("fail"))
if err.UnwrapOr(99) != 99 {
t.Error("UnwrapOr on Err should return default")
}
}
func TestUnwrapPanics(t *testing.T) {
defer func() {
if recover() == nil {
t.Error("Unwrap on Err should panic")
}
}()
Err[int](errors.New("fail")).Unwrap()
}
+10
View File
@@ -0,0 +1,10 @@
package cybersecurity
import "net"
// CIDRBlock represents a parsed CIDR network range.
type CIDRBlock struct {
Network *net.IPNet
Broadcast net.IP
Hosts int
}
+24
View File
@@ -0,0 +1,24 @@
package cybersecurity
// PortResult is a sum type for TCP port scan results.
type PortResult interface{ portResult() }
// PortOpen indicates the port accepted a connection.
type PortOpen struct {
Port int
Banner string
}
// PortClosed indicates the port refused the connection.
type PortClosed struct {
Port int
}
// PortFiltered indicates the port did not respond (timeout).
type PortFiltered struct {
Port int
}
func (PortOpen) portResult() {}
func (PortClosed) portResult() {}
func (PortFiltered) portResult() {}
+21
View File
@@ -0,0 +1,21 @@
package cybersecurity
// ThreatResult is a sum type for SQL injection detection results.
type ThreatResult interface{ threatResult() }
// Clean indicates no threat was detected.
type Clean struct{}
// Suspicious indicates a possible threat with a reason.
type Suspicious struct {
Reason string
}
// Malicious indicates a confirmed threat pattern.
type Malicious struct {
Pattern string
}
func (Clean) threatResult() {}
func (Suspicious) threatResult() {}
func (Malicious) threatResult() {}
+20
View File
@@ -0,0 +1,20 @@
package datascience
// OutlierResult is a sum type representing whether a data point is normal or an outlier.
type OutlierResult interface{ outlierResult() }
// Normal indicates the data point is within expected range.
type Normal struct {
Index int
Value float64
}
// Outlier indicates the data point is anomalous.
type Outlier struct {
Index int
Value float64
ZScore float64
}
func (Normal) outlierResult() {}
func (Outlier) outlierResult() {}
+8
View File
@@ -0,0 +1,8 @@
package finance
// BollingerResult holds the three bands of a Bollinger Bands calculation.
type BollingerResult struct {
Upper []float64
Middle []float64
Lower []float64
}
+8
View File
@@ -0,0 +1,8 @@
package finance
// DrawdownResult holds the maximum drawdown value and the indices where it occurred.
type DrawdownResult struct {
Value float64
Start int
End int
}
+10
View File
@@ -0,0 +1,10 @@
package finance
// OHLCV represents a market candle with open, high, low, close prices and volume.
type OHLCV struct {
Open float64
High float64
Low float64
Close float64
Volume float64
}
+11
View File
@@ -0,0 +1,11 @@
package finance
import "time"
// Tick represents a single trade event in a market.
type Tick struct {
Symbol string
Price float64
Volume float64
Timestamp time.Time
}
+13
View File
@@ -0,0 +1,13 @@
package infra
// ContainerInfo representa la información básica de un contenedor Docker.
type ContainerInfo struct {
ID string // ID corto del contenedor
Name string // Nombre del contenedor
Image string // Imagen usada
Status string // Estado actual (running, exited, etc.)
State string // Estado detallado
Ports string // Mapeo de puertos
Created string // Fecha de creación
Labels map[string]string // Labels del contenedor
}
+10
View File
@@ -0,0 +1,10 @@
package infra
// ImageInfo representa la información básica de una imagen Docker local.
type ImageInfo struct {
ID string // ID corto de la imagen
Repository string // Nombre del repositorio
Tag string // Tag de la imagen
Size string // Tamaño legible (ej: "142MB")
Created string // Fecha de creación
}
+7
View File
@@ -0,0 +1,7 @@
package infra
// MetabaseClient holds the connection details for a Metabase instance API.
type MetabaseClient struct {
BaseURL string // e.g. "http://localhost:3000"
Token string // session token or API key
}
-28
View File
@@ -1,28 +0,0 @@
package infra
// ContainerInfo representa la información básica de un contenedor Docker.
type ContainerInfo struct {
ID string
Name string
Image string
Status string
State string
Ports string
Created string
Labels map[string]string
}
// ImageInfo representa la información básica de una imagen Docker local.
type ImageInfo struct {
ID string
Repository string
Tag string
Size string
Created string
}
// MetabaseClient holds the connection details for a Metabase instance API.
type MetabaseClient struct {
BaseURL string // e.g. "http://localhost:3000"
Token string // session token or API key
}
+9
View File
@@ -0,0 +1,9 @@
package shell
// CmdResult almacena el resultado de ejecutar un comando del sistema.
// Implementation: github.com/lucasdataproyects/devfactory/shell
type CmdResult struct {
Stdout string
Stderr string
ExitCode int
}
+11
View File
@@ -0,0 +1,11 @@
package tui
// BaseModel provee funcionalidad comun a todas las vistas TUI:
// dimensiones de terminal, estilos y manejo de errores.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type BaseModel struct {
Width int
Height int
Styles Styles
Err error
}
+11
View File
@@ -0,0 +1,11 @@
package tui
// ConfirmModel es un dialogo de confirmacion Si/No interactivo.
// Implementa tea.Model del framework Bubble Tea.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type ConfirmModel struct {
BaseModel
prompt string
selected bool
done bool
}
+10
View File
@@ -0,0 +1,10 @@
package tui
// FilteredListModel extiende ListModel con filtrado por texto en tiempo real.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type FilteredListModel struct {
ListModel
query string
allItems []ListItem
placeholder string
}
+9
View File
@@ -0,0 +1,9 @@
package tui
// ListItem representa un item individual en una lista TUI.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type ListItem struct {
Title string
Description string
Value interface{}
}
+15
View File
@@ -0,0 +1,15 @@
package tui
// ListModel es un componente lista seleccionable con cursor, scroll y seleccion.
// Implementa tea.Model del framework Bubble Tea.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type ListModel struct {
items []ListItem
cursor int
selected map[int]struct{}
multi bool
styles Styles
height int
width int
offset int
}
+9
View File
@@ -0,0 +1,9 @@
package tui
// MultiProgressModel gestiona multiples barras de progreso simultaneas.
// Implementa tea.Model del framework Bubble Tea.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type MultiProgressModel struct {
bars []ProgressModel
styles Styles
}
+21
View File
@@ -0,0 +1,21 @@
package tui
import (
"time"
"github.com/charmbracelet/bubbles/progress"
)
// ProgressModel es una barra de progreso con porcentaje, ETA y tiempo transcurrido.
// Implementa tea.Model del framework Bubble Tea.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type ProgressModel struct {
progress progress.Model
current float64
total float64
label string
styles Styles
showPct bool
showETA bool
started time.Time
}
+16
View File
@@ -0,0 +1,16 @@
package tui
import (
"github.com/charmbracelet/bubbles/spinner"
"github.com/charmbracelet/lipgloss"
)
// SpinnerModel es un indicador de carga animado con mensaje personalizable.
// Implementa tea.Model del framework Bubble Tea.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type SpinnerModel struct {
spinner spinner.Model
message string
style lipgloss.Style
active bool
}
@@ -0,0 +1,12 @@
package tui
import "time"
// SpinnerWithTimeoutModel es un spinner que se auto-detiene tras un timeout.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type SpinnerWithTimeoutModel struct {
SpinnerModel
timeout time.Duration
started time.Time
finished bool
}
+34
View File
@@ -0,0 +1,34 @@
package tui
import "github.com/charmbracelet/lipgloss"
// Styles contiene todos los estilos lipgloss pre-configurados para una aplicacion TUI.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type Styles struct {
Theme Theme
Title lipgloss.Style
Subtitle lipgloss.Style
Header lipgloss.Style
Label lipgloss.Style
Text lipgloss.Style
Muted lipgloss.Style
Code lipgloss.Style
Success lipgloss.Style
Error lipgloss.Style
Warning lipgloss.Style
Info lipgloss.Style
Border lipgloss.Style
Box lipgloss.Style
List lipgloss.Style
ListItem lipgloss.Style
Selected lipgloss.Style
Unselected lipgloss.Style
Button lipgloss.Style
ButtonActive lipgloss.Style
Input lipgloss.Style
Cursor lipgloss.Style
Container lipgloss.Style
Section lipgloss.Style
Divider lipgloss.Style
StatusBar lipgloss.Style
}
+17
View File
@@ -0,0 +1,17 @@
package tui
import "github.com/charmbracelet/lipgloss"
// Theme define una paleta de 9 colores semanticos para terminal.
// Implementation: github.com/lucasdataproyects/devfactory/tui
type Theme struct {
Primary lipgloss.Color
Secondary lipgloss.Color
Success lipgloss.Color
Error lipgloss.Color
Warning lipgloss.Color
Info lipgloss.Color
Muted lipgloss.Color
Text lipgloss.Color
Border lipgloss.Color
}