@hyperfrontend/versioning/changelog/models

models

Type definitions and factory functions for the changelog data model.

Exposes Changelog, ChangelogHeader, ChangelogEntry, ChangelogSection, ChangelogItem, CommitRef, and IssueRef, along with create* factories, the section-type registry (SECTION_HEADINGS, getSectionType), and the JSON schema (changelogSchema, validateChangelog). All other changelog/* submodules consume these shapes.

API Reference§

ƒ Functions

§function

checkSchemaCompatibility(source: Changelog, target: Changelog): CompatibilityResult

Checks if two changelogs have compatible schemas. Used to detect format incompatibilities before merge/compare.
Parameters
NameTypeDescription
§source
ChangelogThe source changelog
§target
ChangelogThe target changelog
Returns
CompatibilityResult
Compatibility result with any differences found
Example

Checking schema compatibility before merge

const result = checkSchemaCompatibility(mainChangelog, branchChangelog)
if (!result.compatible) {
  console.log('Schema differences:', result.differences)
}
§function

createChangelog(options?: Partial<Changelog>): Changelog

Creates a new changelog with default values.
Parameters
NameTypeDescription
§options?
Partial<Changelog>Optional configuration to customize the changelog
Returns
Changelog
A new Changelog object with the specified options or defaults
Example

Creating a changelog with custom source

const changelog = createChangelog({ source: 'CHANGELOG.md' })
// => { source: 'CHANGELOG.md', header: { title: '# Changelog', ... }, entries: [] }
§function

createChangelogEntry(version: string, options?: Partial<Omit<ChangelogEntry, "version">>): ChangelogEntry

Creates a new changelog entry.
Parameters
NameTypeDescription
§version
stringThe version string (e.g., '1.0.0')
§options?
Partial<Omit<ChangelogEntry, "version">>Optional configuration for date, sections, and other properties
Returns
ChangelogEntry
A new ChangelogEntry object
Example

Creating a changelog entry with date and sections

const entry = createChangelogEntry('1.0.0', {
  date: '2024-01-15',
  sections: [createChangelogSection('features', 'Added', items)],
})
§function

createChangelogItem(description: string, options?: Partial<Omit<ChangelogItem, "description">>): ChangelogItem

Creates a new changelog item.
Parameters
NameTypeDescription
§description
stringThe description text of the change
§options?
Partial<Omit<ChangelogItem, "description">>Optional configuration for scope, commits, references, and breaking flag
Returns
ChangelogItem
A new ChangelogItem object
Example

Creating a changelog item with options

const item = createChangelogItem('Add user authentication', {
  scope: 'auth',
  breaking: false,
  references: [{ number: 42, type: 'issue' }],
})
§function

createChangelogSection(type: ChangelogSectionType, heading: string, items: unknown): ChangelogSection

Creates a new changelog section.
Parameters
NameTypeDescription
§type
ChangelogSectionTypeThe type of section (features, fixes, breaking, etc.)
§heading
stringThe display heading for the section
§items
unknownOptional array of changelog items in this section(default: [])
Returns
ChangelogSection
A new ChangelogSection object
Example

Creating a features section with items

const section = createChangelogSection('features', 'Added', [
  createChangelogItem('New dashboard widget'),
])
§function

createCommitRef(hash: string, url?: string): CommitRef

Creates a commit reference from a full hash.
Parameters
NameTypeDescription
§hash
stringThe full commit hash
§url?
stringOptional URL to the commit
Returns
CommitRef
A new CommitRef object with both full and short hash
Example

Creating a commit reference

const ref = createCommitRef('abc1234def5678', 'https://github.com/org/repo/commit/abc1234def5678')
// => { hash: 'abc1234def5678', shortHash: 'abc1234', url: 'https://...' }
§function

createEmptyChangelog(): Changelog

Creates a new empty changelog with standard header.
Returns
Changelog
A new empty Changelog with Keep a Changelog format
Example

Creating an empty changelog with standard header

const changelog = createEmptyChangelog()
// => Changelog with standard Keep a Changelog header and no entries
§function

createIssueRef(number: number, type: "issue" | "pull-request", url?: string): IssueRef

Creates an issue reference.
Parameters
NameTypeDescription
§number
numberThe issue or PR number
§type
"issue" | "pull-request"The type of reference ('issue' or 'pull-request')(default: 'issue')
§url?
stringOptional URL to the issue or PR
Returns
IssueRef
A new IssueRef object
Example

Creating issue and PR references

const issueRef = createIssueRef(42, 'issue', 'https://github.com/org/repo/issues/42')
// => { number: 42, type: 'issue', url: 'https://...' }

const prRef = createIssueRef(123, 'pull-request')
// => { number: 123, type: 'pull-request', url: undefined }
§function

createUnreleasedEntry(sections: unknown): ChangelogEntry

Creates an unreleased changelog entry.
Parameters
NameTypeDescription
§sections
unknownOptional array of changelog sections(default: [])
Returns
ChangelogEntry
A new ChangelogEntry object marked as unreleased
Example

Creating an unreleased entry

const unreleased = createUnreleasedEntry([
  createChangelogSection('features', 'Added', [item]),
])
// => { version: 'Unreleased', date: null, unreleased: true, sections: [...] }
§function

getSectionType(heading: string): ChangelogSectionType

Determines the section type from a heading string. Returns 'other' if the heading is not recognized.
Parameters
NameTypeDescription
§heading
stringThe heading string to parse
Returns
ChangelogSectionType
The corresponding ChangelogSectionType
Example

Mapping heading strings to section types

getSectionType('Added')
// => 'features'

getSectionType('Bug Fixes')
// => 'fixes'

getSectionType('Custom Section')
// => 'other'
§function

getShortHash(hash: string): string

Extracts the short hash from a full commit hash.
Parameters
NameTypeDescription
§hash
stringThe full commit hash
Returns
string
The first 7 characters of the hash
Example

Extracting short hash from full hash

getShortHash('abc1234def5678901234567890')
// => 'abc1234'
§function

validateChangelog(changelog: unknown): ValidationResult

Validates a changelog object against the schema.
Parameters
NameTypeDescription
§changelog
unknownThe changelog object to validate
Returns
ValidationResult
Validation result with any errors
Example

Validating a changelog object

const result = validateChangelog(myChangelog)
if (!result.valid) {
  console.log('Validation errors:', result.errors)
}

◈ Interfaces

§interface

Changelog

Changelog
Complete representation of a CHANGELOG.md file. Designed for lossless round-tripping: parse -> modify -> serialize.
Properties
§readonly source?:stringOriginal file path (if parsed from file)
§readonly header:ChangelogHeaderFile header/preamble content
§readonly entries:unknownVersion entries, ordered newest first
§readonly metadata:ChangelogMetadataAdditional metadata extracted during parsing
§interface

ChangelogEntry

Changelog Entry
Represents a single version entry in a changelog.
Properties
§readonly version:stringVersion string (e.g., "1.2.3")
§readonly date:stringRelease date (ISO format or null for unreleased)
§readonly unreleased:booleanWhether this is an unreleased/upcoming section
§readonly compareUrl?:stringCompare URL (e.g., GitHub compare link)
§readonly sections:unknownGrouped changes by category
§readonly rawContent?:stringRaw text for entries that couldn't be parsed structurally
§interface

ChangelogHeader

Changelog Header
The header section of a changelog file.
Properties
§readonly title:stringTitle (e.g., "# Changelog")
§readonly description:unknownDescription paragraphs between title and first entry
§interface

ChangelogItem

Changelog Item
Represents an individual change within a changelog section.
Properties
§readonly scope?:stringScope (e.g., "api", "cli")
§readonly description:stringDescription of the change
§readonly commits:unknownCommit references
§readonly references:unknownIssue/PR references
§readonly breaking:booleanWhether this is a breaking change
§readonly source?:CommitSourceClassification source (for auditing/debugging)
§readonly indirect?:booleanWhether this is an indirect change (dependency or infrastructure)
§interface

ChangelogMetadata

Changelog Metadata
Additional information extracted during parsing.
Properties
§readonly format:ChangelogFormatDetected changelog format/style
§readonly isConventional:booleanWhether the file follows conventional changelog spec
§readonly repositoryUrl?:stringRepository URL if detected
§readonly packageName?:stringPackage name if detected
§readonly warnings:unknownParser warnings/notes
§interface

ChangelogSection

Changelog Section
Represents a category of changes (Features, Bug Fixes, etc.)
Properties
§readonly type:ChangelogSectionTypeSection type (features, fixes, etc.)
§readonly heading:stringSection heading as it appears in file
§readonly items:unknownIndividual change items
§interface

CommitRef

Commit Reference
Represents a reference to a git commit in a changelog item.
Properties
§readonly hash:stringFull commit hash
§readonly shortHash:stringShort commit hash (typically 7 characters)
§readonly url?:stringURL to the commit (e.g., GitHub commit link)
§interface

CompatibilityResult

Schema compatibility check result.
Properties
§readonly compatible:booleanWhether schemas are compatible
§readonly differences:unknownList of schema differences found
§interface

IssueRef

Issue/PR Reference
Represents a reference to an issue or pull request.
Properties
§readonly number:numberIssue or PR number
§readonly url?:stringURL to the issue/PR
§readonly type:"issue" | "pull-request"Type of reference
§interface

SchemaDifference

A single schema difference.
Properties
§readonly path:stringJSON path where difference was found
§readonly type:"type-mismatch" | "missing-property" | "extra-property"Type of difference
§readonly sourceType?:stringType in source schema
§readonly targetType?:stringType in target schema

◆ Types

§type

ChangelogFormat

Changelog Format
Detected format/style of the changelog file.
type ChangelogFormat = "keep-a-changelog" | "conventional" | "custom" | "unknown"
§type

ChangelogSectionType

Changelog Section Types
Categories for grouping changes in a changelog entry.
type ChangelogSectionType = "breaking" | "features" | "fixes" | "performance" | "documentation" | "deprecations" | "refactoring" | "tests" | "build" | "ci" | "chores" | "other"

● Variables

§type

changelogSchema

JSON Schema for a complete Changelog document. Used for validation and format compatibility checking.
§type

SECTION_HEADINGS

Standard section headings for serialization. Maps section types to their preferred heading text.
§type

SECTION_TYPE_MAP

Maps section headings to their canonical types. Used during parsing to normalize different heading styles.