businesscalendar

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 10 Imported by: 3

README

business_calendar

The institutional calendar for the Velty ecosystem: when the establishment is open, and when it is closed regardless of any professional's schedule.

It owns three things:

  1. Business hours — the weekly opening window, one row per day of week.
  2. Holidays — dated closures with a legal/administrative origin, editable at runtime (a new holiday appears by law; nobody recompiles).
  3. Closures — dated closures with a local origin (maintenance, an event).

It does not own any professional's agenda. appointment_booking owns that and consumes this module through the read-only Reader bound.

Replaces the archived github.com/veltylabs/business_hours, whose clock-time ("HH:MM") text encoding is fixed here to minutes from midnight — the same encoding appointment_booking uses for work blocks — and whose hardcoded Spanish day names are gone (translation lives in the consuming app).

Quick start

cal, err := businesscalendar.New(db, businesscalendar.Deps{
    IDs: idGenerator, // model.IDGenerator — required
    Publisher: broker, // events.Publisher — optional; nil disables publishing
})
if err != nil { /* ... */ }

cal.MountOperations(opRegistry) // router.OpRegistry

reader := businesscalendar.Reader(cal) // the port a neighbour module consumes
bounds, err := reader.GetDayBounds(dateMidnightUTC)

New migrates the module's own schema (business_hours, holiday, closure) when the injected backend exposes the ddl.Compiler capability; against storage/mem (the module's own tests) it is a no-op.

Ops

Op Resource Action Args
list_business_hours business_hours read —
upsert_business_hours business_hours create | update day_of_week, open_min, close_min, is_open, notes
get_day_bounds business_hours read date (midnight UTC, seconds)
list_holidays holiday read —
add_holiday holiday create specific_date, name, notes
remove_holiday holiday delete id
list_closures closure read —
add_closure closure create specific_date, reason
remove_closure closure delete id

Times are minutes from midnight (0..1439); get_day_bounds answers "is the establishment open this date, and between which minutes".

The Reader port

interfaces.go declares the read-only port a neighbour depends on:

type Reader interface {
    GetDayBounds(date int64) (DayBounds, error)
}

*Module satisfies it structurally. DayBounds carries Open, OpenMin, CloseMin, and ClosedBy — a ClosedReason naming the origin (WEEKLY | HOLIDAY | CLOSURE). Resolution precedence: Closure > Holiday > weekly rule.

Events

Every successful write publishes EventCalendarChanged (business.calendar.changed) with a typed CalendarChangedPayload saying what changed, its affected date range, and Closed — the direction. Closed is true only when the change closes time (a holiday added, hours narrowed), which is the only direction that can invalidate an existing reservation.

Translation keys

This module renders no hardcoded human language. It introduces these English canonical keys, translated by the consuming app via webtyp.com/fmt/lang: Business hours, Holidays, Closures, Open, Closed, plus the seven weekday names from webtyp.com/date (date.WeekdayName).

Key files

File Role
model.go Definitions (records + transport args), errors, event topic/payload
model_orm.go Generated by ormc — do not edit
module.go Module, Deps, New, service methods, event publishing
interfaces.go The Reader port + GetDayBounds precedence
ops.go Op constants, MountOperations, handlers
view.go Three presenters (NewBusinessHoursView, NewHolidaysView, NewClosuresView)
tests/ Use-case tests, ops tests, conformance (over storage/mem + router/mock/loopback)

Documentation


This module is part of the Velty Labs modules collection.

Documentation

Index

Constants

View Source
const (
	CalendarKindBusinessHours = "BUSINESS_HOURS"
	CalendarKindHoliday       = "HOLIDAY"
	CalendarKindClosure       = "CLOSURE"
)

Payload kinds — the ONLY place these literals live. CalendarChangedPayload.Kind carries one of them.

View Source
const (
	OpListBusinessHours   = "list_business_hours"
	OpUpsertBusinessHours = "upsert_business_hours"
	OpListHolidays        = "list_holidays"
	OpAddHoliday          = "add_holiday"
	OpRemoveHoliday       = "remove_holiday"
	OpListClosures        = "list_closures"
	OpAddClosure          = "add_closure"
	OpRemoveClosure       = "remove_closure"
	OpGetDayBounds        = "get_day_bounds"
)
View Source
const EventCalendarChanged = "business.calendar.changed"

EventCalendarChanged fires on every write. appointment_booking subscribes so a professional's editor reflects widened hours without a recompile (CU-03), a new holiday closes the day for everyone (CU-04), and reservations already booked on a day that just became closed are recomputed into conflict.

Variables

View Source
var (
	ErrNotFound       = fmt.Err("business_calendar: record not found")
	ErrInvalidDay     = fmt.Err("business_calendar: day_of_week must be 0..6")
	ErrInvalidMinutes = fmt.Err("business_calendar: minutes must be 0..1439 and open_min < close_min")
	ErrDuplicateDate  = fmt.Err("business_calendar: a record already exists for that date")
)
View Source
var AddClosureArgsModel = model.Definition{
	Name: "add_closure_args",
	Fields: model.Fields{
		{Name: "specific_date", Type: model.Int()},
		{Name: "reason", Type: model.Text(), NotNull: true},
	},
}
View Source
var AddHolidayArgsModel = model.Definition{
	Name: "add_holiday_args",
	Fields: model.Fields{
		{Name: "specific_date", Type: model.Int()},
		{Name: "name", Type: model.Text(), NotNull: true},
		{Name: "notes", Type: model.Text()},
	},
}
View Source
var BusinessHoursModel = model.Definition{
	Name: "business_hours",
	Fields: model.Fields{
		{Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}},
		{Name: "day_of_week", Type: model.Int(), NotNull: true, DB: &model.FieldDB{Unique: true}},
		{Name: "open_min", Type: model.Int(), NotNull: true},
		{Name: "close_min", Type: model.Int(), NotNull: true},
		{Name: "is_open", Type: model.Bool(), NotNull: true},
		{Name: "notes", Type: model.Text()},
		{Name: "updated_at", Type: model.Int(), NotNull: true},
	},
}

