Documentation
¶
Overview ¶
Package domain holds the models: their bun tags are the schema, their json tags the API's JSON and the web app's types.
Index ¶
- Constants
- Variables
- func Forbidden(message string) error
- func Invalid(message string) error
- func IsDate(value string) bool
- func NotFound(message string) error
- func Unauthorized(message string) error
- type Application
- type Backup
- type BatchFailure
- type BatchResult
- type Changes
- type DeletedApplication
- type Filter
- type FollowUp
- type KnownSources
- type LoginFailure
- type NewApplication
- type OAuthCode
- type PreferenceChanges
- type Preferences
- type Setting
- type Source
- type Status
- type StatusChange
- type Token
- type TokenKind
Constants ¶
const ( MaxShort = 200 MaxComment = 10000 )
Limits of the free text, in runes.
const ( PlanBase = "base" PlanPro = "pro" )
The plans of the web app: base keeps the interface to the list and its form, pro adds the dashboard and the tools.
const ( MinFollowUpDays = 1 MaxFollowUpDays = 90 MaxNoReplyDays = 365 MinTrashDays = 1 MaxTrashDays = 365 )
Limits of FollowUpDays.
const BackupVersion = 1
BackupVersion is the layout of a Backup: a file of another version is refused rather than half read.
const DateLayout = time.DateOnly
DateLayout is the layout of applied_at and of the date filters.
const DateTimeLayout = "2006-01-02T15:04"
DateTimeLayout is the layout of interview_at: a local date and time, no zone.
const MaxBatch = 500
MaxBatch is the most applications one batch creates.
const MaxIDs = 500
MaxIDs is the most ids one request names.
const MaxSource = 60
MaxSource is the most characters of a source's name.
const SettingPasswordHash = "password_hash"
Setting keys.
const SettingPreferences = "preferences"
SettingPreferences is the key of the preferences, stored as JSON in the settings.
Variables ¶
var ( ErrNoCompany = Invalid("company is required") ErrNoLocation = Invalid("location (the city) is required") ErrLong = Invalid("company, location, street, postal_code, country, website, source_detail, contact_name and contact_email have at most 200 characters, comment 10000") ErrInvalidWebsite = Invalid("website must be an http(s) URL or an e-mail") ErrInvalidSource = Invalid("source is spontaneous, job_post, recruiter or a name of at most 60 characters") ErrInvalidDetail = Invalid("source_detail must be the job post's http(s) URL for job_post, the recruiter's e-mail for recruiter, empty for spontaneous; free for another source") ErrInvalidStatus = Invalid("status must be one of applied, responded, interview, offer, rejected, no_reply") ErrInvalidRating = Invalid("rating must be between 0 and 5") ErrInvalidDate = Invalid("dates must look like 2026-01-31") ErrInvalidInterview = Invalid("interview_at must look like 2026-01-31T14:30") ErrInvalidContact = Invalid("contact_email must be an e-mail") )
var ( ErrNoChanges = Invalid("set changes nothing: give at least one field") ErrUndoConflict = Invalid("undo_status goes without status, undo_follow_up without followed_up") ErrNoStatusChange = Invalid("no status change to undo") ErrNoFollowUp = Invalid("no follow-up to undo") )
var ( ErrEmptyBatch = Invalid("the batch is empty") ErrLongBatch = Invalid("at most 500 items per batch") )
var ( ErrInvalid = errors.New("invalid") ErrForbidden = errors.New("forbidden") ErrNotFound = errors.New("not found") )
The kinds of error the API maps to statuses (respond): a process's sentinel errors are made of one of them.
var ( ErrTooManyIDs = Invalid("at most 500 ids per request") ErrInvalidFilter = Invalid("applied_before, applied_after and untouched_since look like 2026-01-31") ErrNoFilter = Invalid("name ids or at least one filter: an empty filter would match every application") )
var ( ErrInvalidPlan = Invalid("plan is base or pro") ErrInvalidFollowUp = Invalid("follow_up_days is between 1 and 90") ErrInvalidNoReply = Invalid("no_reply_days is between 0 and 365") ErrInvalidTrash = Invalid("trash_days is between 1 and 365") ErrLongDefault = Invalid("default_location and default_country have at most 200 characters") )
var Columns = []string{"id", "company", "location", "street", "postal_code", "country", "website", "source", "source_detail", "status", "rating", "comment", "applied_at", "interview_at", "contact_name", "contact_email", "created_at", "updated_at", "followed_up_at"}
Columns are the columns ?fields= may ask for.
var DefaultPreferences = Preferences{Plan: PlanBase, FollowUpDays: 7, NoReplyDays: 10, TrashDays: 30}
DefaultPreferences are the preferences of a base that never saved any.
var ErrInvalidBackup = Invalid("not a callback backup of this version")
var Sources = []Source{SourceSpontaneous, SourceJobPost, SourceRecruiter}
var Statuses = []Status{StatusApplied, StatusResponded, StatusInterview, StatusOffer, StatusRejected, StatusNoReply}
var Waiting = []Status{StatusApplied, StatusResponded, StatusInterview}
Waiting are the statuses that wait on the employer: an application in one of them and without news is to follow up, then no_reply.
Functions ¶
func Unauthorized ¶
Unauthorized is a missing or wrong credential: 401.
Types ¶
type Application ¶
type Application struct {
bun.BaseModel `bun:"table:applications,alias:a" json:"-"`
ID string `bun:",pk" json:"id"`
Company string `bun:",notnull" json:"company,omitempty" binding:"optional"`
// Location is the city; Street, PostalCode and Country complete the address when known.
Location string `bun:",notnull" json:"location,omitempty" binding:"optional"`
Street string `bun:",nullzero" json:"street,omitempty" binding:"optional"`
PostalCode string `bun:",nullzero" json:"postal_code,omitempty" binding:"optional"`
Country string `bun:",nullzero" json:"country,omitempty" binding:"optional"`
// Website is the company's site, or an e-mail to write to when it has none.
Website string `bun:",notnull" json:"website,omitempty" binding:"optional"`
Source Source `bun:",notnull" json:"source,omitempty" binding:"optional" example:"job_post" swaggertype:"string"`
SourceDetail string `bun:",notnull" json:"source_detail,omitempty" binding:"optional"`
Status Status `bun:",notnull" json:"status,omitempty" binding:"optional" enums:"applied,responded,interview,offer,rejected,no_reply"`
Rating int `bun:",notnull" json:"rating,omitempty" binding:"optional"`
Comment string `bun:",notnull" json:"comment,omitempty" binding:"optional"`
AppliedAt string `bun:",notnull" json:"applied_at,omitempty" binding:"optional" example:"2026-01-31"`
// InterviewAt is the next interview's local date and time.
InterviewAt string `bun:",nullzero" json:"interview_at,omitempty" binding:"optional" example:"2026-01-31T14:30"`
ContactName string `bun:",nullzero" json:"contact_name,omitempty" binding:"optional"`
ContactEmail string `bun:",nullzero" json:"contact_email,omitempty" binding:"optional"`
CreatedAt time.Time `bun:",notnull" json:"created_at,omitzero" binding:"optional"`
UpdatedAt time.Time `bun:",notnull" json:"updated_at,omitzero" binding:"optional"`
// FollowedUpAt is the last follow-up, set by an update with followed_up.
FollowedUpAt time.Time `bun:",nullzero" json:"followed_up_at,omitzero" binding:"optional"`
// Truncated tells that comment was cut at max_chars.
Truncated bool `bun:"-" json:"truncated,omitempty" binding:"optional"`
}
Application is a job application. Text is stored raw: the web app escapes it when it shows it. Every field but id may be left out of a response that asks for some fields only (?fields=). The columns have no SQL default: a batch insert leaves out a defaulted column when its first row has the zero value.
func (*Application) Normalize ¶
func (a *Application) Normalize()
Normalize trims the text and fills the defaults: status applied, applied today.
func (*Application) Validate ¶
func (a *Application) Validate() error
Validate checks an application as it will be stored, and returns every error it finds, joined.
type Backup ¶ added in v0.5.0
type Backup struct {
Version int `json:"version" example:"1"`
ExportedAt time.Time `json:"exported_at"`
Applications []Application `json:"applications"`
Deleted []DeletedApplication `json:"deleted"`
StatusChanges []StatusChange `json:"status_changes"`
FollowUps []FollowUp `json:"follow_ups"`
}
Backup is everything the account wrote, as one JSON file: GET /api/export gives it, POST /api/import reads it. The settings, the tokens and the sessions stay out: they belong to the base, not to the data.
type BatchFailure ¶
type BatchFailure struct {
Index *int `json:"index,omitempty" binding:"optional"`
Op *int `json:"op,omitempty" binding:"optional"`
ID string `json:"id,omitempty" binding:"optional"`
Error string `json:"error"`
}
BatchFailure is an item of a batch that was not written, and why. Index is its place in the items of a creation; Op the place of its op in an update; ID the application an update or a delete could not write.
type BatchResult ¶
type BatchResult struct {
IDs []string `json:"ids,omitempty" binding:"optional"`
Count int `json:"count"`
Failed []BatchFailure `json:"failed,omitempty" binding:"optional"`
DryRun bool `json:"dry_run,omitempty" binding:"optional"`
}
BatchResult is what a batch wrote: the ids (left out with summary), their count, and the items that failed. Valid items are written even when others fail. DryRun tells that nothing was written: the ids and count are what the call would write.
func (*BatchResult) Summarize ¶
func (r *BatchResult) Summarize(summary bool)
Summarize drops the ids when only the counts are asked.
type Changes ¶
type Changes struct {
Company *string `json:"company,omitempty" binding:"optional"`
Location *string `json:"location,omitempty" binding:"optional"`
Street *string `json:"street,omitempty" binding:"optional"`
PostalCode *string `json:"postal_code,omitempty" binding:"optional"`
Country *string `json:"country,omitempty" binding:"optional"`
Website *string `json:"website,omitempty" binding:"optional"`
Source *Source `json:"source,omitempty" binding:"optional" example:"job_post" swaggertype:"string"`
SourceDetail *string `json:"source_detail,omitempty" binding:"optional"`
Status *Status `json:"status,omitempty" binding:"optional" enums:"applied,responded,interview,offer,rejected,no_reply"`
Rating *int `json:"rating,omitempty" binding:"optional"`
Comment *string `json:"comment,omitempty" binding:"optional"`
AppliedAt *string `json:"applied_at,omitempty" binding:"optional" example:"2026-01-31"`
// InterviewAt, ContactName and ContactEmail are cleared by "".
InterviewAt *string `json:"interview_at,omitempty" binding:"optional" example:"2026-01-31T14:30"`
ContactName *string `json:"contact_name,omitempty" binding:"optional"`
ContactEmail *string `json:"contact_email,omitempty" binding:"optional"`
// FollowedUp records a follow-up now: followed_up_at becomes now, and the status counts as news again.
FollowedUp bool `json:"followed_up,omitempty" binding:"optional"`
// UndoStatus takes the status back to the one before its last change and forgets that change: a status set by
// mistake leaves no step in the history.
UndoStatus bool `json:"undo_status,omitempty" binding:"optional"`
// UndoFollowUp forgets the last follow-up: followed_up_at goes back to the one before, if any.
UndoFollowUp bool `json:"undo_follow_up,omitempty" binding:"optional"`
}
Changes are the fields an update sets; a field left out keeps its value.
type DeletedApplication ¶ added in v0.4.0
type DeletedApplication struct {
bun.BaseModel `bun:"table:deleted_applications,alias:da" json:"-"`
ID string `bun:",pk" json:"id"`
// Application is the row as it was, in JSON: a column the applications gain needs nothing here.
Application Application `bun:"type:json,notnull" json:"application"`
DeletedAt time.Time `bun:",notnull" json:"deleted_at"`
}
DeletedApplication is a deleted application in the trash, kept Preferences.TrashDays so a delete can be undone: the delete moves it here and a restore moves it back. Its status history and follow-ups stay where they are, unread without their application.
type Filter ¶
type Filter struct {
// IDs are the applications by id.
IDs []string `json:"ids,omitempty" binding:"optional"`
// Status is any of these statuses.
Status []Status `json:"status,omitempty" binding:"optional"`
Source Source `json:"source,omitempty" binding:"optional" example:"job_post" swaggertype:"string"`
// Location is this city, whatever the case.
Location string `json:"location,omitempty" binding:"optional" example:"Lyon"`
// Q is text found in the company, the address, website, source_detail, contact or comment, case-insensitive.
Q string `json:"q,omitempty" binding:"optional"`
// AppliedBefore and AppliedAfter are strict: applied_at < before, applied_at > after.
AppliedBefore string `json:"applied_before,omitempty" binding:"optional" example:"2026-01-31"`
AppliedAfter string `json:"applied_after,omitempty" binding:"optional" example:"2026-01-01"`
// UntouchedSince is the applications without news since this day: no status change, follow-up nor interview.
UntouchedSince string `json:"untouched_since,omitempty" binding:"optional" example:"2026-01-01"`
}
Filter picks applications. Every field left out matches all; together they all must match.
func (Filter) Empty ¶
Empty tells a filter that matches every application. A blank q adds no condition (appfilter trims it): empty too.
func (Filter) UntouchedTime ¶
UntouchedTime is the start of the UntouchedSince day, in UTC.
type FollowUp ¶ added in v0.2.0
type FollowUp struct {
bun.BaseModel `bun:"table:follow_ups,alias:fu" json:"-"`
ID int64 `bun:",pk,autoincrement" json:"-"`
ApplicationID string `bun:",notnull" json:"application_id"`
At time.Time `bun:",notnull" json:"at"`
}
FollowUp is the user following an application up (a call, an e-mail), written by an update with followed_up and deleted with the application. The application keeps the last one in followed_up_at.
type KnownSources ¶ added in v0.3.0
type KnownSources struct {
// contains filtered or unexported fields
}
KnownSources are the source names in use, to write a source the way it is already written.
func NewKnownSources ¶ added in v0.3.0
func NewKnownSources(sources []Source) KnownSources
NewKnownSources knows the built-in sources and sources.
func (KnownSources) Match ¶ added in v0.3.0
func (k KnownSources) Match(source Source) Source
Match returns the known name that source equals but for case, else source, then knows it: "linkedin" reuses "LinkedIn", and a batch agrees with itself. A name already in use as written is kept, so a case can be fixed.
type LoginFailure ¶
type LoginFailure struct {
bun.BaseModel `bun:"table:login_failures,alias:lf"`
Key string `bun:",pk"`
Count int `bun:",notnull"`
LastAt time.Time `bun:",notnull"`
ExpiresAt time.Time `bun:",notnull"`
}
LoginFailure counts the wrong passwords in a row of a key (an address): kept in the base, a restart forgets none.
type NewApplication ¶
type NewApplication struct {
Company string `json:"company"`
Location string `json:"location"`
Street string `json:"street,omitempty" binding:"optional"`
PostalCode string `json:"postal_code,omitempty" binding:"optional"`
Country string `json:"country,omitempty" binding:"optional"`
Website string `json:"website,omitempty" binding:"optional"`
Source Source `json:"source,omitempty" binding:"optional" example:"job_post" swaggertype:"string"`
SourceDetail string `json:"source_detail,omitempty" binding:"optional"`
Status Status `json:"status,omitempty" binding:"optional" enums:"applied,responded,interview,offer,rejected,no_reply"`
Rating int `json:"rating,omitempty" binding:"optional"`
Comment string `json:"comment,omitempty" binding:"optional"`
AppliedAt string `json:"applied_at,omitempty" binding:"optional" example:"2026-01-31"`
InterviewAt string `json:"interview_at,omitempty" binding:"optional" example:"2026-01-31T14:30"`
ContactName string `json:"contact_name,omitempty" binding:"optional"`
ContactEmail string `json:"contact_email,omitempty" binding:"optional"`
}
NewApplication is an application to create: what is left out gets its default (Normalize).
func (NewApplication) Application ¶
func (n NewApplication) Application() Application
Application is the new application, not yet stored: no id nor timestamps.
type OAuthCode ¶
type OAuthCode struct {
bun.BaseModel `bun:"table:oauth_codes,alias:oc"`
CodeHash string `bun:",pk"`
ClientID string `bun:",notnull"`
RedirectURI string `bun:",notnull"`
CodeChallenge string `bun:",notnull"`
ReadOnly bool `bun:",notnull"`
ExpiresAt time.Time `bun:",notnull"`
}
OAuthCode is an authorization code between the consent and the token: it serves once, for a minute. The client proves with the verifier of CodeChallenge (PKCE S256) that it is the one which asked.
type PreferenceChanges ¶ added in v0.2.0
type PreferenceChanges struct {
Plan *string `json:"plan,omitempty" binding:"optional" enums:"base,pro"`
DefaultLocation *string `json:"default_location,omitempty" binding:"optional"`
DefaultCountry *string `json:"default_country,omitempty" binding:"optional"`
FollowUpDays *int `json:"follow_up_days,omitempty" binding:"optional"`
NoReplyDays *int `json:"no_reply_days,omitempty" binding:"optional"`
TrashDays *int `json:"trash_days,omitempty" binding:"optional"`
}
PreferenceChanges are the preferences an update sets; one left out keeps its value.
func (PreferenceChanges) Apply ¶ added in v0.2.0
func (c PreferenceChanges) Apply(p *Preferences)
Apply writes the changes into p.
type Preferences ¶ added in v0.2.0
type Preferences struct {
Plan string `json:"plan" enums:"base,pro"`
// DefaultLocation and DefaultCountry fill a new application of the web app; both may be empty.
DefaultLocation string `json:"default_location"`
DefaultCountry string `json:"default_country"`
// FollowUpDays is how long an application waits without news before it is to follow up.
FollowUpDays int `json:"follow_up_days"`
// NoReplyDays is how long a waiting application stays without news (since its last follow-up, status change or
// interview, else the day it applied) before the server moves it to no_reply; 0 never does.
NoReplyDays int `json:"no_reply_days"`
// TrashDays is how long a deleted application can be restored, before it is gone with its history.
TrashDays int `json:"trash_days"`
}
Preferences are the settings of the one account that follow it on every device; the theme stays on each device.
func (Preferences) Validate ¶ added in v0.2.0
func (p Preferences) Validate() error
Validate checks preferences as they will be stored.
type Setting ¶
type Setting struct {
bun.BaseModel `bun:"table:settings,alias:s"`
Key string `bun:",pk"`
Value string `bun:",notnull"`
}
Setting is a value of the one account: its password hash, its preferences.
type Source ¶
type Source string
Source is how the application started: one of the known sources below, or any name the user gives (Facebook, a temp agency...).
type Status ¶
type Status string
Status is where the application stands in the pipeline.
const ( StatusApplied Status = "applied" StatusResponded Status = "responded" StatusInterview Status = "interview" StatusOffer Status = "offer" StatusRejected Status = "rejected" // StatusNoReply is an application nobody answered: the server moves a waiting one there once it waited long enough. StatusNoReply Status = "no_reply" )
type StatusChange ¶ added in v0.2.0
type StatusChange struct {
bun.BaseModel `bun:"table:status_changes,alias:sc" json:"-"`
ID int64 `bun:",pk,autoincrement" json:"-"`
ApplicationID string `bun:",notnull" json:"application_id"`
// Company is read from the application, to tell the changes apart without reading the applications.
Company string `bun:",scanonly" json:"company,omitempty" binding:"optional"`
// From is the status before the change, empty when the application was created with Status.
From Status `bun:",nullzero" json:"from,omitempty" enums:"applied,responded,interview,offer,rejected,no_reply"`
Status Status `bun:",notnull" json:"status" enums:"applied,responded,interview,offer,rejected,no_reply"`
At time.Time `bun:",notnull" json:"at"`
}
StatusChange is an application reaching a status: written with the application and at each change of its status, deleted with it. The funnel and the response delays of the dashboard come from them.
type Token ¶
type Token struct {
bun.BaseModel `bun:"table:tokens,alias:t" json:"-"`
ID string `bun:",pk" json:"id"`
Kind TokenKind `bun:",notnull" json:"kind" enums:"session,api,oauth"`
Name string `bun:",notnull,default:''" json:"name"`
Hash string `bun:",notnull,unique" json:"-"`
ReadOnly bool `bun:",notnull,default:false" json:"read_only"`
CreatedAt time.Time `bun:",notnull" json:"created_at"`
LastUsedAt time.Time `bun:",nullzero" json:"last_used_at,omitzero" binding:"optional"` // never used when absent
ExpiresAt time.Time `bun:",nullzero" json:"expires_at,omitzero" binding:"optional"` // no limit when absent
ClientID string `bun:",nullzero" json:"-"`
RefreshHash string `bun:",nullzero" json:"-"`
AccessExpiresAt time.Time `bun:",nullzero" json:"-"`
}
Token lets a client in. The base keeps the SHA-256 of the token, never the token.
type TokenKind ¶
type TokenKind string
TokenKind tells what a token is for.
const ( // TokenSession is a login of the web app or the CLI: 30 days, started again at each use. TokenSession TokenKind = "session" // TokenAPI is made from the settings for a script or an agent: it never manages the tokens. TokenAPI TokenKind = "api" // TokenOAuth is the connection of an OAuth client (the MCP over HTTP): Hash is its access token, valid until // AccessExpiresAt, RefreshHash its refresh token, valid until ExpiresAt. TokenOAuth TokenKind = "oauth" )