domain

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	MaxShort   = 200
	MaxComment = 10000
)

Limits of the free text, in runes.

View Source
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.

View Source
const (
	MinFollowUpDays = 1
	MaxFollowUpDays = 90
	MaxNoReplyDays  = 365
	MinTrashDays    = 1
	MaxTrashDays    = 365
)

Limits of FollowUpDays.

View Source
const BackupVersion = 1

BackupVersion is the layout of a Backup: a file of another version is refused rather than half read.

View Source
const DateLayout = time.DateOnly

DateLayout is the layout of applied_at and of the date filters.

View Source
const DateTimeLayout = "2006-01-02T15:04"

DateTimeLayout is the layout of interview_at: a local date and time, no zone.

View Source
const InviteLifetime = 7 * 24 * time.Hour

InviteLifetime is how long an invitation waits for its sign-up.

View Source
const MaxBatch = 500

MaxBatch is the most applications one batch creates.

View Source
const MaxIDs = 500

MaxIDs is the most ids one request names.

View Source
const MaxList = 50

MaxList is the most interviews, or contacts, an application has.

View Source
const MaxSource = 60

MaxSource is the most characters of a source's name.

Variables

View Source
var (
	ErrNoCompany        = Invalid("company is required")
	ErrNoLocation       = Invalid("location (the city) is required")
	ErrLong             = Invalid("company, title, location, street, postal_code, 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")
)
View Source
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")
)
View Source
var (
	ErrEmptyBatch = Invalid("the batch is empty")
	ErrLongBatch  = Invalid("at most 500 items per batch")
)
View Source
var (
	ErrInvalid      = errors.New("invalid")
	ErrUnauthorized = errors.New("unauthorized")
	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.

View Source
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")
)
View Source
var (
	ErrLongList          = Invalid("an application has at most 50 interviews and 50 contacts")
	ErrInvalidKind       = Invalid("an interview's kind is hr, manager, tech or other")
	ErrInvalidContactRow = Invalid("a contact has a name or an e-mail; name, email and role have at most 200 characters, a note 10000")
)
View Source
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 has at most 200 characters")
)
View Source
var AddUserModes = []string{"invitation", "public"}

AddUserModes are the ways an account is created in the multi mode, the first one by default: by invitation of an admin only, or by anyone reaching the web app.