BusinessHoursModel: one row per day of week. day_of_week is unique — this module never writes more than seven rows.

Times are MINUTES FROM MIDNIGHT (0..1439), the same encoding appointment_booking uses for work blocks. The archived business_hours module stored clock-time text and forced a conversion at the one boundary that has to compare the two; the encoding is fixed here instead.

View Source
var BusinessHours_ = struct {
	Id        string
	DayOfWeek string
	OpenMin   string
	CloseMin  string
	IsOpen    string
	Notes     string
	UpdatedAt string
}{
	Id:        "id",
	DayOfWeek: "day_of_week",
	OpenMin:   "open_min",
	CloseMin:  "close_min",
	IsOpen:    "is_open",
	Notes:     "notes",
	UpdatedAt: "updated_at",
}
View Source
var ClosureModel = model.Definition{
	Name: "closure",
	Fields: model.Fields{
		{Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}},
		{Name: "specific_date", Type: model.Int(), NotNull: true},
		{Name: "reason", Type: model.Text(), NotNull: true},
		{Name: "updated_at", Type: model.Int(), NotNull: true},
	},
}

ClosureModel: a dated closure the establishment itself decided (maintenance, an event). Separate from Holiday because the ORIGIN is what the UI shows and what an administrator filters by — collapsing both into one table with a "type" column would make the origin a magic string.

View Source
var Closure_ = struct {
	Id           string
	SpecificDate string
	Reason       string
	UpdatedAt    string
}{
	Id:           "id",
	SpecificDate: "specific_date",
	Reason:       "reason",
	UpdatedAt:    "updated_at",
}
View Source
var GetDayBoundsArgsModel = model.Definition{
	Name: "get_day_bounds_args",
	Fields: model.Fields{
		{Name: "date", Type: model.Int()},
	},
}
View Source
var HolidayModel = model.Definition{
	Name: "holiday",
	Fields: model.Fields{
		{Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}},
		{Name: "specific_date", Type: model.Int(), NotNull: true},
		{Name: "name", Type: model.Text(), NotNull: true},
		{Name: "notes", Type: model.Text()},
		{Name: "updated_at", Type: model.Int(), NotNull: true},
	},
}

HolidayModel: a dated closure with a legal/administrative origin. Editable at runtime — a holiday that appears by law must never require a recompile.

View Source
var Holiday_ = struct {
	Id           string
	SpecificDate string
	Name         string
	Notes        string
	UpdatedAt    string
}{
	Id:           "id",
	SpecificDate: "specific_date",
	Name:         "name",
	Notes:        "notes",
	UpdatedAt:    "updated_at",
}
View Source
var ListClosuresArgsModel = model.Definition{
	Name: "list_closures_args",
	Fields: model.Fields{
		{Name: "from", Type: model.Int()},
		{Name: "to", Type: model.Int()},
	},
}
View Source
var ListHolidaysArgsModel = model.Definition{
	Name: "list_holidays_args",
	Fields: model.Fields{
		{Name: "from", Type: model.Int()},
		{Name: "to", Type: model.Int()},
	},
}
View Source
var RemoveClosureArgsModel = model.Definition{
	Name: "remove_closure_args",
	Fields: model.Fields{
		{Name: "id", Type: model.Text(), NotNull: true},
	},
}
View Source
var RemoveHolidayArgsModel = model.Definition{
	Name: "remove_holiday_args",
	Fields: model.Fields{
		{Name: "id", Type: model.Text(), NotNull: true},
	},
}
View Source
var UpsertBusinessHoursArgsModel = model.Definition{
	Name: "upsert_business_hours_args",
	Fields: model.Fields{
		{Name: "day_of_week", Type: model.Int()},
		{Name: "open_min", Type: model.Int()},
		{Name: "close_min", Type: model.Int()},
		{Name: "is_open", Type: model.Bool()},
		{Name: "notes", Type: model.Text()},
	},
}

Transport-only Args Definitions.

Constraints follow the harness's NotNull semantics: on a base int/bool kind, NotNull rejects the ZERO value (ValidateFields: NotNull && IsZeroPtr), so day_of_week 0 (Sunday), is_open false, or midnight (0 minutes) would be unrepresentable if NotNull were set here. Required ints are therefore enforced as DOMAIN rules in the service (ErrInvalidDay/ErrInvalidMinutes), the single fail-closed chokepoint every write path crosses; NotNull stays only on the text fields where empty is never legal.

Functions

func NewBusinessHoursView added in v0.0.2

func NewBusinessHoursView(caller router.Caller) view.Presenter

NewBusinessHoursView builds the weekly-hours Presenter — read + save (upsert). The app decides which renderer draws it.

func NewClosuresView added in v0.0.2

