lockfile

package
v1.43.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LockV2 = "2.0.0"
)

Variables

View Source
var GetUUID = func() string {
	return uuid.NewString()
}

Functions

func ComputeFileChecksum

func ComputeFileChecksum(fileSystem fs.FS, relPath string) (string, error)

ComputeFileChecksum returns a checksum string like "sha1:<hex>" by hashing the normalized contents of root/relPath using the provided filesystem.

func HashNormalizedSHA1

func HashNormalizedSHA1(r io.Reader) (string, error)

HashNormalizedSHA1 computes SHA1 over a canonicalized stream: - Strip UTF-8 BOM only if present at the very beginning - Convert CRLF and lone CR to LF - Ignore the presence of a single trailing LF (drop it if present)

func PopulateMissingChecksums

func PopulateMissingChecksums(lf *LockFile, fileSystem fs.FS) error

PopulateMissingChecksums computes last_write_checksum for any TrackedFiles entries where LastWriteChecksum is empty. The fileSystem should be rooted at the directory containing the generated files (parent of .speakeasy/).

Types

type GeneratedTests

type GeneratedTests = *sequencedmap.Map[string, string]

type LoadOption

type LoadOption func(*loadOptions)

func WithFileSystem

func WithFileSystem(fileSystem fs.FS) LoadOption

type LockFile

type LockFile struct {
	LockVersion          string                       `yaml:"lockVersion"`
	ID                   string                       `yaml:"id"`
	Management           Management                   `yaml:"management"`
	PersistentEdits      *PersistentEdits             `yaml:"persistentEdits,omitempty"`
	Features             map[string]map[string]string `yaml:"features,omitempty"`
	TrackedFiles         TrackedFiles                 `yaml:"trackedFiles,omitempty"`
	Examples             Examples                     `yaml:"examples,omitempty"`
	ExamplesVersion      string                       `yaml:"examplesVersion,omitempty"`
	GeneratedTests       GeneratedTests               `yaml:"generatedTests,omitempty"`
	AdditionalProperties map[string]any               `yaml:",inline"`

	ReleaseNotes string `yaml:"releaseNotes,omitempty"`
}

func Load

func Load(data []byte, opts ...LoadOption) (*LockFile, error)

func New

func New() *LockFile

type Management

type Management struct {
	DocChecksum          string         `yaml:"docChecksum,omitempty"`
	DocVersion           string         `yaml:"docVersion,omitempty"`
	SpeakeasyVersion     string         `yaml:"speakeasyVersion,omitempty"`
	GenerationVersion    string         `yaml:"generationVersion,omitempty"`
	ReleaseVersion       string         `yaml:"releaseVersion,omitempty"`
	ConfigChecksum       string         `yaml:"configChecksum,omitempty"`
	RepoURL              string         `yaml:"repoURL,omitempty"`
	RepoSubDirectory     string         `yaml:"repoSubDirectory,omitempty"`
	InstallationURL      string         `yaml:"installationURL,omitempty"`
	Published            bool           `yaml:"published,omitempty"`
	AdditionalProperties map[string]any `yaml:",inline"`
}

type OperationExamples

type OperationExamples struct {
	Parameters  *ParameterExamples                                              `yaml:"parameters,omitempty"`
	RequestBody *sequencedmap.Map[string, yaml.Node]                            `yaml:"requestBody,omitempty"`
	Responses   *sequencedmap.Map[string, *sequencedmap.Map[string, yaml.Node]] `yaml:"responses,omitempty"`
}

type ParameterExamples

type ParameterExamples struct {
	Path   *sequencedmap.Map[string, yaml.Node] `yaml:"path,omitempty"`
	Query  *sequencedmap.Map[string, yaml.Node] `yaml:"query,omitempty"`
	Header *sequencedmap.Map[string, yaml.Node] `yaml:"header,omitempty"`
}

type PersistentEdits

type PersistentEdits struct {
	// Maps to refs/speakeasy/gen/<UUID>
	GenerationID string `yaml:"generation_id,omitempty"`

	// Parent Commit (Links history for compression)
	PristineCommitHash string `yaml:"pristine_commit_hash,omitempty"`

	// Content Checksum (Enables No-Op/Determinism check)
	PristineTreeHash string `yaml:"pristine_tree_hash,omitempty"`
}

type TrackedFile

type TrackedFile struct {
	// Identity (The "Breadcrumb")
	// UUID embedded in the file header. Allows detecting "Moves/Renames".
	ID string `yaml:"id,omitempty"`

	// The Dirty Check (Optimization)
	// The SHA-1 of the file content exactly as written to disk last time.
	// If Disk_SHA == LastWriteChecksum, we skip the merge (Fast Path).
	LastWriteChecksum string `yaml:"last_write_checksum,omitempty"`

	// The O(1) Lookup Key
	// Stores the Blob Hash of the file from the PREVIOUS run.
	// Only populated if persistentEdits is enabled.
	PristineGitObject string `yaml:"pristine_git_object,omitempty"`

	// Deleted indicates the user deleted this file from disk.
	// Set pre-generation by scanning disk vs lockfile entries.
	// When true, the generator should not regenerate this file.
	Deleted bool `yaml:"deleted,omitempty"`

	// MovedTo indicates the user moved/renamed this file to a new path.
	// Set pre-generation by scanning @generated-id headers on disk.
	// The generator should write to the new path instead of the original.
	MovedTo string `yaml:"moved_to,omitempty"`

	AdditionalProperties map[string]any `yaml:",inline"`
}

type TrackedFiles

type TrackedFiles = *sequencedmap.Map[string, TrackedFile]

Jump to

Keyboard shortcuts

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