projection

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatVersion = 1
)

Variables

This section is empty.

Functions

func Apply

func Apply(properties gvas.Properties, document *Document, options ApplyOptions) (*Output, []Diagnostic, error)

Apply resolves document against one decoded save and returns ordered output.

func IsInvalidDocument

func IsInvalidDocument(err error) bool

IsInvalidDocument reports whether err is a projection-document validation error rather than a save decoding or matching error.

Types

type ApplyOptions

type ApplyOptions struct {
	AllowPartial bool
	Explain      bool
}

ApplyOptions controls projection resolution.

type Diagnostic

type Diagnostic struct {
	Severity   Severity       `json:"severity"`
	Kind       DiagnosticKind `json:"kind"`
	OutputPath string         `json:"outputPath,omitempty"`
	SourcePath string         `json:"sourcePath,omitempty"`
	Message    string         `json:"message"`
	Candidates []string       `json:"candidates,omitempty"`
	Score      int            `json:"score,omitempty"`
}

Diagnostic is one machine-readable matching decision or problem.

type DiagnosticKind

type DiagnosticKind string

DiagnosticKind names what a Diagnostic reports. The set is closed, so a consumer can switch on it exhaustively. It is spelled DiagnosticKind rather than Kind because Kind already names the shape kinds.

const (
	// DiagnosticMissing reports a requested field with no match.
	DiagnosticMissing DiagnosticKind = "missing"
	// DiagnosticAmbiguous reports more than one equally good match.
	DiagnosticAmbiguous DiagnosticKind = "ambiguous"
	// DiagnosticIncompatible reports a match whose kind differs from the shape.
	DiagnosticIncompatible DiagnosticKind = "incompatible"
	// DiagnosticSelected records a match that was taken.
	DiagnosticSelected DiagnosticKind = "selected"
	// DiagnosticRejected records a candidate that lost to the selected one.
	DiagnosticRejected DiagnosticKind = "rejected"
	// DiagnosticRoot records which candidate became the projection root.
	DiagnosticRoot DiagnosticKind = "root"
)

type Document

type Document struct {
	Schema            string
	ProjectionVersion int
	Name              string
	GameVersion       string
	SaveType          string
	Shape             *Shape
}

Document is one validated projection document.

func Parse

func Parse(data []byte) (*Document, error)

Parse validates and parses a projection document.

func ParseReader

func ParseReader(reader io.Reader) (*Document, error)

ParseReader reads and parses a projection document without reading more than the document-size limit into memory.

func ResolvePreset

func ResolvePreset(name string) (*Document, error)

ResolvePreset finds a bundled projection by its exact name.

type Field

type Field struct {
	Name  string
	Shape *Shape
}

Field preserves a requested object's serialized key order.

type InvalidDocumentError

type InvalidDocumentError struct {
	Path    string
	Message string
}

InvalidDocumentError reports a projection contract violation.

func (*InvalidDocumentError) Error

func (err *InvalidDocumentError) Error() string

type Kind

type Kind uint8

Kind identifies one shape or decoded-data node.

const (
	KindNull Kind = iota
	KindObject
	KindArray
	KindString
	KindNumber
	KindBoolean
)

func (Kind) String

func (kind Kind) String() string

type Output

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

Output is the third of the package's three parallel trees, all keyed by the same Kind: documentNode is what the caller asked for, sourceNode is what the save contains, and Output is the result of matching one against the other.

Its custom marshaler preserves projection object key order.

func (*Output) MarshalJSON

func (value *Output) MarshalJSON() ([]byte, error)

MarshalJSON preserves the ordering in the projection shape.

type Preset

type Preset struct {
	Name        string `json:"name"`
	GameVersion string `json:"gameVersion"`
	SaveType    string `json:"saveType"`
}

Preset describes one bundled projection. GameVersion records the Palworld build the document was verified against; it is provenance reported to the caller, not part of the preset's identity.

func Presets

func Presets() ([]Preset, error)

Presets returns the bundled projections in stable name order.

type ResolutionError

type ResolutionError struct {
	Kind    string
	Path    string
	Message string
}

ResolutionError reports that no unique, complete projection could be resolved.

func (*ResolutionError) Error

func (err *ResolutionError) Error() string

type Severity

type Severity string

Severity ranks a Diagnostic for a consumer deciding whether to fail.

const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityInfo    Severity = "info"
)

type Shape

type Shape struct {
	Kind    Kind
	Fields  []Field
	Element *Shape
}

Shape is the ordered, validated representation of a requested JSON shape.

Jump to

Keyboard shortcuts

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