Documentation
¶
Index ¶
- Constants
- type Adapter
- type AdapterError
- type CredentialDecryptor
- type CredentialDecryptorEncryptor
- type CredentialEncryptor
- type CredentialField
- type DeliveryInfo
- type FileInfo
- type ProductInfo
- type ProgressFunc
- type Registry
- func (r *Registry) Get(id string) (Adapter, bool)
- func (r *Registry) GetSource(id string) (*SourceInfo, error)
- func (r *Registry) List() []Adapter
- func (r *Registry) ListSources() ([]SourceInfo, error)
- func (r *Registry) LoadCredentialsWithDecryptor(decryptor CredentialDecryptor) error
- func (r *Registry) Register(adapter Adapter)
- func (r *Registry) RegisterBuiltinAdapters(adapters ...Adapter)
- func (r *Registry) TestCredentials(ctx context.Context, id string, credentials map[string]string) error
- func (r *Registry) UpdateSource(id string, enabled bool, credentials map[string]string, ...) error
- type SourceInfo
Constants ¶
const ( ErrCodeAuth = "AUTH_ERROR" ErrCodeNotFound = "NOT_FOUND" ErrCodeRateLimit = "RATE_LIMITED" ErrCodeNetwork = "NETWORK_ERROR" ErrCodeInvalidConfig = "INVALID_CONFIG" )
Common error codes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface {
// Identity
ID() string
Name() string
// Credentials
CredentialFields() []CredentialField
SetCredentials(creds map[string]string)
ValidateCredentials(ctx context.Context) error
// Data fetching
FetchProducts(ctx context.Context) ([]ProductInfo, error)
FetchDeliveries(ctx context.Context, productID string) ([]DeliveryInfo, error)
FetchFiles(ctx context.Context, productID, deliveryID string) ([]FileInfo, error)
// Download
DownloadFile(ctx context.Context, file FileInfo, dst io.Writer, progress ProgressFunc) error
}
Adapter defines the interface for patent office API adapters
type AdapterError ¶
AdapterError represents an error from an adapter
func NewAdapterError ¶
func NewAdapterError(code, message string, err error) *AdapterError
NewAdapterError creates a new adapter error
func (*AdapterError) Error ¶
func (e *AdapterError) Error() string
func (*AdapterError) Unwrap ¶
func (e *AdapterError) Unwrap() error
type CredentialDecryptor ¶
CredentialDecryptor interface for decrypting credentials
type CredentialDecryptorEncryptor ¶
type CredentialDecryptorEncryptor interface {
CredentialEncryptor
CredentialDecryptor
}
CredentialDecryptorEncryptor combines both interfaces for UpdateSource
type CredentialEncryptor ¶
CredentialEncryptor interface for encrypting credentials
type CredentialField ¶
type CredentialField struct {
Key string `json:"key"`
Label string `json:"label"`
Type string `json:"type"` // "text", "password"
Required bool `json:"required"`
HelpText string `json:"helpText,omitempty"`
}
CredentialField defines a credential input field
type DeliveryInfo ¶
type DeliveryInfo struct {
ExternalID string `json:"externalId"`
Name string `json:"name"`
PublishedAt time.Time `json:"publishedAt"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
}
DeliveryInfo represents delivery/release metadata from an API
type FileInfo ¶
type FileInfo struct {
ExternalID string `json:"externalId"`
FileName string `json:"fileName"`
FileSize int64 `json:"fileSize"`
Checksum string `json:"checksum,omitempty"`
ChecksumAlgorithm string `json:"checksumAlgorithm,omitempty"`
DownloadURI string `json:"downloadUri"`
ReleasedAt time.Time `json:"releasedAt"`
}
FileInfo represents file metadata from an API
type ProductInfo ¶
type ProductInfo struct {
ExternalID string `json:"externalId"`
Name string `json:"name"`
Description string `json:"description"`
CheckSchedule string `json:"checkSchedule"` // Default cron schedule for this product
}
ProductInfo represents product metadata from an API
type ProgressFunc ¶
type ProgressFunc func(bytesWritten, totalBytes int64)
ProgressFunc is called during file downloads to report progress
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages source adapters
func NewRegistry ¶
NewRegistry creates a new source registry
func (*Registry) GetSource ¶
func (r *Registry) GetSource(id string) (*SourceInfo, error)
GetSource returns a source by ID with its database state
func (*Registry) ListSources ¶
func (r *Registry) ListSources() ([]SourceInfo, error)
ListSources returns all sources with their database state
func (*Registry) LoadCredentialsWithDecryptor ¶
func (r *Registry) LoadCredentialsWithDecryptor(decryptor CredentialDecryptor) error
LoadCredentialsWithDecryptor loads and decrypts credentials for all sources
func (*Registry) RegisterBuiltinAdapters ¶
RegisterBuiltinAdapters registers the built-in source adapters This is called from main.go to avoid import cycles
func (*Registry) TestCredentials ¶
func (r *Registry) TestCredentials(ctx context.Context, id string, credentials map[string]string) error
TestCredentials tests if the credentials for a source are valid
func (*Registry) UpdateSource ¶
func (r *Registry) UpdateSource(id string, enabled bool, credentials map[string]string, cryptor CredentialDecryptorEncryptor) error
UpdateSource updates source configuration
type SourceInfo ¶
type SourceInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
HasCredentials bool `json:"hasCredentials"`
LastSyncAt *time.Time `json:"lastSyncAt,omitempty"`
CredentialFields []CredentialField `json:"credentialFields"`
}
SourceInfo contains source metadata and state