Documentation
¶
Overview ¶
Package profile holds what a user tells getafjob about themselves: the applicant profile, search preferences, documents, answers and text blocks. Personal content is stored sealed with the user's data key.
Index ¶
- Constants
- Variables
- func CleanName(name, mime string) string
- func CleanVariant(label, language string, focus []string) (string, string, []string, error)
- func Lines(s string) []string
- func MonthDate(s string) string
- func NormalizeQuestion(q string) string
- func ProfileValues(p Profile) map[string]string
- func Sniff(b []byte) (string, error)
- func ValidKind(k string) bool
- func WebURL(v string) string
- type Answer
- type Document
- type DocumentStore
- type Documents
- func (s *Documents) Delete(ctx context.Context, userID, id uuid.UUID) error
- func (s *Documents) List(ctx context.Context, userID uuid.UUID) ([]Document, error)
- func (s *Documents) Read(ctx context.Context, userID, id uuid.UUID) (Document, []byte, error)
- func (s *Documents) SetVariant(ctx context.Context, userID, id uuid.UUID, label, language string, ...) error
- func (s *Documents) Upload(ctx context.Context, userID uuid.UUID, kind, name string, data []byte) (Document, error)
- func (s *Documents) WithClock(now func() time.Time) *Documents
- type EducationStation
- type FieldError
- type Files
- type ItemStore
- type Items
- func (s *Items) Answers(ctx context.Context, userID uuid.UUID) ([]Answer, error)
- func (s *Items) Delete(ctx context.Context, userID uuid.UUID, kind string, id uuid.UUID) error
- func (s *Items) SaveAnswer(ctx context.Context, userID uuid.UUID, a Answer) (uuid.UUID, error)
- func (s *Items) SaveTextBlock(ctx context.Context, userID uuid.UUID, t TextBlock) (uuid.UUID, error)
- func (s *Items) TextBlocks(ctx context.Context, userID uuid.UUID) ([]TextBlock, error)
- func (s *Items) WithClock(now func() time.Time) *Items
- type Language
- type Personal
- type Preferences
- type Profile
- type Sealer
- type Service
- func (s *Service) Get(ctx context.Context, userID uuid.UUID) (Snapshot, error)
- func (s *Service) SavePreferences(ctx context.Context, userID uuid.UUID, p Preferences) error
- func (s *Service) SaveProfile(ctx context.Context, userID uuid.UUID, p Profile, version int64) error
- func (s *Service) WithClock(now func() time.Time) *Service
- func (s *Service) WithOnChange(fn func(ctx context.Context, userID uuid.UUID)) *Service
- type Snapshot
- type StationStore
- type Stations
- func (s *Stations) DeleteEducation(ctx context.Context, userID, id uuid.UUID) error
- func (s *Stations) DeleteWorkExperience(ctx context.Context, userID, id uuid.UUID) error
- func (s *Stations) Educations(ctx context.Context, userID uuid.UUID) ([]EducationStation, error)
- func (s *Stations) GetEducation(ctx context.Context, userID, id uuid.UUID) (EducationStation, error)
- func (s *Stations) GetWorkExperience(ctx context.Context, userID, id uuid.UUID) (WorkExperience, error)
- func (s *Stations) MoveEducation(ctx context.Context, userID, id uuid.UUID, direction string) error
- func (s *Stations) MoveWorkExperience(ctx context.Context, userID, id uuid.UUID, direction string) error
- func (s *Stations) ReorderEducations(ctx context.Context, userID uuid.UUID, ids []uuid.UUID) error
- func (s *Stations) ReorderWorkExperiences(ctx context.Context, userID uuid.UUID, ids []uuid.UUID) error
- func (s *Stations) SaveEducation(ctx context.Context, userID uuid.UUID, e EducationStation) (uuid.UUID, error)
- func (s *Stations) SaveWorkExperience(ctx context.Context, userID uuid.UUID, w WorkExperience) (uuid.UUID, error)
- func (s *Stations) WorkExperiences(ctx context.Context, userID uuid.UUID) ([]WorkExperience, error)
- type Store
- type Stored
- type StoredDocument
- type StoredEducation
- type StoredItem
- type StoredWorkExperience
- type TextBlock
- type ValidationError
- type Work
- type WorkExperience
Constants ¶
const ( KindCV = "cv" KindCertificate = "certificate" KindOther = "other" )
Document kinds.
const ( MimePDF = "application/pdf" MimeDOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document" MimePNG = "image/png" MimeJPEG = "image/jpeg" )
Accepted file types.
const ( MaxDocument = 10 << 20 MaxDocuments = 50 )
Upload limits.
const ( ItemAnswer = "answer" ItemText = "text" )
Item kinds.
const ( WorkplaceRemote = "remote" WorkplaceHybrid = "hybrid" WorkplaceOnsite = "onsite" )
Workplace types for WorkExperience.
const (
MaxItems = 500
)
Limits of the answer bank and text blocks.
const MaxStations = 100
MaxStations limits how many entries a user may keep per category.
Variables ¶
var ( ErrFileType = errors.New("profile: file type not accepted") ErrFileTooLarge = errors.New("profile: file too large") ErrTooManyFiles = errors.New("profile: too many documents") ErrNotFound = errors.New("profile: not found") ErrVariant = errors.New("profile: invalid CV variant") )
Document errors.
var ( // ErrInvalid reports a profile or preferences that fail validation; Fields says why. ErrInvalid = errors.New("profile: invalid") // ErrConflict reports that the profile changed since it was loaded (another tab or device). ErrConflict = errors.New("profile: changed meanwhile") )
var ( // ErrStationNotFound reports that the requested work experience or education station was not found. ErrStationNotFound = errors.New("profile: station not found") // ErrTooManyStations reports exceeding the station limit per category. ErrTooManyStations = errors.New("profile: too many stations") )
var ErrTooManyItems = errors.New("profile: too many entries")
ErrTooManyItems reports a full answer bank or text block list.
var Placeholders = []string{
"first_name", "last_name", "full_name", "email", "phone", "city", "current_title", "notice_period",
"earliest_start", "company", "job_title", "job_location", "date",
}
Placeholders lists what text blocks may use; the values come from the profile and the job.
Functions ¶
func CleanName ¶
CleanName keeps the base name of an uploaded file without control characters, at most 200 characters.
func CleanVariant ¶
CleanVariant normalizes the variant fields of a CV.
func MonthDate ¶
MonthDate cleans a station date and brings month notations to YYYY-MM, the form the planner fills from. Anything else (YYYY-MM, YYYY, free text) stays as written.
func NormalizeQuestion ¶
NormalizeQuestion is the key under which an answer is found: lower case, no punctuation or required markers.
func ProfileValues ¶
ProfileValues are the placeholder values a profile provides.
func Sniff ¶
Sniff returns the type of a file from its first bytes, never from its name or the browser's claim. A DOCX must be a well-formed zip with a Word document inside and bounded entries (no zip bombs).
func WebURL ¶
WebURL adds https:// to a bare link ("linkedin.com/in/max" → "https://linkedin.com/in/max").
Types ¶
type Answer ¶
type Answer struct {
ID uuid.UUID `json:"-"`
Question string `json:"question"`
Answer string `json:"answer"`
}
Answer is a saved answer to a recurring form question. The planner uses it only for the same question.
func FindAnswer ¶
FindAnswer returns the answer saved for the same question.
type Document ¶
type Document struct {
ID uuid.UUID
Kind string
Name string // original file name, cleaned
Mime string
Size int
Label string
Language string // en, de or empty (any)
Focus []string // words of jobs this CV fits, e.g. platform, kubernetes
CreatedAt time.Time
}
Document is a stored file of the user. A CV is also a variant: Label, Language and Focus choose it per job.
type DocumentStore ¶
type DocumentStore interface {
InsertDocument(ctx context.Context, userID uuid.UUID, d StoredDocument) error
Documents(ctx context.Context, userID uuid.UUID) ([]StoredDocument, error)
Document(ctx context.Context, userID, id uuid.UUID) (StoredDocument, error) // ErrNotFound
CountDocuments(ctx context.Context, userID uuid.UUID) (int, error)
UpdateVariant(ctx context.Context, userID, id uuid.UUID, label, language string, focus []string) (bool, error)
DeleteDocument(ctx context.Context, userID, id uuid.UUID) (bool, error)
}
DocumentStore persists document metadata per user (row-level security).
type Documents ¶
type Documents struct {
// contains filtered or unexported fields
}
Documents manages the user's files: type checked by content, contents and names sealed.
func NewDocuments ¶
func NewDocuments(store DocumentStore, files Files, sealer Sealer) *Documents
NewDocuments returns the document service.
func (*Documents) SetVariant ¶
func (s *Documents) SetVariant(ctx context.Context, userID, id uuid.UUID, label, language string, focus []string) error
SetVariant sets label, language and focus words of a CV.
type EducationStation ¶
type EducationStation struct {
ID uuid.UUID `json:"id"`
Institution string `json:"institution"`
Degree string `json:"degree"`
FieldOfStudy string `json:"field_of_study,omitempty"`
StartDate string `json:"start_date,omitempty"`
EndDate string `json:"end_date,omitempty"`
IsCurrent bool `json:"is_current"`
Grade string `json:"grade,omitempty"`
SortOrder int `json:"sort_order"`
}
EducationStation represents a structured educational station.
func (EducationStation) Validate ¶
func (e EducationStation) Validate() []FieldError
Validate checks education station fields.
type FieldError ¶
FieldError names an invalid field and an i18n code (profile.error.*).
type Files ¶
type Files interface {
Put(ctx context.Context, userID uuid.UUID, key string, data []byte) error
Get(ctx context.Context, userID uuid.UUID, key string) ([]byte, error)
Delete(ctx context.Context, userID uuid.UUID, key string) error
}
Files keeps file contents sealed per user (blob.Sealed).
type ItemStore ¶
type ItemStore interface {
Items(ctx context.Context, userID uuid.UUID, kind string) ([]StoredItem, error)
CountItems(ctx context.Context, userID uuid.UUID, kind string) (int, error)
InsertItem(ctx context.Context, userID uuid.UUID, kind string, it StoredItem) error
// UpdateItem and DeleteItem report false when the item does not exist for the user.
UpdateItem(ctx context.Context, userID uuid.UUID, kind string, it StoredItem) (bool, error)
DeleteItem(ctx context.Context, userID uuid.UUID, kind string, id uuid.UUID) (bool, error)
}
ItemStore persists answers and text blocks per user (row-level security).
type Items ¶
type Items struct {
// contains filtered or unexported fields
}
Items manages the answer bank and the text blocks; each entry is sealed on its own.
func (*Items) SaveAnswer ¶
SaveAnswer stores a new (ID nil) or changed answer. A question that is already in the bank updates that entry.
func (*Items) SaveTextBlock ¶
func (s *Items) SaveTextBlock(ctx context.Context, userID uuid.UUID, t TextBlock) (uuid.UUID, error)
SaveTextBlock stores a new (ID nil) or changed text block.
func (*Items) TextBlocks ¶
TextBlocks returns the user's text blocks.
type Personal ¶
type Personal struct {
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
Street string `json:"street,omitempty"`
PostalCode string `json:"postal_code,omitempty"`
City string `json:"city,omitempty"`
Country string `json:"country,omitempty"`
LinkedIn string `json:"linkedin,omitempty"`
GitHub string `json:"github,omitempty"`
Website string `json:"website,omitempty"`
Pronouns string `json:"pronouns,omitempty"`
}
Personal holds contact data.
type Preferences ¶
type Preferences struct {
Titles []string `json:"titles,omitempty"` // wanted job titles and keywords
ExcludeTitles []string `json:"exclude_titles,omitempty"` // titles with these words are skipped
Locations []string `json:"locations,omitempty"` // places for on-site or hybrid work
Remote bool `json:"remote"`
RemoteRegions []string `json:"remote_regions,omitempty"` // e.g. Germany, EU
MinSalary int `json:"min_salary,omitempty"` // yearly gross in EUR, 0: none
CoverLetterLang string `json:"cover_letter_lang,omitempty"`
Diversity string `json:"diversity,omitempty"` // decline or answer
TalentPool bool `json:"talent_pool"`
}
Preferences steer search and matching; they hold no contact data and stay readable for the crawler.
func (Preferences) Validate ¶
func (p Preferences) Validate() []FieldError
Validate checks the preferences.
type Profile ¶
type Profile struct {
Personal Personal `json:"personal"`
Work Work `json:"work"`
Summary string `json:"summary,omitempty"`
Skills []string `json:"skills,omitempty"`
Languages []Language `json:"languages,omitempty"`
Certifications []string `json:"certifications,omitempty"`
}
Profile is the applicant profile; empty fields are unknown (the planner asks instead of guessing).
func (Profile) Missing ¶
Missing lists the fields most forms need that are still empty, in the order of the profile form (the assistant asks for them, the profile page links to them).
func (Profile) Validate ¶
func (p Profile) Validate() []FieldError
Validate checks the profile against the schema; it returns every problem, not just the first.
type Sealer ¶
type Sealer interface {
Seal(ctx context.Context, userID uuid.UUID, purpose string, plaintext []byte) ([]byte, error)
Open(ctx context.Context, userID uuid.UUID, purpose string, ciphertext []byte) ([]byte, error)
}
Sealer encrypts per user (crypto.Envelope).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service reads and writes profiles.
func NewService ¶
NewService returns a profile service.
func (*Service) Get ¶
Get loads the user's profile and preferences (empty ones if there are none yet).
func (*Service) SavePreferences ¶
SavePreferences validates and stores the preferences.
func (*Service) SaveProfile ¶
func (s *Service) SaveProfile(ctx context.Context, userID uuid.UUID, p Profile, version int64) error
SaveProfile validates p and stores it sealed if the profile is still at version.
type Snapshot ¶
type Snapshot struct {
Profile Profile
Preferences Preferences
Version int64
}
Snapshot is a loaded profile with its version for the next save.
type StationStore ¶
type StationStore interface {
ListWorkExperiences(ctx context.Context, userID uuid.UUID) ([]StoredWorkExperience, error)
GetWorkExperience(ctx context.Context, userID, id uuid.UUID) (StoredWorkExperience, error)
InsertWorkExperience(ctx context.Context, w StoredWorkExperience) error
UpdateWorkExperience(ctx context.Context, w StoredWorkExperience) (bool, error)
UpdateWorkExperienceOrder(ctx context.Context, userID, id uuid.UUID, sortOrder int, updatedAt time.Time) (bool, error)
DeleteWorkExperience(ctx context.Context, userID, id uuid.UUID) (bool, error)
CountWorkExperiences(ctx context.Context, userID uuid.UUID) (int, error)
ListEducations(ctx context.Context, userID uuid.UUID) ([]StoredEducation, error)
GetEducation(ctx context.Context, userID, id uuid.UUID) (StoredEducation, error)
InsertEducation(ctx context.Context, e StoredEducation) error
UpdateEducation(ctx context.Context, e StoredEducation) (bool, error)
UpdateEducationOrder(ctx context.Context, userID, id uuid.UUID, sortOrder int, updatedAt time.Time) (bool, error)
DeleteEducation(ctx context.Context, userID, id uuid.UUID) (bool, error)
CountEducations(ctx context.Context, userID uuid.UUID) (int, error)
}
StationStore persists work experiences and educations per user (row-level security).
type Stations ¶
type Stations struct {
// contains filtered or unexported fields
}
Stations manages work experiences and educations with envelope encryption.
func NewStations ¶
func NewStations(store StationStore, sealer Sealer) *Stations
NewStations returns a new stations service.
func (*Stations) DeleteEducation ¶
DeleteEducation removes an education entry.
func (*Stations) DeleteWorkExperience ¶
DeleteWorkExperience removes a work experience.
func (*Stations) Educations ¶
Educations lists the user's education entries in sort order.
func (*Stations) GetEducation ¶
func (s *Stations) GetEducation(ctx context.Context, userID, id uuid.UUID) (EducationStation, error)
GetEducation returns one education entry by ID.
func (*Stations) GetWorkExperience ¶
func (s *Stations) GetWorkExperience(ctx context.Context, userID, id uuid.UUID) (WorkExperience, error)
GetWorkExperience returns one work experience by ID.
func (*Stations) MoveEducation ¶
MoveEducation moves an education entry up or down in sort order.
func (*Stations) MoveWorkExperience ¶
func (s *Stations) MoveWorkExperience(ctx context.Context, userID, id uuid.UUID, direction string) error
MoveWorkExperience moves an entry up or down in sort order.
func (*Stations) ReorderEducations ¶
ReorderEducations puts the user's degrees in the given order; ids must name each of them exactly once.
func (*Stations) ReorderWorkExperiences ¶
func (s *Stations) ReorderWorkExperiences(ctx context.Context, userID uuid.UUID, ids []uuid.UUID) error
ReorderWorkExperiences puts the user's positions in the given order; ids must name each of them exactly once.
func (*Stations) SaveEducation ¶
func (s *Stations) SaveEducation(ctx context.Context, userID uuid.UUID, e EducationStation) (uuid.UUID, error)
SaveEducation creates (ID nil) or updates an education station.
func (*Stations) SaveWorkExperience ¶
func (s *Stations) SaveWorkExperience(ctx context.Context, userID uuid.UUID, w WorkExperience) (uuid.UUID, error)
SaveWorkExperience creates (ID nil) or updates a work experience.
func (*Stations) WorkExperiences ¶
WorkExperiences lists the user's work experiences in sort order.
type Store ¶
type Store interface {
Load(ctx context.Context, userID uuid.UUID) (Stored, error)
// SaveProfile stores sealed if the stored version is still version; false when someone saved in between.
SaveProfile(ctx context.Context, userID uuid.UUID, sealed []byte, version int64, at time.Time) (bool, error)
SavePreferences(ctx context.Context, userID uuid.UUID, prefs []byte, at time.Time) error
}
Store persists profiles per user (row-level security).
type Stored ¶
type Stored struct {
Sealed []byte // nil: no profile yet
Preferences []byte // JSON, nil: none yet
Version int64 // 0: nothing stored
UpdatedAt time.Time
}
Stored is the raw state of a user's profile: the sealed profile and the readable preferences.
type StoredDocument ¶
StoredDocument is a document row; SealedName still needs opening.
type StoredEducation ¶
type StoredEducation struct {
ID uuid.UUID
UserID uuid.UUID
Institution string
Degree string
FieldOfStudy string
StartDate string
EndDate string
IsCurrent bool
Grade string
SortOrder int
CreatedAt time.Time
UpdatedAt time.Time
}
StoredEducation is an education database row.
type StoredItem ¶
StoredItem is a sealed answer or text block.
type StoredWorkExperience ¶
type StoredWorkExperience struct {
ID uuid.UUID
UserID uuid.UUID
Company string
Title string
Location string
WorkplaceType string
StartDate string
EndDate string
IsCurrent bool
SealedBullets []byte
SortOrder int
CreatedAt time.Time
UpdatedAt time.Time
}
StoredWorkExperience is a work experience database row with sealed bullet points.
type TextBlock ¶
type TextBlock struct {
ID uuid.UUID `json:"-"`
Name string `json:"name"`
Language string `json:"language,omitempty"` // en, de or empty (any)
Body string `json:"body"`
}
TextBlock is a reusable text (cover letter parts, motivation) with placeholders like {company}.
func (TextBlock) Fill ¶
Fill replaces the placeholders with values. Missing lists placeholders without a value; they stay in the text, so a caller never sends a text with a gap it did not notice.
func (TextBlock) Validate ¶
func (t TextBlock) Validate() []FieldError
Validate checks a text block; unknown placeholders are errors, so a typo never reaches an application.
type ValidationError ¶
type ValidationError struct{ Fields []FieldError }
ValidationError carries the field errors of ErrInvalid.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
Unwrap makes errors.Is(err, ErrInvalid) work.
type Work ¶
type Work struct {
CurrentTitle string `json:"current_title,omitempty"`
CurrentEmployer string `json:"current_employer,omitempty"`
YearsTotal string `json:"years_total,omitempty"`
YearsRelevant string `json:"years_relevant,omitempty"`
NoticePeriod string `json:"notice_period,omitempty"`
EarliestStart string `json:"earliest_start,omitempty"`
SalaryExpectation string `json:"salary_expectation,omitempty"` // yearly gross in EUR, as typed
WorkAuthorizedEU bool `json:"work_authorized_eu"`
NeedsSponsorship bool `json:"needs_sponsorship"`
WillingToRelocate bool `json:"willing_to_relocate"`
DriversLicense string `json:"drivers_license,omitempty"`
WorkplacePreferred string `json:"workplace_preferred,omitempty"` // free text, e.g. "Remote in Germany"
}
Work holds the facts application forms ask about.
type WorkExperience ¶
type WorkExperience struct {
ID uuid.UUID `json:"id"`
Company string `json:"company"`
Title string `json:"title"`
Location string `json:"location,omitempty"`
WorkplaceType string `json:"workplace_type,omitempty"` // "", "remote", "hybrid", "onsite"
StartDate string `json:"start_date"`
EndDate string `json:"end_date,omitempty"`
IsCurrent bool `json:"is_current"`
DescriptionBullets []string `json:"description_bullets,omitempty"`
SortOrder int `json:"sort_order"`
}
WorkExperience represents a structured employment position station.
func (WorkExperience) Validate ¶
func (w WorkExperience) Validate() []FieldError
Validate checks work experience fields.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
adapters
|
|
|
pgstore
Package pgstore implements profile.Store on PostgreSQL.
|
Package pgstore implements profile.Store on PostgreSQL. |
|
Package cvimport reads the text of a CV (PDF or DOCX) and fills profile fields from it with heuristics, without AI.
|
Package cvimport reads the text of a CV (PDF or DOCX) and fills profile fields from it with heuristics, without AI. |