models

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SystemIDPattern is the required format for a game system's system_id: lowercase
	// kebab-case slug.
	SystemIDPattern = `^[a-z0-9]+(-[a-z0-9]+)*$`
)

Variables

This section is empty.

Functions

func Create

func Create(c context.Context, gs *GameSystemVersion, systemID string, createdBy string) (*string, error)

Create adds a new game system: its meta record (with systemID) and first (live) version.

func EnsureIndexes

func EnsureIndexes(c context.Context) error

EnsureIndexes creates the indexes game system version queries rely on. Safe to call on every startup.

func RejectVersion

func RejectVersion(c context.Context, id string, version int, reviewedBy string, reviewNote *string) error

RejectVersion marks a submitted version rejected, with an optional note.

func ValidateSystemID

func ValidateSystemID(s string) bool

ValidateSystemID reports whether s is a well-formed system_id slug.

Types

type EntityMeta

type EntityMeta struct {
	ID             string    `bson:"_id" json:"id"`
	SystemID       string    `bson:"system_id" json:"system_id"`
	CurrentVersion int       `bson:"current_version" json:"current_version"`
	CreatedAt      time.Time `bson:"created_at" json:"created_at"`
	CreatedBy      string    `bson:"created_by" json:"created_by"`
}

EntityMeta is the stable-identity record: id, the version currently live, and creation audit.

func GetMeta

func GetMeta(c context.Context, id string) (*EntityMeta, error)

GetMeta fetches a game system's meta record, matching id against either the document `_id` or the `system_id` slug in a single query.

type GameSystemVersion

type GameSystemVersion struct {
	ID               string          `bson:"_id" json:"id"`
	RecordID         string          `bson:"record_id" json:"record_id"`
	Version          int             `bson:"version" json:"version"`
	Name             string          `bson:"name" json:"name"`
	Edition          string          `bson:"edition" json:"edition"`
	PublisherID      string          `bson:"publisher_id,omitempty" json:"publisher_id,omitempty"`
	Notes            string          `bson:"notes" json:"notes"`
	Tags             []modelcore.Tag `bson:"tags" json:"tags"`
	VersionLifecycle `bson:",inline"`
}

GameSystemVersion is one full-snapshot version of a game system's substantive fields, plus the shared submission/review audit trail (VersionLifecycle).

func AcceptVersion

func AcceptVersion(c context.Context, id string, version int, selectedFields []string, reviewedBy string, reviewNote *string) (*GameSystemVersion, []string, error)

AcceptVersion reviews a submitted version - accept all changed fields (selectedFields nil) or only the ones named. A conflict is a selected field whose current value has diverged from the submission's base since it was submitted; conflicting fields are reported, not silently overwritten.

func CreateVersion

func CreateVersion(c context.Context, id string, gs *GameSystemVersion, state VersionState, submittedBy string) (*GameSystemVersion, error)

CreateVersion creates a new version for an existing game system - editor/admin: state Live, goes current immediately and archives the previous current version; submitter: state Submitted, current pointer untouched.

func Get

Get returns a game system's meta merged with its current version's data - the flattened current view GET /systems/:id returns. id may be the document `_id` or the `system_id`.

func GetVersion

func GetVersion(c context.Context, recordID string, version int) (*GameSystemVersion, error)

GetVersion fetches one game system version's full field snapshot.

func List

func List(c context.Context) ([]*GameSystemVersion, error)

List returns every live game system's current version - the flattened view GET /systems returns.

func ListVersions

func ListVersions(c context.Context, id string) ([]*GameSystemVersion, error)

ListVersions returns every version of a game system, newest first.

func RetractVersion

func RetractVersion(c context.Context, id string, version int, submitterID string) (*GameSystemVersion, error)

RetractVersion lets the original submitter withdraw their own pending submission.

func SetCurrentVersion

func SetCurrentVersion(c context.Context, id string, version int) (*GameSystemVersion, error)

SetCurrentVersion rolls a game system back (or forward) to an arbitrary existing version.

type VersionLifecycle

type VersionLifecycle struct {
	State            VersionState `bson:"state" json:"state"`
	BaseVersion      *int         `bson:"base_version,omitempty" json:"base_version,omitempty"`
	SubmittedBy      string       `bson:"submitted_by" json:"submitted_by"`
	SubmittedAt      time.Time    `bson:"submitted_at" json:"submitted_at"`
	ReviewedBy       *string      `bson:"reviewed_by,omitempty" json:"reviewed_by,omitempty"`
	ReviewedAt       *time.Time   `bson:"reviewed_at,omitempty" json:"reviewed_at,omitempty"`
	ReviewNote       *string      `bson:"review_note,omitempty" json:"review_note,omitempty"`
	ResultingVersion *int         `bson:"resulting_version,omitempty" json:"resulting_version,omitempty"`
}

VersionLifecycle is the submission/review audit trail on a version record - state, provenance, and review outcome. Matches catalog-api's shared VersionLifecycle shape.

type VersionState

type VersionState string

VersionState is one of a fixed set of states a version record can be in - matching catalog-api's version model exactly (see platform's catalog-entity-versioning spec).

const (
	VersionStateSubmitted         VersionState = "submitted"
	VersionStateLive              VersionState = "live"
	VersionStateArchived          VersionState = "archived"
	VersionStateRejected          VersionState = "rejected"
	VersionStatePartiallyAccepted VersionState = "partially_accepted"
	VersionStateWithdrawn         VersionState = "withdrawn"
)

Jump to

Keyboard shortcuts

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