Documentation
¶
Index ¶
- Constants
- Variables
- func ComputeFileChecksum(fileSystem fs.FS, relPath string) (string, error)
- func HashNormalizedSHA1(r io.Reader) (string, error)
- func PopulateMissingChecksums(lf *LockFile, fileSystem fs.FS) error
- type Examples
- type GeneratedTests
- type LoadOption
- type LockFile
- type Management
- type OperationExamples
- type ParameterExamples
- type PersistentEdits
- type TrackedFile
- type TrackedFiles
Constants ¶
View Source
const (
LockV2 = "2.0.0"
)
Variables ¶
View Source
var GetUUID = func() string { return uuid.NewString() }
Functions ¶
func ComputeFileChecksum ¶
ComputeFileChecksum returns a checksum string like "sha1:<hex>" by hashing the normalized contents of root/relPath using the provided filesystem.
func HashNormalizedSHA1 ¶
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 ¶
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 Examples ¶
type Examples = *sequencedmap.Map[string, *sequencedmap.Map[string, OperationExamples]]
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"`
}
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]
Click to show internal directories.
Click to hide internal directories.