func NewClosuresView(caller router.Caller) view.Presenter

NewClosuresView builds the closures Presenter — full CRUD (list, add, remove).

func NewHolidaysView added in v0.0.2

func NewHolidaysView(caller router.Caller) view.Presenter

NewHolidaysView builds the holidays Presenter — full CRUD (list, add, remove).

Types

type AddClosureArgs added in v0.0.2

type AddClosureArgs struct {
	SpecificDate int64
	Reason       string
}

func (*AddClosureArgs) DecodeFields added in v0.0.2

func (m *AddClosureArgs) DecodeFields(r model.FieldReader)

func (*AddClosureArgs) EncodeFields added in v0.0.2

func (m *AddClosureArgs) EncodeFields(w model.FieldWriter)

func (*AddClosureArgs) IsNil added in v0.0.2

func (m *AddClosureArgs) IsNil() bool

func (*AddClosureArgs) ModelName added in v0.0.2

func (m *AddClosureArgs) ModelName() string

func (*AddClosureArgs) Pointers added in v0.0.2

func (m *AddClosureArgs) Pointers() []any

func (*AddClosureArgs) Schema added in v0.0.2

func (m *AddClosureArgs) Schema() []model.Field

func (*AddClosureArgs) Validate added in v0.0.2

func (m *AddClosureArgs) Validate(action byte) error

type AddClosureArgsList added in v0.0.2

type AddClosureArgsList []*AddClosureArgs

func (*AddClosureArgsList) Append added in v0.0.2

func (s *AddClosureArgsList) Append() model.Fielder

func (*AddClosureArgsList) At added in v0.0.2

func (*AddClosureArgsList) DecodeFields added in v0.0.2

func (s *AddClosureArgsList) DecodeFields(_ model.FieldReader)

func (*AddClosureArgsList) EncodeFields added in v0.0.2

func (s *AddClosureArgsList) EncodeFields(_ model.FieldWriter)

func (*AddClosureArgsList) IsNil added in v0.0.2

func (s *AddClosureArgsList) IsNil() bool

func (*AddClosureArgsList) Len added in v0.0.2

func (s *AddClosureArgsList) Len() int

func (*AddClosureArgsList) Pointers added in v0.0.2

func (s *AddClosureArgsList) Pointers() []any

func (*AddClosureArgsList) Schema added in v0.0.2

func (s *AddClosureArgsList) Schema() []model.Field

type AddHolidayArgs added in v0.0.2

type AddHolidayArgs struct {
	SpecificDate int64
	Name         string
	Notes        string
}

func (*AddHolidayArgs) DecodeFields added in v0.0.2

func (m *AddHolidayArgs) DecodeFields(r model.FieldReader)

func (*AddHolidayArgs) EncodeFields added in v0.0.2

func (m *AddHolidayArgs) EncodeFields(w model.FieldWriter)

func (*AddHolidayArgs) IsNil added in v0.0.2

func (m *AddHolidayArgs) IsNil() bool

func (*AddHolidayArgs) ModelName added in v0.0.2

func (m *AddHolidayArgs) ModelName() string

func (*AddHolidayArgs) Pointers added in v0.0.2

func (m *AddHolidayArgs) Pointers() []any

func (*AddHolidayArgs) Schema added in v0.0.2

func (m *AddHolidayArgs) Schema() []model.Field

func (*AddHolidayArgs) Validate added in v0.0.2

func (m *AddHolidayArgs) Validate(action byte) error

type AddHolidayArgsList added in v0.0.2

type AddHolidayArgsList []*AddHolidayArgs

func (*AddHolidayArgsList) Append added in v0.0.2

func (s *AddHolidayArgsList) Append() model.Fielder

func (*AddHolidayArgsList) At added in v0.0.2

func (*AddHolidayArgsList) DecodeFields added in v0.0.2

func (s *AddHolidayArgsList) DecodeFields(_ model.FieldReader)

func (*AddHolidayArgsList) EncodeFields added in v0.0.2

func (s *AddHolidayArgsList) EncodeFields(_ model.FieldWriter)

func (*AddHolidayArgsList) IsNil added in v0.0.2

func (s *AddHolidayArgsList) IsNil() bool

func (*AddHolidayArgsList) Len added in v0.0.2

func (s *AddHolidayArgsList) Len() int

func (*AddHolidayArgsList) Pointers added in v0.0.2

func (s *AddHolidayArgsList) Pointers() []any

func (*AddHolidayArgsList) Schema added in v0.0.2

func (s *AddHolidayArgsList) Schema() []model.Field

type BusinessHours added in v0.0.2

type BusinessHours struct {
	Id        string
	DayOfWeek int64
	OpenMin   int64
	CloseMin  int64
	IsOpen    bool
	Notes     string
	UpdatedAt int64
}

func ReadOneBusinessHours added in v0.0.2

func ReadOneBusinessHours(qb *orm.QB, model *BusinessHours) (*BusinessHours, error)

func (*BusinessHours) DecodeFields added in v0.0.2

func (m *BusinessHours) DecodeFields(r model.FieldReader)

func (*BusinessHours) EncodeFields added in v0.0.2

func (m *BusinessHours) EncodeFields(w model.FieldWriter)

func (*BusinessHours) IsNil added in v0.0.2

func (m *BusinessHours) IsNil() bool

func (*BusinessHours) Item added in v0.0.2

func (r *BusinessHours) Item() view.Item

