Bugfixes and documentation cleanup for v1.0 release.
All checks were successful
ci/woodpecker/tag/release Pipeline was successful
All checks were successful
ci/woodpecker/tag/release Pipeline was successful
This commit is contained in:
@@ -14,9 +14,9 @@ import (
|
||||
var schemaFS embed.FS
|
||||
|
||||
const (
|
||||
outputSchemaPath = "output.schema.json"
|
||||
defaultOutputSchemaPath = "default-output.schema.json"
|
||||
minimalOutputSchemaPath = "minimal-output.schema.json"
|
||||
fullOutputSchemaPath = "full-output.schema.json"
|
||||
intermediateOutputSchemaPath = "intermediate-output.schema.json"
|
||||
minimalOutputSchemaPath = "minimal-output.schema.json"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -32,10 +32,10 @@ type Transcript struct {
|
||||
OverlapGroups []OverlapGroup `json:"overlap_groups"`
|
||||
}
|
||||
|
||||
// DefaultTranscript is seriatim's default public JSON output contract.
|
||||
type DefaultTranscript struct {
|
||||
Metadata DefaultMetadata `json:"metadata"`
|
||||
Segments []DefaultSegment `json:"segments"`
|
||||
// IntermediateTranscript is seriatim's intermediate public JSON output contract.
|
||||
type IntermediateTranscript struct {
|
||||
Metadata IntermediateMetadata `json:"metadata"`
|
||||
Segments []IntermediateSegment `json:"segments"`
|
||||
}
|
||||
|
||||
// MinimalTranscript is seriatim's compact public JSON output contract.
|
||||
@@ -55,8 +55,8 @@ type Metadata struct {
|
||||
OutputModules []string `json:"output_modules"`
|
||||
}
|
||||
|
||||
// DefaultMetadata records default artifact identity.
|
||||
type DefaultMetadata struct {
|
||||
// IntermediateMetadata records intermediate artifact identity.
|
||||
type IntermediateMetadata struct {
|
||||
Application string `json:"application"`
|
||||
Version string `json:"version"`
|
||||
OutputSchema string `json:"output_schema"`
|
||||
@@ -84,9 +84,9 @@ type Segment struct {
|
||||
OverlapGroupID int `json:"overlap_group_id,omitempty"`
|
||||
}
|
||||
|
||||
// DefaultSegment is the compact public transcript segment shape with
|
||||
// IntermediateSegment is the compact public transcript segment shape with
|
||||
// categories.
|
||||
type DefaultSegment struct {
|
||||
type IntermediateSegment struct {
|
||||
ID int `json:"id"`
|
||||
Start float64 `json:"start"`
|
||||
End float64 `json:"end"`
|
||||
@@ -115,7 +115,7 @@ type OverlapGroup struct {
|
||||
Resolution string `json:"resolution"`
|
||||
}
|
||||
|
||||
// ValidateTranscript validates a typed transcript against the public JSON
|
||||
// ValidateTranscript validates a full transcript against the public JSON
|
||||
// schema and seriatim-specific semantic rules.
|
||||
func ValidateTranscript(transcript Transcript) error {
|
||||
if err := validateSemantics(transcript); err != nil {
|
||||
@@ -129,18 +129,18 @@ func ValidateTranscript(transcript Transcript) error {
|
||||
return ValidateJSON(data)
|
||||
}
|
||||
|
||||
// ValidateDefaultTranscript validates the default transcript against the
|
||||
// default JSON schema and seriatim-specific semantic rules.
|
||||
func ValidateDefaultTranscript(transcript DefaultTranscript) error {
|
||||
if err := validateDefaultSemantics(transcript); err != nil {
|
||||
// ValidateIntermediateTranscript validates the intermediate transcript against
|
||||
// the intermediate JSON schema and seriatim-specific semantic rules.
|
||||
func ValidateIntermediateTranscript(transcript IntermediateTranscript) error {
|
||||
if err := validateIntermediateSemantics(transcript); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
data, err := json.Marshal(transcript)
|
||||
if err != nil {
|
||||
return fmt.Errorf("marshal default transcript for schema validation: %w", err)
|
||||
return fmt.Errorf("marshal intermediate transcript for schema validation: %w", err)
|
||||
}
|
||||
return ValidateDefaultJSON(data)
|
||||
return ValidateIntermediateJSON(data)
|
||||
}
|
||||
|
||||
// ValidateMinimalTranscript validates a minimal transcript against the minimal
|
||||
@@ -159,13 +159,13 @@ func ValidateMinimalTranscript(transcript MinimalTranscript) error {
|
||||
|
||||
// ValidateJSON validates serialized output JSON against the public schema.
|
||||
func ValidateJSON(data []byte) error {
|
||||
return validateJSONWithSchema(data, outputSchemaPath)
|
||||
return validateJSONWithSchema(data, fullOutputSchemaPath)
|
||||
}
|
||||
|
||||
// ValidateDefaultJSON validates serialized default output JSON against the
|
||||
// default public schema.
|
||||
func ValidateDefaultJSON(data []byte) error {
|
||||
return validateJSONWithSchema(data, defaultOutputSchemaPath)
|
||||
// ValidateIntermediateJSON validates serialized intermediate output JSON
|
||||
// against the intermediate public schema.
|
||||
func ValidateIntermediateJSON(data []byte) error {
|
||||
return validateJSONWithSchema(data, intermediateOutputSchemaPath)
|
||||
}
|
||||
|
||||
// ValidateMinimalJSON validates serialized minimal output JSON against the
|
||||
@@ -245,7 +245,7 @@ func validateSemantics(transcript Transcript) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateDefaultSemantics(transcript DefaultTranscript) error {
|
||||
func validateIntermediateSemantics(transcript IntermediateTranscript) error {
|
||||
for index, segment := range transcript.Segments {
|
||||
wantID := index + 1
|
||||
if segment.ID != wantID {
|
||||
|
||||
Reference in New Issue
Block a user