/** * An isomorphic library for detecting and classifying changes between TypeScript declaration files. * * @remarks * This package analyzes TypeScript source code to identify API changes and classify them * according to semantic versioning impact (major, minor, patch, or none). * * This core package is designed to work in both Node.js and browser environments. * It does not use any Node.js-specific APIs like `fs`. * * @example * ```ts * import * as ts from 'typescript'; * import { analyzeChanges } from '@api-extractor-tools/change-detector-core'; * * const result = analyzeChanges(oldSource, newSource, ts); * console.log(`Release type: ${result.releaseType}`); * * for (const { change, releaseType, matchedRule } of result.results) { * console.log(`[${releaseType}] ${change.explanation}`); * } * ``` * * @packageDocumentation */ import type * as ts from 'typescript'; export type { ReleaseType, SymbolKind, SourceLocation, SymbolMetadata, ExportedSymbol, ChangeCategory, AnalyzedChange, Change, VersioningPolicy, ClassifyContext, ChangesByImpact, ComparisonStats, ComparisonReport, } from './types'; export { type ParameterInfo, type ParameterPositionAnalysis, type ParameterOrderAnalysis, type ReorderingConfidence, extractParameterInfo, detectParameterReordering, editDistance, nameSimilarity, interpretNameChange, } from './parameter-analysis'; export { type SourceMapping, type ProcessResult, type InputProcessor, type InputProcessorOptions, type InputProcessorDefinition, type PolicyContext, type ExtendedVersioningPolicy, type PolicyOptions, type PolicyDefinition, type ReportOutputFormat, type ReportOutput, type Reporter, type AsyncReporter, type ReporterOptions, type ReporterDefinition, type ValidationResult, type Validator, type ValidatorDefinition, type PluginMetadata, type ChangeDetectorPlugin, type PluginLifecycle, type ChangeDetectorPluginWithLifecycle, type PluginErrorCode, PluginError, type PluginResult, PLUGIN_KEYWORDS, type DiscoveredPlugin, type ResolvedPlugin, type InputProcessorPlugin, adaptLegacyInputProcessorPlugin, } from './plugin-types'; export { type PluginValidationError, type PluginValidationResult, type PluginValidationOptions, validatePlugin, isValidPlugin, formatValidationErrors, } from './plugin-validation'; export type { PluginDiscoveryOptions, PluginDiscoveryLogger, PluginPackageInfo, LoadedPlugin, PluginDiscoveryError, PluginDiscoveryResult, } from './plugin-discovery'; export { type ResolvedCapability, type RegisterOptions, type RegistryLogger, type PluginRegistryOptions, type PluginRegistry, createPluginRegistry, } from './plugin-registry'; export type { SourcePosition, SourceRange, NodeKind, Modifier, TypeParameterInfo, ParameterInfo as ASTParameterInfo, SignatureInfo, PropertyInfo, EnumMemberInfo, TypeInfo, NodeMetadata, AnalyzableNode, ModuleAnalysis, ModuleAnalysisWithTypes, ChangeTarget, ChangeAction, ChangeAspect, ChangeImpact, ChangeTag, AddedDescriptor, RemovedDescriptor, ModifiedDescriptor, RenamedDescriptor, ReorderedDescriptor, ChangeDescriptor, ChangeContext, ApiChange, ClassifiedChange, ParseOptions, DiffOptions, } from './ast/types'; export { parseModule, parseModuleWithTypes } from './ast/parser'; export { diffModules, flattenChanges, groupChangesByDescriptor, } from './ast/differ'; export type { ASTReporterOptions, ASTComparisonReport, ASTChangeJSON, ASTReportJSON, } from './ast/reporter'; export { createASTComparisonReport, formatSourceLocation, formatASTReportAsText, formatASTReportAsMarkdown, formatASTReportAsJSON, } from './ast/reporter'; export type { ASTAwarePolicyOptions, ASTAwarePolicyDefinition, HybridPolicyDefinition, ASTAwareReporterOptions, ASTAwareReporter, ASTAwareReporterDefinition, ASTProcessResult, ASTAwareInputProcessor, ASTCapability, } from './ast/plugin-types'; export { isASTAwarePolicyDefinition, isASTAwareReporterDefinition, isASTAwareInputProcessor, createASTAwarePolicyDefinition, createASTAwareReporterDefinition, } from './ast/plugin-types'; export { defaultASTPolicy, readOnlyASTPolicy, writeOnlyASTPolicy, } from './ast/plugin-types'; export { textASTReporter, markdownASTReporter, jsonASTReporter, } from './ast/plugin-types'; export type { ChangeMatcher, PolicyRule, Policy, ClassificationResult, } from './ast/rule-builder'; export { RuleBuilder, rule, PolicyBuilder, createPolicy, classifyChange, classifyChanges, determineOverallRelease, } from './ast/rule-builder'; export { semverDefaultPolicy, semverReadOnlyPolicy, semverWriteOnlyPolicy, } from './ast/builtin-policies'; export type { IntentExpression, IntentRule, PatternTemplate, PatternVariable, PatternRule, DimensionalRule, DSLRule, DSLPolicy, IntentParseResult, PatternCompileResult, PatternDecompileResult, IntentSynthesisResult, ValidationResult as DSLValidationResult, ValidationError as DSLValidationError, ValidationWarning as DSLValidationWarning, DSLBuilderState, TransformOptions, TransformationChain, } from './dsl'; export { COMMON_PATTERNS, COMMON_INTENTS, isIntentRule, isPatternRule, isDimensionalRule, ProgressiveRuleBuilder, createProgressivePolicy, createStandardPolicy, parseIntent, isValidIntentExpression, suggestIntentCorrections, compilePattern, isValidPatternTemplate, inferConstraints, decompileToPattern, findBestPattern, calculatePatternConfidence, synthesizeIntent, detectCommonPattern, generateIntentExpression, } from './dsl'; import type { ApiChange, ParseOptions, DiffOptions } from './ast/types'; import type { Policy, ClassificationResult } from './ast/rule-builder'; import type { ReleaseType } from './types'; /** * Options for the analyzeChanges convenience function. * * @alpha */ export interface AnalyzeChangesOptions { /** Policy to use for classification (defaults to semverDefaultPolicy) */ policy?: Policy; /** Options for parsing source code */ parseOptions?: ParseOptions; /** Options for comparing modules */ diffOptions?: DiffOptions; } /** * Result of analyzing changes between two source files. * * @alpha */ export interface AnalyzeChangesResult { /** All detected API changes */ changes: ApiChange[]; /** Classification results with matched rules */ results: ClassificationResult[]; /** The overall release type (highest severity) */ releaseType: ReleaseType; } /** * Convenience function that combines parsing, diffing, and classification. * * This is the recommended entry point for change analysis. It handles the * full workflow of: * 1. Parsing both source files into AST analyses with TypeChecker * 2. Computing structural changes between them * 3. Classifying changes according to the policy * 4. Determining the overall release type * * @param oldSource - The old (baseline) source code * @param newSource - The new source code to compare * @param tsModule - The TypeScript module to use for type checking * @param options - Optional configuration for parsing, diffing, and policy * @returns Analysis results including changes, classifications, and release type * * @example * ```ts * import * as ts from 'typescript'; * import { analyzeChanges } from '@api-extractor-tools/change-detector-core'; * * const result = analyzeChanges(oldSource, newSource, ts); * console.log(`Release type: ${result.releaseType}`); * * for (const { change, releaseType, matchedRule } of result.results) { * console.log(`[${releaseType}] ${change.explanation}`); * if (matchedRule) { * console.log(` Rule: ${matchedRule.name}`); * } * } * ``` * * @alpha */ export declare function analyzeChanges(oldSource: string, newSource: string, tsModule: typeof ts, options?: AnalyzeChangesOptions): AnalyzeChangesResult; import type { ExportedSymbol } from './types'; /** * Result of parsing a declaration string. * * @alpha */ export interface ParseDeclarationResult { /** Map of symbol names to their information */ symbols: Map; /** Any errors encountered during parsing */ errors: string[]; } /** * Parse a TypeScript declaration string and extract exported symbols. * * @remarks * This is a compatibility function that wraps the AST parser to provide * the legacy ExportedSymbol format used by input processors. * * @param content - TypeScript source code to parse * @param tsModule - The TypeScript module to use * @param filename - Optional filename for error messages * @returns Parse result with symbols and errors * * @example * ```ts * import * as ts from 'typescript'; * import { parseDeclarationString } from '@api-extractor-tools/change-detector-core'; * * const result = parseDeclarationString( * 'export declare function greet(name: string): string;', * ts * ); * console.log(result.symbols.get('greet')); * ``` * * @alpha */ export declare function parseDeclarationString(content: string, _tsModule: typeof ts, _filename?: string): ParseDeclarationResult; //# sourceMappingURL=index.d.ts.map