@hyperfrontend/versioning/changelog/modelsmodels
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
Parameters
Returns
CompatibilityResultExample
Checking schema compatibility before merge
const result = checkSchemaCompatibility(mainChangelog, branchChangelog)
if (!result.compatible) {
console.log('Schema differences:', result.differences)
}Parameters
| Name | Type | Description |
|---|---|---|
§options? | Partial<Changelog> | Optional configuration to customize the changelog |
Returns
ChangelogExample
Creating a changelog with custom source
const changelog = createChangelog({ source: 'CHANGELOG.md' })
// => { source: 'CHANGELOG.md', header: { title: '# Changelog', ... }, entries: [] }createChangelogEntry(version: string, options?: Partial<Omit<ChangelogEntry, "version">>): ChangelogEntry
Parameters
Returns
ChangelogEntryExample
Creating a changelog entry with date and sections
const entry = createChangelogEntry('1.0.0', {
date: '2024-01-15',
sections: [createChangelogSection('features', 'Added', items)],
})createChangelogItem(description: string, options?: Partial<Omit<ChangelogItem, "description">>): ChangelogItem
Parameters
Returns
ChangelogItemExample
Creating a changelog item with options
const item = createChangelogItem('Add user authentication', {
scope: 'auth',
breaking: false,
references: [{ number: 42, type: 'issue' }],
})Parameters
Returns
ChangelogLinkExample
Creating a version comparison link
const link = createChangelogLink('1.0.0', 'https://github.com/org/repo/compare/v0.9.0...v1.0.0')
// => { label: '1.0.0', url: 'https://github.com/...' }createChangelogSection(type: ChangelogSectionType, heading: string, items: unknown): ChangelogSection
Parameters
Returns
ChangelogSectionExample
Creating a features section with items
const section = createChangelogSection('features', 'Added', [
createChangelogItem('New dashboard widget'),
])Returns
CommitRefExample
Creating a commit reference
const ref = createCommitRef('abc1234def5678', 'https://github.com/org/repo/commit/abc1234def5678')
// => { hash: 'abc1234def5678', shortHash: 'abc1234', url: 'https://...' }Returns
ChangelogExample
Creating an empty changelog with standard header
const changelog = createEmptyChangelog()
// => Changelog with standard Keep a Changelog header and no entriesParameters
Returns
IssueRefExample
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 }Parameters
| Name | Type | Description |
|---|---|---|
§sections | unknown | Optional array of changelog sections (default: []) |
Returns
ChangelogEntryExample
Creating an unreleased entry
const unreleased = createUnreleasedEntry([
createChangelogSection('features', 'Added', [item]),
])
// => { version: 'Unreleased', date: null, unreleased: true, sections: [...] }Parameters
| Name | Type | Description |
|---|---|---|
§heading | string | The heading string to parse |
Returns
ChangelogSectionTypeExample
Mapping heading strings to section types
getSectionType('Added')
// => 'features'
getSectionType('Bug Fixes')
// => 'fixes'
getSectionType('Custom Section')
// => 'other'Parameters
| Name | Type | Description |
|---|---|---|
§hash | string | The full commit hash |
Returns
stringExample
Extracting short hash from full hash
getShortHash('abc1234def5678901234567890')
// => 'abc1234'Parameters
| Name | Type | Description |
|---|---|---|
§changelog | unknown | The changelog object to validate |
Returns
ValidationResultExample
Validating a changelog object
const result = validateChangelog(myChangelog)
if (!result.valid) {
console.log('Validation errors:', result.errors)
}◈ Interfaces
Complete representation of a CHANGELOG.md file. Designed for lossless round-tripping: parse -> modify -> serialize.
Represents a single version entry in a changelog.
Properties
The header section of a changelog file.
Represents an individual change within a changelog section.
Properties
Represents a link defined in the changelog header or elsewhere.
Additional information extracted during parsing.
Properties
Represents a category of changes (Features, Bug Fixes, etc.)
Represents a reference to a git commit in a changelog item.
Represents a reference to an issue or pull request.
◆ Types
Detected format/style of the changelog file.
type ChangelogFormat = "keep-a-changelog" | "conventional" | "custom" | "unknown"Categories for grouping changes in a changelog entry.
type ChangelogSectionType = "breaking" | "features" | "fixes" | "performance" | "documentation" | "deprecations" | "refactoring" | "tests" | "build" | "ci" | "chores" | "other"