Documentation
¶
Overview ¶
Package formfiller provides intelligent form filling capabilities.
Index ¶
- Variables
- type Config
- type CreateTemplateRequest
- type DetectRequest
- type DetectResponse
- type DetectedField
- type DetectionConfig
- type DetectionSource
- type Detector
- type FieldAttributes
- type FieldPatterns
- type FieldType
- type FillTemplate
- type Handler
- func (h *Handler) CreateTemplate(c echo.Context) error
- func (h *Handler) DeleteTemplate(c echo.Context) error
- func (h *Handler) DetectFields(c echo.Context) error
- func (h *Handler) GetConfig(c echo.Context) error
- func (h *Handler) GetPatterns(c echo.Context) error
- func (h *Handler) GetSiteMapping(c echo.Context) error
- func (h *Handler) GetTemplate(c echo.Context) error
- func (h *Handler) ListTemplates(c echo.Context) error
- func (h *Handler) RegisterRoutes(g *echo.Group)
- func (h *Handler) SaveSiteMapping(c echo.Context) error
- func (h *Handler) UpdatePatterns(c echo.Context) error
- func (h *Handler) UpdateTemplate(c echo.Context) error
- type LearningConfig
- type SiteMapping
- type Store
- func (s *Store) CreateTemplate(req *CreateTemplateRequest) (*FillTemplate, error)
- func (s *Store) DeleteTemplate(id string) error
- func (s *Store) GetDefaultTemplate() *FillTemplate
- func (s *Store) GetPatterns() *FieldPatterns
- func (s *Store) GetSiteMapping(domain string) (*SiteMapping, error)
- func (s *Store) GetTemplate(id string) (*FillTemplate, error)
- func (s *Store) ListTemplates() []*FillTemplate
- func (s *Store) SaveSiteMapping(mapping *SiteMapping) error
- func (s *Store) UpdatePatterns(patterns map[FieldType][]string) error
- func (s *Store) UpdateTemplate(id string, req *UpdateTemplateRequest) (*FillTemplate, error)
- type UpdateTemplateRequest
- type WidgetConfig
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidDomain = errors.New("invalid site domain")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Enabled bool `json:"enabled"`
Widget WidgetConfig `json:"widget"`
// Password configuration is handled client-side for security
Detection DetectionConfig `json:"detection"`
Learning LearningConfig `json:"learning"`
}
Config represents the form filler configuration.
type CreateTemplateRequest ¶
type CreateTemplateRequest struct {
Name string `json:"name"`
IsDefault bool `json:"is_default"`
Fields map[string]string `json:"fields"`
}
CreateTemplateRequest represents a request to create a template.
type DetectRequest ¶
type DetectRequest struct {
HTML string `json:"html"`
URL string `json:"url,omitempty"`
TemplateID string `json:"template_id,omitempty"`
}
DetectRequest represents a field detection request.
type DetectResponse ¶
type DetectResponse struct {
Fields []DetectedField `json:"fields"`
Count int `json:"count"`
}
DetectResponse represents a field detection response.
type DetectedField ¶
type DetectedField struct {
Selector string `json:"selector"`
FieldType FieldType `json:"field_type"`
Confidence float64 `json:"confidence"`
DetectionSource DetectionSource `json:"detection_source"`
SuggestedValue string `json:"suggested_value,omitempty"`
Attributes FieldAttributes `json:"attributes"`
}
DetectedField represents a detected form field.
type DetectionConfig ¶
type DetectionConfig struct {
UseLLMFallback bool `json:"use_llm_fallback"`
ConfidenceThreshold float64 `json:"confidence_threshold"`
ScanIntervalMs int `json:"scan_interval_ms"`
}
DetectionConfig represents detection configuration.
type DetectionSource ¶
type DetectionSource string
DetectionSource indicates how a field was detected.
const ( DetectionAttribute DetectionSource = "attribute" DetectionLabel DetectionSource = "label" DetectionPattern DetectionSource = "pattern" DetectionLLM DetectionSource = "llm" )
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector handles field detection logic.
func NewDetector ¶
func NewDetector(patterns *FieldPatterns) *Detector
NewDetector creates a new field detector.
func (*Detector) DetectFieldType ¶
func (d *Detector) DetectFieldType(attrs FieldAttributes) (FieldType, float64, DetectionSource)
DetectFieldType detects the field type from attributes.
func (*Detector) DetectFields ¶
func (d *Detector) DetectFields(fields []FieldAttributes, template *FillTemplate) []DetectedField
DetectFields detects fields from a list of field attributes.
type FieldAttributes ¶
type FieldAttributes struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Autocomplete string `json:"autocomplete,omitempty"`
Label string `json:"label,omitempty"`
}
FieldAttributes contains HTML attributes of a form field.
type FieldPatterns ¶
type FieldPatterns struct {
Patterns map[FieldType][]string `json:"patterns"`
UpdatedAt time.Time `json:"updated_at"`
}
FieldPatterns represents field detection patterns.
func DefaultPatterns ¶
func DefaultPatterns() *FieldPatterns
DefaultPatterns returns the default field detection patterns.
type FieldType ¶
type FieldType string
FieldType represents the type of a form field.
const ( FieldFirstName FieldType = "firstName" FieldLastName FieldType = "lastName" FieldFullName FieldType = "fullName" FieldEmail FieldType = "email" FieldPhone FieldType = "phone" FieldAddress FieldType = "address" FieldCity FieldType = "city" FieldState FieldType = "state" FieldZipCode FieldType = "zipCode" FieldCountry FieldType = "country" FieldUsername FieldType = "username" FieldPassword FieldType = "password" FieldConfirmPassword FieldType = "confirmPassword" FieldBirthDate FieldType = "birthDate" FieldCompany FieldType = "company" FieldTitle FieldType = "title" FieldCustom FieldType = "custom" )
type FillTemplate ¶
type FillTemplate struct {
ID string `json:"id"`
Name string `json:"name"`
IsDefault bool `json:"is_default"`
Fields map[string]string `json:"fields"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
FillTemplate represents a fill template with field values.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles HTTP requests for form filler.
func NewHandler ¶
NewHandler creates a new form filler handler.
func NewLazyHandler ¶
NewLazyHandler creates a handler whose store is initialized on first use.
func (*Handler) CreateTemplate ¶
CreateTemplate creates a new template.
func (*Handler) DeleteTemplate ¶
DeleteTemplate deletes a template.
func (*Handler) DetectFields ¶
DetectFields detects fields from HTML or field attributes.
func (*Handler) GetPatterns ¶
GetPatterns returns the field patterns.
func (*Handler) GetSiteMapping ¶
GetSiteMapping returns a site mapping by domain.
func (*Handler) GetTemplate ¶
GetTemplate returns a template by ID.
func (*Handler) ListTemplates ¶
ListTemplates returns all templates.
func (*Handler) RegisterRoutes ¶
RegisterRoutes registers the form filler routes.
func (*Handler) SaveSiteMapping ¶
SaveSiteMapping saves a site mapping.
func (*Handler) UpdatePatterns ¶
UpdatePatterns updates the field patterns.
type LearningConfig ¶
type LearningConfig struct {
Enabled bool `json:"enabled"`
SyncEnabled bool `json:"sync_enabled"`
MaxSiteMappings int `json:"max_site_mappings"`
}
LearningConfig represents learning configuration.
type SiteMapping ¶
type SiteMapping struct {
Domain string `json:"domain"`
FieldMappings map[string]string `json:"field_mappings"` // selector -> fieldType
LastUsed time.Time `json:"last_used"`
UserCorrections int `json:"user_corrections"`
}
SiteMapping represents site-specific field mappings.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store handles persistence for form filler data.
func (*Store) CreateTemplate ¶
func (s *Store) CreateTemplate(req *CreateTemplateRequest) (*FillTemplate, error)
CreateTemplate creates a new template.
func (*Store) DeleteTemplate ¶
DeleteTemplate deletes a template.
func (*Store) GetDefaultTemplate ¶
func (s *Store) GetDefaultTemplate() *FillTemplate
GetDefaultTemplate returns the default template.
func (*Store) GetPatterns ¶
func (s *Store) GetPatterns() *FieldPatterns
GetPatterns returns the field patterns.
func (*Store) GetSiteMapping ¶
func (s *Store) GetSiteMapping(domain string) (*SiteMapping, error)
GetSiteMapping returns a site mapping by domain.
func (*Store) GetTemplate ¶
func (s *Store) GetTemplate(id string) (*FillTemplate, error)
GetTemplate returns a template by ID.
func (*Store) ListTemplates ¶
func (s *Store) ListTemplates() []*FillTemplate
ListTemplates returns all templates.
func (*Store) SaveSiteMapping ¶
func (s *Store) SaveSiteMapping(mapping *SiteMapping) error
SaveSiteMapping saves a site mapping.
func (*Store) UpdatePatterns ¶
UpdatePatterns updates the field patterns.
func (*Store) UpdateTemplate ¶
func (s *Store) UpdateTemplate(id string, req *UpdateTemplateRequest) (*FillTemplate, error)
UpdateTemplate updates an existing template.
type UpdateTemplateRequest ¶
type UpdateTemplateRequest struct {
Name string `json:"name,omitempty"`
IsDefault *bool `json:"is_default,omitempty"`
Fields map[string]string `json:"fields,omitempty"`
}
UpdateTemplateRequest represents a request to update a template.
type WidgetConfig ¶
type WidgetConfig struct {
DefaultPosition string `json:"default_position"`
KeyboardShortcut string `json:"keyboard_shortcut"`
AutoShowOnForms bool `json:"auto_show_on_forms"`
}
WidgetConfig represents widget configuration.