import { ChangelogEntry, ChangelogSection, ChangelogItem, Changelog, CommitRef, ChangelogHeader, IssueRef, ChangelogLink, ChangelogMetadata } from '../models'; /** * Represents the diff between two changelogs. */ interface ChangelogDiff { /** Entries added in target but not in source */ readonly added: readonly ChangelogEntry[]; /** Entries removed from source but not in target */ readonly removed: readonly ChangelogEntry[]; /** Entries present in both but with differences */ readonly modified: readonly EntryDiff[]; /** Whether changelogs are structurally identical */ readonly identical: boolean; /** Summary statistics */ readonly stats: DiffStats; } /** * Statistics about the diff. */ interface DiffStats { /** Number of added entries */ readonly addedCount: number; /** Number of removed entries */ readonly removedCount: number; /** Number of modified entries */ readonly modifiedCount: number; /** Total number of property changes across all modified entries */ readonly totalChanges: number; } /** * Represents differences in a single entry. */ interface EntryDiff { /** Version of the entry */ readonly version: string; /** Original entry (from source) */ readonly source: ChangelogEntry; /** Modified entry (from target) */ readonly target: ChangelogEntry; /** List of property differences */ readonly changes: readonly PropertyDiff[]; /** Sections added in target */ readonly addedSections: readonly ChangelogSection[]; /** Sections removed from source */ readonly removedSections: readonly ChangelogSection[]; /** Sections that were modified */ readonly modifiedSections: readonly SectionDiff[]; } /** * Represents differences in a single section. */ interface SectionDiff { /** Section type */ readonly type: string; /** Original section (from source) */ readonly source: ChangelogSection; /** Modified section (from target) */ readonly target: ChangelogSection; /** Items added in target */ readonly addedItems: readonly ChangelogItem[]; /** Items removed from source */ readonly removedItems: readonly ChangelogItem[]; /** Items that were modified */ readonly modifiedItems: readonly ItemDiff[]; } /** * Represents differences in a single item. */ interface ItemDiff { /** Description from source */ readonly sourceDescription: string; /** Source item */ readonly source: ChangelogItem; /** Target item */ readonly target: ChangelogItem; /** List of property changes */ readonly changes: readonly PropertyDiff[]; } /** * Represents a single property difference. */ interface PropertyDiff { /** Path to the property (e.g., ['date'], ['sections', '0', 'heading']) */ readonly path: readonly string[]; /** Type of change */ readonly type: 'added' | 'removed' | 'changed'; /** Previous value (for 'removed' and 'changed') */ readonly oldValue?: unknown; /** New value (for 'added' and 'changed') */ readonly newValue?: unknown; } /** * Computes the diff between two changelogs. * * @param source - The source/original changelog * @param target - The target/modified changelog * @returns Detailed diff of changes * * @example Comparing two changelogs * ```ts * const diff = diffChangelogs(mainChangelog, branchChangelog) * console.log(`Added: ${diff.added.length}, Removed: ${diff.removed.length}`) * ``` */ declare function diffChangelogs(source: Changelog, target: Changelog): ChangelogDiff; /** * Computes the diff between two changelog entries. * * @param source - The source entry * @param target - The target entry * @returns Detailed entry diff * * @example Computing diff between two entries * ```typescript * const diff = diffEntries(entryV1, entryV2) * // => { version: '1.0.0', changes: [{ path: ['date'], type: 'changed', ... }], sectionsChanged: true } * ``` */ declare function diffEntries(source: ChangelogEntry, target: ChangelogEntry): EntryDiff; /** * Creates a human-readable summary of a changelog diff. * * @param diff - The diff to summarize * @returns A string summary of the changes * * @example Creating human-readable diff summary * ```typescript * const diff = diffChangelogs(oldChangelog, newChangelog) * summarizeDiff(diff) * // => 'Added 2 version(s): 1.2.0, 1.1.0; Modified 1 version(s): 1.0.0' * ``` */ declare function summarizeDiff(diff: ChangelogDiff): string; /** * Checks if two changelogs are structurally identical. * * @param a - First changelog * @param b - Second changelog * @returns True if changelogs are identical * * @example Checking changelog equality * ```ts * if (isChangelogEqual(mainChangelog, branchChangelog)) { * console.log('Changelogs are identical') * } * ``` */ declare function isChangelogEqual(a: Changelog, b: Changelog): boolean; /** * Checks if two changelog headers are equal. * * @param a - First header * @param b - Second header * @returns True if headers are equal * * @example Comparing changelog headers * ```typescript * isHeaderEqual(changelog1.header, changelog2.header) * // => true if titles, descriptions, and links match * ``` */ declare function isHeaderEqual(a: ChangelogHeader, b: ChangelogHeader): boolean; /** * Checks if two changelog links are equal. * * @param a - First link * @param b - Second link * @returns True if links are equal * * @example Comparing changelog links * ```typescript * isLinkEqual({ label: '1.0.0', url: '...' }, { label: '1.0.0', url: '...' }) * // => true * ``` */ declare function isLinkEqual(a: ChangelogLink, b: ChangelogLink): boolean; /** * Checks if two changelog entries are equal. * * @param a - First entry * @param b - Second entry * @returns True if entries are equal * * @example Comparing changelog entries * ```typescript * isEntryEqual(entryA, entryB) * // => true if version, date, sections, and all nested data match * ``` */ declare function isEntryEqual(a: ChangelogEntry, b: ChangelogEntry): boolean; /** * Checks if two changelog entries describe the same release. * * The date and the compare URL are stamped when an entry is generated: the date is the * day of generation and the compare URL ends at whatever commit was HEAD. Neither is * derived from the commits the entry describes, so an entry regenerated later for the * same release differs in both while saying exactly the same thing. This comparison * reads the version, the unreleased flag, the raw content, and the sections, which is * what a release's changelog entry asserts about the commits behind it. * * @param a - First entry * @param b - Second entry * @returns True if both entries carry the same version and sections * * @example Validating a committed entry against one regenerated today * ```typescript * isEntryContentEqual(committedEntry, regeneratedEntry) * // => true even though the dates and compare URLs differ * ``` */ declare function isEntryContentEqual(a: ChangelogEntry, b: ChangelogEntry): boolean; /** * Checks if two changelog sections are equal. * * @param a - First section * @param b - Second section * @returns True if sections are equal * * @example Comparing changelog sections * ```typescript * isSectionEqual(featuresA, featuresB) * // => true if type, heading, and all items match * ``` */ declare function isSectionEqual(a: ChangelogSection, b: ChangelogSection): boolean; /** * Checks if two changelog items are equal. * * @param a - First item * @param b - Second item * @returns True if items are equal * * @example Comparing changelog items * ```typescript * isItemEqual(itemA, itemB) * // => true if description, scope, breaking, commits, and references match * ``` */ declare function isItemEqual(a: ChangelogItem, b: ChangelogItem): boolean; /** * Checks if two commit references are equal. * * @param a - First commit ref * @param b - Second commit ref * @returns True if commit refs are equal * * @example Comparing commit references * ```typescript * isCommitRefEqual(commitA, commitB) * // => true if hash, shortHash, and url match * ``` */ declare function isCommitRefEqual(a: CommitRef, b: CommitRef): boolean; /** * Checks if two issue references are equal. * * @param a - First issue ref * @param b - Second issue ref * @returns True if issue refs are equal * * @example Comparing issue references * ```typescript * isIssueRefEqual({ number: 42, type: 'issue' }, { number: 42, type: 'issue' }) * // => true * ``` */ declare function isIssueRefEqual(a: IssueRef, b: IssueRef): boolean; /** * Checks if two changelog metadata objects are equal. * * @param a - First metadata * @param b - Second metadata * @returns True if metadata are equal * * @example Comparing changelog metadata * ```typescript * isMetadataEqual(changelog1.metadata, changelog2.metadata) * // => true if format, isConventional, repositoryUrl, and warnings match * ``` */ declare function isMetadataEqual(a: ChangelogMetadata, b: ChangelogMetadata): boolean; /** * Checks if two changelogs have the same entries (by version). * Does not compare entry contents, only versions present. * * @param a - First changelog * @param b - Second changelog * @returns True if both changelogs have the same versions * * @example Checking if changelogs have the same versions * ```typescript * haveSameVersions(changelog1, changelog2) * // => true if both have entries for the same version strings * ``` */ declare function haveSameVersions(a: Changelog, b: Changelog): boolean; /** * Checks if a changelog contains a specific version. * * @param changelog - The changelog to search * @param version - The version to look for * @returns True if the version exists in the changelog * * @example Checking if a changelog contains a version * ```typescript * hasVersion(changelog, '2.0.0') * // => true if an entry for version 2.0.0 exists * ``` */ declare function hasVersion(changelog: Changelog, version: string): boolean; /** * Gets an entry by version from a changelog. * * @param changelog - The changelog to search * @param version - The version to find * @returns The entry if found, undefined otherwise * * @example Getting an entry by version * ```typescript * const entry = getEntryByVersion(changelog, '1.0.0') * // => ChangelogEntry for 1.0.0 or undefined * ``` */ declare function getEntryByVersion(changelog: Changelog, version: string): ChangelogEntry | undefined; export { diffChangelogs, diffEntries, getEntryByVersion, hasVersion, haveSameVersions, isChangelogEqual, isCommitRefEqual, isEntryContentEqual, isEntryEqual, isHeaderEqual, isIssueRefEqual, isItemEqual, isLinkEqual, isMetadataEqual, isSectionEqual, summarizeDiff }; export type { ChangelogDiff, DiffStats, EntryDiff, ItemDiff, PropertyDiff, SectionDiff };