Item projects a BusinessHours row as a view.Item (view.Itemizer). The weekday label is rendered from the canonical English name (date.WeekdayName) through lang.Translate — this module hardcodes no human language; the consuming app registers the dictionary.

func (*BusinessHours) ModelName added in v0.0.2

func (m *BusinessHours) ModelName() string

func (*BusinessHours) Pointers added in v0.0.2

func (m *BusinessHours) Pointers() []any

func (*BusinessHours) Schema added in v0.0.2

func (m *BusinessHours) Schema() []model.Field

func (*BusinessHours) Validate added in v0.0.2

func (m *BusinessHours) Validate(action byte) error

type BusinessHoursList added in v0.0.2

type BusinessHoursList []*BusinessHours

func ReadAllBusinessHours added in v0.0.2

func ReadAllBusinessHours(qb *orm.QB) (BusinessHoursList, error)

func (*BusinessHoursList) Append added in v0.0.2

func (s *BusinessHoursList) Append() model.Fielder

func (*BusinessHoursList) At added in v0.0.2

func (*BusinessHoursList) DecodeFields added in v0.0.2

func (s *BusinessHoursList) DecodeFields(_ model.FieldReader)

func (*BusinessHoursList) EncodeFields added in v0.0.2

func (s *BusinessHoursList) EncodeFields(_ model.FieldWriter)

func (*BusinessHoursList) IsNil added in v0.0.2

func (s *BusinessHoursList) IsNil() bool

func (*BusinessHoursList) Len added in v0.0.2

func (s *BusinessHoursList) Len() int

func (*BusinessHoursList) Pointers added in v0.0.2

func (s *BusinessHoursList) Pointers() []any

func (*BusinessHoursList) Schema added in v0.0.2

func (s *BusinessHoursList) Schema() []model.Field

type CalendarChangedPayload added in v0.0.2

type CalendarChangedPayload struct {
	// FromDate/ToDate bound the affected dates (midnight UTC seconds).
	// For a holiday or closure both equal that single date. For a business
	// hours change they are 0/0 — a weekly rule has no bounded range, and the
	// subscriber must recompute its whole horizon.
	FromDate int64
	ToDate   int64
	// Kind names what moved, so a subscriber can skip work it does not care
	// about. One of CalendarKindBusinessHours | CalendarKindHoliday |
	// CalendarKindClosure.
	Kind string
	// Closed reports the direction. true when the change CLOSES time (a
	// holiday added, hours narrowed) — the only direction that can invalidate
	// an existing reservation. false when it opens time, which never does.
	Closed bool
}

CalendarChangedPayload says WHAT changed, not merely that something did. A subscriber that only learns "the calendar changed" has to recompute every reservation of every professional; with the range it recomputes a window.

Implements model.Encodable, which events.Event.Payload requires.

func (*CalendarChangedPayload) DecodeFields added in v0.0.2

func (p *CalendarChangedPayload) DecodeFields(r model.FieldReader)

func (*CalendarChangedPayload) EncodeFields added in v0.0.2

func (p *CalendarChangedPayload) EncodeFields(w model.FieldWriter)

func (*CalendarChangedPayload) IsNil added in v0.0.2

func (p *CalendarChangedPayload) IsNil() bool

type ClosedReason added in v0.0.2

type ClosedReason string

ClosedReason names the origin of a closure. The string literals live ONLY in these constants — never inline at a call site.

const (
	ClosedWeekly  ClosedReason = "WEEKLY"  // business_hours says closed that weekday
	ClosedHoliday ClosedReason = "HOLIDAY" // a Holiday row falls on that date
	ClosedLocal   ClosedReason = "CLOSURE" // a Closure row falls on that date
)

type Closure added in v0.0.2

type Closure struct {
	Id           string
	SpecificDate int64
	Reason       string
	UpdatedAt    int64
}

func ReadOneClosure added in v0.0.2

func ReadOneClosure(qb *orm.QB, model *Closure) (*Closure, error)

func (*Closure) DecodeFields added in v0.0.2

func (m *Closure) DecodeFields(r model.FieldReader)

func (*Closure) EncodeFields added in v0.0.2

func (m *Closure) EncodeFields(w model.FieldWriter)

func (*Closure) IsNil added in v0.0.2

func (m *Closure) IsNil() bool

func (*Closure) Item added in v0.0.2

func (c *Closure) Item() view.Item

Item projects a Closure as a view.Item.

func (*Closure) ModelName added in v0.0.2

func (m *Closure) ModelName() string

func (*Closure) Pointers added in v0.0.2

func (m *Closure) Pointers() []any

func (*Closure) Schema added in v0.0.2

func (m *Closure) Schema() []model.Field

func (*Closure) Validate added in v0.0.2

func (m *Closure) Validate(action byte) error

type ClosureList added in v0.0.2

type ClosureList []*Closure

func ReadAllClosure added in v0.0.2

func ReadAllClosure(qb *orm.QB) (ClosureList, error)

func (*ClosureList) Append added in v0.0.2

func (s *ClosureList) Append() model.Fielder

func (*ClosureList) At added in v0.0.2

func (s *ClosureList) At(i int) model.Fielder

func (*ClosureList) DecodeFields added in v0.0.2

func (s *ClosureList) DecodeFields(_ model.FieldReader)

func (*ClosureList) EncodeFields added in v0.0.2

func (s *ClosureList) EncodeFields(_ model.FieldWriter)

func (*ClosureList) IsNil added in v0.0.2

func (s *ClosureList) IsNil() bool

func (*ClosureList) Len added in v0.0.2

func (s *ClosureList) Len() int

func (*ClosureList) Pointers added in v0.0.2

func (s *ClosureList) Pointers() []any

func (*ClosureList) Schema added in v0.0.2

func (s *ClosureList) Schema() []model.Field

type DayDetail added in v0.0.4

type DayDetail struct {
	Bounds tinytime.DayBounds
	// ClosedBy names why the day is closed. "" when Bounds.Open is true.
	ClosedBy ClosedReason
}

DayDetail is this module's own answer for one date: the neutral bounds PLUS why a closed day is closed. ClosedBy is this module's vocabulary and never crosses to a neighbour — see Reader below.

It is an output-only result model: it implements model.Encodable so the get_day_bounds op can respond with it, and it is never a DB table.

func (*DayDetail) EncodeFields added in v0.0.4

func (d *DayDetail) EncodeFields(w model.FieldWriter)

func (*DayDetail) IsNil added in v0.0.4

func (d *DayDetail) IsNil() bool

type Deps added in v0.0.2

type Deps struct {
	IDs       model.IDGenerator
	Publisher events.Publisher
}

Deps carries the injected collaborators a module may never construct itself. IDs is required; Publisher is optional — nil disables event publishing silently (no-op).

type GetDayBoundsArgs added in v0.0.2

type GetDayBoundsArgs struct {
	Date int64
}

func (*GetDayBoundsArgs) DecodeFields added in v0.0.2

func (m *GetDayBoundsArgs) DecodeFields(r model.FieldReader)

func (*GetDayBoundsArgs) EncodeFields added in v0.0.2

func (m *GetDayBoundsArgs) EncodeFields(w model.FieldWriter)

func (*GetDayBoundsArgs) IsNil added in v0.0.2

func (m *GetDayBoundsArgs) IsNil() bool

func (*GetDayBoundsArgs) ModelName added in v0.0.2

func (m *GetDayBoundsArgs) ModelName() string

func (*GetDayBoundsArgs) Pointers added in v0.0.2

func (m *GetDayBoundsArgs) Pointers() []any

func (*GetDayBoundsArgs) Schema added in v0.0.2

func (m *GetDayBoundsArgs) Schema() []model.Field

func (*GetDayBoundsArgs) Validate added in v0.0.2

func (m *GetDayBoundsArgs) Validate(action byte) error

type GetDayBoundsArgsList added in v0.0.2

type GetDayBoundsArgsList []*GetDayBoundsArgs

func (*GetDayBoundsArgsList) Append added in v0.0.2

func (s *GetDayBoundsArgsList) Append() model.Fielder

func (*GetDayBoundsArgsList) At added in v0.0.2

func (*GetDayBoundsArgsList) DecodeFields added in v0.0.2

func (s *GetDayBoundsArgsList) DecodeFields(_ model.FieldReader)

func (*GetDayBoundsArgsList) EncodeFields added in v0.0.2

func (s *GetDayBoundsArgsList) EncodeFields(_ model.FieldWriter)

func (*GetDayBoundsArgsList) IsNil added in v0.0.2

func (s *GetDayBoundsArgsList) IsNil() bool

func (*GetDayBoundsArgsList) Len added in v0.0.2

func (s *GetDayBoundsArgsList) Len() int

func (*GetDayBoundsArgsList) Pointers added in v0.0.2

func (s *GetDayBoundsArgsList) Pointers() []any

func (*GetDayBoundsArgsList) Schema added in v0.0.2

func (s *GetDayBoundsArgsList) Schema() []model.Field

type Holiday added in v0.0.2

type Holiday struct {
	Id           string
	SpecificDate int64
	Name         string
	Notes        string
	UpdatedAt    int64
}

func ReadOneHoliday added in v0.0.2

func ReadOneHoliday(qb *orm.QB, model *Holiday) (*Holiday, error)

func (*Holiday) DecodeFields added in v0.0.2

func (m *Holiday) DecodeFields(r model.FieldReader)

func (*Holiday) EncodeFields added in v0.0.2

func (m *Holiday) EncodeFields(w model.FieldWriter)

func (*Holiday) IsNil added in v0.0.2

func (m *Holiday) IsNil() bool

func (*Holiday) Item added in v0.0.2

func (h *Holiday) Item() view.Item

Item projects a Holiday as a view.Item.

func (*Holiday) ModelName added in v0.0.2

func (m *Holiday) ModelName() string

func (*Holiday) Pointers added in v0.0.2

func (m *Holiday) Pointers() []any

func (*Holiday) Schema added in v0.0.2

func (m *Holiday) Schema() []model.Field

func (*Holiday) Validate added in v0.0.2

func (m *Holiday) Validate(action byte) error

type HolidayList added in v0.0.2

type HolidayList []*Holiday

func ReadAllHoliday added in v0.0.2

func ReadAllHoliday(qb *orm.QB) (HolidayList, error)

func (*HolidayList) Append added in v0.0.2

func (s *HolidayList) Append() model.Fielder

func (*HolidayList) At added in v0.0.2

func (s *HolidayList) At(i int) model.Fielder

func (*HolidayList) DecodeFields added in v0.0.2

func (s *HolidayList) DecodeFields(_ model.FieldReader)

func (*HolidayList) EncodeFields added in v0.0.2

func (s *HolidayList) EncodeFields(_ model.FieldWriter)

func (*HolidayList) IsNil added in v0.0.2

func (s *HolidayList) IsNil() bool

func (*HolidayList) Len added in v0.0.2

func (s *HolidayList) Len() int

func (*HolidayList) Pointers added in v0.0.2

func (s *HolidayList) Pointers() []any

func (*HolidayList) Schema added in v0.0.2

func (s *HolidayList) Schema() []model.Field

type ListClosuresArgs added in v0.0.2

type ListClosuresArgs struct {
	From int64
	To   int64
}

func (*ListClosuresArgs) DecodeFields added in v0.0.2

func (m *ListClosuresArgs) DecodeFields(r model.FieldReader)

func (*ListClosuresArgs) EncodeFields added in v0.0.2

func (m *ListClosuresArgs) EncodeFields(w model.FieldWriter)

func (*ListClosuresArgs) IsNil added in v0.0.2

func (m *ListClosuresArgs) IsNil() bool

func (*ListClosuresArgs) ModelName added in v0.0.2

func (m *ListClosuresArgs) ModelName() string

func (*ListClosuresArgs) Pointers added in v0.0.2

func (m *ListClosuresArgs) Pointers() []any

func (*ListClosuresArgs) Schema added in v0.0.2

func (m *ListClosuresArgs) Schema() []model.Field

func (*ListClosuresArgs) Validate added in v0.0.2

func (m *ListClosuresArgs) Validate(action byte) error

type ListClosuresArgsList added in v0.0.2

type ListClosuresArgsList []*ListClosuresArgs

func (*ListClosuresArgsList) Append added in v0.0.2

func (s *ListClosuresArgsList) Append() model.Fielder

func (*ListClosuresArgsList) At added in v0.0.2

func (*ListClosuresArgsList) DecodeFields added in v0.0.2

func (s *ListClosuresArgsList) DecodeFields(_ model.FieldReader)

func (*ListClosuresArgsList) EncodeFields added in v0.0.2

func (s *ListClosuresArgsList) EncodeFields(_ model.FieldWriter)

func (*ListClosuresArgsList) IsNil added in v0.0.2

func (s *ListClosuresArgsList) IsNil() bool

func (*ListClosuresArgsList) Len added in v0.0.2

func (s *ListClosuresArgsList) Len() int

func (*ListClosuresArgsList) Pointers added in v0.0.2

func (s *ListClosuresArgsList) Pointers() []any

func (*ListClosuresArgsList) Schema added in v0.0.2

func (s *ListClosuresArgsList) Schema() []model.Field

type ListHolidaysArgs added in v0.0.2

type ListHolidaysArgs struct {
	From int64
	To   int64
}

func (*ListHolidaysArgs) DecodeFields added in v0.0.2

func (m *ListHolidaysArgs) DecodeFields(r model.FieldReader)

func (*ListHolidaysArgs) EncodeFields added in v0.0.2

func (m *ListHolidaysArgs) EncodeFields(w model.FieldWriter)

func (*ListHolidaysArgs) IsNil added in v0.0.2

func (m *ListHolidaysArgs) IsNil() bool

func (*ListHolidaysArgs) ModelName added in v0.0.2

func (m *ListHolidaysArgs) ModelName() string

func (*ListHolidaysArgs) Pointers added in v0.0.2

func (m *ListHolidaysArgs) Pointers() []any

func (*ListHolidaysArgs) Schema added in v0.0.2

func (m *ListHolidaysArgs) Schema() []model.Field

func (*ListHolidaysArgs) Validate added in v0.0.2

func (m *ListHolidaysArgs) Validate(action byte) error

type ListHolidaysArgsList added in v0.0.2

type ListHolidaysArgsList []*ListHolidaysArgs

func (*ListHolidaysArgsList) Append added in v0.0.2

func (s *ListHolidaysArgsList) Append() model.Fielder

func (*ListHolidaysArgsList) At added in v0.0.2

func (*ListHolidaysArgsList) DecodeFields added in v0.0.2

func (s *ListHolidaysArgsList) DecodeFields(_ model.FieldReader)

func (*ListHolidaysArgsList) EncodeFields added in v0.0.2

func (s *ListHolidaysArgsList) EncodeFields(_ model.FieldWriter)

func (*ListHolidaysArgsList) IsNil added in v0.0.2

func (s *ListHolidaysArgsList) IsNil() bool

func (*ListHolidaysArgsList) Len added in v0.0.2

func (s *ListHolidaysArgsList) Len() int

func (*ListHolidaysArgsList) Pointers added in v0.0.2

func (s *ListHolidaysArgsList) Pointers() []any

func (*ListHolidaysArgsList) Schema added in v0.0.2

func (s *ListHolidaysArgsList) Schema() []model.Field

type Module added in v0.0.2

type Module struct {
	// contains filtered or unexported fields
}

func New

func New(db *orm.DB, deps Deps) (*Module, error)

func (*Module) AddClosure added in v0.0.2

func (m *Module) AddClosure(c Closure) error

AddClosure registers a dated closure the establishment itself decided (maintenance, an event). Same-kind dates are unique, so a second closure on an already-closed-by-closure date is rejected with ErrDuplicateDate.

func (*Module) AddHoliday added in v0.0.2

func (m *Module) AddHoliday(h Holiday) error

AddHoliday registers a dated legal/administrative closure. A second row on the same date is rejected (ErrDuplicateDate) — a duplicated holiday would double-close a day and make RemoveHoliday look broken.

func (*Module) GetDayBounds added in v0.0.2

func (m *Module) GetDayBounds(date int64) (tinytime.DayBounds, error)

GetDayBounds is the Reader port: the neutral bounds only, no reason attached. Satisfies any sibling's own BoundsReader-shaped interface structurally.

func (*Module) GetDayDetail added in v0.0.4

func (m *Module) GetDayDetail(date int64) (DayDetail, error)

GetDayDetail resolves the establishment's status for one date, INCLUDING why a closed day is closed. This is the single resolution path — GetBounds wraps it and simply discards ClosedBy for a Go-level consumer that never asked for it.

Resolution order, in this exact precedence:

  1. A Closure on that date → {Open: false, ClosedBy: ClosedLocal}.
  2. A Holiday on that date → {Open: false, ClosedBy: ClosedHoliday}.
  3. BusinessHours for that weekday with is_open == false → {Open: false, ClosedBy: ClosedWeekly}.
  4. Otherwise {Open: true, OpenMin, CloseMin}.

A local closure outranks a holiday because it is the more specific, more recent decision, and because a holiday the establishment chose to work through must not be reopened by removing the closure. A weekday with no business_hours row at all is closed (closed by default — the absence of a schedule never means open).

func (*Module) ListBusinessHours added in v0.0.2

func (m *Module) ListBusinessHours() ([]BusinessHours, error)

ListBusinessHours returns all seven weekday rules ordered by day_of_week. An empty week is a valid state (closed by default), not an error.

func (*Module) ListClosures added in v0.0.2

func (m *Module) ListClosures(from, to int64) ([]Closure, error)

ListClosures returns closures in the range [from, to] (midnight UTC seconds, inclusive). A zero from/to means unbounded in that direction.

func (*Module) ListHolidays added in v0.0.2

func (m *Module) ListHolidays(from, to int64) ([]Holiday, error)

ListHolidays returns holidays in the range [from, to] (midnight UTC seconds, inclusive). A zero from/to means unbounded in that direction.

func (*Module) ModelName added in v0.0.2

func (m *Module) ModelName() string

func (*Module) MountOperations added in v0.0.2

func (m *Module) MountOperations(reg router.OperationRegistry)

func (*Module) RemoveClosure added in v0.0.2

func (m *Module) RemoveClosure(id string) error

RemoveClosure deletes a closure by id.

func (*Module) RemoveHoliday added in v0.0.2

func (m *Module) RemoveHoliday(id string) error

RemoveHoliday deletes a holiday by id and reopens its day for booking.

func (*Module) UpsertBusinessHours added in v0.0.2

func (m *Module) UpsertBusinessHours(h BusinessHours) error

UpsertBusinessHours creates or updates the weekly rule for one weekday. A brand-new row can never invalidate existing availability (the day had no hours before, so it was already closed by default), so a create publishes Closed: false; only an update that narrows the window publishes Closed: true.

type Reader added in v0.0.2

type Reader interface {
	// GetDayBounds answers "is the establishment open on this date, and
	// between which minutes". date is midnight UTC in seconds.
	GetDayBounds(date int64) (tinytime.DayBounds, error)
}

Reader is the READ-ONLY port this module's own consumers depend on — a convenience alias, not the contract a sibling domain module names.

A neighbour that only needs "is this date usable, and between which minutes" (e.g. veltylabs/appointment_booking) declares its OWN interface returning tinytime.DayBounds — a neutral leaf both sides already import — and this Module satisfies it structurally, with no adapter and no import in either direction. See webtyp/docs/AGENDA_DOMAIN_MASTER_PLAN.md §3-bis for why: a generic booking module must not depend on any specific institutional calendar.

type RemoveClosureArgs added in v0.0.2

type RemoveClosureArgs struct {
	Id string
}

func (*RemoveClosureArgs) DecodeFields added in v0.0.2

func (m *RemoveClosureArgs) DecodeFields(r model.FieldReader)

func (*RemoveClosureArgs) EncodeFields added in v0.0.2

func (m *RemoveClosureArgs) EncodeFields(w model.FieldWriter)

func (*RemoveClosureArgs) IsNil added in v0.0.2

func (m *RemoveClosureArgs) IsNil() bool

func (*RemoveClosureArgs) ModelName added in v0.0.2

func (m *RemoveClosureArgs) ModelName() string

func (*RemoveClosureArgs) Pointers added in v0.0.2

func (m *RemoveClosureArgs) Pointers() []any

func (*RemoveClosureArgs) Schema added in v0.0.2

func (m *RemoveClosureArgs) Schema() []model.Field

func (*RemoveClosureArgs) Validate added in v0.0.2

func (m *RemoveClosureArgs) Validate(action byte) error

type RemoveClosureArgsList added in v0.0.2

type RemoveClosureArgsList []*RemoveClosureArgs

func (*RemoveClosureArgsList) Append added in v0.0.2

func (s *RemoveClosureArgsList) Append() model.Fielder

func (*RemoveClosureArgsList) At added in v0.0.2

func (*RemoveClosureArgsList) DecodeFields added in v0.0.2

func (s *RemoveClosureArgsList) DecodeFields(_ model.FieldReader)

func (*RemoveClosureArgsList) EncodeFields added in v0.0.2

func (s *RemoveClosureArgsList) EncodeFields(_ model.FieldWriter)

func (*RemoveClosureArgsList) IsNil added in v0.0.2

func (s *RemoveClosureArgsList) IsNil() bool

func (*RemoveClosureArgsList) Len added in v0.0.2

func (s *RemoveClosureArgsList) Len() int

func (*RemoveClosureArgsList) Pointers added in v0.0.2

func (s *RemoveClosureArgsList) Pointers() []any

func (*RemoveClosureArgsList) Schema added in v0.0.2

func (s *RemoveClosureArgsList) Schema() []model.Field

type RemoveHolidayArgs added in v0.0.2

type RemoveHolidayArgs struct {
	Id string
}

func (*RemoveHolidayArgs) DecodeFields added in v0.0.2

func (m *RemoveHolidayArgs) DecodeFields(r model.FieldReader)

func (*RemoveHolidayArgs) EncodeFields added in v0.0.2

func (m *RemoveHolidayArgs) EncodeFields(w model.FieldWriter)

func (*RemoveHolidayArgs) IsNil added in v0.0.2

func (m *RemoveHolidayArgs) IsNil() bool

func (*RemoveHolidayArgs) ModelName added in v0.0.2

func (m *RemoveHolidayArgs) ModelName() string

func (*RemoveHolidayArgs) Pointers added in v0.0.2

func (m *RemoveHolidayArgs) Pointers() []any

func (*RemoveHolidayArgs) Schema added in v0.0.2

func (m *RemoveHolidayArgs) Schema() []model.Field

func (*RemoveHolidayArgs) Validate added in v0.0.2

func (m *RemoveHolidayArgs) Validate(action byte) error

type RemoveHolidayArgsList added in v0.0.2

type RemoveHolidayArgsList []*RemoveHolidayArgs

func (*RemoveHolidayArgsList) Append added in v0.0.2

func (s *RemoveHolidayArgsList) Append() model.Fielder

func (*RemoveHolidayArgsList) At added in v0.0.2

func (*RemoveHolidayArgsList) DecodeFields added in v0.0.2

func (s *RemoveHolidayArgsList) DecodeFields(_ model.FieldReader)

func (*RemoveHolidayArgsList) EncodeFields added in v0.0.2

func (s *RemoveHolidayArgsList) EncodeFields(_ model.FieldWriter)

func (*RemoveHolidayArgsList) IsNil added in v0.0.2

func (s *RemoveHolidayArgsList) IsNil() bool

func (*RemoveHolidayArgsList) Len added in v0.0.2

func (s *RemoveHolidayArgsList) Len() int

func (*RemoveHolidayArgsList) Pointers added in v0.0.2

func (s *RemoveHolidayArgsList) Pointers() []any

func (*RemoveHolidayArgsList) Schema added in v0.0.2

func (s *RemoveHolidayArgsList) Schema() []model.Field

type UpsertBusinessHoursArgs added in v0.0.2

type UpsertBusinessHoursArgs struct {
	DayOfWeek int64
	OpenMin   int64
	CloseMin  int64
	IsOpen    bool
	Notes     string
}

func (*UpsertBusinessHoursArgs) DecodeFields added in v0.0.2

func (m *UpsertBusinessHoursArgs) DecodeFields(r model.FieldReader)

func (*UpsertBusinessHoursArgs) EncodeFields added in v0.0.2

func (m *UpsertBusinessHoursArgs) EncodeFields(w model.FieldWriter)

func (*UpsertBusinessHoursArgs) IsNil added in v0.0.2

func (m *UpsertBusinessHoursArgs) IsNil() bool

func (*UpsertBusinessHoursArgs) ModelName added in v0.0.2

func (m *UpsertBusinessHoursArgs) ModelName() string

func (*UpsertBusinessHoursArgs) Pointers added in v0.0.2

func (m *UpsertBusinessHoursArgs) Pointers() []any

func (*UpsertBusinessHoursArgs) Schema added in v0.0.2

func (m *UpsertBusinessHoursArgs) Schema() []model.Field

func (*UpsertBusinessHoursArgs) Validate added in v0.0.2

func (m *UpsertBusinessHoursArgs) Validate(action byte) error

type UpsertBusinessHoursArgsList added in v0.0.2

type UpsertBusinessHoursArgsList []*UpsertBusinessHoursArgs

func (*UpsertBusinessHoursArgsList) Append added in v0.0.2

func (*UpsertBusinessHoursArgsList) At added in v0.0.2

func (*UpsertBusinessHoursArgsList) DecodeFields added in v0.0.2

func (s *UpsertBusinessHoursArgsList) DecodeFields(_ model.FieldReader)

func (*UpsertBusinessHoursArgsList) EncodeFields added in v0.0.2

func (s *UpsertBusinessHoursArgsList) EncodeFields(_ model.FieldWriter)

func (*UpsertBusinessHoursArgsList) IsNil added in v0.0.2

func (s *UpsertBusinessHoursArgsList) IsNil() bool

func (*UpsertBusinessHoursArgsList) Len added in v0.0.2

func (*UpsertBusinessHoursArgsList) Pointers added in v0.0.2

func (s *UpsertBusinessHoursArgsList) Pointers() []any

func (*UpsertBusinessHoursArgsList) Schema added in v0.0.2

func (s *UpsertBusinessHoursArgsList) Schema() []model.Field

Jump to

Keyboard shortcuts

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