workshop

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPackage

func BuildPackage(opts PackageOptions) error

BuildPackage validates a workshop item directory and produces a .steamworkshop zip archive.

Types

type InstallOptions

type InstallOptions struct {
	// PublishedFileId is the Steam Workshop file ID (used as directory name).
	PublishedFileId string
	// ZipData is the raw zip archive bytes to extract.
	ZipData []byte
	// InstallDir is the base directory; item is installed to <InstallDir>/<PublishedFileId>/.
	InstallDir string
	// ValidateRuleset runs the server-side validator after extraction.
	ValidateRuleset bool
}

InstallOptions controls how a Workshop item is installed.

type InstallResult

type InstallResult struct {
	ItemDir        string
	Manifest       *WorkshopManifest
	AlreadyCurrent bool
}

InstallResult holds the outcome of a successful Workshop item install.

func Install

func Install(opts InstallOptions) (InstallResult, error)

Install extracts a Workshop zip archive to the install directory, validates the manifest, optionally validates the ruleset YAML, and returns the result.

Calling Install twice with the same zip data is a no-op (AlreadyCurrent=true).

type ItemType

type ItemType string

ItemType classifies a Workshop item.

const (
	ItemTypeRuleset  ItemType = "ruleset"
	ItemTypeCardPack ItemType = "card_pack"
	ItemTypeGameMode ItemType = "game_mode" // ruleset + UI theme
)

type ModCheckOptions

type ModCheckOptions struct {
	// PackageDir is the path to the workshop item directory (already extracted).
	PackageDir string
	// AllowedStepTypes overrides the default allowlist. If nil, defaults are used.
	AllowedStepTypes []string
}

ModCheckOptions controls the automated moderation check.

type ModCheckResult

type ModCheckResult struct {
	Passed     bool
	Violations []string
	Warnings   []string
}

ModCheckResult holds the outcome of the moderation check.

func RunModCheck

func RunModCheck(opts ModCheckOptions) (ModCheckResult, error)

RunModCheck performs automated pre-publish moderation checks on a workshop package directory.

type PackageOptions

type PackageOptions struct {
	// SourceDir is the directory containing manifest.json and item files.
	SourceDir string
	// OutputPath is the destination .steamworkshop zip file path.
	OutputPath string
	// MaxTotalBytes is the maximum allowed total uncompressed size (default 100 MB).
	MaxTotalBytes int64
	// MaxPreviewBytes is the maximum allowed size for the preview image (default 1 MB).
	MaxPreviewBytes int64
}

PackageOptions controls the workshop package build.

type ValidationResult

type ValidationResult struct {
	Valid    bool
	Errors   []string
	Manifest *WorkshopManifest
}

ValidationResult holds the outcome of a workshop package validation.

func ValidatePackage

func ValidatePackage(packageDir string, strictMode bool) (ValidationResult, error)

ValidatePackage validates an extracted workshop item directory. If strictMode is true, ruleset YAML step types are also checked against an allowlist of safe step types.

type VersionDB

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

VersionDB is a JSON-backed store of Workshop item version records. It is stored as a single JSON file at the configured path.

func NewVersionDB

func NewVersionDB(dbPath string) *VersionDB

NewVersionDB creates a VersionDB backed by a JSON file at dbPath. Existing data is loaded lazily on first access.

func (*VersionDB) Get

func (db *VersionDB) Get(publishedFileId string) (VersionRecord, bool)

Get returns the VersionRecord for the given publishedFileId, if it exists.

func (*VersionDB) ListAll

func (db *VersionDB) ListAll() ([]VersionRecord, error)

ListAll returns all VersionRecords.

func (*VersionDB) Remove

func (db *VersionDB) Remove(publishedFileId string) error

Remove deletes the VersionRecord for the given publishedFileId.

func (*VersionDB) Set

func (db *VersionDB) Set(r VersionRecord) error

Set inserts or updates a VersionRecord.

type VersionRecord

type VersionRecord struct {
	PublishedFileId string    `json:"publishedFileId"`
	LastUpdatedAt   time.Time `json:"lastUpdatedAt"`
	InstalledAt     time.Time `json:"installedAt"`
	Version         string    `json:"version"`
	ItemDir         string    `json:"itemDir"`
}

VersionRecord tracks the installed state of a Workshop item.

type WorkshopManifest

type WorkshopManifest struct {
	SchemaVersion    int      `json:"schemaVersion"`
	ItemType         ItemType `json:"itemType"`
	Title            string   `json:"title"`
	Description      string   `json:"description"`
	Tags             []string `json:"tags"`
	PreviewImagePath string   `json:"previewImagePath"`
	GameTypes        []string `json:"gameTypes"`
	MinPlayers       int      `json:"minPlayers"`
	MaxPlayers       int      `json:"maxPlayers"`
	Author           string   `json:"author"`  // Steam ID 64 as string
	Version          string   `json:"version"` // semver string
}

WorkshopManifest is the deserialized form of a Workshop item's manifest.json.

func (*WorkshopManifest) Validate

func (m *WorkshopManifest) Validate() error

Validate checks that the manifest has required fields and valid values.

Jump to

Keyboard shortcuts

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