View Source
var Columns = []string{"id", "company", "title", "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.

View Source
var Countries = loadCountries()

Countries are the countries of countries.yaml, by code.

View Source
var DefaultPreferences = Preferences{Plan: PlanBase, FollowUpDays: 7, NoReplyDays: 10, TrashDays: 30}

DefaultPreferences are the preferences of an account that never saved any.

View Source
var ErrInvalidBackup = Invalid("not a callback backup of this version")
View Source
var ErrInvalidCountry = Invalid("country is an ISO 3166-1 alpha-2 code (IT) or its English name (Italy): GET /api/countries")

ErrInvalidCountry is a country that is neither a code nor an English name of countries.yaml.

View Source
var Modes = []string{"single", "multi"}

Modes are how many accounts a server holds, the first one by default: one, whose login is the password alone, or several, each logging in with its name, created by sign-up (AddUserModes).

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 CountryCode added in v0.6.0

func CountryCode(value string) string

CountryCode is the code of a country given by its code or English name, whatever the case; "" stays "". A value it does not know is returned as is, for Validate to refuse.

func Forbidden

func Forbidden(message string) error

Forbidden is a credential that cannot do this: 403.

func Invalid

func Invalid(message string) error

Invalid is an error of the input: 400.

func IsCountry added in v0.6.0

func IsCountry(value string) bool

IsCountry tells a stored country: empty or a code.

func IsDate

func IsDate(value string) bool

IsDate tells a date of DateLayout.

func NotFound

func NotFound(message string) error

NotFound is a missing item: 404.

func Unauthorized

func Unauthorized(message string) error

Unauthorized is a missing or wrong credential: 401.

func UserID added in v0.6.0

func UserID(ctx context.Context) string

UserID is the account of ctx, "" without one. A bun.Tx hands its RunInTx functions the ctx it began with, not the one given: begin transactions with a ctx that has the account.

func WithUser added in v0.6.0

func WithUser(ctx context.Context, userID string) context.Context

WithUser gives ctx the account the processes act for: the API from the request's token, serve's jobs from each account.

Types

type Application

type Application struct {
	bun.BaseModel `bun:"table:applications,alias:a" json:"-"`

	ID string `bun:",pk" json:"id"`
	// UserID is the account it belongs to. Its default only serves the ALTER TABLE of an older base: every insert of a
	// batch sets the same account, so bun never leaves it out.
	UserID  string `bun:",notnull,default:''" json:"-"`
	Company string `bun:",notnull" json:"company,omitempty" binding:"optional"`
	// Title is the job title of the post.
	Title string `bun:",nullzero" json:"title,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"`
	// Interviews and Contacts are read with the application when no fields are asked, or when fields name them.
	Interviews []Interview `bun:"rel:has-many,join:id=application_id" json:"interviews,omitempty" binding:"optional"`
	Contacts   []Contact   `bun:"rel:has-many,join:id=application_id" json:"contacts,omitempty" 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) KeepCountry added in v0.6.0

func (a *Application) KeepCountry() bool

KeepCountry stores a's country as its code, or moves a country it does not know (free text from a base or a backup older than Countries) to the start of the comment rather than lose it. It tells whether it changed a.

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"`
	// Title is cleared by "".
	Title        *string `json:"title,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"`
	// Interviews and Contacts replace the lists whole. Without them, interview_at sets the last interview's date
	// ("" removes it), contact_name and contact_email the first contact's (both "" remove it).
	Interviews   *[]Interview `json:"interviews,omitempty" binding:"optional"`
	Contacts     *[]Contact   `json:"contacts,omitempty" binding:"optional"`
	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.

func (Changes) Apply

func (c Changes) Apply(a *Application)

Apply writes the changes into a.

func (Changes) ChangesLists added in v0.8.0

func (c Changes) ChangesLists() bool

ChangesLists tells changes that rewrite the interviews or the contacts.

func (Changes) Empty

func (c Changes) Empty() bool

Empty tells changes that set nothing.

type Contact added in v0.8.0

type Contact struct {
	bun.BaseModel `bun:"table:contacts,alias:ct" json:"-"`

	ID            int64  `bun:",pk,autoincrement" json:"-"`
	ApplicationID string `bun:",notnull" json:"-"`
	Name          string `bun:",nullzero" json:"name,omitempty" binding:"optional"`
	Email         string `bun:",nullzero" json:"email,omitempty" binding:"optional"`
	Role          string `bun:",nullzero" json:"role,omitempty" binding:"optional"`
}

Contact is one person of an application, deleted with it. The application keeps the first one in contact_name and contact_email.

type Country added in v0.6.0

type Country struct {
	Code string `yaml:"code" json:"code" example:"IT"`
	Name string `yaml:"name" json:"name" example:"Italy"`
	Key  string `yaml:"key" json:"key" example:"countries.IT"`
}

Country is a country an application can name: Code is stored, Key is the web app's i18n key of its name.

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"`
	UserID string `bun:",notnull,default:''" json:"-"` // apart: Application leaves it out of its JSON
	// 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

func (f Filter) Empty() bool

Empty tells a filter that matches every application. A blank q adds no condition (appfilter trims it): empty too.

func (Filter) UntouchedTime

func (f Filter) UntouchedTime() time.Time

UntouchedTime is the start of the UntouchedSince day, in UTC.

func (Filter) Validate

func (f Filter) Validate() error

Validate checks the values of the filter.

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 Interview added in v0.8.0

type Interview struct {
	bun.BaseModel `bun:"table:interviews,alias:iv" json:"-"`

	ID            int64         `bun:",pk,autoincrement" json:"-"`
	ApplicationID string        `bun:",notnull" json:"-"`
	At            string        `bun:",notnull" json:"at" example:"2026-01-31T14:30"`
	Kind          InterviewKind `bun:",notnull" json:"kind,omitempty" binding:"optional" enums:"hr,manager,tech,other"`
	Note          string        `bun:",nullzero" json:"note,omitempty" binding:"optional"`
}

Interview is one interview of an application, deleted with it. The application keeps the last one in interview_at.

type InterviewKind added in v0.8.0

type InterviewKind string

InterviewKind is who the interview is with.

const (
	InterviewHR      InterviewKind = "hr"
	InterviewManager InterviewKind = "manager"
	InterviewTech    InterviewKind = "tech"
	InterviewOther   InterviewKind = "other"
)

type Invite added in v0.6.0

type Invite struct {
	bun.BaseModel `bun:"table:invites,alias:iv" json:"-"`

	ID        string `bun:",pk" json:"id"`
	TokenHash string `bun:",notnull,unique" json:"-"`
	// Token is sealed by CALLBACK_SECRET in the base, in clear in the API, so the link shows again; "" without the
	// secret, or for the invitations made before it was kept: their link was shown once.
	Token     string    `bun:",notnull,default:''" json:"token"`
	UserID    string    `bun:",notnull" json:"created_by"` // the admin who made it
	CreatedAt time.Time `bun:",notnull" json:"created_at"`
	ExpiresAt time.Time `bun:",notnull" json:"expires_at"`
	UsedAt    time.Time `bun:",nullzero" json:"-"` // set when it created an account
}

Invite lets someone create an account in the invitation mode, once, for InviteLifetime: the base keeps the hash of its token, which goes to the admin who made it only.

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"`
	Title        string `json:"title,omitempty" binding:"optional"`
	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"`
	// Interviews and Contacts are the lists; without them interview_at and the contact make one of each.
	Interviews []Interview `json:"interviews,omitempty" binding:"optional"`
	Contacts   []Contact   `json:"contacts,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"`
	UserID        string    `bun:",notnull,default:''"`
	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 (a code of Countries) 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 an 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 ServerMode added in v0.6.0

type ServerMode struct {
	Mode        string `json:"mode" enums:"single,multi"`
	AddUserMode string `json:"add_user_mode" enums:"invitation,public"`
}

ServerMode is how the server runs, which the login and sign-up pages read: one of Modes, one of AddUserModes.

func (ServerMode) Multi added in v0.6.0

func (m ServerMode) Multi() bool

Multi tells whether the server holds several accounts.

func (ServerMode) Public added in v0.6.0

func (m ServerMode) Public() bool

Public tells whether anyone may create an account.

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...).

const (
	SourceSpontaneous Source = "spontaneous"
	SourceJobPost     Source = "job_post"
	SourceRecruiter   Source = "recruiter"
)

The known sources, whose source_detail is checked: a job post's URL, a recruiter's e-mail, nothing when spontaneous.

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"
)

func (Status) Answered added in v0.5.0

func (s Status) Answered() bool

Answered tells that the employer replied: any status but applied, and 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"`
	UserID     string    `bun:",notnull,default:''" json:"-"`
	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"
)

type User added in v0.6.0

type User struct {
	bun.BaseModel `bun:"table:users,alias:u" json:"-"`

	ID           string `bun:",pk" json:"id"`
	Name         string `bun:",notnull" json:"name"` // unique case-insensitive, see createschema
	PasswordHash string `bun:",notnull" json:"-"`
	Admin        bool   `bun:",notnull,default:false" json:"admin"`
	// Preferences are stored as JSON: readpreferences reads them over DefaultPreferences, so a preference added since
	// keeps its default. A pointer, so an insert without them writes the default {}, not zeros.
	Preferences *Preferences `bun:"type:json,nullzero,notnull,default:'{}'" json:"preferences,omitempty" binding:"optional"`
	CreatedAt   time.Time    `bun:",notnull" json:"created_at"`
}

User is an account: every application, token and OAuth code belongs to one.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL