// Package core holds the pure domain model for dolt.sr.ht: value types, // name/path validation, and the access-control matrix. It performs no I/O and // imports nothing outside the standard library, so every other package can // depend on it freely. package core import "time" // Visibility mirrors the Postgres `visibility` enum. type Visibility string const ( VisibilityPublic Visibility = "PUBLIC" VisibilityUnlisted Visibility = "UNLISTED" VisibilityPrivate Visibility = "PRIVATE" ) // AccessMode mirrors the Postgres `access_mode` enum: an ACL grant is either // read-only (browse + clone) or read-write (+ push). type AccessMode string const ( AccessRO AccessMode = "RO" AccessRW AccessMode = "RW" ) // UserType mirrors the Postgres `user_type` enum, itself a mirror of meta's // user type. SUSPENDED users may read but never write. type UserType string const ( UserTypePending UserType = "PENDING" UserTypeUser UserType = "USER" UserTypeAdmin UserType = "ADMIN" UserTypeSuspended UserType = "SUSPENDED" ) // Op is an operation whose authorization is decided by Allowed. type Op int const ( // OpBrowse is a read of repository metadata/contents through the web UI. OpBrowse Op = iota // OpCloneRead is a read over the remotesapi (clone/pull/fetch). OpCloneRead // OpPush is a write over the remotesapi (push). OpPush // OpAdmin is an owner-only administrative action (settings, ACLs, delete). OpAdmin ) func (o Op) String() string { switch o { case OpBrowse: return "browse" case OpCloneRead: return "clone-read" case OpPush: return "push" case OpAdmin: return "admin" default: return "unknown" } } // Repo is a hosted Dolt database. Path is the absolute on-disk NBS store dir. type Repo struct { ID int Name string Description string OwnerID int OwnerName string Path string Visibility Visibility // Created and Updated are the row's timestamps, in UTC. They are read by // the surfaces that publish a database as a record rather than as a page — // /query is the first — and are the zero time for a Repo built in memory // rather than read from the store. Created time.Time Updated time.Time } // Caller is the authenticated principal for a request. A nil *Caller is an // anonymous request. Suspended is carried explicitly (rather than derived from // UserType) because the token/cookie resolver decides it, and it gates all // write operations regardless of ACL. type Caller struct { UserID int Username string UserType UserType Suspended bool }